Merge pull request #28 from public-awesome/check-whitelist-validity
Check specified whitelist contract address validity prior to collection creation
This commit is contained in:
commit
7266ea5af2
@ -6,7 +6,7 @@ export interface ConfirmationModalProps {
|
|||||||
export const ConfirmationModal = (props: ConfirmationModalProps) => {
|
export const ConfirmationModal = (props: ConfirmationModalProps) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<input className="modal-toggle" id="my-modal-2" type="checkbox" />
|
<input className="modal-toggle" defaultChecked id="my-modal-2" type="checkbox" />
|
||||||
<label className="cursor-pointer modal" htmlFor="my-modal-2">
|
<label className="cursor-pointer modal" htmlFor="my-modal-2">
|
||||||
<label
|
<label
|
||||||
className="absolute top-[40%] bottom-5 left-1/3 max-w-xl max-h-40 border-2 no-scrollbar modal-box"
|
className="absolute top-[40%] bottom-5 left-1/3 max-w-xl max-h-40 border-2 no-scrollbar modal-box"
|
||||||
|
@ -70,7 +70,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti
|
|||||||
/>
|
/>
|
||||||
<NumberInput {...unitPriceState} isRequired />
|
<NumberInput {...unitPriceState} isRequired />
|
||||||
<NumberInput {...perAddressLimitState} isRequired />
|
<NumberInput {...perAddressLimitState} isRequired />
|
||||||
<FormControl htmlId="timestamp" isRequired subtitle="Start time for the minting" title="Start Time">
|
<FormControl htmlId="timestamp" isRequired subtitle="Minting start time (local)" title="Start Time">
|
||||||
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
@ -71,10 +71,15 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
checkUploadDetails()
|
checkUploadDetails()
|
||||||
checkCollectionDetails()
|
checkCollectionDetails()
|
||||||
checkMintingDetails()
|
checkMintingDetails()
|
||||||
checkWhitelistDetails()
|
|
||||||
checkRoyaltyDetails()
|
checkRoyaltyDetails()
|
||||||
setReadyToCreate(true)
|
checkWhitelistDetails()
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
.then(() => {
|
||||||
|
setReadyToCreate(true)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
toast.error(`Error in Whitelist Configuration: ${err.message}`)
|
||||||
|
setReadyToCreate(false)
|
||||||
|
})
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error(error.message)
|
toast.error(error.message)
|
||||||
setUploading(false)
|
setUploading(false)
|
||||||
@ -324,10 +329,15 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
if (Number(mintingDetails.startTime) < new Date().getTime() * 1000000) throw new Error('Invalid start time')
|
if (Number(mintingDetails.startTime) < new Date().getTime() * 1000000) throw new Error('Invalid start time')
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkWhitelistDetails = () => {
|
const checkWhitelistDetails = async () => {
|
||||||
if (!whitelistDetails) throw new Error('Please fill out the whitelist details')
|
if (!whitelistDetails) throw new Error('Please fill out the whitelist details')
|
||||||
if (whitelistDetails.whitelistType === 'existing') {
|
if (whitelistDetails.whitelistType === 'existing') {
|
||||||
if (whitelistDetails.contractAddress === '') throw new Error('Whitelist contract address is required')
|
if (whitelistDetails.contractAddress === '') throw new Error('Whitelist contract address is required')
|
||||||
|
else {
|
||||||
|
const contract = whitelistContract?.use(whitelistDetails.contractAddress)
|
||||||
|
//check if the address belongs to a whitelist contract (see performChecks())
|
||||||
|
const config = await contract?.config()
|
||||||
|
}
|
||||||
} else if (whitelistDetails.whitelistType === 'new') {
|
} else if (whitelistDetails.whitelistType === 'new') {
|
||||||
if (whitelistDetails.members?.length === 0) throw new Error('Whitelist member list cannot be empty')
|
if (whitelistDetails.members?.length === 0) throw new Error('Whitelist member list cannot be empty')
|
||||||
if (whitelistDetails.unitPrice === '') throw new Error('Whitelist unit price is required')
|
if (whitelistDetails.unitPrice === '') throw new Error('Whitelist unit price is required')
|
||||||
@ -489,13 +499,13 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
{readyToCreate && <ConfirmationModal confirm={createCollection} />}
|
{readyToCreate && <ConfirmationModal confirm={createCollection} />}
|
||||||
<div className="flex justify-end w-full">
|
<div className="flex justify-end w-full">
|
||||||
<Button className="px-0 mb-6 max-h-12" isLoading={creatingCollection} onClick={performChecks} variant="solid">
|
<Button
|
||||||
<label
|
className="relative justify-center p-2 mb-6 max-h-12 text-white bg-plumbus hover:bg-plumbus-light border-0"
|
||||||
className="relative justify-end w-full h-full text-white bg-plumbus hover:bg-plumbus-light border-0 btn modal-button"
|
isLoading={creatingCollection}
|
||||||
htmlFor="my-modal-2"
|
onClick={performChecks}
|
||||||
>
|
variant="solid"
|
||||||
Create Collection
|
>
|
||||||
</label>
|
Create Collection
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user