From c3edb2222987a18adbec0f2015bb5cb2f2ffad43 Mon Sep 17 00:00:00 2001 From: Mentor Palokaj Date: Fri, 5 Nov 2021 12:25:18 +0100 Subject: [PATCH] Add testnet ad option --- functions/integrations/avatar.js | 12 ++++++------ minter/src/App.css | 12 +++++++++++- minter/src/components/avatar.js | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/functions/integrations/avatar.js b/functions/integrations/avatar.js index 2887356..bcf0fcb 100644 --- a/functions/integrations/avatar.js +++ b/functions/integrations/avatar.js @@ -11,8 +11,8 @@ module.exports = async function( req, res ) { try { // Get request data - const { message, signature, signatory } = req.body - if( !message || !signatory || !signature ) throw new Error( `Malformed request` ) + const { message, signature, signatory, network } = req.body + if( !message || !signatory || !signature || !network ) throw new Error( `Malformed request` ) // Decode message const confirmedSignatory = web3.eth.accounts.recover( message, signature ) @@ -24,21 +24,21 @@ module.exports = async function( req, res ) { if( signer.toLowerCase() !== confirmedSignatory.toLowerCase() || !tokenId || !validator || chainId !== chain ) throw new Error( `Invalid message` ) // Check if validator was already assigned - const validatorProfile = await db.collection( `${ chain === '0x1' ? 'mainnet' : 'rinkeby' }Validators` ).doc( validator ).get().then( dataFromSnap ) + const validatorProfile = await db.collection( `${ network }Validators` ).doc( validator ).get().then( dataFromSnap ) if( validatorProfile && validatorProfile.owner !== signatory ) throw new Error( `Validator already claimed by another wallet. If this is in error, contact mentor.eth on Discord.\n\nThe reason someone else can claim your validator is that we don't want to you to have to expose your validator private key to the world for security reasons <3` ) // Write new data to db await db.collection( `${ chain === '0x1' ? 'mainnet' : 'rinkeby' }Validators` ).doc( validator ).set( { tokenId, owner: signatory, - src: `https://storage.googleapis.com/rocketeer-nft.appspot.com/${ chain === '0x1' ? 'mainnet' : 'rinkeby' }Rocketeers/${ tokenId }.jpg`, + src: `https://storage.googleapis.com/rocketeer-nft.appspot.com/${ network }Rocketeers/${ tokenId }.jpg`, updated: Date.now() } ) // Update the static overview JSON const storage = getStorage() const bucket = storage.bucket() - const cacheFile = bucket.file( `integrations/${ chain === '0x1' ? 'mainnet' : 'rinkeby' }Avatars.json` ) + const cacheFile = bucket.file( `integrations/${ network }Avatars.json` ) // Load existing json let jsonstring = '{}' @@ -52,7 +52,7 @@ module.exports = async function( req, res ) { // Get items that have not been updated const tenSecondsAgo = Date.now() - ( 10 * 1000 ) - const shouldBeUpdated = await db.collection( `${ chain === '0x1' ? 'mainnet' : 'rinkeby' }Validators` ).where( 'updated', '>', cachedJson.updated || tenSecondsAgo ).get().then( dataFromSnap ) + const shouldBeUpdated = await db.collection( `${ network }Validators` ).where( 'updated', '>', cachedJson.updated || tenSecondsAgo ).get().then( dataFromSnap ) // Update items that should be updated ( including current update ) shouldBeUpdated.map( doc => { diff --git a/minter/src/App.css b/minter/src/App.css index 42edb25..4444056 100644 --- a/minter/src/App.css +++ b/minter/src/App.css @@ -137,7 +137,7 @@ h1, p, label { height: 200px; } -#avatar input { +#avatar input:not([type=radio]) { padding: 1rem; width: 350px; } @@ -146,4 +146,14 @@ h1, p, label { margin: 3rem 0; max-width: 300px; text-align: center; +} + +.radios { + display: flex; + align-items: center; + justify-content: center; +} + +.radios .row { + width: 200px; } \ No newline at end of file diff --git a/minter/src/components/avatar.js b/minter/src/components/avatar.js index ea736ea..34f4d31 100644 --- a/minter/src/components/avatar.js +++ b/minter/src/components/avatar.js @@ -15,6 +15,7 @@ export default function Verifier() { const balance = useBalanceOf() const chainId = useChainId() const address = useAddress() + const [ network, setNetwork ] = useState( 'mainnet' ) const [ loading, setLoading ] = useState( ) const metamaskAddress = useAddress() const [ validatorAddress, setValidatorAddress ] = useState( ) @@ -36,6 +37,7 @@ export default function Verifier() { signer: address.toLowerCase(), tokenId: id, validator: validatorAddress.toLowerCase(), + network, chainId } ), address ) @@ -79,6 +81,19 @@ export default function Verifier() {

Input the address you want to assign the avatar to.

+

Select the network you want to assign for:

+
+
+ setNetwork( 'mainnet' ) } id="mainnet" type="radio" name="network" checked={ network == 'mainnet' }/> + +
+
+ setNetwork( 'testnet' ) } id="testnet" type="radio" name="network" checked={ network == 'testnet' }/> + +
+
+ +

Click the Rocketeer you want to assign to this address.