From 970d34bc82fd68120382992b7ee3959b4b2b67db Mon Sep 17 00:00:00 2001 From: Andres Adjimann Date: Wed, 7 Aug 2024 09:43:58 -0300 Subject: [PATCH] feat: upgrade solc version, use only one OZ version --- .../ERC2771HandlerUpgradeable.sol | 2 +- .../ERC721BurnMemoryUpgradeable.sol | 2 +- .../contracts/nft-collection/NFTCollection.sol | 18 +++++++----------- .../UpdatableOperatorFiltererUpgradeable.sol | 2 +- packages/avatar/hardhat.config.ts | 9 +++++++++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/avatar/contracts/nft-collection/ERC2771HandlerUpgradeable.sol b/packages/avatar/contracts/nft-collection/ERC2771HandlerUpgradeable.sol index 6b04e97f59..266fd8a652 100644 --- a/packages/avatar/contracts/nft-collection/ERC2771HandlerUpgradeable.sol +++ b/packages/avatar/contracts/nft-collection/ERC2771HandlerUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version -pragma solidity 0.8.15; +pragma solidity 0.8.26; /// @dev minimal ERC2771 handler to keep bytecode-size down /// based on: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.6.0/contracts/metatx/ERC2771Context.sol diff --git a/packages/avatar/contracts/nft-collection/ERC721BurnMemoryUpgradeable.sol b/packages/avatar/contracts/nft-collection/ERC721BurnMemoryUpgradeable.sol index a14ea44e81..d99717c385 100644 --- a/packages/avatar/contracts/nft-collection/ERC721BurnMemoryUpgradeable.sol +++ b/packages/avatar/contracts/nft-collection/ERC721BurnMemoryUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.15; +pragma solidity 0.8.26; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/token/ERC721/ERC721Upgradeable.sol"; diff --git a/packages/avatar/contracts/nft-collection/NFTCollection.sol b/packages/avatar/contracts/nft-collection/NFTCollection.sol index c7bb17f6e0..e3a89be661 100644 --- a/packages/avatar/contracts/nft-collection/NFTCollection.sol +++ b/packages/avatar/contracts/nft-collection/NFTCollection.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.15; +pragma solidity 0.8.26; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/security/ReentrancyGuardUpgradeable.sol"; import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/access/Ownable2StepUpgradeable.sol"; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/utils/ContextUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/security/PausableUpgradeable.sol"; -import {ECDSA} from "@openzeppelin/contracts-0.8.15/utils/cryptography/ECDSA.sol"; -import {IERC20} from "@openzeppelin/contracts-0.8.15/token/ERC20/IERC20.sol"; -import {IERC20Metadata} from "@openzeppelin/contracts-0.8.15/token/ERC20/extensions/IERC20Metadata.sol"; -import {SafeERC20} from "@openzeppelin/contracts-0.8.15/token/ERC20/utils/SafeERC20.sol"; import {ERC2981Upgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/token/common/ERC2981Upgradeable.sol"; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/token/ERC721/ERC721Upgradeable.sol"; +import {ECDSA} from "@openzeppelin/contracts-0.8.13/utils/cryptography/ECDSA.sol"; +import {IERC20} from "@openzeppelin/contracts-0.8.13/token/ERC20/IERC20.sol"; +import {IERC20Metadata} from "@openzeppelin/contracts-0.8.13/token/ERC20/extensions/IERC20Metadata.sol"; +import {SafeERC20} from "@openzeppelin/contracts-0.8.13/token/ERC20/utils/SafeERC20.sol"; import {IERC4906} from "../common/IERC4906.sol"; import {UpdatableOperatorFiltererUpgradeable} from "./UpdatableOperatorFiltererUpgradeable.sol"; import {ERC2771HandlerUpgradeable} from "./ERC2771HandlerUpgradeable.sol"; @@ -493,11 +493,9 @@ IERC4906 SafeERC20.safeTransferFrom(IERC20(_msgSender()), _wallet, mintTreasury, _price); } - for (uint256 i; i < _amount;) { + for (uint256 i; i < _amount; i++) { // @dev start with tokenId = 1 _safeMint(_wallet, totalSupply + i + 1); - - unchecked {++i;} } waveOwnerToClaimedCounts[_wallet][indexWave - 1] += _amount; waveTotalMinted += _amount; @@ -518,15 +516,13 @@ IERC4906 require(_checkWaveNotComplete(_amount), "NFTCollection: wave completed"); - for (uint256 i; i < _amount;) { + for (uint256 i; i < _amount; i++) { address _wallet = _wallets[i]; require(_checkLimitNotReached(_wallet, 1), "NFTCollection: max allowed"); // @dev safeMint already checks the destination address // @dev start with tokenId = 1 _safeMint(_wallet, totalSupply + i + 1); waveOwnerToClaimedCounts[_wallet][indexWave - 1] += 1; - - unchecked {++i;} } waveTotalMinted += _amount; totalSupply += _amount; diff --git a/packages/avatar/contracts/nft-collection/UpdatableOperatorFiltererUpgradeable.sol b/packages/avatar/contracts/nft-collection/UpdatableOperatorFiltererUpgradeable.sol index 899f3f156a..652eded454 100644 --- a/packages/avatar/contracts/nft-collection/UpdatableOperatorFiltererUpgradeable.sol +++ b/packages/avatar/contracts/nft-collection/UpdatableOperatorFiltererUpgradeable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // solhint-disable one-contract-per-file -pragma solidity 0.8.15; +pragma solidity 0.8.26; import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable-0.8.13/utils/ContextUpgradeable.sol"; diff --git a/packages/avatar/hardhat.config.ts b/packages/avatar/hardhat.config.ts index a46e499f71..c2a0df89c3 100644 --- a/packages/avatar/hardhat.config.ts +++ b/packages/avatar/hardhat.config.ts @@ -10,6 +10,15 @@ const config: HardhatUserConfig = { }, solidity: { compilers: [ + { + version: '0.8.26', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, { version: '0.8.18', settings: {