Skip to content

Commit a716f8c

Browse files
authored
Crosschain unified interface (#170)
* created unified interface for crosschain transactions * added interface functionality for setter and getter of bridge * Update implementation - implemented `sendCrossChainPayloadWithToken` - implemented `sendCrossChainPayload` - implemented `setRouter` - implemented `getRouter` - implemented `onMessageSent` - implemented `onMessageReceived` * updated to unify to just one * FIX: PR updates * Switched over to being an abstract contract
1 parent 15052bc commit a716f8c

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)