|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity >=0.8.4 <0.9; |
| 3 | + |
| 4 | +/** |
| 5 | + * @title ICustomInstructionsFacet |
| 6 | + * @notice Interface for the CustomInstructionsFacet contract. |
| 7 | + */ |
| 8 | +interface ICustomInstructionsFacet { |
| 9 | + /// @notice Struct containing custom call information |
| 10 | + struct CustomCall { |
| 11 | + /// @notice Target contract address |
| 12 | + address targetContract; |
| 13 | + /// @notice value (in wei) to send with the call |
| 14 | + uint256 value; |
| 15 | + /// @notice Call data |
| 16 | + bytes data; |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * @notice Emitted when a custom instruction is registered. |
| 21 | + * @param customInstructionHash The hash representing the registered instructions. |
| 22 | + */ |
| 23 | + event CustomInstructionRegistered(bytes32 indexed customInstructionHash); |
| 24 | + |
| 25 | + /** |
| 26 | + * @notice Emitted when a custom instruction is already registered. |
| 27 | + * @param customInstructionHash The hash representing the already registered instructions. |
| 28 | + */ |
| 29 | + event CustomInstructionAlreadyRegistered( |
| 30 | + bytes32 indexed customInstructionHash |
| 31 | + ); |
| 32 | + |
| 33 | + /** |
| 34 | + * @notice Reverts if the custom instruction is empty (zero custom calls). |
| 35 | + */ |
| 36 | + error EmptyCustomInstruction(); |
| 37 | + |
| 38 | + /** |
| 39 | + * @notice Reverts if the target address of a custom call is zero. |
| 40 | + */ |
| 41 | + error TargetAddressZero(); |
| 42 | + |
| 43 | + /** |
| 44 | + * @notice Reverts if the target address of a custom call is not a contract. |
| 45 | + * @param target The target address. |
| 46 | + */ |
| 47 | + error TargetNotAContract(address target); |
| 48 | + |
| 49 | + /** |
| 50 | + * @notice Register custom instruction and return the call hash. |
| 51 | + * @param _customInstruction Custom instruction (array of custom calls) to register. |
| 52 | + * @return _customInstructionHash The hash representing the registered custom instruction. |
| 53 | + */ |
| 54 | + function registerCustomInstruction( |
| 55 | + CustomCall[] memory _customInstruction |
| 56 | + ) external returns (bytes32 _customInstructionHash); |
| 57 | + |
| 58 | + /** |
| 59 | + * @notice Get a custom instruction for a given call hash. |
| 60 | + * @param _customInstructionHash The hash representing the custom instruction. |
| 61 | + * @return _customInstruction Custom instruction (array of custom calls) for the hash. |
| 62 | + */ |
| 63 | + function getCustomInstruction( |
| 64 | + bytes32 _customInstructionHash |
| 65 | + ) external view returns (CustomCall[] memory _customInstruction); |
| 66 | + /** |
| 67 | + * @notice Get paginated custom instruction hashes. |
| 68 | + * @param _start The starting index. |
| 69 | + * @param _end The ending index. |
| 70 | + * @return _customInstructionHashes Array of custom instruction hashes for the requested page. |
| 71 | + * @return _totalLength The total number of custom instruction hashes. |
| 72 | + */ |
| 73 | + function getCustomInstructionHashes( |
| 74 | + uint256 _start, |
| 75 | + uint256 _end |
| 76 | + ) |
| 77 | + external |
| 78 | + view |
| 79 | + returns ( |
| 80 | + bytes32[] memory _customInstructionHashes, |
| 81 | + uint256 _totalLength |
| 82 | + ); |
| 83 | + |
| 84 | + /** |
| 85 | + * @notice Encode a custom instruction to get its call hash. |
| 86 | + * @param _customInstruction Custom instruction (array of custom calls) to encode. |
| 87 | + * @return _customInstructionHash The hash representing the custom instruction. |
| 88 | + */ |
| 89 | + function encodeCustomInstruction( |
| 90 | + CustomCall[] memory _customInstruction |
| 91 | + ) external pure returns (bytes32 _customInstructionHash); |
| 92 | +} |
0 commit comments