Skip to content

Commit

Permalink
Add NatSpecs to Initializable (#11252)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-chrzan authored Oct 16, 2024
1 parent d9a8384 commit 451def4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/protocol/contracts/common/Initializable.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.5.13 <0.9.0;

/**
* @title Used with proxied contracts that have an `initialize` function.
* @notice Ensures the `initialize` function:
* - gets called only once
* - cannot be called on the logic contract.
*/
contract Initializable {
bool public initialized;

/**
* @notice Ensures the initializer function cannot be called more than once.
*/
modifier initializer() {
require(!initialized, "contract already initialized");
initialized = true;
_;
}

/**
* @notice By default, ensures that the `initialize` function cannot be called
* on the logic contract.
* @param testingDeployment When set to true, allows the `initialize` function
* to be called, which is useful in testing when not setting up with a Proxy.
*/
constructor(bool testingDeployment) public {
if (!testingDeployment) {
initialized = true;
Expand Down

0 comments on commit 451def4

Please sign in to comment.