Skip to content

Commit

Permalink
Merge branch 'main' into fix/check_chain_name
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth authored Sep 27, 2024
2 parents 69bda6a + b680103 commit 4cef49f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

/**
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/InterchainTokenDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 8 additions & 0 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 4cef49f

Please sign in to comment.