L1ToL2CrossDomainMessengerGatewayAdapter
Inherits: IERC7786GatewaySource, IL1ToL2CrossDomainMessengerGatewayAdapter
Title: L1ToL2CrossDomainMessengerGatewayAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Optimism (https://github.com/ethereum-optimism/optimism)
ERC-7786 cross-chain gateway facet over the canonical OP Stack L1<->L2 CrossDomainMessenger predeploy.
sendMessage dispatches a message via the messenger (no fee); receiveCrossChainMessage is the
messenger-invoked delivery callback on the destination adapter. Carries deposits (L1->L2) and
withdrawals (L2->L1); direction-agnostic (identical adapter on both domains).
Stateless delegator — logic/storage live in L1ToL2CrossDomainMessengerGatewayAdapterLib. A canonical
L1<->L2 pair has exactly ONE other domain, so the trusted remote is a SINGLE fixed counterpart
(counterpartChainId, counterpartAdapter) (NOT a chainId => remote map). INVERTED INBOUND AUTH: the
messenger CALLs receiveCrossChainMessage as the _target during relay, so msg.sender is the L2
messenger predeploy — the counterpart gateway is authenticated out-of-band via xDomainMessageSender,
not from msg.sender.
Notes:
- lattice-version: 0.1.0
- lattice-source: Optimism
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 |
receiveCrossChainMessage
Inbound delivery callback the messenger invokes on THIS adapter during relay. Authenticates the
messenger + the authenticated counterpart sender against the configured counterpart adapter,
de-dups, then hands off to the ERC-7930 recipient via the IERC7786Recipient handshake.
function receiveCrossChainMessage(
bytes calldata sender,
bytes calldata recipient,
bytes calldata payload,
uint256 nonce
) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| sender | bytes | The ERC-7930 sender interoperable address (origin chain + caller). |
| recipient | bytes | The ERC-7930 recipient interoperable address (must target THIS chain). |
| payload | bytes | The opaque message payload delivered to the recipient. |
| nonce | uint256 | The source-minted monotonic nonce; (counterpartChainId, nonce) forms the globally-uniquedelivery id. |
messenger
The fixed OP Stack L2 CrossDomainMessenger predeploy this adapter sends to / accepts deliveries
from (0x4200000000000000000000000000000000000007).
function messenger() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
counterpartChainId
The configured counterpart (paired-domain) chain id (0 = unset).
function counterpartChainId() external view virtual returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
counterpartAdapter
The configured counterpart gateway adapter on the paired domain (0 = unset).
function counterpartAdapter() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
minGasLimit
The minGasLimit the messenger relays outbound messages with.
function minGasLimit() external view virtual returns (uint32);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
setCounterpart
Configures the fixed counterpart (paired-domain chainId + sibling adapter). Rejects a zero adapter. Admin only.
function setCounterpart(uint256 chainId, address adapter) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| adapter | address |
setMinGasLimit
Configures the relay minGasLimit. Admin only.
function setMinGasLimit(uint32 newMinGasLimit) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| newMinGasLimit | uint32 |
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 L1ToL2CrossDomainMessengerGatewayAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
counterpartAdapter() 0x423d4bee
counterpartChainId() 0xb8b5b334
messenger() 0x3cb747bf
minGasLimit() 0x5aeb4d77
receiveCrossChainMessage(bytes,bytes,bytes,uint256) 0x610683bc
sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c
setCounterpart(uint256,address) 0xddcba0e7
setMinGasLimit(uint32) 0xe6ca35d4
supportsAttribute(bytes4) 0xdc680a0f
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |