diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 305a9c19..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "solidity.compileUsingRemoteVersion": "v0.8.23+commit.f704f362" -} diff --git a/src/module/token/crosschain/CrossChain.sol b/src/module/token/crosschain/CrossChain.sol new file mode 100644 index 00000000..a4af05d5 --- /dev/null +++ b/src/module/token/crosschain/CrossChain.sol @@ -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); + +}