From f9da62eeec4f98e37e323c3adb7768560ee3d73a Mon Sep 17 00:00:00 2001 From: Kambiz Asadzadeh Date: Tue, 31 Oct 2023 16:51:08 +0330 Subject: [PATCH 1/3] Fixed Some Warnings. - In Solidity, constructors are, by default, already considered public, and specifying it explicitly is unnecessary. --- hardhat/smart-contracts/AuctionDemo.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardhat/smart-contracts/AuctionDemo.sol b/hardhat/smart-contracts/AuctionDemo.sol index 95533fb..201600b 100644 --- a/hardhat/smart-contracts/AuctionDemo.sol +++ b/hardhat/smart-contracts/AuctionDemo.sol @@ -33,7 +33,7 @@ contract auctionDemo is Ownable { _; } - constructor (address _minter, address _gencore, address _adminsContract) public { + constructor (address _minter, address _gencore, address _adminsContract) { minter = IMinterContract(_minter); gencore = _gencore; adminsContract = INextGenAdmins(_adminsContract); From 2c84191066b694b4c90d132eb38c3b1497c7100c Mon Sep 17 00:00:00 2001 From: Kambiz Asadzadeh Date: Tue, 31 Oct 2023 16:55:59 +0330 Subject: [PATCH 2/3] Some Fixes. - Marking the some functions as `pure` accurately reflects its behavior and can help prevent confusion about whether it reads, making the code more clear and precise. --- hardhat/smart-contracts/IMinterContract.sol | 2 +- hardhat/smart-contracts/MinterContract.sol | 2 +- hardhat/smart-contracts/NextGenAdmins.sol | 2 +- hardhat/smart-contracts/RandomizerNXT.sol | 2 +- hardhat/smart-contracts/RandomizerRNG.sol | 2 +- hardhat/smart-contracts/RandomizerVRF.sol | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hardhat/smart-contracts/IMinterContract.sol b/hardhat/smart-contracts/IMinterContract.sol index 52b7291..a8eb4bd 100644 --- a/hardhat/smart-contracts/IMinterContract.sol +++ b/hardhat/smart-contracts/IMinterContract.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.19; interface IMinterContract { // retrieve if the contract is minter contract - function isMinterContract() external view returns (bool); + function isMinterContract() external pure returns (bool); // retrieve the public end time of a sale function getEndTime(uint256 _collectionID) external view returns (uint); diff --git a/hardhat/smart-contracts/MinterContract.sol b/hardhat/smart-contracts/MinterContract.sol index df50841..2af8bc0 100644 --- a/hardhat/smart-contracts/MinterContract.sol +++ b/hardhat/smart-contracts/MinterContract.sol @@ -503,7 +503,7 @@ contract NextGenMinterContract is Ownable { // get minter contract status - function isMinterContract() external view returns (bool) { + function isMinterContract() external pure returns (bool) { return true; } diff --git a/hardhat/smart-contracts/NextGenAdmins.sol b/hardhat/smart-contracts/NextGenAdmins.sol index dc68ddd..d358931 100644 --- a/hardhat/smart-contracts/NextGenAdmins.sol +++ b/hardhat/smart-contracts/NextGenAdmins.sol @@ -80,7 +80,7 @@ contract NextGenAdmins is Ownable{ // get admin contract status - function isAdminContract() external view returns (bool) { + function isAdminContract() external pure returns (bool) { return true; } diff --git a/hardhat/smart-contracts/RandomizerNXT.sol b/hardhat/smart-contracts/RandomizerNXT.sol index 0c7818c..b4eb835 100644 --- a/hardhat/smart-contracts/RandomizerNXT.sol +++ b/hardhat/smart-contracts/RandomizerNXT.sol @@ -59,7 +59,7 @@ contract NextGenRandomizerNXT { } // get randomizer contract status - function isRandomizerContract() external view returns (bool) { + function isRandomizerContract() external pure returns (bool) { return true; } diff --git a/hardhat/smart-contracts/RandomizerRNG.sol b/hardhat/smart-contracts/RandomizerRNG.sol index a3b2cbc..c0300fc 100644 --- a/hardhat/smart-contracts/RandomizerRNG.sol +++ b/hardhat/smart-contracts/RandomizerRNG.sol @@ -86,7 +86,7 @@ contract NextGenRandomizerRNG is ArrngConsumer, Ownable { receive() external payable {} // get randomizer contract status - function isRandomizerContract() external view returns (bool) { + function isRandomizerContract() external pure returns (bool) { return true; } } diff --git a/hardhat/smart-contracts/RandomizerVRF.sol b/hardhat/smart-contracts/RandomizerVRF.sol index 086ff49..8e0a5c9 100644 --- a/hardhat/smart-contracts/RandomizerVRF.sol +++ b/hardhat/smart-contracts/RandomizerVRF.sol @@ -102,7 +102,7 @@ contract NextGenRandomizerVRF is VRFConsumerBaseV2, Ownable { } // get randomizer contract status - function isRandomizerContract() external view returns (bool) { + function isRandomizerContract() external pure returns (bool) { return true; } From dfec6be66f82f2f696fbed0731df25cec085f2e5 Mon Sep 17 00:00:00 2001 From: Kambiz Asadzadeh Date: Tue, 31 Oct 2023 17:07:42 +0330 Subject: [PATCH 3/3] Optimization and enhancement. - Optimized and Enhanced Word Retrieval Function. --- hardhat/smart-contracts/XRandoms.sol | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hardhat/smart-contracts/XRandoms.sol b/hardhat/smart-contracts/XRandoms.sol index 963425c..4bffdc3 100644 --- a/hardhat/smart-contracts/XRandoms.sol +++ b/hardhat/smart-contracts/XRandoms.sol @@ -12,10 +12,8 @@ pragma solidity ^0.8.19; contract randomPool { - function getWord(uint256 id) private pure returns (string memory) { - - // array storing the words list - string[100] memory wordsList = ["Acai", "Ackee", "Apple", "Apricot", "Avocado", "Babaco", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blood Orange", + // wordsList is a pre-defined array containing 100 unique words. + string[100] private wordsList = ["Acai", "Ackee", "Apple", "Apricot", "Avocado", "Babaco", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blood Orange", "Blueberry", "Boysenberry", "Breadfruit", "Brush Cherry", "Canary Melon", "Cantaloupe", "Carambola", "Casaba Melon", "Cherimoya", "Cherry", "Clementine", "Cloudberry", "Coconut", "Cranberry", "Crenshaw Melon", "Cucumber", "Currant", "Curry Berry", "Custard Apple", "Damson Plum", "Date", "Dragonfruit", "Durian", "Eggplant", "Elderberry", "Feijoa", "Finger Lime", "Fig", "Gooseberry", "Grapes", "Grapefruit", "Guava", "Honeydew Melon", "Huckleberry", "Italian Prune Plum", @@ -24,13 +22,10 @@ contract randomPool { "Plantain", "Plum", "Pomegranate", "Pomelo", "Prickly Pear", "Pulasan", "Quine", "Rambutan", "Raspberries", "Rhubarb", "Rose Apple", "Sapodilla", "Satsuma", "Soursop", "Star Apple", "Star Fruit", "Strawberry", "Sugar Apple", "Tamarillo", "Tamarind", "Tangelo", "Tangerine", "Ugli", "Velvet Apple", "Watermelon"]; - // returns a word based on index - if (id==0) { - return wordsList[id]; - } else { - return wordsList[id - 1]; - } - } + function getWord(uint256 id) public view returns (string memory) { + require(id > 0 && id <= wordsList.length, "Invalid word ID"); + return wordsList[id - 1]; + } function randomNumber() public view returns (uint256){ uint256 randomNum = uint(keccak256(abi.encodePacked(block.prevrandao, blockhash(block.number - 1), block.timestamp))) % 1000;