From 97632b9372125e0a88452d05d8b7adb880b7096b Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Wed, 30 Oct 2024 00:32:28 -0400 Subject: [PATCH] fix(its)!: remove gateway token entrypoints (#291) --- contracts/InterchainTokenService.sol | 58 ++++++------------- .../interfaces/IInterchainTokenService.sol | 1 - package-lock.json | 16 ++--- package.json | 4 +- test/InterchainTokenService.js | 49 +++++----------- 5 files changed, 42 insertions(+), 86 deletions(-) diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index a19e1d5b..5b2afc14 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -410,6 +410,23 @@ contract InterchainTokenService is _expressExecute(commandId, sourceChain, payload); } + /** + * @notice Returns the express executor for a given command. + * @param commandId The commandId for the contractCall. + * @param sourceChain The source chain. + * @param sourceAddress The source address. + * @param payloadHash The hash of the payload. + * @return expressExecutor The address of the express executor. + */ + function getExpressExecutor( + bytes32 commandId, + string calldata sourceChain, + string calldata sourceAddress, + bytes32 payloadHash + ) external view returns (address expressExecutor) { + expressExecutor = _getExpressExecutor(commandId, sourceChain, sourceAddress, payloadHash); + } + /** * @notice Uses the caller's tokens to fullfill a sendCall ahead of time. Use this only if you have detected an outgoing * interchainTransfer that matches the parameters passed here. @@ -633,47 +650,6 @@ contract InterchainTokenService is _execute(commandId, sourceChain, sourceAddress, payload, payloadHash); } - /** - * @notice Call with gateway tokens are not supported. - */ - function contractCallWithTokenValue( - string calldata /* sourceChain */, - string calldata /* sourceAddress */, - bytes calldata /* payload */, - string calldata /* symbol */, - uint256 /* amount */ - ) public pure override returns (address, uint256) { - revert NotSupported(); - } - - /** - * @notice Call with gateway tokens are not supported. - */ - function expressExecuteWithToken( - bytes32 /* commandId */, - string calldata /* sourceChain */, - string calldata /* sourceAddress */, - bytes calldata /* payload */, - string calldata /* tokenSymbol */, - uint256 /* amount */ - ) external payable { - revert NotSupported(); - } - - /** - * @notice Call with gateway tokens are not supported. - */ - function executeWithToken( - bytes32 /* commandId */, - string calldata /* sourceChain */, - string calldata /* sourceAddress */, - bytes calldata /* payload */, - string calldata /* tokenSymbol */, - uint256 /* amount */ - ) external pure { - revert NotSupported(); - } - /** * @notice Processes the payload data for a send token call. * @param commandId The unique message id. diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index 451236a2..664cbd04 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -49,7 +49,6 @@ interface IInterchainTokenService is error CannotDeployRemotelyToSelf(); error InvalidPayload(); error GatewayCallFailed(bytes data); - error NotSupported(); event InterchainTransfer( bytes32 indexed tokenId, diff --git a/package-lock.json b/package-lock.json index 45b8fe9f..10755915 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,10 +10,10 @@ "license": "MIT", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.4.0", - "@axelar-network/axelar-gmp-sdk-solidity": "6.0.1" + "@axelar-network/axelar-gmp-sdk-solidity": "6.0.3" }, "devDependencies": { - "@axelar-network/axelar-chains-config": "^1.2.0", + "@axelar-network/axelar-chains-config": "^1.3.0", "@axelarjs/evm": "^0.2.1", "@changesets/cli": "^2.27.9", "@nomicfoundation/hardhat-toolbox": "^2.0.2", @@ -70,9 +70,9 @@ } }, "node_modules/@axelar-network/axelar-chains-config": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@axelar-network/axelar-chains-config/-/axelar-chains-config-1.2.0.tgz", - "integrity": "sha512-JGQ6Bo8J/iTq7s6iNLf3lhsZRmeVACvPAoEoGMiZA5WdNqku7x8nXGG4i36FaVOASt6UPYK10l/5D5d31fh4JQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@axelar-network/axelar-chains-config/-/axelar-chains-config-1.3.0.tgz", + "integrity": "sha512-k633v2pJF8qPM3pDSawSqm7K4AgqmGicj2fUk0O0HwWB1jS2l/oFm+x5jB58HT64xhf8x7VB4BhdJQtMdKcOPA==", "dev": true, "dependencies": { "@ethersproject/keccak256": "^5.7.0", @@ -80,9 +80,9 @@ } }, "node_modules/@axelar-network/axelar-gmp-sdk-solidity": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@axelar-network/axelar-gmp-sdk-solidity/-/axelar-gmp-sdk-solidity-6.0.1.tgz", - "integrity": "sha512-hxLRvxrx7LjG8QqL5Myh4Fq1hGN4y64ZK6a0YtoIK44YXLloeWSzgDVn5C8E8FoQHOTYAE6RpSVbilDgss480Q==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@axelar-network/axelar-gmp-sdk-solidity/-/axelar-gmp-sdk-solidity-6.0.3.tgz", + "integrity": "sha512-5kUQUhIbtmuREhxQ54Q9XCTx61k3HeEqN9jWN8w0VOIT3pZI1c3URjmlfJAnP208jkzJS6YHaLMbZtANJDu0Fw==", "engines": { "node": ">=18" } diff --git a/package.json b/package.json index ac7d1f82..131afba8 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,10 @@ }, "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.4.0", - "@axelar-network/axelar-gmp-sdk-solidity": "6.0.1" + "@axelar-network/axelar-gmp-sdk-solidity": "6.0.3" }, "devDependencies": { - "@axelar-network/axelar-chains-config": "^1.2.0", + "@axelar-network/axelar-chains-config": "^1.3.0", "@axelarjs/evm": "^0.2.1", "@changesets/cli": "^2.27.9", "@nomicfoundation/hardhat-toolbox": "^2.0.2", diff --git a/test/InterchainTokenService.js b/test/InterchainTokenService.js index fb492039..f12ecc7e 100644 --- a/test/InterchainTokenService.js +++ b/test/InterchainTokenService.js @@ -1433,16 +1433,6 @@ describe('Interchain Token Service', () => { }); }); - describe('Execute with token', () => { - it('should revert on execute with token', async () => { - await expectRevert( - (gasOptions) => service.executeWithToken(HashZero, 'sourceChain', wallet.address, '0x', 'TEST', 1, gasOptions), - service, - 'NotSupported', - ); - }); - }); - describe('Receive Remote Tokens', () => { let sourceAddress; const amount = 1234; @@ -2395,15 +2385,6 @@ describe('Interchain Token Service', () => { await service.setPauseStatus(false).then((tx) => tx.wait); }); - - it('Should revert on express execute with token', async () => { - await expectRevert( - (gasOptions) => - service.expressExecuteWithToken(commandId, sourceChain, sourceAddress, '0x', tokenSymbol, amount, gasOptions), - service, - 'NotSupported', - ); - }); }); describe('Express Receive Remote Token', () => { @@ -2486,9 +2467,11 @@ describe('Interchain Token Service', () => { ['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'], [MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, amount, '0x'], ); - const commandId = getRandomBytes32(); + await (await service.expressExecute(commandId, sourceChain, sourceAddress, payload)).wait(); + expect(await service.getExpressExecutor(commandId, sourceChain, sourceAddress, keccak256(payload))).to.equal(wallet.address); + await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload, getRandomBytes32(), 0, commandId); await expect(service.execute(commandId, sourceChain, sourceAddress, payload)) @@ -2507,9 +2490,11 @@ describe('Interchain Token Service', () => { ['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'], [MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, amount, '0x'], ); - const commandId = getRandomBytes32(); + await service.expressExecute(commandId, sourceChain, sourceAddress, payload).then((tx) => tx.wait); + expect(await service.getExpressExecutor(commandId, sourceChain, sourceAddress, keccak256(payload))).to.equal(wallet.address); + await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload, getRandomBytes32(), 0, commandId); await expect(service.execute(commandId, sourceChain, sourceAddress, payload)) @@ -2528,9 +2513,11 @@ describe('Interchain Token Service', () => { ['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'], [MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, amount, '0x'], ); - const commandId = getRandomBytes32(); + await service.expressExecute(commandId, sourceChain, sourceAddress, payload).then((tx) => tx.wait); + expect(await service.getExpressExecutor(commandId, sourceChain, sourceAddress, keccak256(payload))).to.equal(wallet.address); + await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload, getRandomBytes32(), 0, commandId); await expect(service.execute(commandId, sourceChain, sourceAddress, payload)) @@ -2555,9 +2542,11 @@ describe('Interchain Token Service', () => { ['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'], [MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, amount, '0x'], ); - const commandId = getRandomBytes32(); + await service.expressExecute(commandId, sourceChain, sourceAddress, payload).then((tx) => tx.wait); + expect(await service.getExpressExecutor(commandId, sourceChain, sourceAddress, keccak256(payload))).to.equal(wallet.address); + await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload, getRandomBytes32(), 0, commandId); await expect(service.execute(commandId, sourceChain, sourceAddress, payload)) @@ -2584,9 +2573,11 @@ describe('Interchain Token Service', () => { ['uint256', 'bytes32', 'bytes', 'bytes', 'uint256', 'bytes'], [MESSAGE_TYPE_INTERCHAIN_TRANSFER, tokenId, hexlify(wallet.address), destAddress, amount, '0x'], ); - const commandId = getRandomBytes32(); + await service.expressExecute(commandId, sourceChain, sourceAddress, payload).then((tx) => tx.wait); + expect(await service.getExpressExecutor(commandId, sourceChain, sourceAddress, keccak256(payload))).to.equal(wallet.address); + await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload, getRandomBytes32(), 0, commandId); await expect(service.execute(commandId, sourceChain, sourceAddress, payload)) @@ -2969,16 +2960,6 @@ describe('Interchain Token Service', () => { }); }); - describe('Call contract with token value', () => { - it('Should revert on contract call value', async () => { - await expectRevert( - (gasOptions) => service.contractCallWithTokenValue(sourceChain, 'sourceAddress', '0x', 'TEST', 1, gasOptions), - service, - 'NotSupported', - ); - }); - }); - describe('Bytecode checks [ @skip-on-coverage ]', () => { it('Should preserve the same proxy bytecode for each EVM', async () => { const proxyFactory = await ethers.getContractFactory('InterchainProxy', wallet);