Skip to content

Commit

Permalink
contracts: upgrade to openzeppelin 4.5
Browse files Browse the repository at this point in the history
update initializer modifiers as described in: OpenZeppelin/openzeppelin-contracts#3006
  • Loading branch information
davidbrai committed Jan 26, 2022
1 parent fdbf92c commit 14ef9ff
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/hardhat/contracts/ERC721DAODeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ contract ERC721DAODeployer is OwnableUpgradeable {

function createGovernorInstance(GovernorParams calldata governorParams) private returns (ERC721Governor) {
if (governorParams.upgradable) {
return ERC721Governor(address(new ERC1967Proxy(address(governor), "")));
return ERC721Governor(payable(new ERC1967Proxy(address(governor), "")));
}
return ERC721Governor(payable(address(governor).clone()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ abstract contract GovernorVotesERC721QuorumFractionUpgradeable is Initializable,

event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);

function __GovernorVotesERC721QuorumFractionUpgradeable_init(uint256 quorumNumeratorValue) internal initializer {
function __GovernorVotesERC721QuorumFractionUpgradeable_init(uint256 quorumNumeratorValue)
internal
onlyInitializing
{
__Context_init_unchained();
__ERC165_init_unchained();
__IGovernor_init_unchained();
Expand All @@ -29,7 +32,7 @@ abstract contract GovernorVotesERC721QuorumFractionUpgradeable is Initializable,

function __GovernorVotesERC721QuorumFractionUpgradeable_init_unchained(uint256 quorumNumeratorValue)
internal
initializer
onlyInitializing
{
_updateQuorumNumerator(quorumNumeratorValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { ERC721DAOToken } from "../token/ERC721DAOToken.sol";
abstract contract GovernorVotesERC721Upgradeable is Initializable, GovernorUpgradeable {
ERC721DAOToken public token;

function __GovernorVotesERC721Upgradeable_init(ERC721DAOToken token_) internal initializer {
function __GovernorVotesERC721Upgradeable_init(ERC721DAOToken token_) internal onlyInitializing {
__Context_init_unchained();
__ERC165_init_unchained();
__IGovernor_init_unchained();
__GovernorVotesERC721Upgradeable_init_unchained(token_);
}

function __GovernorVotesERC721Upgradeable_init_unchained(ERC721DAOToken token_) internal initializer {
function __GovernorVotesERC721Upgradeable_init_unchained(ERC721DAOToken token_) internal onlyInitializing {
token = token_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract contract FixedPriceFixedSupplyMinter is ERC721Minter {
bool public isTokenPriceLocked;
bool public isOwnerMintLocked;

function __FixedPriceFixedSupplyMinter_init(uint256 maxTokens_, uint256 tokenPrice_) internal initializer {
function __FixedPriceFixedSupplyMinter_init(uint256 maxTokens_, uint256 tokenPrice_) internal onlyInitializing {
maxTokens = maxTokens_;
tokenPrice = tokenPrice_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract FixedPriceSequentialMinter is FixedPriceFixedSupplyMinter {
uint256 maxTokens_,
uint256 tokenPrice_,
uint256 maxMintsPerTx_
) public initializer {
) public onlyInitializing {
__FixedPriceFixedSupplyMinter_init(maxTokens_, tokenPrice_);

maxMintsPerTx = maxMintsPerTx_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FixedPriceFixedSupplyMinter } from "./FixedPriceFixedSupplyMinter.sol";

contract FixedPriceSpecificIDMinter is FixedPriceFixedSupplyMinter {
// this is expected to be called as part of ERC721Minter's initialize function extraInitCallData_
function init(uint256 maxTokens_, uint256 tokenPrice_) public initializer {
function init(uint256 maxTokens_, uint256 tokenPrice_) public onlyInitializing {
__FixedPriceFixedSupplyMinter_init(maxTokens_, tokenPrice_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract PaymentSplitterWithFeeUpgradeable is Initializable, ContextUpgradeable
uint256[] memory shares_,
address payable serviceFeeAddress_,
uint256 serviceFeeBasisPoints_
) internal initializer {
) internal onlyInitializing {
__Context_init_unchained();
__PaymentSplitterWithFee_init_unchained(payees, shares_, serviceFeeAddress_, serviceFeeBasisPoints_);
}
Expand All @@ -63,7 +63,7 @@ contract PaymentSplitterWithFeeUpgradeable is Initializable, ContextUpgradeable
uint256[] memory shares_,
address payable serviceFeeAddress_,
uint256 serviceFeeBasisPoints_
) internal initializer {
) internal onlyInitializing {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
require(serviceFeeBasisPoints_ <= 10000, "Max fee: 10000");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pragma solidity ^0.8.6;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

abstract contract MintingFilter is OwnableUpgradeable {
function __MintingFilter_init(address creator) internal initializer {
function __MintingFilter_init(address creator) internal onlyInitializing {
__Ownable_init();
transferOwnership(creator);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"typescript": "^4.4.4"
},
"dependencies": {
"@openzeppelin/contracts": "^4.3.2",
"@openzeppelin/contracts-upgradeable": "^4.3.2",
"@openzeppelin/contracts": "^v4.5.0-rc.0",
"@openzeppelin/contracts-upgradeable": "^v4.5.0-rc.0",
"base64-sol": "^1.0.1",
"dotenv": "^10.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/test/FixedPriceSequentialMinter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("FixedPriceSequentialMinter", () => {
it("does not let init be called again", async () => {
await expect(
minter.connect(deployer).init(MAX_TOKENS, TOKEN_PRICE, MAX_MINTS_PER_TX)
).to.be.revertedWith("Initializable: contract is already initialized");
).to.be.revertedWith("Initializable: contract is not initializing");
});

describe("Before sale is active", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/test/FixedPriceSpecificIDMinter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("FixedPriceSpecificIDMinter", () => {
it("does not let init be called again", async () => {
await expect(
minter.connect(deployer).init(MAX_TOKENS, TOKEN_PRICE)
).to.be.revertedWith("Initializable: contract is already initialized");
).to.be.revertedWith("Initializable: contract is not initializing");
});

describe("Before sale is active", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BigNumber } from "ethers";
chai.use(solidity);
const { expect } = chai;

describe("PaymentSplitterWithFeeUpradeable", async () => {
describe("PaymentSplitterWithFeeUpgradeable", async () => {
let snapshotId: number;
let deployer: SignerWithAddress;
let user1: SignerWithAddress;
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2400,15 +2400,15 @@
"@types/sinon-chai" "^3.2.3"
"@types/web3" "1.0.19"

"@openzeppelin/contracts-upgradeable@^4.3.2":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.3.2.tgz#92df481362e366c388fc02133cf793029c744cea"
integrity sha512-i/pOaOtcqDk4UqsrOv735uYyTbn6dvfiuVu5hstsgV6c4ZKUtu88/31zT2BzkCg+3JfcwOfgg2TtRKVKKZIGkQ==

"@openzeppelin/contracts@^4.3.2":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.2.tgz#ff80affd6d352dbe1bbc5b4e1833c41afd6283b6"
integrity sha512-AybF1cesONZStg5kWf6ao9OlqTZuPqddvprc0ky7lrUVOjXeKpmQ2Y9FK+6ygxasb+4aic4O5pneFBfwVsRRRg==
"@openzeppelin/contracts-upgradeable@^v4.5.0-rc.0":
version "4.5.0-rc.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.5.0-rc.0.tgz#f74114c3acf728db5d288fa859649f809dfbfb09"
integrity sha512-rplAyaAk5aAUCJLqh9GkV64gFsobPMGgPVSC9cWc+MIRoG3Q67+U1JoqGCTd3rUAJCTBpH4Hnf/QT0qe5rht9Q==

"@openzeppelin/contracts@^v4.5.0-rc.0":
version "4.5.0-rc.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.5.0-rc.0.tgz#dbe4c4380ddf715230fd14da7818142e0c6ba020"
integrity sha512-B6mKfiivxytZLAVgPARXZ5Q/grRpplASm7VgY73PdO3u5ckF6ibMpNwZYT/16Ys3ORaDyylSgJI1PttLZiJ0Lw==

"@popperjs/core@2.4.4":
version "2.4.4"
Expand Down

0 comments on commit 14ef9ff

Please sign in to comment.