diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index 527fb516..af836ed7 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)); /** @@ -343,6 +343,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); @@ -711,6 +713,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) @@ -1083,7 +1087,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); } } diff --git a/test/InterchainTokenService.js b/test/InterchainTokenService.js index 301a11b3..17468286 100644 --- a/test/InterchainTokenService.js +++ b/test/InterchainTokenService.js @@ -662,6 +662,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') @@ -738,6 +740,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') @@ -887,6 +891,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); @@ -1126,6 +1132,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') 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';