Skip to content
Lattice

IWormholeGatewayAdapter

Git Source

Title: IWormholeGatewayAdapter

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)

Admin/read/relay surface of the Wormhole ERC-7786 gateway adapter. The standard source-gateway ABI (sendMessage/supportsAttribute) is on IERC7786GatewaySource; the inbound callback is IWormholeReceiver.receiveWormholeMessages. EVM chains only; value may fund delivery.

Two-phase send: sendMessage with no attribute stores a pending message and returns a non-zero sendId; the sender then calls requestRelay (with gas + value) to dispatch it. sendMessage with a single requestRelay attribute dispatches immediately and returns bytes32(0).

Functions

relayer

function relayer() external view returns (address);

Returns

NameTypeDescription
<none>address

wormholeChainId

function wormholeChainId() external view returns (uint16);

Returns

NameTypeDescription
<none>uint16

getWormholeChain

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

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint16

getChainId

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

Parameters

NameTypeDescription
wormholeuint16

Returns

NameTypeDescription
<none>uint256

getRemoteGateway

function getRemoteGateway(uint256 chainId) external view 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 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;

Parameters

NameTypeDescription
chainIduint256
wormholeuint16

registerRemoteGateway

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

function registerRemoteGateway(uint256 chainId, address remote) external;

Parameters

NameTypeDescription
chainIduint256
remoteaddress

requestRelay

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

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

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).

Events

RegisteredChainEquivalence

Emitted when an EVM chainId ↔ Wormhole chain-id equivalence is registered.

event RegisteredChainEquivalence(uint256 indexed chainId, uint16 wormhole);

Parameters

NameTypeDescription
chainIduint256
wormholeuint16

RegisteredRemoteGateway

Emitted when a trusted remote gateway adapter is registered for a chain.

event RegisteredRemoteGateway(uint256 indexed chainId, address remote);

Parameters

NameTypeDescription
chainIduint256
remoteaddress

Errors

DuplicatedAttribute

More than one attribute was supplied to sendMessage.

error DuplicatedAttribute();

ChainEquivalenceAlreadyRegistered

A chain equivalence is already registered for this chainId or Wormhole id.

error ChainEquivalenceAlreadyRegistered(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

RemoteGatewayAlreadyRegistered

A remote gateway is already registered for this chain.

error RemoteGatewayAlreadyRegistered(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

UnknownMessage

requestRelay referenced a sendId with no pending message.

error UnknownMessage(bytes32 sendId);

Parameters

NameTypeDescription
sendIdbytes32

NotWormholeRelayer

The inbound callback was not invoked by the configured Wormhole relayer.

error NotWormholeRelayer(address caller);

Parameters

NameTypeDescription
calleraddress

InvalidOriginGateway

The inbound source did not match the registered remote gateway for its chain.

error InvalidOriginGateway(uint16 sourceChain, bytes32 sourceAddress);

Parameters

NameTypeDescription
sourceChainuint16
sourceAddressbytes32

MessageAlreadyExecuted

The inbound message (chainId, sendId) was already delivered (replay).

error MessageAlreadyExecuted(uint256 chainId, uint256 sendId);

Parameters

NameTypeDescription
chainIduint256
sendIduint256

RecipientExecutionFailed

The recipient's receiveMessage did not return the ERC-7786 magic value.

error RecipientExecutionFailed();