|
| 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