diff --git a/framework/src/modules/token/cc_method.ts b/framework/src/modules/token/cc_method.ts index 1de07b77125..b179e61b1cd 100644 --- a/framework/src/modules/token/cc_method.ts +++ b/framework/src/modules/token/cc_method.ts @@ -148,7 +148,8 @@ export class TokenInteroperableMethod extends BaseInteroperableMethod { crossChainForwardMessageParams, ccm.params, ); - if (escrowAccount.amount < decodedParams.amount) { + const updatedEscrowAccount = await escrowStore.get(methodContext, escrowKey); + if (updatedEscrowAccount.amount < decodedParams.amount) { this.events.get(BeforeCCMForwardingEvent).error( methodContext, { @@ -163,7 +164,6 @@ export class TokenInteroperableMethod extends BaseInteroperableMethod { throw new Error('Insufficient balance in the sending chain for the transfer.'); } - const updatedEscrowAccount = await escrowStore.getOrDefault(methodContext, escrowKey); updatedEscrowAccount.amount -= decodedParams.amount; await escrowStore.set(methodContext, escrowKey, updatedEscrowAccount); diff --git a/framework/test/unit/modules/token/cc_method.spec.ts b/framework/test/unit/modules/token/cc_method.spec.ts index a475a1881b6..4c2cbf8bdfb 100644 --- a/framework/test/unit/modules/token/cc_method.spec.ts +++ b/framework/test/unit/modules/token/cc_method.spec.ts @@ -276,7 +276,7 @@ describe('TokenInteroperableMethod', () => { ); }); - it('should deduct escrow account for fee and credit to sender if ccm command is forward', async () => { + it('should deduct escrow account for fee and credit to receving chain escrow account if ccm command is forward', async () => { await expect( tokenInteropMethod.beforeCrossChainMessageForwarding({ ccm: { @@ -356,7 +356,7 @@ describe('TokenInteroperableMethod', () => { ); }); - it('should deduct escrow account for fee+ccm.params.amount and credit to sender if ccm command is forward', async () => { + it('should deduct escrow account for fee+ccm.params.amount and credit to sender if ccm command is transfer', async () => { await expect( tokenInteropMethod.beforeCrossChainMessageForwarding({ ccm: { @@ -428,7 +428,7 @@ describe('TokenInteroperableMethod', () => { ).resolves.toBeUndefined(); }); - it('should reject if token id is native and fee payer does not have sufficient balance', async () => { + it('should reject if token id is native and sending chain escrow account does not have sufficient balance', async () => { await expect( tokenInteropMethod.verifyCrossChainMessage({ ccm: {