-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathILayerZeroAdapter.sol
More file actions
112 lines (92 loc) · 4.75 KB
/
ILayerZeroAdapter.sol
File metadata and controls
112 lines (92 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {IAdapter} from "../../common/interfaces/IAdapter.sol";
// From
// https://github.com/LayerZero-Labs/LayerZero-v2/blob/main/packages/layerzero-v2/evm/protocol/contracts/interfaces/ILayerZeroEndpointV2.sol#L28C1-L34C1
/// @notice The message is the raw, original content or instruction as defined by the application in bytes. It
/// represents the core data that the sender intends to deliver to the recipient via the LayerZero Endpoint.
struct MessagingParams {
uint32 dstEid; // destination chain endpoint id
bytes32 receiver; // receiver on destination chain
bytes message; // cross-chain message
bytes options; // settings for executor and dvn
bool payInLzToken; // whether to pay in ZRO token
}
struct MessagingReceipt {
bytes32 guid; // unique identifier for the message
uint64 nonce; // message nonce
MessagingFee fee; // the message fee paid
}
struct MessagingFee {
uint256 nativeFee; // fee in native token
uint256 lzTokenFee; // fee in ZRO token
}
struct Origin {
uint32 srcEid; // source chain endpoint id
bytes32 sender; // sender on source chain
uint64 nonce; // message nonce
}
interface ILayerZeroEndpointV2 {
/// @notice This view function gives the application built on top of LayerZero the ability to requests a quote
/// with the same parameters as they would to send their message. Since the quotes are given on chain there
/// is a race condition in which the prices could change between the time the user gets their quote and the
/// time they submit their message. If the price moves up and the user doesn't send enough funds the
/// transaction will revert, if the price goes down the _refundAddress provided by the app will be refunded
/// the difference.
function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);
/// @notice Send a LayerZero message to the specified address at a LayerZero endpoint specified by our chainId.
function send(MessagingParams calldata _params, address _refundAddress)
external
payable
returns (MessagingReceipt memory);
/// @notice Delegate is authorized by the oapp to configure anything in layerzero
function setDelegate(address _delegate) external;
}
// From
// https://github.com/LayerZero-Labs/LayerZero-v2/blob/main/packages/layerzero-v2/evm/protocol/contracts/interfaces/ILayerZeroReceiver.sol
interface ILayerZeroReceiver {
/// @notice Checks if the path initialization is allowed based on the provided origin.
function allowInitializePath(Origin calldata _origin) external view returns (bool);
/// @notice The path nonce starts from 1.
/// If 0 is returned it means that there is NO nonce ordered enforcement.
/// This function is required by the off-chain executor to determine
/// the OApp expects msg execution is ordered.
function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64);
/// @notice Execute a verified message to the designated receiver
function lzReceive(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address _executor,
bytes calldata _extraData
) external payable;
}
struct LayerZeroSource {
uint16 centrifugeId;
address addr;
}
struct LayerZeroDestination {
uint32 layerZeroEid;
address addr;
}
interface ILayerZeroAdapter is IAdapter, ILayerZeroReceiver {
event Wire(uint16 indexed centrifugeId, uint32 indexed layerZeroEid, address adapter);
event SetDelegate(address indexed newDelegate);
error NotLayerZeroEndpoint();
error InvalidSource();
/// @notice Wire the adapter to a remote one.
/// @param centrifugeId The remote chain's chain ID
/// @param layerZeroEid The remote chain's LayerZero Endpoint ID
/// @param adapter The remote chain's LayerZero adapter address
function wire(uint16 centrifugeId, uint32 layerZeroEid, address adapter) external;
/// @notice Returns the source configuration for a given layerzero endpoint id
/// @param layerZeroEid The remote LayerZero Endpoint ID
/// @return centrifugeId The remote chain id
/// @return addr The address of the remote layerzero adapter
function sources(uint32 layerZeroEid) external view returns (uint16 centrifugeId, address addr);
/// @notice Returns the destination configuration for a given chain id
/// @param centrifugeId The remote chain id
/// @return layerZeroEid The remote LayerZero Endpoint ID
/// @return addr The address of the remote layerzero adapter
function destinations(uint16 centrifugeId) external view returns (uint32 layerZeroEid, address addr);
}