Skip to content
Lattice

HyperlaneGatewayAdapter

Git Source

Inherits: IERC7786GatewaySource, IMessageRecipient, IHyperlaneGatewayAdapter

Title: HyperlaneGatewayAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Hyperlane (https://github.com/hyperlane-xyz/hyperlane-monorepo)

ERC-7786 cross-chain gateway facet over the Hyperlane Mailbox. sendMessage quotes + dispatches a Hyperlane message via the Mailbox's 4-arg dispatch (default hook + synthesized StandardHookMetadata); handle is the Mailbox's delivery callback. EVM chains only.

Stateless delegator — logic/storage live in HyperlaneGatewayAdapterLib. Hyperlane routes by uint32 domain (usually the EVM chainId but NOT guaranteed — the lib holds an admin-registered chainId ⇄ domain map + a 32-byte trusted remote per chain); the Mailbox-gated handle is the inbound analogue of LayerZero's lzReceive / CCIP's ccipReceive. Implements IMessageRecipient so the Mailbox can deliver messages at process time. v1 uses the Mailbox DEFAULT ISM — the facet deliberately does NOT implement ISpecifiesInterchainSecurityModule; pinning a Lattice-custom ISM by adding interchainSecurityModule() later is a compatible additive follow-up.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Hyperlane

Functions

sendMessage

If any of the attributes is not supported, this function SHOULD revert with an

UnsupportedAttribute error. Other errors SHOULD revert with errors not specified in ERC-7786.

Endpoint for creating a new message. If the message requires further (gateway specific) processing before it can be sent to the destination chain, then a non-zero sendId must be returned. Otherwise, the message MUST be sent and this function must return 0.

function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)
        external
        payable
        virtual
        returns (bytes32);

Parameters

NameTypeDescription
recipientbytes
payloadbytes
attributesbytes[]

Returns

NameTypeDescription
<none>bytes32

supportsAttribute

Getter to check whether an attribute is supported or not.

function supportsAttribute(bytes4 selector) external pure virtual returns (bool);

Parameters

NameTypeDescription
selectorbytes4

Returns

NameTypeDescription
<none>bool

handle

Handles a Hyperlane message delivered by the local Mailbox.

function handle(uint32 _origin, bytes32 _sender, bytes calldata _message) external payable virtual;

Parameters

NameTypeDescription
_originuint32The origin Hyperlane domain of the message.
_senderbytes32The 32-byte message sender address on _origin.
_messagebytesThe raw message body.

mailbox

The Hyperlane Mailbox the adapter dispatches to and accepts handle deliveries from.

function mailbox() external view virtual returns (address);

Returns

NameTypeDescription
<none>address

domainOf

The Hyperlane domain registered for chainId (0 = unset).

function domainOf(uint256 chainId) external view virtual returns (uint32);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint32

chainIdOf

The EVM chainId registered for domain (0 = unset).

function chainIdOf(uint32 domain) external view virtual returns (uint256);

Parameters

NameTypeDescription
domainuint32

Returns

NameTypeDescription
<none>uint256

trustedRemoteOf

The trusted 32-byte remote (counterpart adapter) registered for chainId (0 = unset).

function trustedRemoteOf(uint256 chainId) external view virtual returns (bytes32);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>bytes32

destGasLimitOf

The configured handle gas limit for chainId (0 = unset; sends fall back to the adapter default).

function destGasLimitOf(uint256 chainId) external view virtual returns (uint256);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint256

quoteFee

Quotes the Mailbox fee to send payload to recipient (ERC-7930), synthesizing the same wire envelope + StandardHookMetadata a real send would dispatch.

function quoteFee(bytes calldata recipient, bytes calldata payload) external view virtual returns (uint256);

Parameters

NameTypeDescription
recipientbytes
payloadbytes

Returns

NameTypeDescription
<none>uint256

registerDomain

Registers an EVM chainId ↔ Hyperlane domain equivalence (both directions, fail-loud — chain identities are never remapped). Admin only.

function registerDomain(uint256 chainId, uint32 domain) external virtual;

Parameters

NameTypeDescription
chainIduint256
domainuint32

registerRemote

Sets the trusted 32-byte remote (counterpart adapter) for a chain. Tunable. Admin only.

function registerRemote(uint256 chainId, bytes32 remote) external virtual;

Parameters

NameTypeDescription
chainIduint256
remotebytes32

configureDestination

Configures a destination's handle gas limit (0 = use the adapter default). Tunable. Admin only.

function configureDestination(uint256 chainId, uint256 gasLimit) external virtual;

Parameters

NameTypeDescription
chainIduint256
gasLimituint256

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect HyperlaneGatewayAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: chainIdOf(uint32) 0x97a21652 configureDestination(uint256,uint256) 0xcb21a740 destGasLimitOf(uint256) 0x2f85b407 domainOf(uint256) 0xc6c17ec0 handle(uint32,bytes32,bytes) 0x56d5d475 mailbox() 0xd5438eae quoteFee(bytes,bytes) 0x58d14c04 registerDomain(uint256,uint32) 0x5be59524 registerRemote(uint256,bytes32) 0xe914f0f6 sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c supportsAttribute(bytes4) 0xdc680a0f trustedRemoteOf(uint256) 0x3e56e39a

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes