Skip to main content

PauseableEnumerableSet

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

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Stores a uint160 value and its status

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Stores a bytes32 value and its status

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Stores a bytes value and its status

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Set of uint160 values with their statuses

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Set of address values, implemented using Uint160Set

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Set of bytes32 values with their statuses

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Set of bytes values with their statuses

Parameters

NameTypeDescription
selfStatus storage
timestampuint48

set

function set(Status storage self, uint48 timestamp) internal

Sets the initial status of a value

Parameters

NameTypeDescription
selfStatus storageThe status to modify
timestampuint48The timestamp to set as enabled

enable

function enable(Status storage self, uint48 timestamp, uint48 immutablePeriod) internal

Enables a previously disabled value

Parameters

NameTypeDescription
selfStatus storageThe status to modify
timestampuint48The timestamp to set as enabled
immutablePerioduint48The required waiting period after disabling

disable

function disable(Status storage self, uint48 timestamp) internal

Disables an enabled value

Parameters

NameTypeDescription
selfStatus storageThe status to modify
timestampuint48The 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

NameTypeDescription
selfStatus storageThe status to check
timestampuint48The current timestamp
immutablePerioduint48The 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

NameTypeDescription
selfStatus storageThe status to check
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling

Returns

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

NameTypeDescription
selfStatus storageThe status to check
timestampuint48The timestamp to check

Returns

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

NameTypeDescription
selfInner160 storageThe Inner160 to get data from

Returns

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

NameTypeDescription
selfInnerBytes32 storageThe InnerBytes32 to get data from

Returns

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

NameTypeDescription
selfInnerBytes storageThe InnerBytes to get data from

Returns

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

NameTypeDescription
selfAddressSet storageThe AddressSet to query

Returns

NameTypeDescription
uint256uint256 The number of addresses

at

function at(AddressSet storage self, uint256 pos) internal view returns (address, uint48, uint48)

Gets the address and status at a given position

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to query
posuint256The position to query

Returns

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

NameTypeDescription
selfAddressSet storageThe AddressSet to query
timestampuint48The timestamp to check

Returns

NameTypeDescription
arrayaddress[] memoryarray 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

NameTypeDescription
selfAddressSet storageThe AddressSet to query
timestampuint48The timestamp to check
addraddressThe address to check

Returns

NameTypeDescription
boolbool Whether the address was active

register

function register(AddressSet storage self, uint48 timestamp, address addr) internal

Registers a new address

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to modify
timestampuint48The timestamp to set as enabled
addraddressThe address to register

pause

function pause(AddressSet storage self, uint48 timestamp, address addr) internal

Pauses an address

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to modify
timestampuint48The timestamp to set as disabled
addraddressThe address to pause

unpause

function unpause(AddressSet storage self, uint48 timestamp, uint48 immutablePeriod, address addr) internal

Unpauses an address

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to modify
timestampuint48The timestamp to set as enabled
immutablePerioduint48The required waiting period after disabling
addraddressThe address to unpause

unregister

function unregister(AddressSet storage self, uint48 timestamp, uint48 immutablePeriod, address addr) internal

Unregisters an address

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to modify
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
addraddressThe address to unregister

contains

function contains(AddressSet storage self, address addr) internal view returns (bool)

Checks if an address is registered

Parameters

NameTypeDescription
selfAddressSet storageThe AddressSet to query
addraddressThe address to check

Returns

NameTypeDescription
boolbool Whether the address is registered

length

function length(
Uint160Set storage self
) internal view returns (uint256)

Gets the number of uint160s in the set

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to query

Returns

NameTypeDescription
uint256uint256 The number of uint160s

at

function at(Uint160Set storage self, uint256 pos) internal view returns (uint160, uint48, uint48)

Gets the uint160 and status at a given position

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to query
posuint256The position to query

Returns

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

NameTypeDescription
selfUint160Set storageThe Uint160Set to query
timestampuint48The timestamp to check

Returns

NameTypeDescription
arrayuint160[] memoryarray 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

NameTypeDescription
selfUint160Set storageThe Uint160Set to query
timestampuint48The timestamp to check
valueuint160The uint160 to check

Returns

NameTypeDescription
boolbool Whether the uint160 was active

register

function register(Uint160Set storage self, uint48 timestamp, uint160 value) internal

Registers a new uint160

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to modify
timestampuint48The timestamp to set as enabled
valueuint160The uint160 to register

pause

function pause(Uint160Set storage self, uint48 timestamp, uint160 value) internal

Pauses a uint160

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to modify
timestampuint48The timestamp to set as disabled
valueuint160The uint160 to pause

unpause

function unpause(Uint160Set storage self, uint48 timestamp, uint48 immutablePeriod, uint160 value) internal

