Skip to content

Commit

Permalink
Improved function docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestognw committed Jul 20, 2023
1 parent eabc9c0 commit 9777b62
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contracts/proxy/utils/Initializable.sol
Expand Up @@ -187,6 +187,14 @@ abstract contract Initializable {
}
}

/**
* @dev Sets the initialized version.
*
* Requirements:
*
* - If the contract is initializing the version set must not be that of an reinitializer.
* - If the contract is not initializing the version must not be already set.
*/
function _setInitializedVersion(uint64 version) private returns (bool) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
Expand All @@ -204,6 +212,10 @@ abstract contract Initializable {
return !initializing;
}

/**
* @dev Runs before initialization.
* It sets the initialized version and sets the initializing flag to true.
*/
function _beforeInitialize(uint64 version) private returns (bool) {
bool isTopLevelCall = _setInitializedVersion(version);
if (isTopLevelCall) {
Expand All @@ -212,6 +224,10 @@ abstract contract Initializable {
return isTopLevelCall;
}

/**
* @dev Runs after initialization.
* It clears the initializing flag and emits an {Initialized} event if it is a top level call.
*/
function _afterInitialize(bool isTopLevelCall, uint64 version) private {
if (isTopLevelCall) {
_getInitializableStorage()._initializing = false;
Expand Down

0 comments on commit 9777b62

Please sign in to comment.