Skip to content

Commit

Permalink
updated to align with unified crosschain interface
Browse files Browse the repository at this point in the history
  • Loading branch information
GWSzeto committed Sep 20, 2024
1 parent 2c9ed2e commit be6a221
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/module/token/crosschain/zetachain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ contract ZetaChainCrossChain is Module {
config.callbackFunctions = new CallbackFunction[](1);
config.fallbackFunctions = new FallbackFunction[](5);

config.fallbackFunctions[0] = FallbackFunction({selector: this.sendMessage.selector, permissionBits: 0});
config.fallbackFunctions[0] =
FallbackFunction({selector: this.sendCrossChainTransaction.selector, permissionBits: 0});
config.fallbackFunctions[2] = FallbackFunction({selector: this.getTss.selector, permissionBits: 0});
config.fallbackFunctions[4] = FallbackFunction({selector: this.getERC20Custody.selector, permissionBits: 0});
config.fallbackFunctions[1] =
Expand Down Expand Up @@ -85,18 +86,24 @@ contract ZetaChainCrossChain is Module {
FALLBACK FUNCTIONS
//////////////////////////////////////////////////////////////*/

function sendMessage(address callAddress, address recipient, address token, uint256 value, bytes memory data)
external
{
function sendCrossChainTransaction(
uint64 _destinationChain,
address _callAddress,
address _recipient,
address _token,
uint256 _amount,
bytes calldata _data,
bytes memory _extraArgs
) external {
// Mimics the encoding of the ZetaChain client library
// https://github.com/zeta-chain/toolkit/tree/main/packages/client/src
bytes memory encodedData = abi.encodePacked(callAddress, data);
if (token == address(0)) {
(bool success,) = payable(_zetaChainCrossChainStorage().tss).call{value: value}(encodedData);
bytes memory encodedData = abi.encodePacked(_callAddress, _data);
if (_token == address(0)) {
(bool success,) = payable(_zetaChainCrossChainStorage().tss).call{value: _amount}(encodedData);
require(success, "Failed to send message");
} else {
IERC20Custody(_zetaChainCrossChainStorage().erc20Custody).deposit(
abi.encode(recipient), IERC20(token), value, encodedData
abi.encode(_recipient), IERC20(_token), _amount, encodedData
);
}
}
Expand Down

0 comments on commit be6a221

Please sign in to comment.