Unpauses a uint160

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to modify
timestampuint48The timestamp to set as enabled
immutablePerioduint48The required waiting period after disabling
valueuint160The uint160 to unpause

unregister

function unregister(Uint160Set storage self, uint48 timestamp, uint48 immutablePeriod, uint160 value) internal

Unregisters a uint160

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to modify
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
valueuint160The uint160 to unregister

contains

function contains(Uint160Set storage self, uint160 value) internal view returns (bool)

Checks if a uint160 is registered

Parameters

NameTypeDescription
selfUint160Set storageThe Uint160Set to query
valueuint160The uint160 to check

Returns

NameTypeDescription
boolbool Whether the uint160 is registered

length

function length(
Bytes32Set storage self
) internal view returns (uint256)

Gets the number of bytes32s in the set

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query

Returns

NameTypeDescription
uint256uint256 The number of bytes32s

at

function at(Bytes32Set storage self, uint256 pos) internal view returns (bytes32, uint48, uint48)

Gets the bytes32 and status at a given position

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query
posuint256The position to query

Returns

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

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query
timestampuint48The timestamp to check

Returns

NameTypeDescription
arraybytes32[] memoryarray 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

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query
timestampuint48The timestamp to check
valuebytes32The bytes32 to check

Returns

NameTypeDescription
boolbool Whether the bytes32 was active

register

function register(Bytes32Set storage self, uint48 timestamp, bytes32 value) internal

Registers a new bytes32

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to modify
timestampuint48The timestamp to set as enabled
valuebytes32The bytes32 to register

pause

function pause(Bytes32Set storage self, uint48 timestamp, bytes32 value) internal

Pauses a bytes32

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to modify
timestampuint48The timestamp to set as disabled
valuebytes32The bytes32 to pause

unpause

function unpause(Bytes32Set storage self, uint48 timestamp, uint48 immutablePeriod, bytes32 value) internal

Unpauses a bytes32

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to modify
timestampuint48The timestamp to set as enabled
immutablePerioduint48The required waiting period after disabling
valuebytes32The 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

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
valuebytes32The bytes32 to check

Returns

NameTypeDescription
boolbool Whether the bytes32 can be unregistered

unregister

function unregister(Bytes32Set storage self, uint48 timestamp, uint48 immutablePeriod, bytes32 value) internal

Unregisters a bytes32

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to modify
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
valuebytes32The bytes32 to unregister

contains

function contains(Bytes32Set storage self, bytes32 value) internal view returns (bool)

Checks if a bytes32 is registered

Parameters

NameTypeDescription
selfBytes32Set storageThe Bytes32Set to query
valuebytes32The bytes32 to check

Returns

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

NameTypeDescription
selfBytesSet storageThe BytesSet to query

Returns

NameTypeDescription
uint256uint256 The number of bytes values

at

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

NameTypeDescription
selfBytesSet storageThe BytesSet to query
posuint256The position to query

Returns

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

NameTypeDescription
selfBytesSet storageThe BytesSet to query
timestampuint48The timestamp to check

Returns

NameTypeDescription
arraybytes[] memoryarray 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

NameTypeDescription
selfBytesSet storageThe BytesSet to query
timestampuint48The timestamp to check
valuebytes memoryThe bytes value to check

Returns

NameTypeDescription
boolbool Whether the bytes value was active

register

function register(BytesSet storage self, uint48 timestamp, bytes memory value) internal

Registers a new bytes value

Parameters

NameTypeDescription
selfBytesSet storageThe BytesSet to modify
timestampuint48The timestamp to set as enabled
valuebytes memoryThe bytes value to register

pause

function pause(BytesSet storage self, uint48 timestamp, bytes memory value) internal

Pauses a bytes value

Parameters

NameTypeDescription
selfBytesSet storageThe BytesSet to modify
timestampuint48The timestamp to set as disabled
valuebytes memoryThe bytes value to pause

unpause

function unpause(BytesSet storage self, uint48 timestamp, uint48 immutablePeriod, bytes memory value) internal

Unpauses a bytes value

Parameters

NameTypeDescription
selfBytesSet storageThe BytesSet to modify
timestampuint48The timestamp to set as enabled
immutablePerioduint48The required waiting period after disabling
valuebytes memoryThe 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

NameTypeDescription
selfBytesSet storageThe BytesSet to query
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
valuebytes memoryThe bytes value to check

Returns

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

NameTypeDescription
selfBytesSet storageThe BytesSet to modify
timestampuint48The current timestamp
immutablePerioduint48The required waiting period after disabling
valuebytes memoryThe 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

NameTypeDescription
selfBytesSet storageThe BytesSet to query
valuebytes memoryThe bytes value to check

Returns

NameTypeDescription
boolbool Whether the bytes value is registered