diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index 60798948..4b6f469c 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -20,7 +20,7 @@ import { IInterchainTokenExecutable } from './interfaces/IInterchainTokenExecuta import { IInterchainTokenExpressExecutable } from './interfaces/IInterchainTokenExpressExecutable.sol'; import { ITokenManager } from './interfaces/ITokenManager.sol'; import { Create3AddressFixed } from './utils/Create3AddressFixed.sol'; -import { CallContract } from './utils/CallContract.sol'; +import { GatewayCaller } from './utils/GatewayCaller.sol'; import { Operator } from './utils/Operator.sol'; @@ -57,7 +57,7 @@ contract InterchainTokenService is */ address public immutable tokenManager; address public immutable tokenHandler; - address public immutable contractCaller; + address public immutable gatewayCaller; bytes32 internal constant PREFIX_INTERCHAIN_TOKEN_ID = keccak256('its-interchain-token-id'); bytes32 internal constant PREFIX_INTERCHAIN_TOKEN_SALT = keccak256('its-interchain-token-salt'); @@ -116,6 +116,7 @@ contract InterchainTokenService is * @param chainName_ The name of the chain that this contract is deployed on. * @param tokenManagerImplementation_ The tokenManager implementation. * @param tokenHandler_ The tokenHandler implementation. + * @param gatewayCaller_ The gatewayCaller implementation. */ constructor( address tokenManagerDeployer_, @@ -126,7 +127,7 @@ contract InterchainTokenService is string memory chainName_, address tokenManagerImplementation_, address tokenHandler_, - address contractCaller_ + address gatewayCaller_ ) { if ( gasService_ == address(0) || @@ -149,7 +150,7 @@ contract InterchainTokenService is tokenManager = tokenManagerImplementation_; tokenHandler = tokenHandler_; - contractCaller = contractCaller_; + gatewayCaller = gatewayCaller_; } /*******\ @@ -831,16 +832,18 @@ contract InterchainTokenService is if (bytes(destinationAddress).length == 0) revert UntrustedChain(); - (bool success, bytes memory returnData) = contractCaller.delegatecall(abi.encodeWithSelector( - CallContract.callContract.selector, - destinationChain, - destinationAddress, - payload, - metadataVersion, - gasValue - )); + (bool success, bytes memory returnData) = gatewayCaller.delegatecall( + abi.encodeWithSelector( + GatewayCaller.callContract.selector, + destinationChain, + destinationAddress, + payload, + metadataVersion, + gasValue + ) + ); - if(!success) revert CallContractFailed(returnData); + if (!success) revert GatewayCallFailed(returnData); } /** @@ -869,18 +872,20 @@ contract InterchainTokenService is if (bytes(destinationAddress).length == 0) revert UntrustedChain(); - (bool success, bytes memory returnData) = contractCaller.delegatecall(abi.encodeWithSelector( - CallContract.callContractWithToken.selector, - destinationChain, - destinationAddress, - payload, - symbol, - amount, - metadataVersion, - gasValue - )); + (bool success, bytes memory returnData) = gatewayCaller.delegatecall( + abi.encodeWithSelector( + GatewayCaller.callContractWithToken.selector, + destinationChain, + destinationAddress, + payload, + symbol, + amount, + metadataVersion, + gasValue + ) + ); - if(!success) revert CallContractFailed(returnData); + if (!success) revert GatewayCallFailed(returnData); } function _execute( diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index c143cacb..150e0fba 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -50,7 +50,7 @@ interface IInterchainTokenService is error CannotDeploy(TokenManagerType); error InvalidGatewayTokenTransfer(bytes32 tokenId, bytes payload, string tokenSymbol, uint256 amount); error InvalidPayload(); - error CallContractFailed(bytes data); + error GatewayCallFailed(bytes data); event InterchainTransfer( bytes32 indexed tokenId, diff --git a/contracts/test/TestInterchainTokenService.sol b/contracts/test/TestInterchainTokenService.sol index 99c89d4b..afc55a33 100644 --- a/contracts/test/TestInterchainTokenService.sol +++ b/contracts/test/TestInterchainTokenService.sol @@ -16,7 +16,7 @@ contract TestInterchainTokenService is InterchainTokenService { string memory chainName_, address tokenManager_, address tokenHandler_, - address contractCaller_ + address gatewayCaller_ ) InterchainTokenService( tokenManagerDeployer_, @@ -27,7 +27,7 @@ contract TestInterchainTokenService is InterchainTokenService { chainName_, tokenManager_, tokenHandler_, - contractCaller_ + gatewayCaller_ ) { if (LATEST_METADATA_VERSION != uint32(type(MetadataVersion).max)) @@ -37,13 +37,4 @@ contract TestInterchainTokenService is InterchainTokenService { function setupTest(bytes calldata params) external { _setup(params); } - - function callContract( - string calldata destinationChain, - bytes memory payload, - MetadataVersion metadataVersion, - uint256 gasValue - ) external payable { - _callContract(destinationChain, payload, metadataVersion, gasValue); - } } diff --git a/contracts/utils/CallContract.sol b/contracts/utils/GatewayCaller.sol similarity index 98% rename from contracts/utils/CallContract.sol rename to contracts/utils/GatewayCaller.sol index d3482188..6ff80cfc 100644 --- a/contracts/utils/CallContract.sol +++ b/contracts/utils/GatewayCaller.sol @@ -6,10 +6,10 @@ import { IAxelarGasService } from '@axelar-network/axelar-gmp-sdk-solidity/contr import { IAxelarGateway } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol'; /** - * @title CallContract contract + * @title GatewayCaller contract * @notice This contract is used like a library to resolve metadata for the interchain token service */ -contract CallContract { +contract GatewayCaller { error UntrustedChain(); error InvalidMetadataVersion(uint32 metadataVersion); diff --git a/scripts/deploy.js b/scripts/deploy.js index af742ac1..1a32e3f0 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -34,7 +34,7 @@ async function deployInterchainTokenService( interchainTokenFactoryAddress, tokenManagerAddress, tokenHandlerAddress, - contractCaller, + gatewayCaller, chainName, evmChains = [], deploymentKey, @@ -52,7 +52,7 @@ async function deployInterchainTokenService( chainName, tokenManagerAddress, tokenHandlerAddress, - contractCaller, + gatewayCaller, ]); const proxy = await create3DeployContract(create3DeployerAddress, wallet, Proxy, deploymentKey, [ implementation.address, @@ -96,7 +96,7 @@ async function deployAll( const interchainTokenDeployer = await deployContract(wallet, 'InterchainTokenDeployer', [interchainToken.address]); const tokenManager = await deployContract(wallet, 'TokenManager', [interchainTokenServiceAddress]); const tokenHandler = await deployContract(wallet, 'TokenHandler', [gateway.address]); - const contractCaller = await deployContract(wallet, 'CallContract', [gateway.address, gasService.address]); + const gatewayCaller = await deployContract(wallet, 'GatewayCaller', [gateway.address, gasService.address]); const interchainTokenFactoryAddress = await getCreate3Address(create3Deployer.address, wallet, factoryDeploymentKey); @@ -110,7 +110,7 @@ async function deployAll( interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, evmChains, deploymentKey, @@ -134,7 +134,7 @@ async function deployAll( interchainTokenDeployer, tokenManager, tokenHandler, - contractCaller, + gatewayCaller, }; } diff --git a/test/InterchainTokenService.js b/test/InterchainTokenService.js index 9aa411ea..607af4fe 100644 --- a/test/InterchainTokenService.js +++ b/test/InterchainTokenService.js @@ -41,7 +41,7 @@ describe('Interchain Token Service', () => { let interchainTokenDeployer; let tokenManager; let tokenHandler; - let contractCaller; + let gatewayCaller; let interchainTokenFactoryAddress; let serviceTest; @@ -212,7 +212,7 @@ describe('Interchain Token Service', () => { interchainTokenDeployer, tokenManager, tokenHandler, - contractCaller, + gatewayCaller, } = await deployAll(wallet, 'Test', [sourceChain, destinationChain])); testToken = await deployContract(wallet, 'TestInterchainTokenStandard', [ @@ -233,7 +233,7 @@ describe('Interchain Token Service', () => { chainName, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, ]); }); @@ -295,7 +295,7 @@ describe('Interchain Token Service', () => { AddressZero, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -319,7 +319,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -343,7 +343,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, '', [], deploymentKey, @@ -366,7 +366,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -388,7 +388,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -412,7 +412,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -436,7 +436,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, AddressZero, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -460,7 +460,7 @@ describe('Interchain Token Service', () => { interchainTokenFactoryAddress, tokenManager.address, AddressZero, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, diff --git a/test/InterchainTokenServiceUpgradeFlow.js b/test/InterchainTokenServiceUpgradeFlow.js index d58ce779..858ba141 100644 --- a/test/InterchainTokenServiceUpgradeFlow.js +++ b/test/InterchainTokenServiceUpgradeFlow.js @@ -21,7 +21,7 @@ const MINT_BURN = 4; describe('Interchain Token Service Upgrade Flow', () => { let wallet, otherWallet, signer; let service, gateway, gasService; - let tokenManagerDeployer, interchainTokenDeployer, tokenManager, tokenHandler, contractCaller; + let tokenManagerDeployer, interchainTokenDeployer, tokenManager, tokenHandler, gatewayCaller; let interchainTokenFactoryAddress; let axelarServiceGovernanceFactory; @@ -76,7 +76,7 @@ describe('Interchain Token Service Upgrade Flow', () => { interchainTokenDeployer = await deployContract(wallet, 'InterchainTokenDeployer', [interchainToken.address]); tokenManager = await deployContract(wallet, 'TokenManager', [interchainTokenServiceAddress]); tokenHandler = await deployContract(wallet, 'TokenHandler', [gateway.address]); - contractCaller = await deployContract(wallet, 'CallContract', [gateway.address, gasService.address]); + gatewayCaller = await deployContract(wallet, 'GatewayCaller', [gateway.address, gasService.address]); interchainTokenFactoryAddress = await getCreate3Address(create3Deployer.address, wallet, deploymentKey + 'Factory'); axelarServiceGovernanceFactory = await ethers.getContractFactory( @@ -106,7 +106,7 @@ describe('Interchain Token Service Upgrade Flow', () => { interchainTokenFactoryAddress, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, chainName, [], deploymentKey, @@ -130,7 +130,7 @@ describe('Interchain Token Service Upgrade Flow', () => { chainName, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, ]); const newServiceImplementationCodeHash = await getBytecodeHash(newServiceImplementation); const setupParams = '0x'; @@ -197,7 +197,7 @@ describe('Interchain Token Service Upgrade Flow', () => { chainName, tokenManager.address, tokenHandler.address, - contractCaller.address, + gatewayCaller.address, ]); const newServiceImplementationCodeHash = await getBytecodeHash(newServiceImplementation); const setupParams = '0x';