Skip to content

Commit fd9bbae

Browse files
authored
Add ERC-7786 interface (#5737)
1 parent 6ef73e3 commit fd9bbae

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

.changeset/wild-baths-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`IERC7786`: Add the (draft) interface for ERC-7786 "Cross-Chain Messaging Gateway"

contracts/interfaces/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ are useful to interact with third party contracts that implement them.
4545
- {IERC6909Metadata}
4646
- {IERC6909TokenSupply}
4747
- {IERC7674}
48+
- {IERC7786}
4849
- {IERC7802}
4950

5051
== Detailed ABI
@@ -99,4 +100,6 @@ are useful to interact with third party contracts that implement them.
99100

100101
{{IERC7674}}
101102

103+
{{IERC7786}}
104+
102105
{{IERC7802}}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity >=0.8.4;
4+
5+
/**
6+
* @dev Interface for ERC-7786 source gateways.
7+
*
8+
* See ERC-7786 for more details
9+
*/
10+
interface IERC7786GatewaySource {
11+
/**
12+
* @dev Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary. If
13+
* `outboxId` is not zero, then further (gateway specific, and non-standardized) action is required.
14+
*/
15+
event MessageSent(
16+
bytes32 indexed sendId,
17+
bytes sender, // Binary Interoperable Address
18+
bytes receiver, // Binary Interoperable Address
19+
bytes payload,
20+
uint256 value,
21+
bytes[] attributes
22+
);
23+
24+
/// @dev This error is thrown when a message creation fails because of an unsupported attribute being specified.
25+
error UnsupportedAttribute(bytes4 selector);
26+
27+
/// @dev Getter to check whether an attribute is supported or not.
28+
function supportsAttribute(bytes4 selector) external view returns (bool);
29+
30+
/**
31+
* @dev Endpoint for creating a new message. If the message requires further (gateway specific) processing before
32+
* it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the
33+
* message MUST be sent and this function must return 0.
34+
*
35+
* * MUST emit a {MessageSent} event.
36+
*
37+
* If any of the `attributes` is not supported, this function SHOULD revert with an {UnsupportedAttribute} error.
38+
* Other errors SHOULD revert with errors not specified in ERC-7786.
39+
*/
40+
function sendMessage(
41+
bytes calldata recipient, // Binary Interoperable Address
42+
bytes calldata payload,
43+
bytes[] calldata attributes
44+
) external payable returns (bytes32 sendId);
45+
}
46+
47+
/**
48+
* @dev Interface for the ERC-7786 client contract (receiver).
49+
*
50+
* See ERC-7786 for more details
51+
*/
52+
interface IERC7786Receiver {
53+
/**
54+
* @dev Endpoint for receiving cross-chain message.
55+
*
56+
* This function may be called directly by the gateway.
57+
*/
58+
function executeMessage(
59+
bytes32 receiveId,
60+
bytes calldata sender, // Binary Interoperable Address
61+
bytes calldata payload,
62+
bytes[] calldata attributes
63+
) external payable returns (bytes4);
64+
}

0 commit comments

Comments
 (0)