From fb8d0e8e2d4d4362be14687154223a26b0034223 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Fri, 11 Nov 2022 19:43:05 +0100 Subject: [PATCH 1/6] Add Chia network NFT1 CHIP-0007 metadata compatibility. --- constants/network.js | 1 + src/main.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/constants/network.js b/constants/network.js index bd962822e..c47463ae6 100644 --- a/constants/network.js +++ b/constants/network.js @@ -1,6 +1,7 @@ const NETWORK = { eth: "eth", sol: "sol", + chia: "chia" }; module.exports = { diff --git a/src/main.js b/src/main.js index e9c08dcf2..bb3ede110 100644 --- a/src/main.js +++ b/src/main.js @@ -20,6 +20,7 @@ const { namePrefix, network, solanaMetadata, + chiaMetadata, gif, } = require(`${basePath}/src/config.js`); const canvas = createCanvas(format.width, format.height); @@ -141,6 +142,21 @@ const addMetadata = (_dna, _edition) => { attributes: attributesList, compiler: "HashLips Art Engine", }; + + if (network == NETWORK.chia) { + tempMetadata = { + format: chiaMetadata.format, + name: tempMetadata.name, + description: tempMetadata.description, + minting_tool: chiaMetadata.minting_tool || tempMetadata.compiler, + sensitive_content: chiaMetadata.sensitive_content, + series_number: _edition, + series_total: layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo, + attributes: tempMetadata.attributes, + collection: chiaMetadata.collection + }; + } + if (network == NETWORK.sol) { tempMetadata = { //Added metadata for solana @@ -308,7 +324,11 @@ const writeMetaData = (_data) => { }; const saveMetaDataSingleFile = (_editionCount) => { - let metadata = metadataList.find((meta) => meta.edition == _editionCount); + let findFunction = (meta) => meta.edition == _editionCount; + if (network == NETWORK.chia){ + findFunction = (meta) => meta.series_number == _editionCount; + } + let metadata = metadataList.find(findFunction); debugLogs ? console.log( `Writing metadata for ${_editionCount}: ${JSON.stringify(metadata)}` From 67fbecd191e683464e6dfdd18b8c8f7d18d50541 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Fri, 11 Nov 2022 19:57:07 +0100 Subject: [PATCH 2/6] Add chia metadata example --- src/config.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/config.js b/src/config.js index c46d867a0..1aeb32b9c 100644 --- a/src/config.js +++ b/src/config.js @@ -21,6 +21,41 @@ const solanaMetadata = { ], }; +const chiaMetadata = { + format: "CHIP-0007", + sensitive_content: false, + minting_tool: "minting tool", + collection: { + id: "4fa5e6b1-231a-7bae-b18e-c86dced47f52", + name: "collection name", + attributes: [ + { + type: "description", + value: "A NFT collection which only purpose is to test minting. Be ready for the testnet to be flooded with this collection :D! (Love to the Chia community <3)" + }, + { + "type": "twitter", + "value": "@twitterAccount" + }, + { + "type": "website", + "value": "https://mywebsite.com" + }, + { + "type": "icon", + "value": "https://mywebsite.com/icon" + }, + { + "type": "banner", + "value": "https://mywebsite.com/banner" + }, + { + "type": "art_generator", + "value": "HashLips Art Engine" + } + ] + } +}; // If you have selected Solana then the collection starts from 0 automatically const layerConfigurations = [ { From de67113156e1b2d5c9be32e5e70a3437c4b4e012 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Fri, 11 Nov 2022 22:35:58 +0100 Subject: [PATCH 3/6] Do not replace `minting_tool` metadata. --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index bb3ede110..9ded2eb41 100644 --- a/src/main.js +++ b/src/main.js @@ -148,7 +148,7 @@ const addMetadata = (_dna, _edition) => { format: chiaMetadata.format, name: tempMetadata.name, description: tempMetadata.description, - minting_tool: chiaMetadata.minting_tool || tempMetadata.compiler, + minting_tool: tempMetadata.compiler, sensitive_content: chiaMetadata.sensitive_content, series_number: _edition, series_total: layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo, From 13a5520244af46d225ef26a4e19f22ea5328d4f2 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Fri, 11 Nov 2022 23:48:37 +0100 Subject: [PATCH 4/6] Remove `minting_tool` for `chiaMetadata` --- src/config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.js b/src/config.js index 1aeb32b9c..614fdd303 100644 --- a/src/config.js +++ b/src/config.js @@ -24,7 +24,6 @@ const solanaMetadata = { const chiaMetadata = { format: "CHIP-0007", sensitive_content: false, - minting_tool: "minting tool", collection: { id: "4fa5e6b1-231a-7bae-b18e-c86dced47f52", name: "collection name", From dac4e0ea79c52350f54572720fb22c388bd63c82 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Fri, 11 Nov 2022 23:52:38 +0100 Subject: [PATCH 5/6] export `chiaMetadata` --- src/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config.js b/src/config.js index 614fdd303..9c0605fe9 100644 --- a/src/config.js +++ b/src/config.js @@ -151,6 +151,7 @@ module.exports = { namePrefix, network, solanaMetadata, + chiaMetadata, gif, preview_gif, }; From 52f76b5de0e39a8b664bbabb5c2479a084da2e55 Mon Sep 17 00:00:00 2001 From: Gabriel Inzirillo Date: Thu, 8 Dec 2022 12:31:32 +0100 Subject: [PATCH 6/6] Update config.js Remove non standard collection property. The compiler is already used in [`minting_tool` property](https://github.com/Ganbin/hashlips_art_engine/blob/main/src/main.js#L151) --- src/config.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/config.js b/src/config.js index 9c0605fe9..ec14ee323 100644 --- a/src/config.js +++ b/src/config.js @@ -47,10 +47,6 @@ const chiaMetadata = { { "type": "banner", "value": "https://mywebsite.com/banner" - }, - { - "type": "art_generator", - "value": "HashLips Art Engine" } ] }