mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
🐛 write incomplete Rocketeers to database to appease the Opensea api
This commit is contained in:
parent
13f158b655
commit
804a87053f
@ -72,6 +72,26 @@ async function generateRocketeer( id, network='mainnet' ) {
|
|||||||
// Generate randomized attributes
|
// Generate randomized attributes
|
||||||
rocketeer.attributes = pickRandomAttributes( globalAttributes )
|
rocketeer.attributes = pickRandomAttributes( globalAttributes )
|
||||||
|
|
||||||
|
// Set birthday
|
||||||
|
rocketeer.attributes.push( {
|
||||||
|
"display_type": "date",
|
||||||
|
"trait_type": "birthday",
|
||||||
|
"value": Math.floor( Date.now() / 1000 )
|
||||||
|
} )
|
||||||
|
|
||||||
|
// Special editions
|
||||||
|
const edition = { "trait_type": "edition", value: "regular" }
|
||||||
|
if( id <= 50 ) edition.value = 'genesis'
|
||||||
|
if( id % 42 === 0 ) edition.value = 'hitchhiker'
|
||||||
|
if( ( id - 1 ) % 42 == 0 ) edition.value = 'generous'
|
||||||
|
rocketeer.attributes.push( edition )
|
||||||
|
|
||||||
|
// Create description
|
||||||
|
rocketeer.description = `${ rocketeer.name } is a proud member of the ${ rocketeer.attributes.find( ( { trait_type } ) => trait_type == 'patch' ).value } guild.`
|
||||||
|
|
||||||
|
// Write the incomplete Rocketeer to the database, because opensea doesn't update metadata by itself
|
||||||
|
await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer, { merge: true } )
|
||||||
|
|
||||||
// Generate color attributes
|
// Generate color attributes
|
||||||
rocketeer.attributes.push( {
|
rocketeer.attributes.push( {
|
||||||
"trait_type": "outfit color",
|
"trait_type": "outfit color",
|
||||||
@ -90,20 +110,6 @@ async function generateRocketeer( id, network='mainnet' ) {
|
|||||||
value: `rgb( ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) } )`
|
value: `rgb( ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) } )`
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Set birthday
|
|
||||||
rocketeer.attributes.push( {
|
|
||||||
"display_type": "date",
|
|
||||||
"trait_type": "birthday",
|
|
||||||
"value": Math.floor( Date.now() / 1000 )
|
|
||||||
} )
|
|
||||||
|
|
||||||
// Special editions
|
|
||||||
const edition = { "trait_type": "edition", value: "regular" }
|
|
||||||
if( id <= 50 ) edition.value = 'genesis'
|
|
||||||
if( id % 42 === 0 ) edition.value = 'hitchhiker'
|
|
||||||
if( ( id - 1 ) % 42 == 0 ) edition.value = 'generous'
|
|
||||||
rocketeer.attributes.push( edition )
|
|
||||||
|
|
||||||
// Generate, compile and upload image
|
// Generate, compile and upload image
|
||||||
rocketeer.image = await svgFromAttributes( rocketeer.attributes, `${ network }Rocketeers/${id}` )
|
rocketeer.image = await svgFromAttributes( rocketeer.attributes, `${ network }Rocketeers/${id}` )
|
||||||
|
|
||||||
@ -118,9 +124,6 @@ async function generateRocketeer( id, network='mainnet' ) {
|
|||||||
|
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Create description
|
|
||||||
rocketeer.description = `${ rocketeer.name } is a proud member of the ${ rocketeer.attributes.find( ( { trait_type } ) => trait_type == 'patch' ).value } guild.`
|
|
||||||
|
|
||||||
// Save new Rocketeer
|
// Save new Rocketeer
|
||||||
await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer, { merge: true } )
|
await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer, { merge: true } )
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user