Skip to content

Commit

Permalink
Update InterchainTokenService.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Nov 11, 2024
1 parent 22c9676 commit 83425f0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,37 @@ describe('Interchain Token Service', () => {
});
}

for (const type of ['mintBurn', 'mintBurnFrom', 'lockUnlockFee', 'lockUnlock']) {
it(`Should be able to initiate an interchain token transfer via interchainTransfer [${type}] without native gas`, async () => {
[token, tokenManager, tokenId] = await deployFunctions[type](service, `Test Token ${type}`, 'TT', 12, amount * 3, true);
const sendAmount = type === 'lockUnlockFee' ? amount - 10 : amount;
const payload = defaultAbiCoder.encode(
['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'],
[MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, sendAmount, '0x'],
);
const payloadHash = keccak256(payload);

let transferToAddress = AddressZero;

if (type === 'lockUnlock' || type === 'lockUnlockFee') {
transferToAddress = tokenManager.address;
}

await expect(
reportGas(
token.connect(wallet).interchainTransfer(destinationChain, destAddress, amount, metadata),
`Call token.interchainTransfer ${type}`,
),
)
.and.to.emit(token, 'Transfer')
.withArgs(wallet.address, transferToAddress, amount)
.and.to.emit(gateway, 'ContractCall')
.withArgs(service.address, destinationChain, service.address, payloadHash, payload)
.to.emit(service, 'InterchainTransfer')
.withArgs(tokenId, wallet.address, destinationChain, destAddress, sendAmount, HashZero);
});
}

it('Should be able to initiate an interchain token transfer using interchainTransferFrom with max possible allowance', async () => {
const sendAmount = amount;
const payload = defaultAbiCoder.encode(
Expand Down

0 comments on commit 83425f0

Please sign in to comment.