Skip to content

Commit a636b8b

Browse files
authored
Merge pull request #32 from showtime-xyz/disable-initializers-cherry-picked
Fix implementation re-initialization issue
2 parents 980061e + ad9f667 commit a636b8b

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

contracts/SingleEditionMintable.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ contract SingleEditionMintable is
6969
// Global constructor for factory
7070
constructor(SharedNFTLogic _sharedNFTLogic) {
7171
sharedNFTLogic = _sharedNFTLogic;
72+
73+
_disableInitializers();
7274
}
7375

7476
/**
@@ -137,7 +139,7 @@ contract SingleEditionMintable is
137139
}
138140

139141
/**
140-
@param _salePrice if sale price is 0 sale is stopped, otherwise that amount
142+
@param _salePrice if sale price is 0 sale is stopped, otherwise that amount
141143
of ETH is needed to start the sale.
142144
@dev This sets a simple ETH sales price
143145
Setting a sales price allows users to mint the edition until it sells out.
@@ -243,7 +245,7 @@ contract SingleEditionMintable is
243245

244246
/**
245247
@param tokenId Token ID to burn
246-
User burn function for token id
248+
User burn function for token id
247249
*/
248250
function burn(uint256 tokenId) public {
249251
require(_isApprovedOrOwner(_msgSender(), tokenId), "Not approved");

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"dotenv": "^10.0.0"
4242
},
4343
"dependencies": {
44-
"ethers": "^5.4.1",
45-
"@openzeppelin/contracts-upgradeable": "^4.3.2",
46-
"base64-sol": "^1.0.1"
44+
"@openzeppelin/contracts-upgradeable": "^4.7.3",
45+
"base64-sol": "^1.0.1",
46+
"ethers": "^5.4.1"
4747
}
4848
}

test/SingleEditionMintableTest.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,44 @@ describe("SingleEditionMintable", () => {
1313
let signer: SignerWithAddress;
1414
let signerAddress: string;
1515
let dynamicSketch: SingleEditionMintableCreator;
16+
let editionImpl: SingleEditionMintable;
1617

1718
beforeEach(async () => {
18-
const { SingleEditionMintableCreator } = await deployments.fixture([
19+
const { SingleEditionMintableCreator, SingleEditionMintable } = await deployments.fixture([
1920
"SingleEditionMintableCreator",
2021
"SingleEditionMintable",
2122
]);
22-
const dynamicMintableAddress = (
23-
await deployments.get("SingleEditionMintable")
24-
).address;
2523
dynamicSketch = (await ethers.getContractAt(
2624
"SingleEditionMintableCreator",
2725
SingleEditionMintableCreator.address
2826
)) as SingleEditionMintableCreator;
2927

28+
editionImpl = (await ethers.getContractAt(
29+
"SingleEditionMintable",
30+
SingleEditionMintable.address
31+
)) as SingleEditionMintable;
32+
3033
signer = (await ethers.getSigners())[0];
3134
signerAddress = await signer.getAddress();
3235
});
3336

37+
it("does not allow re-initialization of the implementation contract", async () => {
38+
await expect(
39+
editionImpl.initialize(
40+
signerAddress,
41+
"test name",
42+
"SYM",
43+
"description",
44+
"animation",
45+
"0x0000000000000000000000000000000000000000000000000000000000000000",
46+
"uri",
47+
"0x0000000000000000000000000000000000000000000000000000000000000000",
48+
12,
49+
12
50+
)
51+
).to.be.revertedWith("Initializable: contract is already initialized");
52+
});
53+
3454
it("makes a new edition", async () => {
3555
await dynamicSketch.createEdition(
3656
"Testing Token",
@@ -294,7 +314,7 @@ describe("SingleEditionMintable", () => {
294314
200,
295315
200
296316
);
297-
317+
298318
const editionResult = await dynamicSketch.getEditionAtId(1);
299319
const minterContractNew = (await ethers.getContractAt(
300320
"SingleEditionMintable",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,10 @@
521521
"@types/sinon-chai" "^3.2.3"
522522
"@types/web3" "1.0.19"
523523

524-
"@openzeppelin/contracts-upgradeable@^4.3.2":
525-
version "4.3.2"
526-
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.3.2.tgz#92df481362e366c388fc02133cf793029c744cea"
527-
integrity sha512-i/pOaOtcqDk4UqsrOv735uYyTbn6dvfiuVu5hstsgV6c4ZKUtu88/31zT2BzkCg+3JfcwOfgg2TtRKVKKZIGkQ==
524+
"@openzeppelin/contracts-upgradeable@^4.7.3":
525+
version "4.7.3"
526+
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.7.3.tgz#f1d606e2827d409053f3e908ba4eb8adb1dd6995"
527+
integrity sha512-+wuegAMaLcZnLCJIvrVUDzA9z/Wp93f0Dla/4jJvIhijRrPabjQbZe6fWiECLaJyfn5ci9fqf9vTw3xpQOad2A==
528528

529529
"@resolver-engine/core@^0.3.3":
530530
version "0.3.3"

0 commit comments

Comments
 (0)