Append a new token UI update
This commit is contained in:
parent
6e2f41342a
commit
2ad0d893c6
@ -4,6 +4,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { toUtf8 } from '@cosmjs/encoding'
|
import { toUtf8 } from '@cosmjs/encoding'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import clsx from 'clsx'
|
||||||
|
import { Alert } from 'components/Alert'
|
||||||
|
import { Conditional } from 'components/Conditional'
|
||||||
import { useInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import React, { useCallback, useEffect, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
@ -73,7 +76,6 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filterBaseMinterContracts = async () => {
|
const filterBaseMinterContracts = async () => {
|
||||||
setMyBaseMinterContracts([])
|
|
||||||
await fetchMinterContracts()
|
await fetchMinterContracts()
|
||||||
.then((minterContracts) =>
|
.then((minterContracts) =>
|
||||||
minterContracts.map(async (minterContract: any) => {
|
minterContracts.map(async (minterContract: any) => {
|
||||||
@ -107,18 +109,20 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
|
|||||||
})
|
})
|
||||||
}, [debouncedMyBaseMinterContracts])
|
}, [debouncedMyBaseMinterContracts])
|
||||||
|
|
||||||
const debouncedWalletAddress = useDebounce(wallet.address, 500)
|
const debouncedWalletAddress = useDebounce(wallet.address, 300)
|
||||||
|
|
||||||
const displayToast = async () => {
|
const displayToast = async () => {
|
||||||
await toast.promise(filterBaseMinterContracts(), {
|
await toast.promise(filterBaseMinterContracts(), {
|
||||||
loading: 'Fetching Base Minter contracts...',
|
loading: 'Retrieving previous 1/1 collections...',
|
||||||
success: 'Base Minter contracts retrieved.',
|
success: 'Collection retrieval finalized.',
|
||||||
error: 'Unable to retrieve Base Minter contracts.',
|
error: 'Unable to retrieve any 1/1 collections.',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debouncedWalletAddress && baseMinterAcquisitionMethod === 'existing') {
|
if (debouncedWalletAddress && baseMinterAcquisitionMethod === 'existing') {
|
||||||
|
setMyBaseMinterContracts([])
|
||||||
|
existingBaseMinterState.onChange('')
|
||||||
void displayToast()
|
void displayToast()
|
||||||
}
|
}
|
||||||
}, [debouncedWalletAddress, baseMinterAcquisitionMethod])
|
}, [debouncedWalletAddress, baseMinterAcquisitionMethod])
|
||||||
@ -177,20 +181,35 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
|
|||||||
|
|
||||||
{baseMinterAcquisitionMethod === 'existing' && (
|
{baseMinterAcquisitionMethod === 'existing' && (
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-cols-2 grid-flow-col my-4 mx-10">
|
<div className={clsx('my-4 mx-10')}>
|
||||||
|
<Conditional test={myBaseMinterContracts.length !== 0}>
|
||||||
<select
|
<select
|
||||||
className="mt-8 w-full max-w-lg text-sm bg-white/10 select select-bordered"
|
className="mt-4 w-full max-w-3xl text-sm bg-white/10 select select-bordered"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
existingBaseMinterState.onChange(e.target.value.slice(e.target.value.indexOf('stars1')))
|
existingBaseMinterState.onChange(e.target.value.slice(e.target.value.indexOf('stars1')))
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option className="mt-2 text-lg bg-[#1A1A1A]" disabled selected>
|
<option className="mt-2 text-lg bg-[#1A1A1A]" disabled selected>
|
||||||
Select one of your existing Base Minter contracts
|
Select one of your existing 1/1 collections
|
||||||
</option>
|
</option>
|
||||||
{renderBaseMinterContracts()}
|
{renderBaseMinterContracts()}
|
||||||
</select>
|
</select>
|
||||||
<TextInput defaultValue={existingBaseMinterState.value} {...existingBaseMinterState} isRequired />
|
</Conditional>
|
||||||
|
<Conditional test={myBaseMinterContracts.length === 0}>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<Alert className="my-2 w-[90%]" type="info">
|
||||||
|
No previous 1/1 collections were found. You may create a new 1/1 collection or fill in the minter
|
||||||
|
contract address manually.
|
||||||
|
</Alert>
|
||||||
|
<TextInput
|
||||||
|
className="w-3/5"
|
||||||
|
defaultValue={existingBaseMinterState.value}
|
||||||
|
{...existingBaseMinterState}
|
||||||
|
isRequired
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Conditional>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -141,8 +141,12 @@ export const baseMinter = (client: SigningCosmWasmClient, txSigner: string): Bas
|
|||||||
})
|
})
|
||||||
console.log(factoryParameters.params.mint_fee_bps)
|
console.log(factoryParameters.params.mint_fee_bps)
|
||||||
|
|
||||||
const price = (await getConfig()).config.mint_price.amount
|
const price = (await getConfig()).config?.mint_price.amount
|
||||||
console.log(price)
|
if (!price) {
|
||||||
|
throw new Error(
|
||||||
|
'Unable to retrieve a valid mint price. It may be that the given contract address does not belong to a Base Minter contract.',
|
||||||
|
)
|
||||||
|
}
|
||||||
console.log((Number(price) * Number(factoryParameters.params.mint_fee_bps)) / 100)
|
console.log((Number(price) * Number(factoryParameters.params.mint_fee_bps)) / 100)
|
||||||
const res = await client.execute(
|
const res = await client.execute(
|
||||||
senderAddress,
|
senderAddress,
|
||||||
|
Loading…
Reference in New Issue
Block a user