From ffa014c5db9faaebfbb2ec6604ab6ed718968325 Mon Sep 17 00:00:00 2001 From: rohan Date: Thu, 5 May 2022 17:49:35 +0200 Subject: [PATCH 1/2] Addition Of Layer Global Maximum Repeatability Setting Added a new "layerItemsMaxRepeatedTrait" setting that can be used to set the maximum repeatability for all items within the layer. If this is set to 2 for example and your layer has 8 layer items, then a maximum of 16 images will be generated. This allows users to set the maximum repeatability once off for a layer's items instead of specifying each layer item with the same maximum repeatability. Updated rarity on example layer item names. Updated the console logging on the uploadMetas_directory.js script so that the user is not bombarded by messages in the console. --- layers/Background/{Black.png => Black#100.png} | Bin layers/Background/{Blue.png => Blue#70.png} | Bin layers/Background/{Orange.png => Orange#40.png} | Bin layers/Background/{Yellow.png => Yellow#10.png} | Bin .../{High High #20.png => High High#20.png} | Bin layers/Eye color/{Blank #100.png => Blank#100.png} | Bin package-lock.json | 4 ++-- package.json | 2 +- src/config.js | 2 +- src/filters/combination_traits.js | 10 ++++++++-- src/main.js | 4 +++- utils/nftport/uploadMetas_directory.js | 4 +--- 12 files changed, 16 insertions(+), 10 deletions(-) rename layers/Background/{Black.png => Black#100.png} (100%) rename layers/Background/{Blue.png => Blue#70.png} (100%) rename layers/Background/{Orange.png => Orange#40.png} (100%) rename layers/Background/{Yellow.png => Yellow#10.png} (100%) rename layers/Bottom lid/{High High #20.png => High High#20.png} (100%) rename layers/Eye color/{Blank #100.png => Blank#100.png} (100%) diff --git a/layers/Background/Black.png b/layers/Background/Black#100.png similarity index 100% rename from layers/Background/Black.png rename to layers/Background/Black#100.png diff --git a/layers/Background/Blue.png b/layers/Background/Blue#70.png similarity index 100% rename from layers/Background/Blue.png rename to layers/Background/Blue#70.png diff --git a/layers/Background/Orange.png b/layers/Background/Orange#40.png similarity index 100% rename from layers/Background/Orange.png rename to layers/Background/Orange#40.png diff --git a/layers/Background/Yellow.png b/layers/Background/Yellow#10.png similarity index 100% rename from layers/Background/Yellow.png rename to layers/Background/Yellow#10.png diff --git a/layers/Bottom lid/High High #20.png b/layers/Bottom lid/High High#20.png similarity index 100% rename from layers/Bottom lid/High High #20.png rename to layers/Bottom lid/High High#20.png diff --git a/layers/Eye color/Blank #100.png b/layers/Eye color/Blank#100.png similarity index 100% rename from layers/Eye color/Blank #100.png rename to layers/Eye color/Blank#100.png diff --git a/package-lock.json b/package-lock.json index db7342c..fcb7951 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-and-mint-nft-collection", - "version": "1.7.5", + "version": "1.7.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "create-and-mint-nft-collection", - "version": "1.7.5", + "version": "1.7.7", "license": "MIT", "dependencies": { "@chainsafe/dappeteer": "2.3.0", diff --git a/package.json b/package.json index 39306bd..ef863c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-and-mint-nft-collection", - "version": "1.7.5", + "version": "1.7.7", "description": "Source code to create and mint generative art via NFTPort API. Special thanks to codeSTACKr and Hashlips for their source codebase.", "main": "index.js", "bin": "index.js", diff --git a/src/config.js b/src/config.js index 6e4769f..5d3d70f 100644 --- a/src/config.js +++ b/src/config.js @@ -43,7 +43,7 @@ const layerConfigurations = [ { name: "Eyeball" }, { name: "Eye color", maxRepeatedTrait: 2 }, { name: "Iris" }, - { name: "Shine" }, + { name: "Shine", layerItemsMaxRepeatedTrait: 4 }, { name: "Bottom lid", maxRepeatedTrait: 3 }, { name: "Top lid" }, ], diff --git a/src/filters/combination_traits.js b/src/filters/combination_traits.js index 3e3c69f..a014466 100644 --- a/src/filters/combination_traits.js +++ b/src/filters/combination_traits.js @@ -18,11 +18,17 @@ const combinationOfTraitsAlreadyExists = (selectedTraitsList, newTraits, maxRep // Loops through each new trait and add to count for (let i = 0; i < newTraits.length; i++) { - + // Check if trait exists in traitLayerCounts and traitLayerItemCounts objects and if it does, then add to the count, otherwise initialize with a count of 1. traitLayerCounts[`${newTraits[i].layer}`] = traitLayerCounts[`${newTraits[i].layer}`] ? traitLayerCounts[`${newTraits[i].layer}`] + 1 : 1 ; traitLayerItemCounts[`${newTraits[i].layer}/${newTraits[i].name}`] = traitLayerItemCounts[`${newTraits[i].layer}/${newTraits[i].name}`] ? traitLayerItemCounts[`${newTraits[i].layer}/${newTraits[i].name}`] + 1 : 1 ; + // Check if the selected trait has breached the global layer item maximum repeatability limit and return true if that is the case + if (traitLayerItemCounts[`${newTraits[i].layer}/${newTraits[i].name}`] > newTraits[i].layerItemsMaxRepeatedTrait) { + console.log(`Combination of traits filtered because of global layer item (${newTraits[i].layer}) maximum repeatability filtration rule!`); + return true; + } + // Check if the selected trait has breached the layer maximum repeatability limit and return true if that is the case if (traitLayerCounts[`${newTraits[i].layer}`] > newTraits[i].maxRepeatedTrait) { console.log(`Combination of traits filtered because of layer (${newTraits[i].layer}) maximum repeatability filtration rule!`); @@ -43,7 +49,7 @@ const combinationOfTraitsAlreadyExists = (selectedTraitsList, newTraits, maxRep if (traitLayerItemCounts[`${layerItemsMaxRepeatedTraits[layerItem].name}`] > layerItemsMaxRepeatedTraits[layerItem].layerItemMaxRepeatedTrait) { console.log(`Combination of traits filtered because of layer item (${layerItemsMaxRepeatedTraits[layerItem].name}) maximum repeatability filtration rule!`); return true; - } + } } // Return false if the traits have been looped through and the maximum repeatability have not been breached diff --git a/src/main.js b/src/main.js index b89a65a..82ea147 100644 --- a/src/main.js +++ b/src/main.js @@ -94,6 +94,7 @@ const layersSetup = (layersOrder) => { ? layerObj.options?.["displayName"] : layerObj.name, maxRepeatedTrait: layerObj.maxRepeatedTrait, + layerItemsMaxRepeatedTrait: layerObj.layerItemsMaxRepeatedTrait, blend: layerObj.options?.["blend"] != undefined ? layerObj.options?.["blend"] @@ -324,7 +325,8 @@ const selectTraits = (layers) => { name: layer.elements[i].name, filename: layer.elements[i].filename, bypassDNA: layer.bypassDNA, - maxRepeatedTrait: layer.maxRepeatedTrait + maxRepeatedTrait: layer.maxRepeatedTrait, + layerItemsMaxRepeatedTrait: layer.layerItemsMaxRepeatedTrait }, ); } diff --git a/utils/nftport/uploadMetas_directory.js b/utils/nftport/uploadMetas_directory.js index 093976b..77e6387 100644 --- a/utils/nftport/uploadMetas_directory.js +++ b/utils/nftport/uploadMetas_directory.js @@ -95,6 +95,7 @@ async function main() { const response = await fetchWithRetry("https://api.nftport.xyz/v0/metadata/directory", options); console.log("Done with upload of metadata."); + console.log("Starting with update on metadata files to include upload data."); // Loop through each file in the list. for (const file of files) { @@ -123,9 +124,6 @@ async function main() { // Write the allMetadata array to the ipfsMetasDir directory fs.writeFileSync(`${FOLDERS.ipfsMetasDir}/_ipfsMetas.json`,JSON.stringify(allMetadata, null, 2)); - - console.log(`${metaData.name} metadata uploaded!`); - } } From 7a01b865563c8c21125cb6dc78ec57146a03d343 Mon Sep 17 00:00:00 2001 From: Rohan de Jongh <52892685+thepeanutgalleryandco@users.noreply.github.com> Date: Thu, 5 May 2022 17:56:17 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 23be482..5df6d67 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,9 @@ If you would like to support my NFT collection, please take a look at the below. ## UPDATES & FIXES +### Added Layer Global Maximum Repeatability Setting +Added a new `layerItemsMaxRepeatedTrait` setting that can be used to set the maximum repeatability for all items within a layer. If this is set to 2 for example and your layer has 8 layer items, then a maximum of 16 images will be generated. This allows users to set the maximum repeatability once off for a layer's items instead of specifying each layer item with the same maximum repeatability. [Feature - Add Maximum Repeatability For All Items In A Layer In A Single Configuration](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/65) + ### Added Opensea Selling Scripts Added a new script `utils/opensea/sell_nfts.js` that will allow users to sell NFTs between two edition numbers (inclusive) to be put up for sale if the user owns the NFTs. This functionality uses Puppeteer and Chainsafe's Dappeteer, so please use at your own discretion as you will need to make use of your seed phrase for this functionality to work. [Feature - Opensea Polygon Script To Auto Sell NFTs](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/42), [Feature - Opensea Polygon Script To Auto Sell NFTs Additional Fields](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/47) and [Feature - Opensea Polygon Script To Auto Sell NFTs Added Metamask Account Number](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/49) @@ -261,13 +264,12 @@ Modify the following parts at the very least, below are just sample values that #### b. Update your layer configurations - Update your folder names, order in which they need to be processed and the number of images to create -- Optionally add maximum repeatability filtration rule in for the layers - Please see [Maximum Repeatability Feature](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/16) and [Layer Item Maximum Repeatability Settings](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/20) +- Optionally add maximum repeatability filtration rule in for the layers - Please see [Maximum Repeatability Feature](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/16) and [Layer Item Maximum Repeatability Settings](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/20) and [Add Maximum Repeatability For All Items In A Layer In A Single Configuration](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/65) - Optionally add layer combination filtration rules in for the layers - Please see [Layer Combination Exclusion Feature](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/15) - Optionally add layer dependent traits filtration rules in for the layers - Please see [Layer Trait Dependencies Feature](https://github.com/thepeanutgalleryandco/create-and-mint-nft-collection/issues/29) *Example of default configuration along with maximum repeatability and layer compatibility* - -![Screenshot 2022-03-15 at 01 10 17](https://user-images.githubusercontent.com/52892685/158283474-cba5a3cd-011c-4e1b-8371-69093f5dff9d.png) +Screenshot 2022-05-05 at 17 55 14 #### c. Update the width and height of your canvas