-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathIBaseStateRegistry.sol
90 lines (73 loc) · 4.62 KB
/
IBaseStateRegistry.sol
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
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { PayloadState } from "src/types/DataTypes.sol";
/// @title IBaseStateRegistry
/// @dev Interface for BaseStateRegistry
/// @author ZeroPoint Labs
interface IBaseStateRegistry {
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when a cross-chain payload is received in the state registry
event PayloadReceived(uint64 indexed srcChainId, uint64 indexed dstChainId, uint256 indexed payloadId);
/// @dev is emitted when a cross-chain proof is received in the state registry
/// NOTE: comes handy if quorum required is more than 0
event ProofReceived(bytes32 indexed proof);
/// @dev is emitted when a payload id gets updated
event PayloadUpdated(uint256 indexed payloadId);
/// @dev is emitted when a payload id gets processed
event PayloadProcessed(uint256 indexed payloadId);
/// @dev is emitted when the super registry address is updated
event SuperRegistryUpdated(address indexed superRegistry);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev allows users to read the total payloads received by the registry
function payloadsCount() external view returns (uint256);
/// @dev allows user to read the payload state
/// uint256 payloadId_ is the unique payload identifier allocated on the destination chain
function payloadTracking(uint256 payloadId_) external view returns (PayloadState payloadState_);
/// @dev allows users to read the bytes payload_ stored per payloadId_
/// @param payloadId_ is the unique payload identifier allocated on the destination chain
/// @return payloadBody_ the crosschain data received
function payloadBody(uint256 payloadId_) external view returns (bytes memory payloadBody_);
/// @dev allows users to read the uint256 payloadHeader stored per payloadId_
/// @param payloadId_ is the unique payload identifier allocated on the destination chain
/// @return payloadHeader_ the crosschain header received
function payloadHeader(uint256 payloadId_) external view returns (uint256 payloadHeader_);
/// @dev allows users to read the ambs that delivered the payload id
/// @param payloadId_ is the unique payload identifier allocated on the destination chain
/// @return ambIds_ is the identifier of ambs that delivered the message and proof
function getMessageAMB(uint256 payloadId_) external view returns (uint8[] memory ambIds_);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev allows core contracts to send payload to a destination chain.
/// @param srcSender_ is the caller of the function (used for gas refunds).
/// @param ambIds_ is the identifier of the arbitrary message bridge to be used
/// @param dstChainId_ is the internal chainId used throughout the protocol
/// @param message_ is the crosschain payload to be sent
/// @param extraData_ defines all the message bridge related overrides
/// NOTE: dstChainId_ is mapped to message bridge's destination id inside it's implementation contract
/// NOTE: ambIds_ are superform assigned unique identifier for arbitrary message bridges
function dispatchPayload(
address srcSender_,
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes memory extraData_
)
external
payable;
/// @dev allows state registry to receive messages from message bridge implementations
/// @param srcChainId_ is the superform chainId from which the payload is dispatched/sent
/// @param message_ is the crosschain payload received
/// NOTE: Only {IMPLEMENTATION_CONTRACT} role can call this function.
function receivePayload(uint64 srcChainId_, bytes memory message_) external;
/// @dev allows privileged actors to process cross-chain payloads
/// @param payloadId_ is the identifier of the cross-chain payload
/// NOTE: Only {CORE_STATE_REGISTRY_PROCESSOR_ROLE} role can call this function
/// NOTE: this should handle reverting the state on source chain in-case of failure
/// (or) can implement scenario based reverting like in coreStateRegistry
function processPayload(uint256 payloadId_) external payable;
}