ORMP

Git Source

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

NameTypeDescription
toChainIduint256The Message destination chain id.
toaddressUser application contract address which receive the message.
gasLimituint256Gas limit for destination user application used.
encodedbytesThe calldata which encoded by ABI Encoding.
refundaddressReturn extra fee to refund address.
paramsbytesGeneral 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

NameTypeDescription
chainIduint256The source chain id.
channeladdressThe message channel.
msgIndexuint256The source chain message index.
hash_bytes32The 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

NameTypeDescription
toChainIduint256The Message destination chain id.
uaaddress
gasLimituint256Gas limit for destination user application used.
encodedbytesThe calldata which encoded by ABI Encoding.
paramsbytesGeneral 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

NameTypeDescription
messageMessageVerified receive message info.
proofbytesMessage proof of this message.

Returns

NameTypeDescription
dispatchResultboolResult 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);