From 3527862e2ffa0818a01221d5444c5e0632b27ce3 Mon Sep 17 00:00:00 2001 From: nakimura Date: Sat, 7 Oct 2023 18:36:21 +0900 Subject: [PATCH 1/5] add init param for Ownable --- ...\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" "b/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" index 248a9d228..b41c4a0c6 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" @@ -103,7 +103,7 @@ contract Shield is ERC721Enumerable, Ownable { * Constructor for Shields takes in the baseURI to set _baseTokenURI for the collection. * It also initializes an instance of whitelist interface. */ - constructor (string memory baseURI, address whitelistContract) ERC721("ChainIDE Shields", "CS") { + constructor (string memory baseURI, address whitelistContract) ERC721("ChainIDE Shields", "CS") Ownable(msg.sender) { _baseTokenURI = baseURI; _whitelist = IWhitelist(whitelistContract); } From 04f72df32377b4d67ff37d2660f66a5e2dd0e79c Mon Sep 17 00:00:00 2001 From: ysaito <60546319+yk-saito@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:24:34 +0900 Subject: [PATCH 2/5] chore: update solidity compiler to v0.8.20 --- .../en/section-1/lesson-2_Basic Coding.md | 6 +++--- .../en/section-1/lesson-3_Whitelist Function.md | 2 +- .../en/section-2/lesson-2_Mint Function.md | 6 +++--- .../en/section-5/lesson-1_Monorepo configration.md | 2 +- ...\274\343\203\207\343\202\243\343\203\263\343\202\260.md" | 6 +++--- ...\252\343\202\271\343\203\210\346\251\237\350\203\275.md" | 2 +- ...\237\343\203\263\343\203\210\346\251\237\350\203\275.md" | 6 +++--- ...\254\343\203\235\343\201\256\350\250\255\345\256\232.md" | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/Polygon-Whitelist-NFT/en/section-1/lesson-2_Basic Coding.md b/docs/Polygon-Whitelist-NFT/en/section-1/lesson-2_Basic Coding.md index 2436ea1d7..36ba6c8c7 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-1/lesson-2_Basic Coding.md +++ b/docs/Polygon-Whitelist-NFT/en/section-1/lesson-2_Basic Coding.md @@ -16,7 +16,7 @@ In `Whitelist.sol`, let's start with a simple block of code. ```solidity // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; contract Whitelist { constructor() { @@ -33,10 +33,10 @@ Let's talk about the code line by line. This line is referred to `SPDX license identifier`, which addresses the copyright issues of the code that follows. Generally speaking, `UNLICENSED` and `MIT` are the most common suffixes, indicating that the following code is permitted for anyone to use. In other words, you all can freely copy and paste it. You can find more information [here](https://spdx.org/licenses/). ```solidity -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; ``` -This specifies the version of the Solidity compiler that we want the contract to use. It means that only a Solidity compiler with a version between `0.8.4` and `0.9.0` can be used to compile the code. +This specifies the version of the Solidity compiler that we want the contract to use. It means that only a Solidity compiler with a version between `0.8.20` and `0.9.0` can be used to compile the code. ```solidity contract Whitelist { diff --git a/docs/Polygon-Whitelist-NFT/en/section-1/lesson-3_Whitelist Function.md b/docs/Polygon-Whitelist-NFT/en/section-1/lesson-3_Whitelist Function.md index 2c9f357a0..106679534 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-1/lesson-3_Whitelist Function.md +++ b/docs/Polygon-Whitelist-NFT/en/section-1/lesson-3_Whitelist Function.md @@ -6,7 +6,7 @@ The basic knowledge about smart contracts is ready. Let's update the `Whitelist. ```solidity //SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; contract Whitelist { // The address that can operate addAddressToWhitelist function diff --git a/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md b/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md index 881661d3b..73ff3ce89 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md +++ b/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md @@ -48,7 +48,7 @@ We'll insert the following code into the `IWhitelist.sol`. ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; interface IWhitelist { function whitelistedAddresses(address) external view returns (bool); @@ -64,7 +64,7 @@ We insert the code below in `Shield.sol`. ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; @@ -154,7 +154,7 @@ Don't worry, lets talk about this contract step by step. ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md index 886f59d79..75d6d7b0b 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md +++ b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md @@ -151,7 +151,7 @@ import { HardhatUserConfig } from 'hardhat/config'; import '@nomicfoundation/hardhat-toolbox'; const config: HardhatUserConfig = { - solidity: '0.8.4', + solidity: '0.8.20', paths: { artifacts: '../client/artifacts', }, diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-2_\345\237\272\346\234\254\347\232\204\343\201\252\343\202\263\343\203\274\343\203\207\343\202\243\343\203\263\343\202\260.md" "b/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-2_\345\237\272\346\234\254\347\232\204\343\201\252\343\202\263\343\203\274\343\203\207\343\202\243\343\203\263\343\202\260.md" index ab1220830..89f7cf89a 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-2_\345\237\272\346\234\254\347\232\204\343\201\252\343\202\263\343\203\274\343\203\207\343\202\243\343\203\263\343\202\260.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-2_\345\237\272\346\234\254\347\232\204\343\201\252\343\202\263\343\203\274\343\203\207\343\202\243\343\203\263\343\202\260.md" @@ -17,7 +17,7 @@ ```solidity // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; contract Whitelist { constructor() { @@ -34,10 +34,10 @@ contract Whitelist { この行は`SPDXライセンス識別子`と呼ばれ、その後に続くコードの著作権の問題に対処します。一般的には、`UNLICENSED`と`MIT`が最もよく使われる接尾辞で、これは以下のコードが誰でも使ってよいことを示します。言い換えれば、皆さんは自由にコピー&ペーストすることができます。詳細は[こちら](https://spdx.org/licenses/)で確認できます。 ```solidity -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; ``` -これは、コントラクトに使用するSolidityコンパイラのバージョンを指定します。`0.8.4`から`0.9.0`の間のバージョンのSolidityコンパイラのみが使用できることを意味します。 +これは、コントラクトに使用するSolidityコンパイラのバージョンを指定します。`0.8.20`から`0.9.0`の間のバージョンのSolidityコンパイラのみが使用できることを意味します。 ```solidity contract Whitelist { diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-3_\343\203\233\343\203\257\343\202\244\343\203\210\343\203\252\343\202\271\343\203\210\346\251\237\350\203\275.md" "b/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-3_\343\203\233\343\203\257\343\202\244\343\203\210\343\203\252\343\202\271\343\203\210\346\251\237\350\203\275.md" index 163770009..8c0c7cdf3 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-3_\343\203\233\343\203\257\343\202\244\343\203\210\343\203\252\343\202\271\343\203\210\346\251\237\350\203\275.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-1/lesson-3_\343\203\233\343\203\257\343\202\244\343\203\210\343\203\252\343\202\271\343\203\210\346\251\237\350\203\275.md" @@ -6,7 +6,7 @@ ```solidity //SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; contract Whitelist { // The address that can operate addAddressToWhitelist function diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" "b/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" index b41c4a0c6..576604a8d 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-2/lesson-2_\343\203\237\343\203\263\343\203\210\346\251\237\350\203\275.md" @@ -47,7 +47,7 @@ Whitelistコントラクトでは、オーナーアドレスを設定し、`requ ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; interface IWhitelist { function whitelistedAddresses(address) external view returns (bool); @@ -64,7 +64,7 @@ interface IWhitelist { ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; @@ -155,7 +155,7 @@ contract Shield is ERC721Enumerable, Ownable { ```solidity // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" index 0bda0c1c7..509cad4cf 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" @@ -151,7 +151,7 @@ import { HardhatUserConfig } from 'hardhat/config'; import '@nomicfoundation/hardhat-toolbox'; const config: HardhatUserConfig = { - solidity: '0.8.4', + solidity: '0.8.20', paths: { artifacts: '../client/artifacts', }, From 3ae04cc8b95370d49be0118053adf108a4f0124f Mon Sep 17 00:00:00 2001 From: ysaito <60546319+yk-saito@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:26:27 +0900 Subject: [PATCH 3/5] chore: update @openzeppelin/contracts to v5.0.0 --- .../en/section-5/lesson-1_Monorepo configration.md | 2 +- ...\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md index 75d6d7b0b..4e6b35c5a 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md +++ b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-1_Monorepo configration.md @@ -81,7 +81,7 @@ Verify that hardhat has been added to packages/contract/package.json. If the ins Next, install the necessary tools. As before, run the following command in the root of the project. ``` -yarn workspace contract add @openzeppelin/contracts@^4.8.2 && yarn workspace contract add --dev @nomicfoundation/hardhat-chai-matchers@^1.0.0 @nomicfoundation/hardhat-network-helpers@^1.0.8 @nomicfoundation/hardhat-toolbox@^2.0.1 @nomiclabs/hardhat-ethers@^2.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 @typechain/ethers-v5@^10.1.0 @typechain/hardhat@^6.1.2 @types/chai@^4.2.0 @types/mocha@^9.1.0 chai@^4.3.7 hardhat-gas-reporter@^1.0.8 solidity-coverage@^0.8.1 ts-node@^8.0.0 typechain@^8.1.0 typescript@^4.5.0 +yarn workspace contract add @openzeppelin/contracts@^5.0.0 && yarn workspace contract add --dev @nomicfoundation/hardhat-chai-matchers@^1.0.0 @nomicfoundation/hardhat-network-helpers@^1.0.8 @nomicfoundation/hardhat-toolbox@^2.0.1 @nomiclabs/hardhat-ethers@^2.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 @typechain/ethers-v5@^10.1.0 @typechain/hardhat@^6.1.2 @types/chai@^4.2.0 @types/mocha@^9.1.0 chai@^4.3.7 hardhat-gas-reporter@^1.0.8 solidity-coverage@^0.8.1 ts-node@^8.0.0 typechain@^8.1.0 typescript@^4.5.0 ``` At this point, packages/contract/package.json should look like the following. diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" index 509cad4cf..3a2fe1ea6 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-1_\343\203\242\343\203\216\343\203\254\343\203\235\343\201\256\350\250\255\345\256\232.md" @@ -81,7 +81,7 @@ packages/contract/package.jsonにhardhatが追加されていることを確認 次に必要なツールをインストールします。先ほどと同様に、プロジェクトのルートで下記のコマンドを実行してください。 ``` -yarn workspace contract add @openzeppelin/contracts@^4.8.2 && yarn workspace contract add --dev @nomicfoundation/hardhat-chai-matchers@^1.0.0 @nomicfoundation/hardhat-network-helpers@^1.0.8 @nomicfoundation/hardhat-toolbox@^2.0.1 @nomiclabs/hardhat-ethers@^2.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 @typechain/ethers-v5@^10.1.0 @typechain/hardhat@^6.1.2 @types/chai@^4.2.0 @types/mocha@^9.1.0 chai@^4.3.7 hardhat-gas-reporter@^1.0.8 solidity-coverage@^0.8.1 ts-node@^8.0.0 typechain@^8.1.0 typescript@^4.5.0 +yarn workspace contract add @openzeppelin/contracts@^5.0.0 && yarn workspace contract add --dev @nomicfoundation/hardhat-chai-matchers@^1.0.0 @nomicfoundation/hardhat-network-helpers@^1.0.8 @nomicfoundation/hardhat-toolbox@^2.0.1 @nomiclabs/hardhat-ethers@^2.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 @typechain/ethers-v5@^10.1.0 @typechain/hardhat@^6.1.2 @types/chai@^4.2.0 @types/mocha@^9.1.0 chai@^4.3.7 hardhat-gas-reporter@^1.0.8 solidity-coverage@^0.8.1 ts-node@^8.0.0 typechain@^8.1.0 typescript@^4.5.0 ``` ここまでで、packages/contract/package.jsonは下記のようになっているはずです。 From a382fffda974f185905e0b821f4b6474d890fc57 Mon Sep 17 00:00:00 2001 From: ysaito <60546319+yk-saito@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:34:29 +0900 Subject: [PATCH 4/5] feat: Ownable initialization added to en/ --- .../en/section-2/lesson-2_Mint Function.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md b/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md index 73ff3ce89..0d30ebe4a 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md +++ b/docs/Polygon-Whitelist-NFT/en/section-2/lesson-2_Mint Function.md @@ -103,7 +103,7 @@ contract Shield is ERC721Enumerable, Ownable { * Constructor for Shields takes in the baseURI to set _baseTokenURI for the collection. * It also initializes an instance of whitelist interface. */ - constructor (string memory baseURI, address whitelistContract) ERC721("ChainIDE Shields", "CS") { + constructor (string memory baseURI, address whitelistContract) ERC721("ChainIDE Shields", "CS") Ownable(msg.sender) { _baseTokenURI = baseURI; _whitelist = IWhitelist(whitelistContract); } From 2239fdb5b5ed5f31b8de3c0a68722e55648708ad Mon Sep 17 00:00:00 2001 From: ysaito <60546319+yk-saito@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:36:52 +0900 Subject: [PATCH 5/5] chore: update test for custom error --- .../section-5/lesson-2_Automated contract testing.md | 12 ++++++------ ...5\213\225\343\203\206\343\202\271\343\203\210.md" | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-2_Automated contract testing.md b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-2_Automated contract testing.md index 585a3c857..d307e0a12 100644 --- a/docs/Polygon-Whitelist-NFT/en/section-5/lesson-2_Automated contract testing.md +++ b/docs/Polygon-Whitelist-NFT/en/section-5/lesson-2_Automated contract testing.md @@ -161,9 +161,9 @@ describe('Shield', function () { const { shield, alice } = await loadFixture(deployWhitelistFixture); // Verify that an account that is not the owner of the contract will get an error if it tries to execute the setPaused function. - await expect(shield.connect(alice).setPaused(true)).to.be.revertedWith( - 'Ownable: caller is not the owner', - ); + await expect(shield.connect(alice).setPaused(true)) + .to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount') + .withArgs(alice.address); }); }); context('when set to true', function () { @@ -280,9 +280,9 @@ describe('Shield', function () { const { shield, alice } = await loadFixture(deployWhitelistFixture); // Verify that an error occurs when an account that is not the owner of the contract tries to execute the withdraw function. - await expect(shield.connect(alice).withdraw()).to.be.revertedWith( - 'Ownable: caller is not the owner', - ); + await expect(shield.connect(alice).withdraw()) + .to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount') + .withArgs(alice.address); }); }); context('when owner executes', function () { diff --git "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-2_\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\201\256\350\207\252\345\213\225\343\203\206\343\202\271\343\203\210.md" "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-2_\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\201\256\350\207\252\345\213\225\343\203\206\343\202\271\343\203\210.md" index 22b592525..c3e90b868 100644 --- "a/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-2_\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\201\256\350\207\252\345\213\225\343\203\206\343\202\271\343\203\210.md" +++ "b/docs/Polygon-Whitelist-NFT/ja/section-5/lesson-2_\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\201\256\350\207\252\345\213\225\343\203\206\343\202\271\343\203\210.md" @@ -161,9 +161,9 @@ describe('Shield', function () { const { shield, alice } = await loadFixture(deployWhitelistFixture); // コントラクトのオーナーではないアカウントが、setPaused関数を実行しようとするとエラーとなることを確認します。 - await expect(shield.connect(alice).setPaused(true)).to.be.revertedWith( - 'Ownable: caller is not the owner', - ); + await expect(shield.connect(alice).setPaused(true)) + .to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount') + .withArgs(alice.address); }); }); context('when set to true', function () { @@ -280,9 +280,9 @@ describe('Shield', function () { const { shield, alice } = await loadFixture(deployWhitelistFixture); // コントラクトのオーナーではないアカウントが、withdraw関数を実行しようとするとエラーとなることを確認します。 - await expect(shield.connect(alice).withdraw()).to.be.revertedWith( - 'Ownable: caller is not the owner', - ); + await expect(shield.connect(alice).withdraw()) + .to.be.revertedWithCustomError(shield, 'OwnableUnauthorizedAccount') + .withArgs(alice.address); }); }); context('when owner executes', function () {