InitializableReentrancyGuard
Contract module that helps prevent reentrant calls to a function and ensures the initializer has been called. Based on the OpenZeppelin implementation.
State Variables
UNINITIALIZED
The uninitialized state of the contract.
uint256 private constant UNINITIALIZED = 0;
NOT_ENTERED
The state of the contract before entering a function.
uint256 private constant NOT_ENTERED = 1;
ENTERED
The state of the contract after entering a function.
uint256 private constant ENTERED = 2;
STORAGE_STATUS
The storage slot of the InitializableReentrancyGuardStorage struct.
keccak256(abi.encode(uint256(keccak256("InitializableReentrancyGuard.storage.status")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant STORAGE_STATUS = 0x6f33a3bc64034eea47937f56d5e165f09a61a6a995142939d6f3e40f101ea600;
Functions
_getInitializableReentrancyGuardStorage
Gets the struct pointer of the contract storage.
function _getInitializableReentrancyGuardStorage()
internal
pure
returns (InitializableReentrancyGuardStorage storage s_);
Returns
Name | Type | Description |
---|---|---|
s_ | InitializableReentrancyGuardStorage | The pointer to the struct. |
__initializeReentrancyGuard_init
Initializes the storage slot on first deployment.
function __initializeReentrancyGuard_init() internal;
initializedAndNonReentrant
Reverts if the contract is not initialized or in case of a reentrancy.
Prevents a contract from calling itself, directly or indirectly, or using it in an uninitialized state. Calling an initializedAndNonReentrant function before the initialize function was called will revert. Calling an initializedAndNonReentrant function from another initializedAndNonReentrant function is not supported.
modifier initializedAndNonReentrant();
protocolInitializer
Reverts if the contract is initialized, or sets it as initialized.
modifier protocolInitializer();
_checkInitialized
Reverts if the contract is not initialized.
function _checkInitialized() private view;
_checkUninitialized
Reverts if the contract is initialized.
function _checkUninitialized() internal view;
_nonReentrantBefore
Reverts if _status
is ENTERED
, or sets it to ENTERED
.
function _nonReentrantBefore() private;
_nonReentrantAfter
Sets _status
to NOT_ENTERED
function _nonReentrantAfter() private;
Errors
InitializableReentrancyGuardReentrantCall
Unauthorized reentrant call.
error InitializableReentrancyGuardReentrantCall();
InitializableReentrancyGuardUninitialized
Contract was not yet initialized.
error InitializableReentrancyGuardUninitialized();
InitializableReentrancyGuardInvalidInitialization
Contract was already initialized.
error InitializableReentrancyGuardInvalidInitialization();
Structs
InitializableReentrancyGuardStorage
The storage structure of the contract.
Booleans are more expensive than uint256 or any type that takes up a full word because each write operation emits an extra SLOAD to first read the slot's contents, replace the bits taken up by the boolean and then write back. This is the compiler's defense against contract upgrades and pointer aliasing, and it cannot be disabled.
Note: storage-location: erc7201:InitializableReentrancyGuard.storage.status
struct InitializableReentrancyGuardStorage {
uint256 _status;
}
Properties
Name | Type | Description |
---|---|---|
_status | uint256 | The state of the contract. |