Channel
Inherits: UserConfig
A channel is a logical connection over cross-chain network. It used for cross-chain message transfer.
- Accepts messages to be dispatched to destination chains, constructs a Merkle tree of the messages.
- Dispatches verified messages from source chains.
State Variables
dones
msgHash => isDispathed.
mapping(bytes32 => bool) public dones;
count
message count.
uint256 public count;
__self
Self contract address cache.
address private immutable __self = address(this);
Functions
constructor
Init code.
constructor(address dao) UserConfig(dao);
LOCAL_CHAINID
Fetch local chain id.
function LOCAL_CHAINID() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | chainId Local chain id. |
_send
Send message.
function _send(address from, uint256 toChainId, address to, uint256 gasLimit, bytes calldata encoded)
internal
returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
from | address | User application contract address which send the message. |
toChainId | uint256 | The Message destination chain id. |
to | address | User application contract address which receive the message. |
gasLimit | uint256 | Gas limit for destination user application used. |
encoded | bytes | The calldata which encoded by ABI Encoding. |
_recv
Only message.to's config relayer could relay this message.
Receive messages.
function _recv(Message calldata message, bytes calldata proof) internal returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
message | Message | Received message info. |
proof | bytes | Message proof of this message. |
Events
MessageAccepted
Notifies an observer that the message has been accepted.
event MessageAccepted(bytes32 indexed msgHash, Message message);
Parameters
Name | Type | Description |
---|---|---|
msgHash | bytes32 | Hash of the message. |
message | Message | Accepted message info. |
MessageDispatched
Notifies an observer that the message has been dispatched.
event MessageDispatched(bytes32 indexed msgHash, bool dispatchResult);
Parameters
Name | Type | Description |
---|---|---|
msgHash | bytes32 | Hash of the message. |
dispatchResult | bool | The message dispatch result. |