Skip to content

Commit

Permalink
Update ERC20Custody.sol, does not compile yet
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 authored May 31, 2024
1 parent d21bce5 commit 0cfea64
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions contracts/evm/ERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,32 @@ contract ERC20Custody is ReentrancyGuard {
IERC20(asset).safeTransfer(recipient, amount);
emit Withdrawn(recipient, asset, amount);
}

function onReceive(
bytes calldata zetaTxSenderAddress,
uint256 sourceChainId,
address destinationAddress,
address asset, // ERC20 address
uint256 amount,
bytes calldata message,
bytes32 internalSendHash
) external override onlyTssAddress {
bool success = IERC20(asset).transfer(destinationAddress, amount);
if (!success) revert Error();

if (message.length > 0) {
ZetaReceiver(destinationAddress).onZetaMessage(
ZetaInterfaces.ZetaMessage(zetaTxSenderAddress, sourceChainId, destinationAddress, asset, amount, message)
);
}

emit ZetaReceived(zetaTxSenderAddress, sourceChainId, destinationAddress, zetaValue, message, internalSendHash);
}
}

contract AppContract is ZetaReceiver{
function ZetaMessage(address, sender, uint256 srcChainId, address destAddr, address asset, uint256 amount, bytes message) {
(address recipient, ) = unpack(message);
IERC20(asset).transfer(recipient, amount);
}
}

0 comments on commit 0cfea64

Please sign in to comment.