ERC7786OpenBridge
Inherits: IERC7786GatewaySource, IERC7786Recipient, IERC7786OpenBridge
Title: ERC7786OpenBridge
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Adapted for EIP-2535 from OpenZeppelin community-contracts ERC7786OpenBridge (https://github.com/OpenZeppelin/openzeppelin-community-contracts, commit f7e5f08)
N-of-M ERC-7786 aggregator facet: sendMessage fans a message out across M gateways, and
receiveMessage delivers to the recipient once N independent gateways have attested it. It is
both an IERC7786GatewaySource (send) and an IERC7786Recipient (the gateways deliver to it).
Stateless delegator — logic/storage live in ERC7786OpenBridgeLib. OZ's Ownable → AccessControl
and EnumerableSet/state → ERC-7201 storage. (Pausable/sweep from upstream are omitted.)
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 |
receiveMessage
This function may be called directly by the gateway.
Endpoint for receiving cross-chain message.
function receiveMessage(bytes32 receiveId, bytes calldata sender, bytes calldata payload)
external
payable
virtual
returns (bytes4);Parameters
| Name | Type | Description |
|---|---|---|
| receiveId | bytes32 | |
| sender | bytes | |
| payload | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes4 |
getGateways
function getGateways() external view virtual returns (address[] memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address[] |
getThreshold
function getThreshold() external view virtual returns (uint8);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint8 |
getRemoteBridge
function getRemoteBridge(bytes calldata chain) external view virtual returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
| chain | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes |
minDirectCoverage
The minimum DIRECT registry coverage sendMessage requires of a destination (0 = disabled).
function minDirectCoverage() external view virtual returns (uint8);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint8 |
addGateway
function addGateway(address gateway) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
removeGateway
function removeGateway(address gateway) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| gateway | address |
setThreshold
function setThreshold(uint8 threshold) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| threshold | uint8 |
registerRemoteBridge
Registers the matching OpenBridge on a remote chain (full ERC-7930 interoperable address).
Reverts with ThresholdViolation until setThreshold has been called (configure gateways, then the
threshold, then remotes).
function registerRemoteBridge(bytes calldata bridge) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| bridge | bytes |
setMinDirectCoverage
Sets the M-of-N coverage-awareness knob: when non-zero, sendMessage hard-refuses destinations
whose DIRECT gateway coverage in the IChainRegistry is below minDirectCoverage_ (set 2+ to
refuse M=1 routes; 0 — the default — disables the check and preserves prior behavior).
function setMinDirectCoverage(uint8 minDirectCoverage_) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| minDirectCoverage_ | uint8 |
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 ERC7786OpenBridge methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
addGateway(address) 0x68bb3795
getGateways() 0xd82778ce
getRemoteBridge(bytes) 0xd0673410
getThreshold() 0xe75235b8
minDirectCoverage() 0xc62c2f15
receiveMessage(bytes32,bytes,bytes) 0x2432ef26
registerRemoteBridge(bytes) 0x7e1c8ae5
removeGateway(address) 0x8a885e35
sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c
setMinDirectCoverage(uint8) 0x10360b6b
setThreshold(uint8) 0xe5a98603
supportsAttribute(bytes4) 0xdc680a0f
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |