Skip to content

Latest commit

 

History

History
163 lines (141 loc) · 5.21 KB

Initializable.md

File metadata and controls

163 lines (141 loc) · 5.21 KB

Initializable

Based on OpenZeppelin's Initializable contract: https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/master/packages/core/contracts/Initializable.sol (Initializable.sol)

View Source: contracts/Dependencies/Initializable.sol

↘ Derived Contracts: LiquityBaseParams, ZUSDTokenStorage

Initializable

Helper contract to support initializer functions. To use it, replace the constructor with a function that has the initializer modifier. WARNING: Unlike constructors, initializer functions must be manually invoked. This applies both to deploying an Initializable contract, as well as extending an Initializable contract via inheritance. WARNING: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or ensure that all initializers are idempotent, because this is not dealt with automatically as with constructors.

Contract Members

Constants & Variables

bool private initialized;
bool private initializing;
uint256[50] private ______gap;

Modifiers

initializer

Modifier to use in the initializer function of a contract.

modifier initializer() internal

Functions


isConstructor

Returns true if and only if the function is running in the constructor

function isConstructor() private view
returns(bool)
Source Code
function isConstructor() private view returns (bool) {
        // extcodesize checks the size of the code stored in an address, and
        // address returns the current address. Since the code is still not
        // deployed when running a constructor, any checks on its code size will
        // yield zero, making it an effective way to detect if a contract is
        // under construction or not.
        address self = address(this);
        uint256 cs;
        assembly {
            cs := extcodesize(self)
        }
        return cs == 0;
    }

Contracts