mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 02:35:08 +02:00
Add testnet ad option
This commit is contained in:
parent
5d709f4aca
commit
c3edb22229
@ -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 => {
|
||||
|
@ -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;
|
||||
}
|
@ -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() {
|
||||
<p>Input the address you want to assign the avatar to.</p>
|
||||
<input type='text' value={ validatorAddress } />
|
||||
|
||||
<p>Select the network you want to assign for:</p>
|
||||
<div className="radios">
|
||||
<div className="row">
|
||||
<input onClick={ f => setNetwork( 'mainnet' ) } id="mainnet" type="radio" name="network" checked={ network == 'mainnet' }/>
|
||||
<label onClick={ f => setNetwork( 'mainnet' ) } for="mainnet">Mainnet</label>
|
||||
</div>
|
||||
<div className="row">
|
||||
<input onClick={ f => setNetwork( 'testnet' ) } id="testnet" type="radio" name="network" checked={ network == 'testnet' }/>
|
||||
<label onClick={ f => setNetwork( 'testnet' ) } for="testnet">Testnet</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>Click the Rocketeer you want to assign to this address.</p>
|
||||
<div className="row">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user