IWormholeGatewayAdapter
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)
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
| Name | Type | Description |
|---|---|---|
| <none> | address |
wormholeChainId
function wormholeChainId() external view returns (uint16);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint16 |
getWormholeChain
function getWormholeChain(uint256 chainId) external view returns (uint16);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint16 |
getChainId
function getChainId(uint16 wormhole) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| wormhole | uint16 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getRemoteGateway
function getRemoteGateway(uint256 chainId) external view 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 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;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;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| remote | address |
requestRelay
Dispatches a previously-stored pending message via the Wormhole relayer.
function requestRelay(bytes32 sendId, uint256 gasLimit, address refundRecipient) external payable;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). |
Events
RegisteredChainEquivalence
Emitted when an EVM chainId ↔ Wormhole chain-id equivalence is registered.
event RegisteredChainEquivalence(uint256 indexed chainId, uint16 wormhole);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| wormhole | uint16 |
RegisteredRemoteGateway
Emitted when a trusted remote gateway adapter is registered for a chain.
event RegisteredRemoteGateway(uint256 indexed chainId, address remote);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| remote | address |
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
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
RemoteGatewayAlreadyRegistered
A remote gateway is already registered for this chain.
error RemoteGatewayAlreadyRegistered(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
UnknownMessage
requestRelay referenced a sendId with no pending message.
error UnknownMessage(bytes32 sendId);Parameters
| Name | Type | Description |
|---|---|---|
| sendId | bytes32 |
NotWormholeRelayer
The inbound callback was not invoked by the configured Wormhole relayer.
error NotWormholeRelayer(address caller);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address |
InvalidOriginGateway
The inbound source did not match the registered remote gateway for its chain.
error InvalidOriginGateway(uint16 sourceChain, bytes32 sourceAddress);Parameters
| Name | Type | Description |
|---|---|---|
| sourceChain | uint16 | |
| sourceAddress | bytes32 |
MessageAlreadyExecuted
The inbound message (chainId, sendId) was already delivered (replay).
error MessageAlreadyExecuted(uint256 chainId, uint256 sendId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| sendId | uint256 |
RecipientExecutionFailed
The recipient's receiveMessage did not return the ERC-7786 magic value.
error RecipientExecutionFailed();