diff --git a/.changeset/many-tigers-kneel.md b/.changeset/many-tigers-kneel.md new file mode 100644 index 00000000..a17c7f28 --- /dev/null +++ b/.changeset/many-tigers-kneel.md @@ -0,0 +1,5 @@ +--- +'@axelar-network/interchain-token-service': minor +--- + +Interchain tokens now get minted/burnt by the token manager. diff --git a/contracts/TokenHandler.sol b/contracts/TokenHandler.sol index 5db715f6..244c9d7c 100644 --- a/contracts/TokenHandler.sol +++ b/contracts/TokenHandler.sol @@ -43,7 +43,7 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea tokenManagerType == uint256(TokenManagerType.MINT_BURN) || tokenManagerType == uint256(TokenManagerType.MINT_BURN_FROM) ) { - _mintToken(tokenManager, tokenAddress, to, amount); + _mintToken(ITokenManager(tokenManager), tokenAddress, to, amount); return (amount, tokenAddress); } @@ -78,7 +78,7 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea if ( tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN) || tokenManagerType == uint256(TokenManagerType.MINT_BURN) ) { - _burnToken(tokenManager, tokenAddress, from, amount); + _burnToken(ITokenManager(tokenManager), tokenAddress, from, amount); } else if (tokenManagerType == uint256(TokenManagerType.MINT_BURN_FROM)) { _burnTokenFrom(tokenAddress, from, amount); } else if (tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK)) { @@ -132,12 +132,16 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea * @param tokenManager The address of the token manager. */ // slither-disable-next-line locked-ether - function postTokenManagerDeploy(uint256 tokenManagerType, address tokenManager) external payable { - // For lock/unlock token managers, the ITS contract needs an approval from the token manager to transfer tokens on its behalf - if (tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK) || tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK_FEE)) { - ITokenManager(tokenManager).approveService(); - } else if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) { - IMinter(ITokenManager(tokenManager).tokenAddress()).transferMintership(tokenManager); + function postTokenManagerDeploy(uint256 tokenManagerType, ITokenManager tokenManager) external payable { + // For native interhcain tokens we transfer mintership to the token manager. + // This is done here because InterchainToken bytecode needs to be fixed. + if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) { + IMinter(tokenManager.tokenAddress()).transferMintership(address(tokenManager)); + // For lock/unlock token managers, the ITS contract needs an approval from the token manager to transfer tokens on its behalf. + } else if ( + tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK) || tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK_FEE) + ) { + tokenManager.approveService(); } } @@ -161,12 +165,12 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea return diff < amount ? diff : amount; } - function _mintToken(address tokenManager, address tokenAddress, address to, uint256 amount) internal { - ITokenManager(tokenManager).mintToken(tokenAddress, to, amount); + function _mintToken(ITokenManager tokenManager, address tokenAddress, address to, uint256 amount) internal { + tokenManager.mintToken(tokenAddress, to, amount); } - function _burnToken(address tokenManager, address tokenAddress, address from, uint256 amount) internal { - ITokenManager(tokenManager).burnToken(tokenAddress, from, amount); + function _burnToken(ITokenManager tokenManager, address tokenAddress, address from, uint256 amount) internal { + tokenManager.burnToken(tokenAddress, from, amount); } function _burnTokenFrom(address tokenAddress, address from, uint256 amount) internal { diff --git a/contracts/interfaces/ITokenHandler.sol b/contracts/interfaces/ITokenHandler.sol index 7650de21..4d697b9b 100644 --- a/contracts/interfaces/ITokenHandler.sol +++ b/contracts/interfaces/ITokenHandler.sol @@ -2,6 +2,8 @@ pragma solidity ^0.8.0; +import { ITokenManager } from './ITokenManager.sol'; + /** * @title ITokenHandler Interface * @notice This interface is responsible for handling tokens before initiating an interchain token transfer, or after receiving one. @@ -47,5 +49,5 @@ interface ITokenHandler { * @param tokenManagerType The token manager type. * @param tokenManager The address of the token manager. */ - function postTokenManagerDeploy(uint256 tokenManagerType, address tokenManager) external payable; + function postTokenManagerDeploy(uint256 tokenManagerType, ITokenManager tokenManager) external payable; }