Git Source
PauseableEnumerableSet
Library for managing sets of values that can be paused and unpaused
Provides functionality for managing sets of addresses, uint160s, bytes32s and bytes values
Each value in a set has an associated status that tracks when it was enabled/disabled
Methods
set
function set(Status storage self, uint48 timestamp) internal
Stores the enabled and disabled timestamps for a value
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Stores a uint160 value and its status
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Stores a bytes32 value and its status
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Stores a bytes value and its status
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Set of uint160 values with their statuses
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Set of address values, implemented using Uint160Set
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Set of bytes32 values with their statuses
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Set of bytes values with their statuses
Parameters
Name | Type | Description |
---|
self | Status storage | |
timestamp | uint48 | |
set
function set(Status storage self, uint48 timestamp) internal
Sets the initial status of a value
Parameters
Name | Type | Description |
---|
self | Status storage | The status to modify |
timestamp | uint48 | The timestamp to set as enabled |
enable
function enable(Status storage self, uint48 timestamp, uint48 immutablePeriod) internal
Enables a previously disabled value
Parameters
Name | Type | Description |
---|
self | Status storage | The status to modify |
timestamp | uint48 | The timestamp to set as enabled |
immutablePeriod | uint48 | The required waiting period after disabling |
disable
function disable(Status storage self, uint48 timestamp) internal
Disables an enabled value
Parameters
Name | Type | Description |
---|
self | Status storage | The status to modify |
timestamp | uint48 | The timestamp to set as disabled |
validateUnregister
function validateUnregister(Status storage self, uint48 timestamp, uint48 immutablePeriod) internal view
Validates if a value can be unregistered
Parameters
Name | Type | Description |
---|
self | Status storage | The status to check |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
checkUnregister
function checkUnregister(
Status storage self,
uint48 timestamp,
uint48 immutablePeriod
) internal view returns (bool)
Checks if a value can be unregistered
Parameters
Name | Type | Description |
---|
self | Status storage | The status to check |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
Returns
Name | Type | Description |
---|
| bool | bool Whether the value can be unregistered |
wasActiveAt
function wasActiveAt(Status storage self, uint48 timestamp) internal view returns (bool)
Checks if a value was active at a given timestamp
Parameters
Name | Type | Description |
---|
self | Status storage | The status to check |
timestamp | uint48 | The timestamp to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the value was active |
get
function get(
Inner160 storage self
) internal view returns (uint160, uint48, uint48)
Gets the value and status for an Inner160
Parameters
Name | Type | Description |
---|
self | Inner160 storage | The Inner160 to get data from |
Returns
Name | Type | Description |
---|
| uint160 | The value, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
get
function get(
InnerBytes32 storage self
) internal view returns (bytes32, uint48, uint48)
Gets the value and status for an InnerBytes32
Parameters
Name | Type | Description |
---|
self | InnerBytes32 storage | The InnerBytes32 to get data from |
Returns
Name | Type | Description |
---|
| bytes32 | The value, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
get
function get(
InnerBytes storage self
) internal view returns (bytes memory, uint48, uint48)
Gets the value and status for an InnerBytes
Parameters
Name | Type | Description |
---|
self | InnerBytes storage | The InnerBytes to get data from |
Returns
Name | Type | Description |
---|
memory | bytes | The value, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
length
function length(
AddressSet storage self
) internal view returns (uint256)
Gets the number of addresses in the set
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to query |
Returns
Name | Type | Description |
---|
| uint256 | uint256 The number of addresses |
function at(AddressSet storage self, uint256 pos) internal view returns (address, uint48, uint48)
Gets the address and status at a given position
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to query |
pos | uint256 | The position to query |
Returns
Name | Type | Description |
---|
| address | The address, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
getActive
function getActive(AddressSet storage self, uint48 timestamp) internal view returns (address[] memory array)
Gets all active addresses at a given timestamp
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to query |
timestamp | uint48 | The timestamp to check |
Returns
Name | Type | Description |
---|
array | address[] memory | array Array of active addresses |
wasActiveAt
function wasActiveAt(AddressSet storage self, uint48 timestamp, address addr) internal view returns (bool)
Checks if an address was active at a given timestamp
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to query |
timestamp | uint48 | The timestamp to check |
addr | address | The address to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the address was active |
register
function register(AddressSet storage self, uint48 timestamp, address addr) internal
Registers a new address
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to modify |
timestamp | uint48 | The timestamp to set as enabled |
addr | address | The address to register |
pause
function pause(AddressSet storage self, uint48 timestamp, address addr) internal
Pauses an address
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to modify |
timestamp | uint48 | The timestamp to set as disabled |
addr | address | The address to pause |
unpause
function unpause(AddressSet storage self, uint48 timestamp, uint48 immutablePeriod, address addr) internal
Unpauses an address
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to modify |
timestamp | uint48 | The timestamp to set as enabled |
immutablePeriod | uint48 | The required waiting period after disabling |
addr | address | The address to unpause |
unregister
function unregister(AddressSet storage self, uint48 timestamp, uint48 immutablePeriod, address addr) internal
Unregisters an address
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to modify |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
addr | address | The address to unregister |
contains
function contains(AddressSet storage self, address addr) internal view returns (bool)
Checks if an address is registered
Parameters
Name | Type | Description |
---|
self | AddressSet storage | The AddressSet to query |
addr | address | The address to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the address is registered |
length
function length(
Uint160Set storage self
) internal view returns (uint256)
Gets the number of uint160s in the set
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to query |
Returns
Name | Type | Description |
---|
| uint256 | uint256 The number of uint160s |
function at(Uint160Set storage self, uint256 pos) internal view returns (uint160, uint48, uint48)
Gets the uint160 and status at a given position
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to query |
pos | uint256 | The position to query |
Returns
Name | Type | Description |
---|
| uint160 | The uint160, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
getActive
function getActive(Uint160Set storage self, uint48 timestamp) internal view returns (uint160[] memory array)
Gets all active uint160s at a given timestamp
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to query |
timestamp | uint48 | The timestamp to check |
Returns
Name | Type | Description |
---|
array | uint160[] memory | array Array of active uint160s |
wasActiveAt
function wasActiveAt(Uint160Set storage self, uint48 timestamp, uint160 value) internal view returns (bool)
Checks if a uint160 was active at a given timestamp
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to query |
timestamp | uint48 | The timestamp to check |
value | uint160 | The uint160 to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the uint160 was active |
register
function register(Uint160Set storage self, uint48 timestamp, uint160 value) internal
Registers a new uint160
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to modify |
timestamp | uint48 | The timestamp to set as enabled |
value | uint160 | The uint160 to register |
pause
function pause(Uint160Set storage self, uint48 timestamp, uint160 value) internal
Pauses a uint160
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to modify |
timestamp | uint48 | The timestamp to set as disabled |
value | uint160 | The uint160 to pause |
unpause
function unpause(Uint160Set storage self, uint48 timestamp, uint48 immutablePeriod, uint160 value) internal
Unpauses a uint160
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to modify |
timestamp | uint48 | The timestamp to set as enabled |
immutablePeriod | uint48 | The required waiting period after disabling |
value | uint160 | The uint160 to unpause |
unregister
function unregister(Uint160Set storage self, uint48 timestamp, uint48 immutablePeriod, uint160 value) internal
Unregisters a uint160
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to modify |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
value | uint160 | The uint160 to unregister |
contains
function contains(Uint160Set storage self, uint160 value) internal view returns (bool)
Checks if a uint160 is registered
Parameters
Name | Type | Description |
---|
self | Uint160Set storage | The Uint160Set to query |
value | uint160 | The uint160 to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the uint160 is registered |
length
function length(
Bytes32Set storage self
) internal view returns (uint256)
Gets the number of bytes32s in the set
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
Returns
Name | Type | Description |
---|
| uint256 | uint256 The number of bytes32s |
function at(Bytes32Set storage self, uint256 pos) internal view returns (bytes32, uint48, uint48)
Gets the bytes32 and status at a given position
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
pos | uint256 | The position to query |
Returns
Name | Type | Description |
---|
| bytes32 | The bytes32, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
getActive
function getActive(Bytes32Set storage self, uint48 timestamp) internal view returns (bytes32[] memory array)
Gets all active bytes32s at a given timestamp
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
timestamp | uint48 | The timestamp to check |
Returns
Name | Type | Description |
---|
array | bytes32[] memory | array Array of active bytes32s |
wasActiveAt
function wasActiveAt(Bytes32Set storage self, uint48 timestamp, bytes32 value) internal view returns (bool)
Checks if a bytes32 was active at a given timestamp
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
timestamp | uint48 | The timestamp to check |
value | bytes32 | The bytes32 to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes32 was active |
register
function register(Bytes32Set storage self, uint48 timestamp, bytes32 value) internal
Registers a new bytes32
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to modify |
timestamp | uint48 | The timestamp to set as enabled |
value | bytes32 | The bytes32 to register |
pause
function pause(Bytes32Set storage self, uint48 timestamp, bytes32 value) internal
Pauses a bytes32
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to modify |
timestamp | uint48 | The timestamp to set as disabled |
value | bytes32 | The bytes32 to pause |
unpause
function unpause(Bytes32Set storage self, uint48 timestamp, uint48 immutablePeriod, bytes32 value) internal
Unpauses a bytes32
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to modify |
timestamp | uint48 | The timestamp to set as enabled |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes32 | The bytes32 to unpause |
checkUnregister
function checkUnregister(
Bytes32Set storage self,
uint48 timestamp,
uint48 immutablePeriod,
bytes32 value
) internal view returns (bool)
Checks if a bytes32 can be unregistered
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes32 | The bytes32 to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes32 can be unregistered |
unregister
function unregister(Bytes32Set storage self, uint48 timestamp, uint48 immutablePeriod, bytes32 value) internal
Unregisters a bytes32
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to modify |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes32 | The bytes32 to unregister |
contains
function contains(Bytes32Set storage self, bytes32 value) internal view returns (bool)
Checks if a bytes32 is registered
Parameters
Name | Type | Description |
---|
self | Bytes32Set storage | The Bytes32Set to query |
value | bytes32 | The bytes32 to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes32 is registered |
length
function length(
BytesSet storage self
) internal view returns (uint256)
Gets the number of bytes values in the set
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
Returns
Name | Type | Description |
---|
| uint256 | uint256 The number of bytes values |
function at(BytesSet storage self, uint256 pos) internal view returns (bytes memory, uint48, uint48)
Gets the bytes value and status at a given position
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
pos | uint256 | The position to query |
Returns
Name | Type | Description |
---|
memory | bytes | The bytes value, enabled timestamp, and disabled timestamp |
| uint48 | |
| uint48 | |
getActive
function getActive(BytesSet storage self, uint48 timestamp) internal view returns (bytes[] memory array)
Gets all active bytes values at a given timestamp
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
timestamp | uint48 | The timestamp to check |
Returns
Name | Type | Description |
---|
array | bytes[] memory | array Array of active bytes values |
wasActiveAt
function wasActiveAt(BytesSet storage self, uint48 timestamp, bytes memory value) internal view returns (bool)
Checks if a bytes value was active at a given timestamp
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
timestamp | uint48 | The timestamp to check |
value | bytes memory | The bytes value to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes value was active |
register
function register(BytesSet storage self, uint48 timestamp, bytes memory value) internal
Registers a new bytes value
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to modify |
timestamp | uint48 | The timestamp to set as enabled |
value | bytes memory | The bytes value to register |
pause
function pause(BytesSet storage self, uint48 timestamp, bytes memory value) internal
Pauses a bytes value
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to modify |
timestamp | uint48 | The timestamp to set as disabled |
value | bytes memory | The bytes value to pause |
unpause
function unpause(BytesSet storage self, uint48 timestamp, uint48 immutablePeriod, bytes memory value) internal
Unpauses a bytes value
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to modify |
timestamp | uint48 | The timestamp to set as enabled |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes memory | The bytes value to unpause |
checkUnregister
function checkUnregister(
BytesSet storage self,
uint48 timestamp,
uint48 immutablePeriod,
bytes memory value
) internal view returns (bool)
Checks if a bytes value can be unregistered
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes memory | The bytes value to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes value can be unregistered |
unregister
function unregister(BytesSet storage self, uint48 timestamp, uint48 immutablePeriod, bytes memory value) internal
Unregisters a bytes value
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to modify |
timestamp | uint48 | The current timestamp |
immutablePeriod | uint48 | The required waiting period after disabling |
value | bytes memory | The bytes value to unregister |
contains
function contains(BytesSet storage self, bytes memory value) internal view returns (bool)
Checks if a bytes value is registered
Parameters
Name | Type | Description |
---|
self | BytesSet storage | The BytesSet to query |
value | bytes memory | The bytes value to check |
Returns
Name | Type | Description |
---|
| bool | bool Whether the bytes value is registered |