WormholeGatewayAdapter
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)
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
- MUST emit a MessageSent event.
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
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| payload | bytes | |
| attributes | bytes[] |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 |
supportsAttribute
Getter to check whether an attribute is supported or not.
function supportsAttribute(bytes4 selector) external pure virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| payload | bytes | |
| _ | bytes[] | |
| sourceAddress | bytes32 | |
| sourceChain | uint16 | |
| deliveryHash | bytes32 |
requestRelay
Dispatches a previously-stored pending message via the Wormhole relayer.
function requestRelay(bytes32 sendId, uint256 gasLimit, address refundRecipient) external payable virtual;Parameters
| Name | Type | Description |
|---|---|---|
| sendId | bytes32 | The non-zero id returned by sendMessage (no-attribute path). |
| gasLimit | uint256 | Destination gas limit for delivery. |
| refundRecipient | address | Address to refund unused relay funds to (on this chain). |
relayer
function relayer() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
wormholeChainId
function wormholeChainId() external view virtual returns (uint16);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint16 |
getWormholeChain
function getWormholeChain(uint256 chainId) external view virtual returns (uint16);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint16 |
getChainId
function getChainId(uint16 wormhole) external view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| wormhole | uint16 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getRemoteGateway
function getRemoteGateway(uint256 chainId) external view virtual returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| gasLimit | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
registerChainEquivalence
Registers an EVM chainId ↔ Wormhole chain-id equivalence (both directions). Admin only.
function registerChainEquivalence(uint256 chainId, uint16 wormhole) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| wormhole | uint16 |
registerRemoteGateway
Registers a trusted remote gateway adapter for a chain. Admin only.
function registerRemoteGateway(uint256 chainId, address remote) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| remote | address |
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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |