diff --git a/contracts/TokenHandler.sol b/contracts/TokenHandler.sol index 8ac174a7..7b78a4cf 100644 --- a/contracts/TokenHandler.sol +++ b/contracts/TokenHandler.sol @@ -12,7 +12,6 @@ import { ITokenManagerType } from './interfaces/ITokenManagerType.sol'; import { ITokenManager } from './interfaces/ITokenManager.sol'; import { ITokenManagerProxy } from './interfaces/ITokenManagerProxy.sol'; import { IERC20MintableBurnable } from './interfaces/IERC20MintableBurnable.sol'; -import { IERC20BurnableFrom } from './interfaces/IERC20BurnableFrom.sol'; import { IERC20Named } from './interfaces/IERC20Named.sol'; /** @@ -105,9 +104,9 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) { _takeInterchainToken(tokenAddress, from, amount); } else if (tokenManagerType == uint256(TokenManagerType.MINT_BURN)) { - _takeTokenMintBurn(tokenAddress, from, amount); + _burnToken(tokenManager, tokenAddress, from, amount); } else if (tokenManagerType == uint256(TokenManagerType.MINT_BURN_FROM)) { - _takeTokenMintBurnFrom(tokenAddress, from, amount); + _burnTokenFrom(tokenManager, tokenAddress, from, amount); } else if (tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK)) { _transferTokenFrom(tokenAddress, from, tokenManager, amount); } else if (tokenManagerType == uint256(TokenManagerType.LOCK_UNLOCK_FEE)) { @@ -220,8 +219,8 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea ITokenManager(tokenManager).burnToken(tokenAddress, from, amount); } - function _burnTokenFrom(address tokenAddress, address from, uint256 amount) internal { - IERC20(tokenAddress).safeCall(abi.encodeWithSelector(IERC20BurnableFrom.burnFrom.selector, from, amount)); + function _burnTokenFrom(address tokenManager, address tokenAddress, address from, uint256 amount) internal { + ITokenManager(tokenManager).burnTokenFrom(tokenAddress, from, amount); } function _approveGateway(address tokenAddress, uint256 amount) internal { diff --git a/contracts/interfaces/ITokenManager.sol b/contracts/interfaces/ITokenManager.sol index 50c582a9..9c505201 100644 --- a/contracts/interfaces/ITokenManager.sol +++ b/contracts/interfaces/ITokenManager.sol @@ -92,4 +92,13 @@ interface ITokenManager is IBaseTokenManager, IOperator, IFlowLimit, IImplementa * @param amount The amount to burn. */ function burnToken(address tokenAddress_, address from, uint256 amount) external; + + /** + * @notice External function to allow the service to burn tokens through the tokenManager + * @dev This function should revert if called by anyone but the service. + * @param tokenAddress_ The address of the token, since its cheaper to pass it in instead of reading it as the token manager. + * @param from The address to burn the token from. + * @param amount The amount to burn. + */ + function burnTokenFrom(address tokenAddress_, address from, uint256 amount) external; } diff --git a/contracts/token-manager/TokenManager.sol b/contracts/token-manager/TokenManager.sol index e6d30174..93f4fc20 100644 --- a/contracts/token-manager/TokenManager.sol +++ b/contracts/token-manager/TokenManager.sol @@ -11,6 +11,7 @@ import { Multicall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/uti import { ITokenManager } from '../interfaces/ITokenManager.sol'; import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; +import { IERC20BurnableFrom } from '../interfaces/IERC20BurnableFrom.sol'; import { Operator } from '../utils/Operator.sol'; import { FlowLimit } from '../utils/FlowLimit.sol'; @@ -213,4 +214,15 @@ contract TokenManager is ITokenManager, Operator, FlowLimit, Implementation, Mul function burnToken(address tokenAddress_, address from, uint256 amount) external onlyService { IERC20(tokenAddress_).safeCall(abi.encodeWithSelector(IERC20MintableBurnable.burn.selector, from, amount)); } + + /** + * @notice External function to allow the service to burn tokens through the tokenManager + * @dev This function should revert if called by anyone but the service. + * @param tokenAddress_ The address of the token, since its cheaper to pass it in instead of reading it as the token manager. + * @param from The address to burn the token from. + * @param amount The amount to burn. + */ + function burnTokenFrom(address tokenAddress_, address from, uint256 amount) external onlyService { + IERC20(tokenAddress_).safeCall(abi.encodeWithSelector(IERC20BurnableFrom.burnFrom.selector, from, amount)); + } }