draft-IERC7786.sol 2.2 KB

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