Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Chia NFT1 metadata #1460

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions constants/network.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const NETWORK = {
eth: "eth",
sol: "sol",
chia: "chia"
};

module.exports = {
Expand Down
31 changes: 31 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ const solanaMetadata = {
],
};

const chiaMetadata = {
format: "CHIP-0007",
sensitive_content: false,
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"
}
]
}
};
// If you have selected Solana then the collection starts from 0 automatically
const layerConfigurations = [
{
Expand Down Expand Up @@ -117,6 +147,7 @@ module.exports = {
namePrefix,
network,
solanaMetadata,
chiaMetadata,
gif,
preview_gif,
};
22 changes: 21 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
namePrefix,
network,
solanaMetadata,
chiaMetadata,
gif,
} = require(`${basePath}/src/config.js`);
const canvas = createCanvas(format.width, format.height);
Expand Down Expand Up @@ -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: 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
Expand Down Expand Up @@ -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)}`
Expand Down