HyperbridgeGatewayAdapter
Inherits: IERC7786GatewaySource, IIsmpModule, IHyperbridgeGatewayAdapter
Title: HyperbridgeGatewayAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Hyperbridge (https://github.com/polytope-labs/ismp-solidity)
ERC-7786 cross-chain gateway facet over Hyperbridge's ISMP (proof-verified interop: consensus +
state proofs aggregated on a Polkadot-secured coprocessor, delivered by permissionless
proof-carrying relayers — NO attestation committee). sendMessage dispatches a POST request via
the IsmpHost, paying the per-byte protocol fee + optional relayer fee in the host's ERC-20
feeToken() (never msg.value); the host-invoked IIsmpModule hooks are the inbound surface.
Stateless delegator — logic/storage live in HyperbridgeGatewayAdapterLib. Implements ALL SIX
IIsmpModule hooks so the host can notify the module: onAccept (delivery) and
onPostRequestTimeout (native timeout/refund notification — the fee refund itself is host-side to
DispatchPost.payer, the sending user) are live; the four response/GET hooks revert
HyperbridgeUnsupportedHook (the adapter dispatches neither GETs nor responses — silently accepting
them would be a spoofable no-op surface). EVM recipients only in v1; non-EVM (POLKADOT-/SUBSTRATE-)
state machines can be registered raw for inbound auth.
Notes:
- lattice-version: 0.1.0
- lattice-source: Hyperbridge
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.
payable is forced by the interface; the native-token fee path is DEFERRED — stray value reverts.
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 |
sendMessageWithFee
ERC-7786 send with an explicit ISMP relayer fee (charged in the host's feeToken on top of the
per-byte protocol fee; both pulled from the caller). The relayer fee lives OUTSIDE the
IERC7786GatewaySource ABI — same pattern as the LZ/Hyperlane fee-outside-the-ABI precedent —
and the plain sendMessage delegates here with relayerFee = 0 (unfunded/self-relay, valid in
ISMP).
function sendMessageWithFee(bytes calldata recipient, bytes calldata payload, uint256 relayerFee)
external
virtual
returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| payload | bytes | |
| relayerFee | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 | The suite-level keccak256(abi.encode(block.chainid, envelopeNonce)) id. |
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 |
onAccept
Called by the IsmpHost to notify the module of a new proof-verified POST request.
function onAccept(IncomingPostRequest calldata incoming) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| incoming | IncomingPostRequest |
onPostRequestTimeout
Called by the IsmpHost to notify the module of a previously sent POST request that timed out.
function onPostRequestTimeout(PostRequest calldata request) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| request | PostRequest |
onPostResponse
Called by the IsmpHost to notify the module of a POST response to a previously sent request.
Never used — the adapter dispatches no requests that expect responses.
function onPostResponse(IncomingPostResponse calldata) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| _ | IncomingPostResponse |
onGetResponse
Called by the IsmpHost to notify the module of a GET response to a previously sent request.
Never used — the adapter dispatches no GET requests.
function onGetResponse(IncomingGetResponse calldata) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| _ | IncomingGetResponse |
onPostResponseTimeout
Called by the IsmpHost to notify the module of a previously sent POST response that timed out.
Never used — the adapter dispatches no responses that could time out.
function onPostResponseTimeout(PostResponse calldata) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| _ | PostResponse |
onGetTimeout
Called by the IsmpHost to notify the module of a previously sent GET request that timed out.
Never used — the adapter dispatches no GET requests that could time out.
function onGetTimeout(GetRequest calldata) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| _ | GetRequest |
ismpHost
The Hyperbridge IsmpHost the adapter dispatches to and accepts module callbacks from.
function ismpHost() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
hyperbridgeFeeToken
The host's CURRENT ERC-20 fee token (live passthrough of IIsmpDispatcher.feeToken() — never
cached; the host can migrate it).
function hyperbridgeFeeToken() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
stateMachineIdOf
The state machine id registered for chainId (empty = unset).
function stateMachineIdOf(uint256 chainId) external view virtual returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes |
chainIdOfStateMachine
The EVM chainId registered for the state machine id stateMachineId (0 = unset).
function chainIdOfStateMachine(bytes calldata stateMachineId) external view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| stateMachineId | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
hyperbridgeRemoteModuleOf
The trusted remote ISMP module (counterpart adapter) registered for chainId (empty = unset).
function hyperbridgeRemoteModuleOf(uint256 chainId) external view virtual returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes |
hyperbridgeDestTimeoutOf
The configured dispatch timeout (seconds) for chainId (0 = no explicit timeout — the host's
default handling).
function hyperbridgeDestTimeoutOf(uint256 chainId) external view virtual returns (uint64);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint64 |
quoteDispatchFee
Quotes the TOTAL feeToken cost of sending payload to recipient (ERC-7930) with
relayerFee: perByteFee(destStateMachineId) * body.length + relayerFee, where body is the
exact wire envelope a real send would dispatch (same builder — the envelope length is
sender/nonce-independent, so the quote matches the send-time charge).
function quoteDispatchFee(bytes calldata recipient, bytes calldata payload, uint256 relayerFee)
external
view
virtual
returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| payload | bytes | |
| relayerFee | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
registerStateMachine
Registers the EVM chainId ⇄ state machine equivalence for chainId, deriving the id
INTERNALLY as the canonical bytes("EVM-" + chainId) — never caller-supplied (fail-closed).
FAIL-LOUD identity admin: an already-mapped chainId OR id reverts (both directions, via the
keccak reverse map) — identities are never remapped. Admin only.
function registerStateMachine(uint256 chainId) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
registerStateMachineRaw
Registers a RAW (non-EVM) state machine id — POLKADOT/SUBSTRATE/KUSAMA destinations — mapped to
a local routing chainId handle. Same fail-loud both-direction rules as
registerStateMachine; empty ids and chainId 0 are rejected. The chainId is a LOCAL routing
key (it appears in the ERC-7930 recipient), so the admin must pick one that collides with no
real EVM chainId. Admin only.
function registerStateMachineRaw(uint256 chainId, bytes calldata stateMachineId) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| stateMachineId | bytes |
registerRemoteModule
Sets the trusted remote ISMP module (counterpart adapter) for a chain. TUNABLE (updatable), but never empty — clearing a corridor is not supported in v1. Admin only.
function registerRemoteModule(uint256 chainId, bytes calldata module) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| module | bytes |
configureDestinationTimeout
Configures a destination's dispatch timeout in seconds. TUNABLE; 0 = no explicit timeout (the host's default handling). Admin only.
function configureDestinationTimeout(uint256 chainId, uint64 timeout) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| timeout | uint64 |
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 HyperbridgeGatewayAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
chainIdOfStateMachine(bytes) 0xe9771716
configureDestinationTimeout(uint256,uint64) 0xbb0f2a9c
hyperbridgeDestTimeoutOf(uint256) 0x496df793
hyperbridgeFeeToken() 0x08d24c0e
hyperbridgeRemoteModuleOf(uint256) 0x3a52ea6e
ismpHost() 0x134b37c9
onAccept(((bytes,bytes,uint64,bytes,bytes,uint64,bytes),address)) 0x0fee32ce
onGetResponse((((bytes,bytes,uint64,address,uint64,bytes[],uint64,bytes),(bytes,bytes)[]),address)) 0x44ab20f8
onGetTimeout((bytes,bytes,uint64,address,uint64,bytes[],uint64,bytes)) 0xd0fff366
onPostRequestTimeout((bytes,bytes,uint64,bytes,bytes,uint64,bytes)) 0xbc0dd447
onPostResponse((((bytes,bytes,uint64,bytes,bytes,uint64,bytes),bytes,uint64),address)) 0xb2a01bf5
onPostResponseTimeout(((bytes,bytes,uint64,bytes,bytes,uint64,bytes),bytes,uint64)) 0x0bc37bab
quoteDispatchFee(bytes,bytes,uint256) 0xee6ef22a
registerRemoteModule(uint256,bytes) 0xa1d0dd63
registerStateMachine(uint256) 0x4763e06e
registerStateMachineRaw(uint256,bytes) 0x784f0d55
sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c
sendMessageWithFee(bytes,bytes,uint256) 0x7c6bed39
stateMachineIdOf(uint256) 0xaa6f97d5
supportsAttribute(bytes4) 0xdc680a0f
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |