Skip to content

Commit

Permalink
Merge pull request #66 from thepeanutgalleryandco/v1-7-7-Layer-Global…
Browse files Browse the repository at this point in the history
…-Maximum-Repeatability

V1 7 7 layer global maximum repeatability
  • Loading branch information
thepeanutgalleryandco committed May 5, 2022
2 parents 9c844f9 + 160fc7c commit 3a03da5
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
<img width="554" alt="Screenshot 2022-05-05 at 17 55 14" src="https://user-images.githubusercontent.com/52892685/166963557-ee08ff09-557e-4898-a484-8dcf07db5607.png">


#### c. Update the width and height of your canvas
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-and-mint-nft-collection",
"version": "1.7.6",
"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",
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
],
Expand Down
10 changes: 8 additions & 2 deletions src/filters/combination_traits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!`);
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
},
);
}
Expand Down
4 changes: 1 addition & 3 deletions utils/nftport/uploadMetas_directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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!`);

}
}

Expand Down

0 comments on commit 3a03da5

Please sign in to comment.