Add wallet balance check for WL and/or Vending Minter instantiation
This commit is contained in:
parent
eaf3485bab
commit
6b6d0a34a1
@ -103,15 +103,19 @@ const CollectionCreationPage: NextPage = () => {
|
||||
checkRoyaltyDetails()
|
||||
checkWhitelistDetails()
|
||||
.then(() => {
|
||||
checkwalletBalance()
|
||||
setReadyToCreateVm(true)
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(`Error in Whitelist Configuration: ${err.message}`, { style: { maxWidth: 'none' } })
|
||||
if (String(err.message).includes('Insufficient wallet balance'))
|
||||
toast.error(`${err.message}`, { style: { maxWidth: 'none' } })
|
||||
else toast.error(`Error in Whitelist Configuration: ${err.message}`, { style: { maxWidth: 'none' } })
|
||||
setReadyToCreateVm(false)
|
||||
})
|
||||
} catch (error: any) {
|
||||
toast.error(error.message, { style: { maxWidth: 'none' } })
|
||||
setUploading(false)
|
||||
setReadyToCreateVm(false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,8 +644,10 @@ const CollectionCreationPage: NextPage = () => {
|
||||
throw new Error('Invalid unit price: The minimum unit price for whitelisted addresses is 25 STARS')
|
||||
if (whitelistDetails.startTime === '') throw new Error('Start time is required')
|
||||
if (whitelistDetails.endTime === '') throw new Error('End time is required')
|
||||
if (whitelistDetails.perAddressLimit === 0) throw new Error('Per address limit is required')
|
||||
if (whitelistDetails.memberLimit === 0) throw new Error('Member limit is required')
|
||||
if (!whitelistDetails.perAddressLimit || whitelistDetails.perAddressLimit === 0)
|
||||
throw new Error('Per address limit is required')
|
||||
if (!whitelistDetails.memberLimit || whitelistDetails.memberLimit === 0)
|
||||
throw new Error('Member limit is required')
|
||||
if (Number(whitelistDetails.startTime) > Number(whitelistDetails.endTime))
|
||||
throw new Error('Whitelist start time cannot be later than whitelist end time')
|
||||
if (Number(whitelistDetails.startTime) !== Number(mintingDetails?.startTime))
|
||||
@ -666,6 +672,19 @@ const CollectionCreationPage: NextPage = () => {
|
||||
if (royaltyDetails.paymentAddress === '') throw new Error('Royalty payment address is required')
|
||||
}
|
||||
}
|
||||
|
||||
const checkwalletBalance = () => {
|
||||
if (!wallet.initialized) throw new Error('Wallet not connected.')
|
||||
if (whitelistDetails?.whitelistType === 'new' && whitelistDetails.memberLimit) {
|
||||
const amountNeeded = Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 + 1000000000
|
||||
if (amountNeeded >= Number(wallet.balance[0].amount))
|
||||
throw new Error('Insufficient wallet balance to instantiate the required contracts.')
|
||||
} else {
|
||||
const amountNeeded = 1000000000
|
||||
if (amountNeeded >= Number(wallet.balance[0].amount))
|
||||
throw new Error('Insufficient wallet balance to instantiate the required contracts.')
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
if (vendingMinterContractAddress !== null) scrollRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||
}, [vendingMinterContractAddress])
|
||||
|
Loading…
Reference in New Issue
Block a user