|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +pragma solidity ^0.8.20; |
| 3 | + |
| 4 | +abstract contract CrossChain { |
| 5 | + |
| 6 | + /*////////////////////////////////////////////////////////////// |
| 7 | + ERRORS |
| 8 | + //////////////////////////////////////////////////////////////*/ |
| 9 | + |
| 10 | + error OnCrossChainTransactionSentNotImplemented(); |
| 11 | + error OnCrossChainTransactionReceivedNotImplemented(); |
| 12 | + |
| 13 | + /*////////////////////////////////////////////////////////////// |
| 14 | + EXTERNAL FUNCTIONS |
| 15 | + //////////////////////////////////////////////////////////////*/ |
| 16 | + |
| 17 | + /** |
| 18 | + * @notice Sends a cross-chain transaction. |
| 19 | + * @param _destinationChain The destination chain ID. |
| 20 | + * @param _callAddress The address of the contract on the destination chain. |
| 21 | + * @param _payload The payload to send to the destination chain. |
| 22 | + * @param _extraArgs The extra arguments to pass |
| 23 | + * @dev extraArgs may contain items such as token, amount, feeTokenAddress, receipient, gasLimit, etc |
| 24 | + */ |
| 25 | + function sendCrossChainTransaction( |
| 26 | + uint64 _destinationChain, |
| 27 | + address _callAddress, |
| 28 | + bytes calldata _payload, |
| 29 | + bytes calldata _extraArgs |
| 30 | + ) external payable virtual; |
| 31 | + |
| 32 | + /** |
| 33 | + * @notice callback function for when a cross-chain transaction is sent. |
| 34 | + * @param _destinationChain The destination chain ID. |
| 35 | + * @param _callAddress The address of the contract on the destination chain. |
| 36 | + * @param _payload The payload sent to the destination chain. |
| 37 | + * @param _extraArgs The extra arguments sent to the callAddress on the destination chain. |
| 38 | + */ |
| 39 | + function onCrossChainTransactionSent( |
| 40 | + uint64 _destinationChain, |
| 41 | + address _callAddress, |
| 42 | + bytes calldata _payload, |
| 43 | + bytes calldata _extraArgs |
| 44 | + ) internal virtual { |
| 45 | + revert OnCrossChainTransactionSentNotImplemented(); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @notice callback function for when a cross-chain transaction is received. |
| 50 | + * @param _sourceChain The source chain ID. |
| 51 | + * @param _sourceAddress The address of the contract on the source chain. |
| 52 | + * @param _payload The payload sent to the destination chain. |
| 53 | + * @param _extraArgs The extra arguments sent to the callAddress on the destination chain. |
| 54 | + */ |
| 55 | + function onCrossChainTransactionReceived( |
| 56 | + uint64 _sourceChain, |
| 57 | + address _sourceAddress, |
| 58 | + bytes calldata _payload, |
| 59 | + bytes calldata _extraArgs |
| 60 | + ) internal virtual { |
| 61 | + revert OnCrossChainTransactionReceivedNotImplemented(); |
| 62 | + } |
| 63 | + |
| 64 | + function setRouter(address _router) external virtual; |
| 65 | + function getRouter() external view virtual returns (address); |
| 66 | + |
| 67 | +} |
0 commit comments