HyperlaneImplementation

Git Source

Inherits: IAmbImplementation, IMessageRecipient

Author: Zeropoint Labs

allows state registries to use hyperlane for crosschain communication

State Variables

mailbox

IMailbox public mailbox;

igp

IInterchainGasPaymaster public igp;

superRegistry

ISuperRegistry public immutable superRegistry;

ambChainId

mapping(uint64 => uint32) public ambChainId;

superChainId

mapping(uint32 => uint64) public superChainId;

authorizedImpl

mapping(uint32 => address) public authorizedImpl;

processedMessages

mapping(bytes32 => bool) public processedMessages;

Functions

onlyProtocolAdmin

modifier onlyProtocolAdmin();

constructor

constructor(ISuperRegistry superRegistry_);

setHyperlaneConfig

allows protocol admin to configure hyperlane mailbox and gas paymaster

function setHyperlaneConfig(IMailbox mailbox_, IInterchainGasPaymaster igp_) external onlyProtocolAdmin;

Parameters

NameTypeDescription
mailbox_IMailboxis the address of hyperlane mailbox
igp_IInterchainGasPaymasteris the address of hyperlane gas paymaster

dispatchPayload

allows state registry to send message via implementation.

function dispatchPayload(
    address srcSender_,
    uint64 dstChainId_,
    bytes memory message_,
    bytes memory extraData_
)
    external
    payable
    virtual
    override;

Parameters

NameTypeDescription
srcSender_addressis the caller (used for gas refunds)
dstChainId_uint64is the identifier of the destination chain
message_bytesis the cross-chain message to be sent
extraData_bytesis message amb specific override information

setChainId

allows protocol admin to add new chain ids in future

function setChainId(uint64 superChainId_, uint32 ambChainId_) external onlyProtocolAdmin;

Parameters

NameTypeDescription
superChainId_uint64is the identifier of the chain within superform protocol
ambChainId_uint32is the identifier of the chain given by the AMB NOTE: cannot be defined in an interface as types vary for each message bridge (amb)

setReceiver

reset old mappings

allows protocol admin to set receiver implmentation on a new chain id

function setReceiver(uint32 domain_, address authorizedImpl_) external onlyProtocolAdmin;

Parameters

NameTypeDescription
domain_uint32is the identifier of the destination chain within hyperlane
authorizedImpl_addressis the implementation of the hyperlane message bridge on the specified destination NOTE: cannot be defined in an interface as types vary for each message bridge (amb)

handle

function handle(uint32 origin_, bytes32 sender_, bytes calldata body_) external override;

Parameters

NameTypeDescription
origin_uint32
sender_bytes32
body_bytes

estimateFees

not all AMBs will have on-chain estimation for which this function will return 0

1. validate caller

2. validate src chain sender

3. validate message uniqueness

decoding payload NOTE: experimental split of registry contracts

function estimateFees(
    uint64 dstChainId_,
    bytes memory,
    bytes memory extraData_
)
    external
    view
    override
    returns (uint256 fees);

Parameters

NameTypeDescription
dstChainId_uint64is the identifier of the destination chain
<none>bytes
extraData_bytesis any amb-specific information

Returns

NameTypeDescription
feesuint256is the native_tokens to be sent along the transaction

_castAddr

casts an address to bytes32

function _castAddr(address addr_) internal pure returns (bytes32);

Parameters

NameTypeDescription
addr_addressis the address to be casted

Returns

NameTypeDescription
<none>bytes32a bytes32 casted variable of the address passed in params

Events

MailboxAdded

event MailboxAdded(address _newMailbox);

GasPayMasterAdded

event GasPayMasterAdded(address _igp);