Skip to content

Commit

Permalink
fix(protocol): Correct decoding (TKO-03) (#15582)
Browse files Browse the repository at this point in the history
Co-authored-by: Keszey Dániel <keszeyd@MacBook-Pro.local>
  • Loading branch information
adaki2004 and Keszey Dániel authored Jan 26, 2024
1 parent 17b074b commit dc46b27
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/protocol/contracts/tokenvault/ERC20Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,27 @@ contract ERC20Vault is BaseVault {
{
checkRecallMessageContext();

(, address token,, uint256 amount) =
(CanonicalERC20 memory ctoken,,, uint256 amount) =
abi.decode(message.data[4:], (CanonicalERC20, address, address, uint256));

if (token == address(0)) revert VAULT_INVALID_TOKEN();
if (ctoken.addr == address(0)) revert VAULT_INVALID_TOKEN();

if (amount > 0) {
if (bridgedToCanonical[token].addr != address(0)) {
IBridgedERC20(token).mint(message.owner, amount);
if (bridgedToCanonical[ctoken.addr].addr != address(0)) {
IBridgedERC20(ctoken.addr).mint(message.owner, amount);
} else {
ERC20(token).safeTransfer(message.owner, amount);
ERC20(ctoken.addr).safeTransfer(message.owner, amount);
}
}

message.owner.sendEther(message.value);

emit TokenReleased({ msgHash: msgHash, from: message.owner, token: token, amount: amount });
emit TokenReleased({
msgHash: msgHash,
from: message.owner,
token: ctoken.addr,
amount: amount
});
}

function name() public pure override returns (bytes32) {
Expand Down

0 comments on commit dc46b27

Please sign in to comment.