|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +pragma solidity >=0.8.0 <0.9.0; |
| 3 | + |
| 4 | +/// @title IRegistrar |
| 5 | +/// @notice Interface for the Registrar contract. |
| 6 | +interface IRegistrar { |
| 7 | + // ========================================================================= |
| 8 | + // Types |
| 9 | + // ========================================================================= |
| 10 | + |
| 11 | + /// @notice Storage struct for key-value entries. |
| 12 | + struct Entry { |
| 13 | + bytes32 value; |
| 14 | + uint64 epochFrom; // 0 = genesis value |
| 15 | + } |
| 16 | + |
| 17 | + // ========================================================================= |
| 18 | + // Events |
| 19 | + // ========================================================================= |
| 20 | + |
| 21 | + /// @notice Emitted when a key-value pair is updated. |
| 22 | + /// @param key The key that was updated. |
| 23 | + /// @param value The new value associated with the key. |
| 24 | + /// @param epochFrom The epoch from which the new value is active. |
| 25 | + event Updated(bytes32 indexed key, bytes32 value, uint64 epochFrom); |
| 26 | + |
| 27 | + // ========================================================================= |
| 28 | + // Errors |
| 29 | + // ========================================================================= |
| 30 | + |
| 31 | + /// @notice Error when keys and values arrays have different lengths. |
| 32 | + error LengthMismatch(); |
| 33 | + |
| 34 | + // ========================================================================= |
| 35 | + // Functions |
| 36 | + // ========================================================================= |
| 37 | + |
| 38 | + /// @notice Gets the value associated with a key at the current epoch. |
| 39 | + /// @param key The key to look up. |
| 40 | + /// @return value The value associated with the key. |
| 41 | + function get(bytes32 key) external view returns (bytes32 value); |
| 42 | + |
| 43 | + /// @notice Gets the value associated with a key at the next epoch. |
| 44 | + /// @param key The key to look up. |
| 45 | + /// @return value The value associated with the key. |
| 46 | + function getNext(bytes32 key) external view returns (bytes32 value); |
| 47 | + |
| 48 | + /// @notice Batch gets the values associated with keys at the current epoch. |
| 49 | + /// @param keys The keys to look up. |
| 50 | + /// @return values The values associated with the keys. |
| 51 | + function batchGet(bytes32[] calldata keys) external view returns (bytes32[] memory values); |
| 52 | + |
| 53 | + /// @notice Batch gets the values associated with keys at the next epoch. |
| 54 | + /// @param keys The keys to look up. |
| 55 | + /// @return values The values associated with the keys. |
| 56 | + function batchGetNext(bytes32[] calldata keys) external view returns (bytes32[] memory values); |
| 57 | + |
| 58 | + /// @notice Gets all historical entries for a key. |
| 59 | + /// @param key The key to look up. |
| 60 | + /// @return entries The entries associated with the key. |
| 61 | + function getEntries(bytes32 key) external view returns (Entry[] memory entries); |
| 62 | + |
| 63 | + /// @notice Sets a key-value pair, applied from the next epoch. |
| 64 | + /// @param key The key to set. |
| 65 | + /// @param value The value to set. |
| 66 | + function set(bytes32 key, bytes32 value) external; |
| 67 | + |
| 68 | + /// @notice Batch sets key-value pairs, applied from the next epoch. |
| 69 | + /// @param keys The keys to set. |
| 70 | + /// @param values The values to set. |
| 71 | + function batchSet(bytes32[] calldata keys, bytes32[] calldata values) external; |
| 72 | +} |
0 commit comments