Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

67 changes: 67 additions & 0 deletions src/module/token/crosschain/CrossChain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

abstract contract CrossChain {

/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/

error OnCrossChainTransactionSentNotImplemented();
error OnCrossChainTransactionReceivedNotImplemented();

/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/

/**
* @notice Sends a cross-chain transaction.
* @param _destinationChain The destination chain ID.
* @param _callAddress The address of the contract on the destination chain.
* @param _payload The payload to send to the destination chain.
* @param _extraArgs The extra arguments to pass
* @dev extraArgs may contain items such as token, amount, feeTokenAddress, receipient, gasLimit, etc
*/
function sendCrossChainTransaction(
uint64 _destinationChain,
address _callAddress,
bytes calldata _payload,
bytes calldata _extraArgs
) external payable virtual;

/**
* @notice callback function for when a cross-chain transaction is sent.
* @param _destinationChain The destination chain ID.
* @param _callAddress The address of the contract on the destination chain.
* @param _payload The payload sent to the destination chain.
* @param _extraArgs The extra arguments sent to the callAddress on the destination chain.
*/
function onCrossChainTransactionSent(
uint64 _destinationChain,
address _callAddress,
bytes calldata _payload,
bytes calldata _extraArgs
) internal virtual {
revert OnCrossChainTransactionSentNotImplemented();
}

/**
* @notice callback function for when a cross-chain transaction is received.
* @param _sourceChain The source chain ID.
* @param _sourceAddress The address of the contract on the source chain.
* @param _payload The payload sent to the destination chain.
* @param _extraArgs The extra arguments sent to the callAddress on the destination chain.
*/
function onCrossChainTransactionReceived(
uint64 _sourceChain,
address _sourceAddress,
bytes calldata _payload,
bytes calldata _extraArgs
) internal virtual {
revert OnCrossChainTransactionReceivedNotImplemented();
}

function setRouter(address _router) external virtual;
function getRouter() external view virtual returns (address);

}