ORMP
Inherits: ReentrancyGuard, Channel
An endpoint is a type of network node for cross-chain communication. It is an interface exposed by a communication channel.
An endpoint is associated with an immutable channel and user configuration.
State Variables
hashLookup
oracle => lookupKey => hash
mapping(address => mapping(bytes32 => bytes32)) public hashLookup;
Functions
constructor
constructor(address dao) Channel(dao);
version
function version() public pure returns (string memory);
send
follow https://eips.ethereum.org/EIPS/eip-5750
Send a cross-chain message over the endpoint.
function send(
uint256 toChainId,
address to,
uint256 gasLimit,
bytes calldata encoded,
address refund,
bytes calldata params
) external payable sendNonReentrant returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
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. |
refund | address | Return extra fee to refund address. |
params | bytes | General extensibility for relayer to custom functionality. |
importHash
Hash is an abstract of the proof system, it can be a block hash or a message root hash, specifically provided by oracles.
Import hash by any oracle address.
function importHash(uint256 chainId, address channel, uint256 msgIndex, bytes32 hash_) external;
Parameters
Name | Type | Description |
---|---|---|
chainId | uint256 | The source chain id. |
channel | address | The message channel. |
msgIndex | uint256 | The source chain message index. |
hash_ | bytes32 | The hash to import. |
_handleFee
function _handleFee(
address ua,
address refund,
bytes32 msgHash,
uint256 toChainId,
uint256 gasLimit,
bytes calldata encoded,
bytes calldata params
) internal;
fee
Get a quote in source native gas, for the amount that send() requires to pay for message delivery.
function fee(uint256 toChainId, address ua, uint256 gasLimit, bytes calldata encoded, bytes calldata params)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
toChainId | uint256 | The Message destination chain id. |
ua | address | |
gasLimit | uint256 | Gas limit for destination user application used. |
encoded | bytes | The calldata which encoded by ABI Encoding. |
params | bytes | General extensibility for relayer to custom functionality. |
_handleRelayer
function _handleRelayer(
address relayer,
uint256 toChainId,
address ua,
uint256 gasLimit,
bytes calldata encoded,
bytes calldata params
) internal returns (uint256);
_handleOracle
function _handleOracle(address oracle, uint256 toChainId, address ua) internal returns (uint256);
recv
Only channel could call this function.
Recv verified message from Channel and dispatch to destination user application address.
function recv(Message calldata message, bytes calldata proof)
external
payable
recvNonReentrant
returns (bool dispatchResult);
Parameters
Name | Type | Description |
---|---|---|
message | Message | Verified receive message info. |
proof | bytes | Message proof of this message. |
Returns
Name | Type | Description |
---|---|---|
dispatchResult | bool | Result of the message dispatch. |
_dispatch
Dispatch the cross chain message.
function _dispatch(Message memory message, bytes32 msgHash) private returns (bool dispatchResult);
_sendValue
Replacement for Solidity's transfer
: sends amount
wei to
recipient
, forwarding all available gas and reverting on errors.
function _sendValue(address recipient, uint256 amount) internal;
Events
MessageAssigned
event MessageAssigned(
bytes32 indexed msgHash,
address indexed oracle,
address indexed relayer,
uint256 oracleFee,
uint256 relayerFee,
bytes params
);
HashImported
event HashImported(address indexed oracle, uint256 chainId, address channel, uint256 msgIndex, bytes32 hash);