From ea099d5e887860d31dd16337d73abd52b548d535 Mon Sep 17 00:00:00 2001 From: Mentor Palokaj Date: Sat, 30 Oct 2021 09:14:18 +0200 Subject: [PATCH] Tesdy for testing --- contracts/Rocketeer.sol | 5 ----- functions/index.js | 10 ++++++++-- functions/modules/mainnet.js | 2 +- functions/modules/rocketeer.js | 10 ++++++---- functions/modules/svg-generator.js | 7 +++++-- functions/modules/testnet.js | 2 ++ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/contracts/Rocketeer.sol b/contracts/Rocketeer.sol index 61f26f0..faf8b5b 100644 --- a/contracts/Rocketeer.sol +++ b/contracts/Rocketeer.sol @@ -55,11 +55,6 @@ contract Rocketeer is ERC721Tradable { // No more than max supply require( nextTokenId <= ROCKETEER_MAX_SUPPLY, "Maximum Rocketeer supply reached" ); - // Every 42nd unit becomes a special edition, gas fees paid for but not owned by the minter - if( nextTokenId % 42 == 0 ) { - mintTo( owner() ); - } - mintTo( _to ); } diff --git a/functions/index.js b/functions/index.js index 7aa13c2..8e42059 100644 --- a/functions/index.js +++ b/functions/index.js @@ -2,8 +2,14 @@ const functions = require( 'firebase-functions' ) const testnetAPI = require( './modules/testnet' ) const mainnetAPI = require( './modules/mainnet' ) +// Runtime config +const runtime = { + timeoutSeconds: 540, + memory: '4GB' +} + // Testnet endpoint -exports.testnetMetadata = functions.https.onRequest( testnetAPI ) +exports.testnetMetadata = functions.runWith( runtime ).https.onRequest( testnetAPI ) // Mainnet endpoint -exports.mainnetMetadata = functions.https.onRequest( mainnetAPI ) \ No newline at end of file +exports.mainnetMetadata = functions.runWith( runtime ).https.onRequest( mainnetAPI ) \ No newline at end of file diff --git a/functions/modules/mainnet.js b/functions/modules/mainnet.js index 3595c74..39f3c6a 100644 --- a/functions/modules/mainnet.js +++ b/functions/modules/mainnet.js @@ -40,7 +40,7 @@ app.get( '/api/collection', async ( req, res ) => res.json( { totalSupply: await getTotalSupply( 'mainnet' ).catch( f => 'error' ), description: "A testnet collection", external_url: web2domain, - image: "https://rocketpool.net/images/rocket.png", + image: "https://rocketeer.web.app/assets/draft-rocketeer.png", name: `Rocketeer collection`, seller_fee_basis_points: 0, fee_recipient: "0x0" diff --git a/functions/modules/rocketeer.js b/functions/modules/rocketeer.js index 95c32ce..7267c1a 100644 --- a/functions/modules/rocketeer.js +++ b/functions/modules/rocketeer.js @@ -79,11 +79,13 @@ async function generateRocketeer( id, network='mainnet' ) { value: `rgb( ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) }, ${ randomNumberBetween( 0, 255 ) } )` } ) - // Write to demo file + // Special editions + const edition = { "trait_type": "edition", value: "regular" } + if( id > 50 ) edition.value = 'genesis' + if( id % 42 === 0 ) edition.value = 'hitchhiker' - - // TODO: Generate, compile and upload image - rocketeer.image = await svgFromAttributes( rocketeer.attributes ) + // Generate, compile and upload image + rocketeer.image = await svgFromAttributes( rocketeer.attributes, `${ network }Rocketeers/${id}.svg` ) // Save new Rocketeer await db.collection( `${ network }Rocketeers` ).doc( id ).set( rocketeer ) diff --git a/functions/modules/svg-generator.js b/functions/modules/svg-generator.js index 117d71c..0a4487a 100644 --- a/functions/modules/svg-generator.js +++ b/functions/modules/svg-generator.js @@ -6,7 +6,10 @@ const { promises: fs } = require( 'fs' ) const { getStorage } = require( 'firebase-admin/storage' ) -module.exports = async function svgFromAttributes( attributes=[] ) { +module.exports = async function svgFromAttributes( attributes=[], path='' ) { + + if( !path.length ) throw new Error( 'svgFromAttributes missing path' ) + if( !attributes.length ) throw new Error( 'svgFromAttributes missing attributes' ) const { value: primary_color } = attributes.find( ( { trait_type } ) => trait_type == "outfit color" ) const { value: accent_color } = attributes.find( ( { trait_type } ) => trait_type == "outfit accent color" ) @@ -119,7 +122,7 @@ module.exports = async function svgFromAttributes( attributes=[] ) { const bucket = storage.bucket() // Make file reference - const file = bucket.file( `rocketeers/demo-${ Date.now() }.svg` ) + const file = bucket.file( path ) // Save file buffer await file.save( bakedSvg ) diff --git a/functions/modules/testnet.js b/functions/modules/testnet.js index 4376330..cfb8afb 100644 --- a/functions/modules/testnet.js +++ b/functions/modules/testnet.js @@ -2,7 +2,9 @@ const app = require( './express' )() const { getTotalSupply } = require( './contract' ) const { safelyReturnRocketeer, web2domain } = require( './rocketeer' ) +//////////////////////////////// // Specific Rocketeer instances +//////////////////////////////// app.get( '/testnetapi/rocketeer/:id', async ( req, res ) => { // Parse the request