From be24c940e2b6bc56e20f9e45cb0a05f2ec479336 Mon Sep 17 00:00:00 2001 From: ahramy Date: Tue, 17 Sep 2024 13:53:20 -0700 Subject: [PATCH 1/4] fix: modified wrong data decoding in _checkPayloadAgainstGatewayData (#278) --- contracts/InterchainTokenService.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index f96bc72a..c6d5815f 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -707,6 +707,8 @@ contract InterchainTokenService is * @param amount The amount for the call contract with token. */ function _checkPayloadAgainstGatewayData(bytes memory payload, string calldata tokenSymbol, uint256 amount) internal view { + // The same payload is decoded in both _checkPayloadAgainstGatewayData and _contractCallValue using different parameters. + // This is intentional, as using `uint256` instead of `bytes` improves gas efficiency without any functional difference. (, bytes32 tokenId, , , uint256 amountInPayload) = abi.decode(payload, (uint256, bytes32, uint256, uint256, uint256)); if (validTokenAddress(tokenId) != gateway.tokenAddresses(tokenSymbol) || amount != amountInPayload) From 8d83b44eaa5187521ef4556d1e86b1bbf0f69913 Mon Sep 17 00:00:00 2001 From: ahramy Date: Wed, 25 Sep 2024 12:13:40 +0900 Subject: [PATCH 2/4] chore: use named return (#283) --- contracts/InterchainTokenService.sol | 2 +- contracts/utils/InterchainTokenDeployer.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index c6d5815f..e61f0ed1 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -1081,7 +1081,7 @@ contract InterchainTokenService is * @return salt The computed salt for the token deployment. */ function _getInterchainTokenSalt(bytes32 tokenId) internal pure returns (bytes32 salt) { - return keccak256(abi.encode(PREFIX_INTERCHAIN_TOKEN_SALT, tokenId)); + salt = keccak256(abi.encode(PREFIX_INTERCHAIN_TOKEN_SALT, tokenId)); } /** diff --git a/contracts/utils/InterchainTokenDeployer.sol b/contracts/utils/InterchainTokenDeployer.sol index f39eed8c..0ec736f3 100644 --- a/contracts/utils/InterchainTokenDeployer.sol +++ b/contracts/utils/InterchainTokenDeployer.sol @@ -72,6 +72,6 @@ contract InterchainTokenDeployer is IInterchainTokenDeployer, Create3Fixed { * @return tokenAddress The token address. */ function deployedAddress(bytes32 salt) external view returns (address tokenAddress) { - return _create3Address(salt); + tokenAddress = _create3Address(salt); } } From 874287f32e7a2f4d26005001ce940e816c6fc551 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Tue, 24 Sep 2024 23:17:08 -0400 Subject: [PATCH 3/4] fix!: use lower case ITS hub chain name (#280) --- contracts/InterchainTokenService.sol | 2 +- test/constants.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index e61f0ed1..ef301984 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -91,7 +91,7 @@ contract InterchainTokenService is * @dev Chain name where ITS Hub exists. This is used for routing ITS calls via ITS hub. * This is set as a constant, since the ITS Hub will exist on Axelar. */ - string internal constant ITS_HUB_CHAIN_NAME = 'Axelarnet'; + string internal constant ITS_HUB_CHAIN_NAME = 'axelarnet'; bytes32 internal constant ITS_HUB_CHAIN_NAME_HASH = keccak256(abi.encodePacked(ITS_HUB_CHAIN_NAME)); /** diff --git a/test/constants.js b/test/constants.js index 8b9b2826..9afa5c7e 100644 --- a/test/constants.js +++ b/test/constants.js @@ -19,7 +19,7 @@ const OPERATOR_ROLE = 1; const FLOW_LIMITER_ROLE = 2; // Chain name for ITS Hub chain -const ITS_HUB_CHAIN_NAME = 'Axelarnet'; +const ITS_HUB_CHAIN_NAME = 'axelarnet'; const ITS_HUB_ROUTING_IDENTIFIER = 'hub'; const ITS_HUB_ADDRESS = 'axelar1xyz'; From b68010324fcb6121af0e12acfc3f92688bdfe04d Mon Sep 17 00:00:00 2001 From: ahramy Date: Fri, 27 Sep 2024 00:05:06 +0900 Subject: [PATCH 4/4] chore: added InterchainTokenIdClaimed event (#281) --- contracts/InterchainTokenService.sol | 2 ++ test/InterchainTokenService.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index ef301984..e3929ce1 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -341,6 +341,8 @@ contract InterchainTokenService is tokenId = interchainTokenId(deployer, salt); + emit InterchainTokenIdClaimed(tokenId, deployer, salt); + if (bytes(destinationChain).length == 0) { address tokenAddress = _deployInterchainToken(tokenId, minter, name, symbol, decimals); diff --git a/test/InterchainTokenService.js b/test/InterchainTokenService.js index 3cce96cf..cb4e8c09 100644 --- a/test/InterchainTokenService.js +++ b/test/InterchainTokenService.js @@ -621,6 +621,8 @@ describe('Interchain Token Service', () => { 'Call deployInterchainToken on source chain', ), ) + .to.emit(service, 'InterchainTokenIdClaimed') + .withArgs(tokenId, wallet.address, salt) .to.emit(service, 'InterchainTokenDeployed') .withArgs(tokenId, tokenAddress, wallet.address, tokenName, tokenSymbol, tokenDecimals) .to.emit(service, 'TokenManagerDeployed') @@ -697,6 +699,8 @@ describe('Interchain Token Service', () => { 'Send deployInterchainToken to remote chain', ), ) + .to.emit(service, 'InterchainTokenIdClaimed') + .withArgs(tokenId, wallet.address, salt) .to.emit(service, 'InterchainTokenDeploymentStarted') .withArgs(tokenId, tokenName, tokenSymbol, tokenDecimals, minter, destinationChain) .and.to.emit(gasService, 'NativeGasPaidForContractCall') @@ -846,6 +850,8 @@ describe('Interchain Token Service', () => { const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); await expect(reportGas(service.deployTokenManager(salt, '', LOCK_UNLOCK, params, 0), 'Call deployTokenManager on source chain')) + .to.emit(service, 'InterchainTokenIdClaimed') + .withArgs(tokenId, wallet.address, salt) .to.emit(service, 'TokenManagerDeployed') .withArgs(tokenId, tokenManagerAddress, LOCK_UNLOCK, params); @@ -1085,6 +1091,8 @@ describe('Interchain Token Service', () => { 'Send deployTokenManager to remote chain', ), ) + .to.emit(service, 'InterchainTokenIdClaimed') + .withArgs(tokenId, wallet.address, salt) .to.emit(service, 'TokenManagerDeploymentStarted') .withArgs(tokenId, destinationChain, type, params) .and.to.emit(gasService, 'NativeGasPaidForContractCall')