Skip to content

Commit

Permalink
Burn token without the callback
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Apr 4, 2024
1 parent 28f513d commit 9b7811d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions contracts/src/AgentExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ contract AgentExecutor {
emit TokenMinted(tokenID, token, recipient, amount);
}

function burnToken(bytes32 tokenID, address sender, uint256 amount) external {
address token = Gateway(msg.sender).tokenAddressOf(tokenID);
function burnToken(bytes32 tokenID, address token, address sender, uint256 amount) external {
ERC20(token).burn(sender, amount);
emit TokenBurnt(tokenID, token, sender, amount);
}
Expand Down
15 changes: 10 additions & 5 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ library Assets {
uint128 amount
) external returns (Ticket memory ticket) {
// Polkadot-native token: burn wrapped token
_burnToken(executor, agent, info.tokenID, sender, amount);
_burnToken(executor, agent, info.tokenID, info.token, sender, amount);

if (destinationChainFee == 0) {
revert InvalidDestinationFee();
Expand All @@ -214,10 +214,15 @@ library Assets {
emit IGateway.TokenSent(info.token, sender, destinationChain, destinationAddress, amount);
}

function _burnToken(address agentExecutor, address agent, bytes32 tokenID, address sender, uint256 amount)
internal
{
bytes memory call = abi.encodeCall(AgentExecutor.burnToken, (tokenID, sender, amount));
function _burnToken(
address agentExecutor,
address agent,
bytes32 tokenID,
address token,
address sender,
uint256 amount
) internal {
bytes memory call = abi.encodeCall(AgentExecutor.burnToken, (tokenID, token, sender, amount));
(bool success, bytes memory returndata) = (Agent(payable(agent)).invoke(agentExecutor, call));
Call.verifyResult(success, returndata);
}
Expand Down

0 comments on commit 9b7811d

Please sign in to comment.