Skip to content
Lattice

WormholeGatewayAdapter

Git Source

Inherits: IERC7786GatewaySource, IWormholeReceiver, IWormholeGatewayAdapter

Title: WormholeGatewayAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin community-contracts WormholeGatewayAdapter (https://github.com/OpenZeppelin/openzeppelin-community-contracts, commit f7e5f08)

(https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/f7e5f08e8fd42023084eb41f4a992d7be897b915/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol)

Dual-mode ERC-7786 gateway facet over the Wormhole relayer. Two-phase send (pending + requestRelay, or immediate via a requestRelay attribute); receiveWormholeMessages is the relayer's delivery callback. EVM chains only.

Stateless delegator — logic/storage live in WormholeGatewayAdapterLib. OZ's immutable relayer + Ownable are converted to ERC-7201 storage + AccessControl; BitMaps replay → a plain mapping.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: OpenZeppelin

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

receiveWormholeMessages

Delivery callback invoked by the Wormhole relayer. sourceAddress is a universal address.

function receiveWormholeMessages(
        bytes calldata payload,
        bytes[] calldata, /*additionalVaas*/
        bytes32 sourceAddress,
        uint16 sourceChain,
        bytes32 deliveryHash
    ) external payable virtual;

Parameters

NameTypeDescription
payloadbytes
_bytes[]
sourceAddressbytes32
sourceChainuint16
deliveryHashbytes32

requestRelay

Dispatches a previously-stored pending message via the Wormhole relayer.

function requestRelay(bytes32 sendId, uint256 gasLimit, address refundRecipient) external payable virtual;

Parameters

NameTypeDescription
sendIdbytes32The non-zero id returned by sendMessage (no-attribute path).
gasLimituint256Destination gas limit for delivery.
refundRecipientaddressAddress to refund unused relay funds to (on this chain).

relayer

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

Returns

NameTypeDescription
<none>address

wormholeChainId

function wormholeChainId() external view virtual returns (uint16);

Returns

NameTypeDescription
<none>uint16

getWormholeChain

function getWormholeChain(uint256 chainId) external view virtual returns (uint16);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint16

getChainId

function getChainId(uint16 wormhole) external view virtual returns (uint256);

Parameters

NameTypeDescription
wormholeuint16

Returns

NameTypeDescription
<none>uint256

getRemoteGateway

function getRemoteGateway(uint256 chainId) external view virtual returns (address);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>address

quoteRelay

Quote the native cost to relay a message to recipient (ERC-7930) with gasLimit.

function quoteRelay(bytes calldata recipient, uint256 gasLimit) external view virtual returns (uint256);

Parameters

NameTypeDescription
recipientbytes
gasLimituint256

Returns

NameTypeDescription
<none>uint256

registerChainEquivalence

Registers an EVM chainId ↔ Wormhole chain-id equivalence (both directions). Admin only.

function registerChainEquivalence(uint256 chainId, uint16 wormhole) external virtual;

Parameters

NameTypeDescription
chainIduint256
wormholeuint16

registerRemoteGateway

Registers a trusted remote gateway adapter for a chain. Admin only.

function registerRemoteGateway(uint256 chainId, address remote) external virtual;

Parameters

NameTypeDescription
chainIduint256
remoteaddress

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 WormholeGatewayAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: getChainId(uint16) 0x6986e77d getRemoteGateway(uint256) 0x752bcf06 getWormholeChain(uint256) 0x674f6f4e quoteRelay(bytes,uint256) 0x29ff017c receiveWormholeMessages(bytes,bytes[],bytes32,uint16,bytes32) 0x529dca32 registerChainEquivalence(uint256,uint16) 0x1d03ada8 registerRemoteGateway(uint256,address) 0x997ce1f0 relayer() 0x8406c079 requestRelay(bytes32,uint256,address) 0xa4766700 sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c supportsAttribute(bytes4) 0xdc680a0f wormholeChainId() 0x793e64e3

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

Returns

NameTypeDescription
selectorsbytes