From 2a6cc3012a41e72e8fd2c8eb3d1017a63931e6ce Mon Sep 17 00:00:00 2001 From: Foivos Date: Thu, 2 Nov 2023 18:18:10 +0200 Subject: [PATCH] feat: renamed a bunch of stuff for simplifying (on another PR) (#136) * renamed a bunch of stuff * prettier * minor name fix --- .../InterchainTokenService.sol | 244 +++++++++--------- .../interfaces/IInterchainTokenService.sol | 96 +++---- .../IStandardizedTokenRegistrar.sol | 2 +- .../CanonicalTokenRegistrar.sol | 6 +- .../StandardizedTokenRegistrar.sol | 30 +-- docs/index.md | 32 +-- test/TokenRegistrars.js | 8 +- test/TokenService.js | 60 ++--- test/TokenServiceFullFlow.js | 18 +- 9 files changed, 240 insertions(+), 256 deletions(-) diff --git a/contracts/interchain-token-service/InterchainTokenService.sol b/contracts/interchain-token-service/InterchainTokenService.sol index 1a3a6da7..30624def 100644 --- a/contracts/interchain-token-service/InterchainTokenService.sol +++ b/contracts/interchain-token-service/InterchainTokenService.sol @@ -127,10 +127,10 @@ contract InterchainTokenService is /** * @notice This modifier is used to ensure certain functions can only be called by TokenManagers. - * @param tokenId the `tokenId` of the TokenManager trying to perform the call. + * @param tokenId_ the `tokenId_` of the TokenManager trying to perform the call. */ - modifier onlyTokenManager(bytes32 tokenId) { - address tokenManager = tokenManagerAddress(tokenId); + modifier onlyTokenManager(bytes32 tokenId_) { + address tokenManager = tokenManagerAddress(tokenId_); if (msg.sender != tokenManager) revert NotTokenManager(msg.sender, tokenManager); _; @@ -148,64 +148,64 @@ contract InterchainTokenService is } /** - * @notice Calculates the address of a TokenManager from a specific tokenId. The TokenManager does not need to exist already. - * @param tokenId the tokenId. + * @notice Calculates the address of a TokenManager from a specific tokenId_. The TokenManager does not need to exist already. + * @param tokenId_ the tokenId_. * @return tokenManagerAddress_ deployment address of the TokenManager. */ - function tokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) { - tokenManagerAddress_ = _create3Address(tokenId); + function tokenManagerAddress(bytes32 tokenId_) public view returns (address tokenManagerAddress_) { + tokenManagerAddress_ = _create3Address(tokenId_); } /** - * @notice Returns the address of a TokenManager from a specific tokenId. The TokenManager needs to exist already. - * @param tokenId the tokenId. + * @notice Returns the address of a TokenManager from a specific tokenId_. The TokenManager needs to exist already. + * @param tokenId_ the tokenId_. * @return tokenManagerAddress_ deployment address of the TokenManager. */ - function validTokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress_) { - tokenManagerAddress_ = tokenManagerAddress(tokenId); - if (tokenManagerAddress_.code.length == 0) revert TokenManagerDoesNotExist(tokenId); + function validTokenManagerAddress(bytes32 tokenId_) public view returns (address tokenManagerAddress_) { + tokenManagerAddress_ = tokenManagerAddress(tokenId_); + if (tokenManagerAddress_.code.length == 0) revert TokenManagerDoesNotExist(tokenId_); } /** * @notice Returns the address of the token that an existing tokenManager points to. - * @param tokenId the tokenId. + * @param tokenId_ the tokenId_. * @return tokenAddress_ the address of the token. */ - function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_) { - address tokenManagerAddress_ = validTokenManagerAddress(tokenId); + function tokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_) { + address tokenManagerAddress_ = validTokenManagerAddress(tokenId_); tokenAddress_ = ITokenManager(tokenManagerAddress_).tokenAddress(); } /** - * @notice Returns the address of the standardized token that would be deployed with a given tokenId. + * @notice Returns the address of the standardized token that would be deployed with a given tokenId_. * The token does not need to exist. - * @param tokenId the tokenId. + * @param tokenId_ the tokenId_. * @return tokenAddress_ the address of the standardized token. */ - function standardizedTokenAddress(bytes32 tokenId) public view returns (address tokenAddress_) { - tokenId = _getStandardizedTokenSalt(tokenId); - tokenAddress_ = _create3Address(tokenId); + function interchainTokenAddress(bytes32 tokenId_) public view returns (address tokenAddress_) { + tokenId_ = _getStandardizedTokenSalt(tokenId_); + tokenAddress_ = _create3Address(tokenId_); } /** - * @notice Calculates the tokenId that would correspond to a canonical link for a given token. + * @notice Calculates the tokenId_ that would correspond to a canonical link for a given token. * This will depend on what chain it is called from, unlike custom tokenIds. * @param tokenAddress_ the address of the token. - * @return tokenId the tokenId that the canonical TokenManager would get (or has gotten) for the token. + * @return tokenId_ the tokenId_ that the canonical TokenManager would get (or has gotten) for the token. */ - function canonicalTokenId(address tokenAddress_) public view returns (bytes32 tokenId) { - tokenId = keccak256(abi.encode(PREFIX_STANDARDIZED_TOKEN_ID, chainNameHash, tokenAddress_)); + function canonicalTokenId(address tokenAddress_) public view returns (bytes32 tokenId_) { + tokenId_ = keccak256(abi.encode(PREFIX_STANDARDIZED_TOKEN_ID, chainNameHash, tokenAddress_)); } /** - * @notice Calculates the tokenId that would correspond to a custom link for a given deployer with a specified salt. + * @notice Calculates the tokenId_ that would correspond to a custom link for a given deployer with a specified salt. * This will not depend on what chain it is called from, unlike canonical tokenIds. * @param sender the address of the TokenManager deployer. * @param salt the salt that the deployer uses for the deployment. - * @return tokenId the tokenId that the custom TokenManager would get (or has gotten). + * @return tokenId_ the tokenId_ that the custom TokenManager would get (or has gotten). */ - function customTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId) { - tokenId = keccak256(abi.encode(PREFIX_CUSTOM_TOKEN_ID, sender, salt)); + function tokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId_) { + tokenId_ = keccak256(abi.encode(PREFIX_CUSTOM_TOKEN_ID, sender, salt)); } /** @@ -227,31 +227,31 @@ contract InterchainTokenService is /** * @notice Getter function for the flow limit of an existing token manager with a give token ID. - * @param tokenId the token ID of the TokenManager. + * @param tokenId_ the token ID of the TokenManager. * @return flowLimit_ the flow limit. */ - function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + function flowLimit(bytes32 tokenId_) external view returns (uint256 flowLimit_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); flowLimit_ = tokenManager.flowLimit(); } /** * @notice Getter function for the flow out amount of an existing token manager with a give token ID. - * @param tokenId the token ID of the TokenManager. + * @param tokenId_ the token ID of the TokenManager. * @return flowOutAmount_ the flow out amount. */ - function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + function flowOutAmount(bytes32 tokenId_) external view returns (uint256 flowOutAmount_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); flowOutAmount_ = tokenManager.flowOutAmount(); } /** * @notice Getter function for the flow in amount of an existing token manager with a give token ID. - * @param tokenId the token ID of the TokenManager. + * @param tokenId_ the token ID of the TokenManager. * @return flowInAmount_ the flow in amount. */ - function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_) { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + function flowInAmount(bytes32 tokenId_) external view returns (uint256 flowInAmount_) { + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); flowInAmount_ = tokenManager.flowInAmount(); } @@ -262,36 +262,36 @@ contract InterchainTokenService is /** * @notice Used to register canonical tokens. Caller does not matter. * @param tokenAddress_ the token to be bridged. - * @return tokenId the tokenId that was used for this canonical token. + * @return tokenId_ the tokenId_ that was used for this canonical token. */ - function registerCanonicalToken(address tokenAddress_) external payable whenNotPaused returns (bytes32 tokenId) { + function registerCanonicalToken(address tokenAddress_) external payable whenNotPaused returns (bytes32 tokenId_) { (, string memory tokenSymbol, ) = _validateToken(tokenAddress_); if (gateway.tokenAddresses(tokenSymbol) == tokenAddress_) revert GatewayToken(); - tokenId = canonicalTokenId(tokenAddress_); - _deployTokenManager(tokenId, TokenManagerType.LOCK_UNLOCK, abi.encode('', tokenAddress_)); + tokenId_ = canonicalTokenId(tokenAddress_); + _deployTokenManager(tokenId_, TokenManagerType.LOCK_UNLOCK, abi.encode('', tokenAddress_)); } /** * @notice Used to deploy remote TokenManagers and standardized tokens for a canonical token. This needs to be * called from the chain that registered the canonical token, and anyone can call it. - * @param tokenId the tokenId of the canonical token. + * @param tokenId_ the tokenId_ of the canonical token. * @param destinationChain the name of the chain to deploy the TokenManager and standardized token to. * @param gasValue the amount of native tokens to be used to pay for gas for the remote deployment. * At least the amount specified needs to be passed to the call * @dev `gasValue` exists because this function can be part of a multicall involving multiple functions that could make remote contract calls. */ - function deployRemoteCanonicalToken(bytes32 tokenId, string calldata destinationChain, uint256 gasValue) public payable whenNotPaused { + function deployRemoteCanonicalToken(bytes32 tokenId_, string calldata destinationChain, uint256 gasValue) public payable whenNotPaused { address tokenAddress_; { - tokenAddress_ = validTokenManagerAddress(tokenId); + tokenAddress_ = validTokenManagerAddress(tokenId_); tokenAddress_ = ITokenManager(tokenAddress_).tokenAddress(); bytes32 canonicalTokenId_ = canonicalTokenId(tokenAddress_); - if (canonicalTokenId_ != tokenId) revert InvalidCanonicalTokenId(canonicalTokenId_); + if (canonicalTokenId_ != tokenId_) revert InvalidCanonicalTokenId(canonicalTokenId_); } (string memory tokenName, string memory tokenSymbol, uint8 tokenDecimals) = _validateToken(tokenAddress_); - _deployRemoteStandardizedToken(tokenId, tokenName, tokenSymbol, tokenDecimals, '', '', 0, '', destinationChain, gasValue); + _deployRemoteStandardizedToken(tokenId_, tokenName, tokenSymbol, tokenDecimals, '', '', 0, '', destinationChain, gasValue); } /** @@ -304,13 +304,13 @@ contract InterchainTokenService is bytes32 salt, TokenManagerType tokenManagerType, bytes memory params - ) public payable whenNotPaused returns (bytes32 tokenId) { + ) public payable whenNotPaused returns (bytes32 tokenId_) { address deployer_ = msg.sender; - tokenId = customTokenId(deployer_, salt); + tokenId_ = tokenId(deployer_, salt); - emit CustomTokenIdClaimed(tokenId, deployer_, salt); + emit CustomTokenIdClaimed(tokenId_, deployer_, salt); - _deployTokenManager(tokenId, tokenManagerType, params); + _deployTokenManager(tokenId_, tokenManagerType, params); } /** @@ -324,19 +324,19 @@ contract InterchainTokenService is * @dev `gasValue` exists because this function can be part of a multicall involving multiple functions * that could make remote contract calls. */ - function deployRemoteCustomTokenManager( + function deployTokenManager( bytes32 salt, string calldata destinationChain, TokenManagerType tokenManagerType, bytes calldata params, uint256 gasValue - ) external payable whenNotPaused returns (bytes32 tokenId) { + ) external payable whenNotPaused returns (bytes32 tokenId_) { address deployer_ = msg.sender; - tokenId = customTokenId(deployer_, salt); + tokenId_ = tokenId(deployer_, salt); - emit CustomTokenIdClaimed(tokenId, deployer_, salt); + emit CustomTokenIdClaimed(tokenId_, deployer_, salt); - _deployRemoteTokenManager(tokenId, destinationChain, gasValue, tokenManagerType, params); + _deployRemoteTokenManager(tokenId_, destinationChain, gasValue, tokenManagerType, params); } /** @@ -356,10 +356,10 @@ contract InterchainTokenService is uint256 mintAmount, address distributor ) external payable whenNotPaused { - bytes32 tokenId = customTokenId(msg.sender, salt); - _deployStandardizedToken(tokenId, distributor, name, symbol, decimals, mintAmount, msg.sender); - address tokenAddress_ = standardizedTokenAddress(tokenId); - _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(msg.sender.toBytes(), tokenAddress_)); + bytes32 tokenId_ = tokenId(msg.sender, salt); + _deployInterchainToken(tokenId_, distributor, name, symbol, decimals, mintAmount, msg.sender); + address tokenAddress_ = interchainTokenAddress(tokenId_); + _deployTokenManager(tokenId_, TokenManagerType.MINT_BURN, abi.encode(msg.sender.toBytes(), tokenAddress_)); } /** @@ -378,7 +378,7 @@ contract InterchainTokenService is * specified needs to be passed to the call * @dev `gasValue` exists because this function can be part of a multicall involving multiple functions that could make remote contract calls. */ - function deployAndRegisterRemoteStandardizedToken( + function deployInterchainToken( bytes32 salt, string memory name, string memory symbol, @@ -390,9 +390,9 @@ contract InterchainTokenService is string calldata destinationChain, uint256 gasValue ) external payable whenNotPaused { - bytes32 tokenId = customTokenId(msg.sender, salt); + bytes32 tokenId_ = tokenId(msg.sender, salt); _deployRemoteStandardizedToken( - tokenId, + tokenId_, name, symbol, decimals, @@ -411,13 +411,13 @@ contract InterchainTokenService is string calldata sourceAddress, bytes calldata payload ) public view virtual onlyRemoteService(sourceChain, sourceAddress) whenNotPaused returns (address, uint256) { - (uint256 selector, bytes32 tokenId, , uint256 amount) = abi.decode(payload, (uint256, bytes32, bytes, uint256)); + (uint256 selector, bytes32 tokenId_, , uint256 amount) = abi.decode(payload, (uint256, bytes32, bytes, uint256)); if (selector != SELECTOR_RECEIVE_TOKEN && selector != SELECTOR_RECEIVE_TOKEN_WITH_DATA) { revert InvalidExpressSelector(selector); } - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); return (tokenManager.tokenAddress(), amount); } @@ -450,7 +450,7 @@ contract InterchainTokenService is * @param payload the payload of the receive token */ function _expressExecute(string calldata sourceChain, bytes calldata payload) internal { - (uint256 selector, bytes32 tokenId, bytes memory sourceAddress, bytes memory destinationAddressBytes, uint256 amount) = abi.decode( + (uint256 selector, bytes32 tokenId_, bytes memory sourceAddress, bytes memory destinationAddressBytes, uint256 amount) = abi.decode( payload, (uint256, bytes32, bytes, bytes, uint256) ); @@ -458,7 +458,7 @@ contract InterchainTokenService is IERC20 token; { - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); token = IERC20(tokenManager.tokenAddress()); } @@ -471,7 +471,7 @@ contract InterchainTokenService is sourceChain, sourceAddress, data, - tokenId, + tokenId_, address(token), amount ); @@ -482,35 +482,35 @@ contract InterchainTokenService is /** * @notice Transfer a token interchain. - * @param tokenId the tokenId for the token link. + * @param tokenId_ the tokenId_ for the token link. * @param destinationChain the name of the chain to send the token to. * @param destinationAddress the recipient of the interchain transfer. * @param amount the amount of token to give. * @param metadata the data to be passed to the destination. If provided with a bytes4(0) prefix, it'll execute the destination contract. */ function interchainTransfer( - bytes32 tokenId, + bytes32 tokenId_, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, bytes calldata metadata ) external payable whenNotPaused { - ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId_)); amount = tokenManager.takeToken(msg.sender, amount); - _transmitSendToken(tokenId, msg.sender, destinationChain, destinationAddress, amount, metadata); + _transmitSendToken(tokenId_, msg.sender, destinationChain, destinationAddress, amount, metadata); } function sendTokenWithData( - bytes32 tokenId, + bytes32 tokenId_, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, bytes calldata data ) external payable whenNotPaused { - ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(tokenManagerAddress(tokenId_)); amount = tokenManager.takeToken(msg.sender, amount); uint32 prefix = 0; - _transmitSendToken(tokenId, msg.sender, destinationChain, destinationAddress, amount, abi.encodePacked(prefix, data)); + _transmitSendToken(tokenId_, msg.sender, destinationChain, destinationAddress, amount, abi.encodePacked(prefix, data)); } /*********************\ @@ -518,8 +518,8 @@ contract InterchainTokenService is \*********************/ /** - * @notice Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager. - * @param tokenId the tokenId of the TokenManager (which must be the msg.sender). + * @notice Transmit a sendTokenWithData for the given tokenId_. Only callable by a token manager. + * @param tokenId_ the tokenId_ of the TokenManager (which must be the msg.sender). * @param sourceAddress the address where the token is coming from, which will also be used for reimbursement of gas. * @param destinationChain the name of the chain to send tokens to. * @param destinationAddress the destinationAddress for the interchainTransfer. @@ -527,14 +527,14 @@ contract InterchainTokenService is * @param metadata the data to be passed to the destination. */ function transmitSendToken( - bytes32 tokenId, + bytes32 tokenId_, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, uint256 amount, bytes calldata metadata - ) external payable onlyTokenManager(tokenId) whenNotPaused { - _transmitSendToken(tokenId, sourceAddress, destinationChain, destinationAddress, amount, metadata); + ) external payable onlyTokenManager(tokenId_) whenNotPaused { + _transmitSendToken(tokenId_, sourceAddress, destinationChain, destinationAddress, amount, metadata); } /*************\ @@ -611,7 +611,7 @@ contract InterchainTokenService is } if (selector == SELECTOR_DEPLOY_TOKEN_MANAGER) return _processDeployTokenManagerPayload(payload); - if (selector == SELECTOR_DEPLOY_AND_REGISTER_STANDARDIZED_TOKEN) return _processDeployStandardizedTokenAndManagerPayload(payload); + if (selector == SELECTOR_DEPLOY_AND_REGISTER_STANDARDIZED_TOKEN) return _processDeployInterchainTokenPayload(payload); revert SelectorUnknown(selector); } @@ -659,17 +659,17 @@ contract InterchainTokenService is bytes calldata payload, uint256 selector ) internal { - bytes32 tokenId; + bytes32 tokenId_; bytes memory sourceAddress; address destinationAddress; uint256 amount; { bytes memory destinationAddressBytes; - (, tokenId, sourceAddress, destinationAddressBytes, amount) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256)); + (, tokenId_, sourceAddress, destinationAddressBytes, amount) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256)); destinationAddress = destinationAddressBytes.toAddress(); } - ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(validTokenManagerAddress(tokenId_)); // Return token to the existing express caller if (expressExecutor != address(0)) { @@ -685,13 +685,13 @@ contract InterchainTokenService is (, , , , , data) = abi.decode(payload, (uint256, bytes32, bytes, bytes, uint256, bytes)); // slither-disable-next-line reentrancy-events - emit TokenReceivedWithData(tokenId, sourceChain, sourceAddress, destinationAddress, amount); + emit TokenReceivedWithData(tokenId_, sourceChain, sourceAddress, destinationAddress, amount); bytes32 result = IInterchainTokenExecutable(destinationAddress).executeWithInterchainToken( sourceChain, sourceAddress, data, - tokenId, + tokenId_, tokenManager.tokenAddress(), amount ); @@ -699,7 +699,7 @@ contract InterchainTokenService is if (result != EXECUTE_SUCCESS) revert ExecuteWithInterchainTokenFailed(destinationAddress); } else { // slither-disable-next-line reentrancy-events - emit TokenReceived(tokenId, sourceChain, sourceAddress, destinationAddress, amount); + emit TokenReceived(tokenId_, sourceChain, sourceAddress, destinationAddress, amount); } } @@ -708,22 +708,22 @@ contract InterchainTokenService is * @param payload The encoded data payload to be processed */ function _processDeployTokenManagerPayload(bytes calldata payload) internal { - (, bytes32 tokenId, TokenManagerType tokenManagerType, bytes memory params) = abi.decode( + (, bytes32 tokenId_, TokenManagerType tokenManagerType, bytes memory params) = abi.decode( payload, (uint256, bytes32, TokenManagerType, bytes) ); - _deployTokenManager(tokenId, tokenManagerType, params); + _deployTokenManager(tokenId_, tokenManagerType, params); } /** * @notice Process a deploy standardized token and manager payload. * @param payload The encoded data payload to be processed */ - function _processDeployStandardizedTokenAndManagerPayload(bytes calldata payload) internal { + function _processDeployInterchainTokenPayload(bytes calldata payload) internal { ( , - bytes32 tokenId, + bytes32 tokenId_, string memory name, string memory symbol, uint8 decimals, @@ -732,8 +732,8 @@ contract InterchainTokenService is uint256 mintAmount, bytes memory operatorBytes ) = abi.decode(payload, (uint256, bytes32, string, string, uint8, bytes, bytes, uint256, bytes)); - address tokenAddress_ = standardizedTokenAddress(tokenId); - address tokenManagerAddress_ = tokenManagerAddress(tokenId); + address tokenAddress_ = interchainTokenAddress(tokenId_); + address tokenManagerAddress_ = tokenManagerAddress(tokenId_); address distributor; address mintTo; @@ -753,8 +753,8 @@ contract InterchainTokenService is operatorBytes = address(this).toBytes(); } - _deployStandardizedToken(tokenId, distributor, name, symbol, decimals, mintAmount, mintTo); - _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(operatorBytes, tokenAddress_)); + _deployInterchainToken(tokenId_, distributor, name, symbol, decimals, mintAmount, mintTo); + _deployTokenManager(tokenId_, TokenManagerType.MINT_BURN, abi.encode(operatorBytes, tokenAddress_)); } /** @@ -787,28 +787,28 @@ contract InterchainTokenService is /** * @notice Deploys a token manager on a destination chain. - * @param tokenId The ID of the token + * @param tokenId_ The ID of the token * @param destinationChain The chain where the token manager will be deployed * @param gasValue The amount of gas to be paid for the transaction * @param tokenManagerType The type of token manager to be deployed * @param params Additional parameters for the token manager deployment */ function _deployRemoteTokenManager( - bytes32 tokenId, + bytes32 tokenId_, string calldata destinationChain, uint256 gasValue, TokenManagerType tokenManagerType, bytes memory params ) internal { - emit RemoteTokenManagerDeploymentInitialized(tokenId, destinationChain, gasValue, tokenManagerType, params); + emit RemoteTokenManagerDeploymentInitialized(tokenId_, destinationChain, gasValue, tokenManagerType, params); - bytes memory payload = abi.encode(SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId, tokenManagerType, params); + bytes memory payload = abi.encode(SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId_, tokenManagerType, params); _callContract(destinationChain, payload, gasValue); } /** * @notice Deploys a standardized token on a destination chain. - * @param tokenId The ID of the token + * @param tokenId_ The ID of the token * @param name The name of the token * @param symbol The symbol of the token * @param decimals The number of decimals of the token @@ -820,7 +820,7 @@ contract InterchainTokenService is * @param gasValue The amount of gas to be paid for the transaction */ function _deployRemoteStandardizedToken( - bytes32 tokenId, + bytes32 tokenId_, string memory name, string memory symbol, uint8 decimals, @@ -833,7 +833,7 @@ contract InterchainTokenService is ) internal { // slither-disable-next-line reentrancy-events emit RemoteStandardizedTokenAndManagerDeploymentInitialized( - tokenId, + tokenId_, name, symbol, decimals, @@ -847,7 +847,7 @@ contract InterchainTokenService is bytes memory payload = abi.encode( SELECTOR_DEPLOY_AND_REGISTER_STANDARDIZED_TOKEN, - tokenId, + tokenId_, name, symbol, decimals, @@ -861,14 +861,14 @@ contract InterchainTokenService is /** * @notice Deploys a token manager - * @param tokenId The ID of the token + * @param tokenId_ The ID of the token * @param tokenManagerType The type of the token manager to be deployed * @param params Additional parameters for the token manager deployment */ - function _deployTokenManager(bytes32 tokenId, TokenManagerType tokenManagerType, bytes memory params) internal { + function _deployTokenManager(bytes32 tokenId_, TokenManagerType tokenManagerType, bytes memory params) internal { // slither-disable-next-line controlled-delegatecall (bool success, bytes memory returnData) = tokenManagerDeployer.delegatecall( - abi.encodeWithSelector(ITokenManagerDeployer.deployTokenManager.selector, tokenId, tokenManagerType, params) + abi.encodeWithSelector(ITokenManagerDeployer.deployTokenManager.selector, tokenId_, tokenManagerType, params) ); if (!success) revert TokenManagerDeploymentFailed(returnData); @@ -878,21 +878,21 @@ contract InterchainTokenService is } // slither-disable-next-line reentrancy-events - emit TokenManagerDeployed(tokenId, tokenManager, tokenManagerType, params); + emit TokenManagerDeployed(tokenId_, tokenManager, tokenManagerType, params); } /** * @notice Compute the salt for a standardized token deployment. - * @param tokenId The ID of the token + * @param tokenId_ The ID of the token * @return salt The computed salt for the token deployment */ - function _getStandardizedTokenSalt(bytes32 tokenId) internal pure returns (bytes32 salt) { - return keccak256(abi.encode(PREFIX_STANDARDIZED_TOKEN_SALT, tokenId)); + function _getStandardizedTokenSalt(bytes32 tokenId_) internal pure returns (bytes32 salt) { + return keccak256(abi.encode(PREFIX_STANDARDIZED_TOKEN_SALT, tokenId_)); } /** * @notice Deploys a standardized token. - * @param tokenId The ID of the token + * @param tokenId_ The ID of the token * @param distributor The distributor address for the token * @param name The name of the token * @param symbol The symbol of the token @@ -900,8 +900,8 @@ contract InterchainTokenService is * @param mintAmount The amount of tokens to be minted upon deployment * @param mintTo The address where the minted tokens will be sent upon deployment */ - function _deployStandardizedToken( - bytes32 tokenId, + function _deployInterchainToken( + bytes32 tokenId_, address distributor, string memory name, string memory symbol, @@ -909,8 +909,8 @@ contract InterchainTokenService is uint256 mintAmount, address mintTo ) internal { - bytes32 salt = _getStandardizedTokenSalt(tokenId); - address tokenManagerAddress_ = tokenManagerAddress(tokenId); + bytes32 salt = _getStandardizedTokenSalt(tokenId_); + address tokenManagerAddress_ = tokenManagerAddress(tokenId_); // slither-disable-next-line controlled-delegatecall (bool success, bytes memory returnData) = standardizedTokenDeployer.delegatecall( @@ -936,7 +936,7 @@ contract InterchainTokenService is } // slither-disable-next-line reentrancy-events - emit StandardizedTokenDeployed(tokenId, tokenAddress_, distributor, name, symbol, decimals, mintAmount, mintTo); + emit StandardizedTokenDeployed(tokenId_, tokenAddress_, distributor, name, symbol, decimals, mintAmount, mintTo); } function _decodeMetadata(bytes memory metadata) internal pure returns (uint32 version, bytes memory data) { @@ -954,8 +954,8 @@ contract InterchainTokenService is } /** - * @notice Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager. - * @param tokenId the tokenId of the TokenManager (which must be the msg.sender). + * @notice Transmit a sendTokenWithData for the given tokenId_. Only callable by a token manager. + * @param tokenId_ the tokenId_ of the TokenManager (which must be the msg.sender). * @param sourceAddress the address where the token is coming from, which will also be used for reimburment of gas. * @param destinationChain the name of the chain to send tokens to. * @param destinationAddress the destinationAddress for the interchainTransfer. @@ -963,7 +963,7 @@ contract InterchainTokenService is * @param metadata the data to be passed to the destiantion. */ function _transmitSendToken( - bytes32 tokenId, + bytes32 tokenId_, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, @@ -973,9 +973,9 @@ contract InterchainTokenService is bytes memory payload; if (metadata.length < 4) { // slither-disable-next-line reentrancy-events - emit TokenSent(tokenId, destinationChain, destinationAddress, amount); + emit TokenSent(tokenId_, destinationChain, destinationAddress, amount); - payload = abi.encode(SELECTOR_RECEIVE_TOKEN, tokenId, sourceAddress.toBytes(), destinationAddress, amount); + payload = abi.encode(SELECTOR_RECEIVE_TOKEN, tokenId_, sourceAddress.toBytes(), destinationAddress, amount); _callContract(destinationChain, payload, msg.value); return; @@ -985,9 +985,9 @@ contract InterchainTokenService is if (version > 0) revert InvalidMetadataVersion(version); // slither-disable-next-line reentrancy-events - emit TokenSentWithData(tokenId, destinationChain, destinationAddress, amount, sourceAddress, metadata); + emit TokenSentWithData(tokenId_, destinationChain, destinationAddress, amount, sourceAddress, metadata); - payload = abi.encode(SELECTOR_RECEIVE_TOKEN_WITH_DATA, tokenId, sourceAddress.toBytes(), destinationAddress, amount, metadata); + payload = abi.encode(SELECTOR_RECEIVE_TOKEN_WITH_DATA, tokenId_, sourceAddress.toBytes(), destinationAddress, amount, metadata); _callContract(destinationChain, payload, msg.value); } diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index ea911ebd..44085714 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -15,7 +15,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec error LengthMismatch(); error InvalidTokenManagerImplementationType(address implementation); error NotRemoteService(); - error TokenManagerDoesNotExist(bytes32 tokenId); + error TokenManagerDoesNotExist(bytes32 tokenId_); error NotTokenManager(address caller, address tokenManager); error ExecuteWithInterchainTokenFailed(address contractAddress); error InvalidCanonicalTokenId(bytes32 expectedCanonicalTokenId); @@ -29,9 +29,9 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec error UntrustedChain(string chainName); error InvalidExpressSelector(uint256 selector); - event TokenSent(bytes32 indexed tokenId, string destinationChain, bytes destinationAddress, uint256 indexed amount); + event TokenSent(bytes32 indexed tokenId_, string destinationChain, bytes destinationAddress, uint256 indexed amount); event TokenSentWithData( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, string destinationChain, bytes destinationAddress, uint256 indexed amount, @@ -39,28 +39,28 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec bytes data ); event TokenReceived( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, string sourceChain, bytes sourceAddress, address indexed destinationAddress, uint256 indexed amount ); event TokenReceivedWithData( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, string sourceChain, bytes sourceAddress, address indexed destinationAddress, uint256 indexed amount ); event RemoteTokenManagerDeploymentInitialized( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, string destinationChain, uint256 indexed gasValue, TokenManagerType indexed tokenManagerType, bytes params ); event RemoteStandardizedTokenAndManagerDeploymentInitialized( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, string tokenName, string tokenSymbol, uint8 tokenDecimals, @@ -71,9 +71,9 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec string destinationChain, uint256 indexed gasValue ); - event TokenManagerDeployed(bytes32 indexed tokenId, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params); + event TokenManagerDeployed(bytes32 indexed tokenId_, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params); event StandardizedTokenDeployed( - bytes32 indexed tokenId, + bytes32 indexed tokenId_, address tokenAddress, address indexed distributor, string name, @@ -82,7 +82,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec uint256 indexed mintAmount, address mintTo ); - event CustomTokenIdClaimed(bytes32 indexed tokenId, address indexed deployer, bytes32 indexed salt); + event CustomTokenIdClaimed(bytes32 indexed tokenId_, address indexed deployer, bytes32 indexed salt); event PausedSet(bool indexed paused, address indexed msgSender); /** @@ -104,75 +104,75 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec function standardizedTokenDeployer() external view returns (address standardizedTokenDeployerAddress); /** - * @notice Returns the address of the token manager associated with the given tokenId. - * @param tokenId The tokenId of the token manager. + * @notice Returns the address of the token manager associated with the given tokenId_. + * @param tokenId_ The tokenId_ of the token manager. * @return tokenManagerAddress_ The address of the token manager. */ - function tokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_); + function tokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_); /** - * @notice Returns the address of the valid token manager associated with the given tokenId. - * @param tokenId The tokenId of the token manager. + * @notice Returns the address of the valid token manager associated with the given tokenId_. + * @param tokenId_ The tokenId_ of the token manager. * @return tokenManagerAddress_ The address of the valid token manager. */ - function validTokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_); + function validTokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_); /** - * @notice Returns the address of the token associated with the given tokenId. - * @param tokenId The tokenId of the token manager. + * @notice Returns the address of the token associated with the given tokenId_. + * @param tokenId_ The tokenId_ of the token manager. * @return tokenAddress_ The address of the token. */ - function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_); + function tokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_); /** - * @notice Returns the address of the standardized token associated with the given tokenId. - * @param tokenId The tokenId of the standardized token. + * @notice Returns the address of the standardized token associated with the given tokenId_. + * @param tokenId_ The tokenId_ of the standardized token. * @return tokenAddress_ The address of the standardized token. */ - function standardizedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress_); + function interchainTokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_); /** - * @notice Returns the canonical tokenId associated with the given tokenAddress. + * @notice Returns the canonical tokenId_ associated with the given tokenAddress. * @param tokenAddress_ The address of the token. - * @return tokenId The canonical tokenId associated with the tokenAddress. + * @return tokenId_ The canonical tokenId_ associated with the tokenAddress. */ - function canonicalTokenId(address tokenAddress_) external view returns (bytes32 tokenId); + function canonicalTokenId(address tokenAddress_) external view returns (bytes32 tokenId_); /** - * @notice Returns the custom tokenId associated with the given operator and salt. + * @notice Returns the custom tokenId_ associated with the given operator and salt. * @param operator_ The operator address. * @param salt The salt used for token id calculation. - * @return tokenId The custom tokenId associated with the operator and salt. + * @return tokenId_ The custom tokenId_ associated with the operator and salt. */ - function customTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId); + function tokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId_); /** - * @notice Registers a canonical token and returns its associated tokenId. + * @notice Registers a canonical token and returns its associated tokenId_. * @param tokenAddress_ The address of the canonical token. - * @return tokenId The tokenId associated with the registered canonical token. + * @return tokenId_ The tokenId_ associated with the registered canonical token. */ - function registerCanonicalToken(address tokenAddress_) external payable returns (bytes32 tokenId); + function registerCanonicalToken(address tokenAddress_) external payable returns (bytes32 tokenId_); /** * @notice Deploys a standardized canonical token on a remote chain. - * @param tokenId The tokenId of the canonical token. + * @param tokenId_ The tokenId_ of the canonical token. * @param destinationChain The name of the destination chain. * @param gasValue The gas value for deployment. */ - function deployRemoteCanonicalToken(bytes32 tokenId, string calldata destinationChain, uint256 gasValue) external payable; + function deployRemoteCanonicalToken(bytes32 tokenId_, string calldata destinationChain, uint256 gasValue) external payable; /** * @notice Deploys a custom token manager contract. * @param salt The salt used for token manager deployment. * @param tokenManagerType The type of token manager. * @param params The deployment parameters. - * @return tokenId The tokenId of the deployed token manager. + * @return tokenId_ The tokenId_ of the deployed token manager. */ function deployCustomTokenManager( bytes32 salt, TokenManagerType tokenManagerType, bytes memory params - ) external payable returns (bytes32 tokenId); + ) external payable returns (bytes32 tokenId_); /** * @notice Deploys a custom token manager contract on a remote chain. @@ -182,13 +182,13 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec * @param params The deployment parameters. * @param gasValue The gas value for deployment. */ - function deployRemoteCustomTokenManager( + function deployTokenManager( bytes32 salt, string calldata destinationChain, TokenManagerType tokenManagerType, bytes calldata params, uint256 gasValue - ) external payable returns (bytes32 tokenId); + ) external payable returns (bytes32 tokenId_); /** * @notice Deploys a standardized token and registers it. The token manager type will be lock/unlock unless the distributor matches its address, in which case it will be a mint/burn one. @@ -221,7 +221,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec * @param destinationChain The name of the destination chain. * @param gasValue The gas value for deployment. */ - function deployAndRegisterRemoteStandardizedToken( + function deployInterchainToken( bytes32 salt, string memory name, string memory symbol, @@ -242,7 +242,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_); function interchainTransfer( - bytes32 tokenId, + bytes32 tokenId_, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, @@ -250,7 +250,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec ) external payable; function sendTokenWithData( - bytes32 tokenId, + bytes32 tokenId_, string calldata destinationChain, bytes calldata destinationAddress, uint256 amount, @@ -259,7 +259,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec /** * @notice Initiates an interchain token transfer. Only callable by TokenManagers - * @param tokenId The tokenId of the token to be transmitted. + * @param tokenId_ The tokenId_ of the token to be transmitted. * @param sourceAddress The source address of the token. * @param destinationChain The name of the destination chain. * @param destinationAddress The destination address on the destination chain. @@ -267,7 +267,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec * @param metadata The metadata associated with the transmission. */ function transmitSendToken( - bytes32 tokenId, + bytes32 tokenId_, address sourceAddress, string calldata destinationChain, bytes memory destinationAddress, @@ -284,24 +284,24 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec /** * @notice Returns the flow limit for a specific token. - * @param tokenId The tokenId of the token. + * @param tokenId_ The tokenId_ of the token. * @return flowLimit_ The flow limit for the token. */ - function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_); + function flowLimit(bytes32 tokenId_) external view returns (uint256 flowLimit_); /** * @notice Returns the total amount of outgoing flow for a specific token. - * @param tokenId The tokenId of the token. + * @param tokenId_ The tokenId_ of the token. * @return flowOutAmount_ The total amount of outgoing flow for the token. */ - function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_); + function flowOutAmount(bytes32 tokenId_) external view returns (uint256 flowOutAmount_); /** * @notice Returns the total amount of incoming flow for a specific token. - * @param tokenId The tokenId of the token. + * @param tokenId_ The tokenId_ of the token. * @return flowInAmount_ The total amount of incoming flow for the token. */ - function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_); + function flowInAmount(bytes32 tokenId_) external view returns (uint256 flowInAmount_); /** * @notice Sets the paused state of the contract. diff --git a/contracts/interfaces/IStandardizedTokenRegistrar.sol b/contracts/interfaces/IStandardizedTokenRegistrar.sol index 83fdc06b..064f7b9f 100644 --- a/contracts/interfaces/IStandardizedTokenRegistrar.sol +++ b/contracts/interfaces/IStandardizedTokenRegistrar.sol @@ -14,7 +14,7 @@ interface IStandardizedTokenRegistrar { function standardizedTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId); - function standardizedTokenAddress(address deployer, bytes32 salt) external view returns (address tokenAddress); + function interchainTokenAddress(address deployer, bytes32 salt) external view returns (address tokenAddress); function deployStandardizedToken( bytes32 salt, diff --git a/contracts/token-registrars/CanonicalTokenRegistrar.sol b/contracts/token-registrars/CanonicalTokenRegistrar.sol index 82c47c4b..88dae318 100644 --- a/contracts/token-registrars/CanonicalTokenRegistrar.sol +++ b/contracts/token-registrars/CanonicalTokenRegistrar.sol @@ -40,7 +40,7 @@ contract CanonicalTokenRegistrar is ICanonicalTokenRegistrar, ITokenManagerType, } function canonicalTokenId(address tokenAddress) public view returns (bytes32 tokenId) { - tokenId = service.customTokenId(address(this), canonicalTokenSalt(tokenAddress)); + tokenId = service.tokenId(address(this), canonicalTokenSalt(tokenAddress)); } function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) { @@ -51,7 +51,7 @@ contract CanonicalTokenRegistrar is ICanonicalTokenRegistrar, ITokenManagerType, function deployAndRegisterRemoteCanonicalToken(bytes32 salt, string calldata destinationChain, uint256 gasValue) external payable { // This ensures that the token manager has been deployed by this address, so it's safe to trust it. - bytes32 tokenId = service.customTokenId(address(this), salt); + bytes32 tokenId = service.tokenId(address(this), salt); IERC20Named token = IERC20Named(service.tokenAddress(tokenId)); // The 3 lines below will revert if the token manager does not exist. string memory tokenName = token.name(); @@ -59,7 +59,7 @@ contract CanonicalTokenRegistrar is ICanonicalTokenRegistrar, ITokenManagerType, uint8 tokenDecimals = token.decimals(); // slither-disable-next-line arbitrary-send-eth - service.deployAndRegisterRemoteStandardizedToken{ value: gasValue }( + service.deployInterchainToken{ value: gasValue }( salt, tokenName, tokenSymbol, diff --git a/contracts/token-registrars/StandardizedTokenRegistrar.sol b/contracts/token-registrars/StandardizedTokenRegistrar.sol index b340f945..7e24bc11 100644 --- a/contracts/token-registrars/StandardizedTokenRegistrar.sol +++ b/contracts/token-registrars/StandardizedTokenRegistrar.sol @@ -54,11 +54,11 @@ contract StandardizedTokenRegistrar is IStandardizedTokenRegistrar, ITokenManage } function standardizedTokenId(address deployer, bytes32 salt) public view returns (bytes32 tokenId) { - tokenId = service.customTokenId(address(this), standardizedTokenSalt(deployer, salt)); + tokenId = service.tokenId(address(this), standardizedTokenSalt(deployer, salt)); } - function standardizedTokenAddress(address deployer, bytes32 salt) public view returns (address tokenAddress) { - tokenAddress = service.standardizedTokenAddress(standardizedTokenId(deployer, salt)); + function interchainTokenAddress(address deployer, bytes32 salt) public view returns (address tokenAddress) { + tokenAddress = service.interchainTokenAddress(standardizedTokenId(deployer, salt)); } function deployStandardizedToken( @@ -71,13 +71,13 @@ contract StandardizedTokenRegistrar is IStandardizedTokenRegistrar, ITokenManage ) external payable { address sender = msg.sender; salt = standardizedTokenSalt(sender, salt); - bytes32 tokenId = service.customTokenId(address(this), salt); + bytes32 tokenId = service.tokenId(address(this), salt); service.deployAndRegisterStandardizedToken(salt, name, symbol, decimals, mintAmount, distributor); ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId)); tokenManager.transferOperatorship(sender); - IStandardizedToken token = IStandardizedToken(service.standardizedTokenAddress(tokenId)); + IStandardizedToken token = IStandardizedToken(service.interchainTokenAddress(tokenId)); token.safeTransfer(sender, mintAmount); } @@ -98,9 +98,9 @@ contract StandardizedTokenRegistrar is IStandardizedTokenRegistrar, ITokenManage { address sender = msg.sender; salt = standardizedTokenSalt(sender, salt); - bytes32 tokenId = service.customTokenId(address(this), salt); + bytes32 tokenId = service.tokenId(address(this), salt); - IStandardizedToken token = IStandardizedToken(service.standardizedTokenAddress(tokenId)); + IStandardizedToken token = IStandardizedToken(service.interchainTokenAddress(tokenId)); ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId)); tokenName = token.name(); @@ -118,20 +118,10 @@ contract StandardizedTokenRegistrar is IStandardizedTokenRegistrar, ITokenManage } } - _deployAndRegisterRemoteStandardizedToken( - salt, - tokenName, - tokenSymbol, - tokenDecimals, - distributor, - operator, - mintAmount, - destinationChain, - gasValue - ); + _deployInterchainToken(salt, tokenName, tokenSymbol, tokenDecimals, distributor, operator, mintAmount, destinationChain, gasValue); } - function _deployAndRegisterRemoteStandardizedToken( + function _deployInterchainToken( bytes32 salt, string memory tokenName, string memory tokenSymbol, @@ -143,7 +133,7 @@ contract StandardizedTokenRegistrar is IStandardizedTokenRegistrar, ITokenManage uint256 gasValue ) internal { // slither-disable-next-line arbitrary-send-eth - service.deployAndRegisterRemoteStandardizedToken{ value: gasValue }( + service.deployInterchainToken{ value: gasValue }( salt, tokenName, tokenSymbol, diff --git a/docs/index.md b/docs/index.md index a1a5f9ac..aa0385fa 100644 --- a/docs/index.md +++ b/docs/index.md @@ -230,10 +230,10 @@ Returns the address of the token that an existing tokenManager points to. | ------------ | ------- | ------------------------- | | tokenAddress | address | the address of the token. | -### standardizedTokenAddress +### interchainTokenAddress ```solidity -function standardizedTokenAddress(bytes32 tokenId) public view returns (address tokenAddress) +function interchainTokenAddress(bytes32 tokenId) public view returns (address tokenAddress) ``` Returns the address of the standardized token that would be deployed with a given tokenId. @@ -272,10 +272,10 @@ This will depend on what chain it is called from, unlike custom tokenIds. | ------- | ------- | ------------------------------------------------------------------------------------ | | tokenId | bytes32 | the tokenId that the canonical TokenManager would get (or has gotten) for the token. | -### customTokenId +### tokenId ```solidity -function customTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId) +function tokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId) ``` Calculates the tokenId that would correspond to a custom link for a given deployer with a specified salt. @@ -494,10 +494,10 @@ Used to deploy custom TokenManagers with the specified salt. Different callers w | tokenManagerType | enum ITokenManagerType.TokenManagerType | the type of TokenManager to be deployed. | | params | bytes | the params that will be used to initialize the TokenManager. | -### deployRemoteCustomTokenManager +### deployTokenManager ```solidity -function deployRemoteCustomTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) +function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) ``` Used to deploy remote custom TokenManagers. @@ -535,10 +535,10 @@ can be calculated ahead of time) then a mint/burn TokenManager is used. Otherwis | mintAmount | uint256 | the amount of token to be mint during deployment to msg.sender. | | distributor | address | the address that will be able to mint and burn the deployed token. | -### deployAndRegisterRemoteStandardizedToken +### deployInterchainToken ```solidity -function deployAndRegisterRemoteStandardizedToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable +function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable ``` Used to deploy a standardized token alongside a TokenManager in another chain. If the `distributor` is empty @@ -1325,10 +1325,10 @@ Returns the address of the token associated with the given tokenId. | ------------ | ------- | ------------------------- | | tokenAddress | address | The address of the token. | -### standardizedTokenAddress +### interchainTokenAddress ```solidity -function standardizedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress) +function interchainTokenAddress(bytes32 tokenId) external view returns (address tokenAddress) ``` Returns the address of the standardized token associated with the given tokenId. @@ -1365,10 +1365,10 @@ Returns the canonical tokenId associated with the given tokenAddress. | ------- | ------- | ------------------------------------------------------- | | tokenId | bytes32 | The canonical tokenId associated with the tokenAddress. | -### customTokenId +### tokenId ```solidity -function customTokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId) +function tokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId) ``` Returns the custom tokenId associated with the given operator and salt. @@ -1508,10 +1508,10 @@ Deploys a custom token manager contract. | ------- | ------- | ------------------------------------------ | | tokenId | bytes32 | The tokenId of the deployed token manager. | -### deployRemoteCustomTokenManager +### deployTokenManager ```solidity -function deployRemoteCustomTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) +function deployTokenManager(bytes32 salt, string destinationChain, enum ITokenManagerType.TokenManagerType tokenManagerType, bytes params, uint256 gasValue) external payable returns (bytes32 tokenId) ``` Deploys a custom token manager contract on a remote chain. @@ -1545,10 +1545,10 @@ Deploys a standardized token and registers it. The token manager type will be lo | mintAmount | uint256 | The amount of tokens to mint to the deployer. | | distributor | address | The address of the distributor for mint/burn operations. | -### deployAndRegisterRemoteStandardizedToken +### deployInterchainToken ```solidity -function deployAndRegisterRemoteStandardizedToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable +function deployInterchainToken(bytes32 salt, string name, string symbol, uint8 decimals, bytes distributor, bytes operator, string destinationChain, uint256 gasValue) external payable ``` Deploys and registers a standardized token on a remote chain. diff --git a/test/TokenRegistrars.js b/test/TokenRegistrars.js index 6babb794..c23222a4 100644 --- a/test/TokenRegistrars.js +++ b/test/TokenRegistrars.js @@ -137,7 +137,7 @@ describe('Token Registrsrs', () => { it('Should register a token', async () => { const salt = keccak256('0x'); tokenId = await standardizedTokenRegistrar.standardizedTokenId(wallet.address, salt); - const tokenAddress = await standardizedTokenRegistrar.standardizedTokenAddress(wallet.address, salt); + const tokenAddress = await standardizedTokenRegistrar.interchainTokenAddress(wallet.address, salt); const params = defaultAbiCoder.encode(['bytes', 'address'], [standardizedTokenRegistrar.address, tokenAddress]); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet); const token = new Contract(tokenAddress, IERC20.abi, wallet); @@ -160,7 +160,7 @@ describe('Token Registrsrs', () => { const salt = keccak256('0x12'); tokenId = await standardizedTokenRegistrar.standardizedTokenId(wallet.address, salt); - const tokenAddress = await standardizedTokenRegistrar.standardizedTokenAddress(wallet.address, salt); + const tokenAddress = await standardizedTokenRegistrar.interchainTokenAddress(wallet.address, salt); let params = defaultAbiCoder.encode(['bytes', 'address'], [standardizedTokenRegistrar.address, tokenAddress]); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet); const token = new Contract(tokenAddress, IERC20.abi, wallet); @@ -230,7 +230,7 @@ describe('Token Registrsrs', () => { const salt = keccak256('0x1245'); tokenId = await standardizedTokenRegistrar.standardizedTokenId(wallet.address, salt); - const tokenAddress = await standardizedTokenRegistrar.standardizedTokenAddress(wallet.address, salt); + const tokenAddress = await standardizedTokenRegistrar.interchainTokenAddress(wallet.address, salt); let params = defaultAbiCoder.encode(['bytes', 'address'], [standardizedTokenRegistrar.address, tokenAddress]); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet); const token = new Contract(tokenAddress, IERC20.abi, wallet); @@ -281,7 +281,7 @@ describe('Token Registrsrs', () => { const salt = keccak256('0x124567'); tokenId = await standardizedTokenRegistrar.standardizedTokenId(wallet.address, salt); - const tokenAddress = await standardizedTokenRegistrar.standardizedTokenAddress(wallet.address, salt); + const tokenAddress = await standardizedTokenRegistrar.interchainTokenAddress(wallet.address, salt); let params = defaultAbiCoder.encode(['bytes', 'address'], [standardizedTokenRegistrar.address, tokenAddress]); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet); const token = new Contract(tokenAddress, IERC20.abi, wallet); diff --git a/test/TokenService.js b/test/TokenService.js index 815d0579..3527a94f 100644 --- a/test/TokenService.js +++ b/test/TokenService.js @@ -54,7 +54,7 @@ describe('Interchain Token Service', () => { skipApprove = false, ) { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), TokenManager.abi, wallet); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); @@ -78,7 +78,7 @@ describe('Interchain Token Service', () => { skipApprove = false, ) { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), TokenManager.abi, wallet); const token = await deployContract(wallet, 'FeeOnTransferTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); @@ -100,7 +100,7 @@ describe('Interchain Token Service', () => { const makeDeployNewMintBurn = (type) => async function deployNewMintBurn(tokenName, tokenSymbol, tokenDecimals, mintAmount = 0) { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); @@ -354,7 +354,7 @@ describe('Interchain Token Service', () => { it('Should revert if setup fails on TokenManager implementation deployment', async () => { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const validParams = defaultAbiCoder.encode(['bytes', 'address'], ['0x', wallet.address]); const tokenManagerProxy = await deployContract(wallet, `TokenManagerProxy`, [ service.address, @@ -487,8 +487,8 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const mintAmount = 123456; - const tokenId = await service.customTokenId(wallet.address, salt); - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenId = await service.tokenId(wallet.address, salt); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); await expect( @@ -514,7 +514,7 @@ describe('Interchain Token Service', () => { await tx.wait(); const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const gasValue = 1e6; await expectRevert( @@ -542,8 +542,8 @@ describe('Interchain Token Service', () => { it('Should register a standardized token', async () => { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenId = await service.tokenId(wallet.address, salt); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); await expect( @@ -585,8 +585,8 @@ describe('Interchain Token Service', () => { it('Should revert when registering a standardized token as a lock/unlock for a second time', async () => { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenId = await service.tokenId(wallet.address, salt); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); await expect( @@ -638,7 +638,7 @@ describe('Interchain Token Service', () => { }); it('Should initialize a remote standardized token deployment', async () => { - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const payload = defaultAbiCoder.encode( ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes', 'uint256', 'bytes'], [ @@ -654,7 +654,7 @@ describe('Interchain Token Service', () => { ], ); await expect( - service.deployAndRegisterRemoteStandardizedToken( + service.deployInterchainToken( salt, tokenName, tokenSymbol, @@ -693,7 +693,7 @@ describe('Interchain Token Service', () => { await expectRevert( (gasOptions) => - service.deployAndRegisterRemoteStandardizedToken( + service.deployInterchainToken( salt, tokenName, tokenSymbol, @@ -767,7 +767,7 @@ describe('Interchain Token Service', () => { const mintTo = '0x'; const mintAmount = 1234; const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [distributor, tokenAddress]); const payload = defaultAbiCoder.encode( ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes', 'uint256', 'bytes'], @@ -805,7 +805,7 @@ describe('Interchain Token Service', () => { const operator = wallet.address; const mintTo = '0x'; const mintAmount = 0; - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]); const payload = defaultAbiCoder.encode( ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes', 'uint256', 'bytes'], @@ -840,7 +840,7 @@ describe('Interchain Token Service', () => { const mintTo = '0x'; const mintAmount = 1234; const operator = '0x'; - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [service.address, tokenAddress]); const payload = defaultAbiCoder.encode( ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes', 'uint256', 'bytes'], @@ -887,7 +887,7 @@ describe('Interchain Token Service', () => { const mintTo = arrayify(tokenManagerAddress); const mintAmount = 1234; const operator = '0x'; - const tokenAddress = await service.standardizedTokenAddress(tokenId); + const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [service.address, tokenAddress]); const payload = defaultAbiCoder.encode( ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes', 'uint256', 'bytes'], @@ -954,7 +954,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -977,7 +977,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -1000,7 +1000,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -1025,7 +1025,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'FeeOnTransferTokenTest', [ tokenName, @@ -1055,7 +1055,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -1081,7 +1081,7 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); @@ -1103,7 +1103,7 @@ describe('Interchain Token Service', () => { it('Should initialize a remote custom token manager deployment', async () => { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const gasValue = 1e6; const params = '0x1234'; const type = LOCK_UNLOCK; @@ -1112,7 +1112,7 @@ describe('Interchain Token Service', () => { [SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId, type, params], ); - await expect(service.deployRemoteCustomTokenManager(salt, destinationChain, type, params, gasValue, { value: gasValue })) + await expect(service.deployTokenManager(salt, destinationChain, type, params, gasValue, { value: gasValue })) .to.emit(service, 'RemoteTokenManagerDeploymentInitialized') .withArgs(tokenId, destinationChain, gasValue, type, params) .and.to.emit(gasService, 'NativeGasPaidForContractCall') @@ -1132,7 +1132,7 @@ describe('Interchain Token Service', () => { await expectRevert( (gasOptions) => - service.deployRemoteCustomTokenManager(salt, destinationChain, type, params, gasValue, { + service.deployTokenManager(salt, destinationChain, type, params, gasValue, { ...gasOptions, value: gasValue, }), @@ -1154,7 +1154,7 @@ describe('Interchain Token Service', () => { it('Should initialize a remote custom token manager deployment', async () => { const salt = getRandomBytes32(); - const tokenId = await service.customTokenId(wallet.address, salt); + const tokenId = await service.tokenId(wallet.address, salt); const gasValue = 1e6; const params = '0x1234'; const type = LOCK_UNLOCK; @@ -1163,7 +1163,7 @@ describe('Interchain Token Service', () => { [SELECTOR_DEPLOY_TOKEN_MANAGER, tokenId, type, params], ); - await expect(service.deployRemoteCustomTokenManager(salt, destinationChain, type, params, gasValue, { value: gasValue })) + await expect(service.deployTokenManager(salt, destinationChain, type, params, gasValue, { value: gasValue })) .to.emit(service, 'RemoteTokenManagerDeploymentInitialized') .withArgs(tokenId, destinationChain, gasValue, type, params) .and.to.emit(gasService, 'NativeGasPaidForContractCall') @@ -1183,7 +1183,7 @@ describe('Interchain Token Service', () => { await expectRevert( (gasOptions) => - service.deployRemoteCustomTokenManager(salt, destinationChain, type, params, gasValue, { + service.deployTokenManager(salt, destinationChain, type, params, gasValue, { ...gasOptions, value: gasValue, }), diff --git a/test/TokenServiceFullFlow.js b/test/TokenServiceFullFlow.js index 7b059cc7..650ca3b8 100644 --- a/test/TokenServiceFullFlow.js +++ b/test/TokenServiceFullFlow.js @@ -147,8 +147,8 @@ describe('Interchain Token Service Full Flow', () => { const tokenCap = BigInt(1e18); before(async () => { - tokenId = await service.customTokenId(wallet.address, salt); - const tokenAddress = await service.standardizedTokenAddress(tokenId); + tokenId = await service.tokenId(wallet.address, salt); + const tokenAddress = await service.interchainTokenAddress(tokenId); token = new Contract(tokenAddress, StandardizedToken.abi, wallet); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); tokenManager = new Contract(tokenManagerAddress, ITokenManager.abi, wallet); @@ -167,7 +167,7 @@ describe('Interchain Token Service Full Flow', () => { let value = 0; for (const i in otherChains) { - const tx = await service.populateTransaction.deployAndRegisterRemoteStandardizedToken( + const tx = await service.populateTransaction.deployInterchainToken( salt, name, symbol, @@ -191,7 +191,7 @@ describe('Interchain Token Service Full Flow', () => { const tx = service.multicall(data, { value }); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); - const expectedTokenAddress = await service.standardizedTokenAddress(tokenId); + const expectedTokenAddress = await service.interchainTokenAddress(tokenId); await expect(tx) .to.emit(service, 'StandardizedTokenDeployed') .withArgs(tokenId, expectedTokenAddress, wallet.address, name, symbol, decimals, tokenCap, wallet.address) @@ -271,7 +271,7 @@ describe('Interchain Token Service Full Flow', () => { // The below is used to deploy a token, but any ERC20 that has a mint capability can be used instead. token = await deployContract(wallet, 'InterchainTokenTest', [name, symbol, decimals, wallet.address]); - tokenId = await service.customTokenId(wallet.address, salt); + tokenId = await service.tokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); await (await token.mint(wallet.address, tokenCap)).wait(); await (await token.setTokenManager(tokenManagerAddress)).wait(); @@ -287,13 +287,7 @@ describe('Interchain Token Service Full Flow', () => { let value = 0; for (const i in otherChains) { - const tx = await service.populateTransaction.deployRemoteCustomTokenManager( - salt, - otherChains[i], - MINT_BURN, - params, - gasValues[i], - ); + const tx = await service.populateTransaction.deployTokenManager(salt, otherChains[i], MINT_BURN, params, gasValues[i]); data.push(tx.data); value += gasValues[i]; }