Implement wallet balance checks
This commit is contained in:
parent
9f513857c9
commit
663b1d9999
@ -106,8 +106,15 @@ export const OpenEditionMinterCreator = ({
|
|||||||
checkMintingDetails()
|
checkMintingDetails()
|
||||||
void checkRoyaltyDetails()
|
void checkRoyaltyDetails()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// TODO: check wallet balance
|
void checkwalletBalance()
|
||||||
setReadyToCreate(true)
|
.then(() => {
|
||||||
|
setReadyToCreate(true)
|
||||||
|
})
|
||||||
|
.catch((error: any) => {
|
||||||
|
toast.error(`Error in Wallet Balance: ${error.message}`, { style: { maxWidth: 'none' } })
|
||||||
|
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
|
||||||
|
setReadyToCreate(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
toast.error(`Error in Royalty Details: ${error.message}`, { style: { maxWidth: 'none' } })
|
toast.error(`Error in Royalty Details: ${error.message}`, { style: { maxWidth: 'none' } })
|
||||||
@ -286,6 +293,21 @@ export const OpenEditionMinterCreator = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkwalletBalance = async () => {
|
||||||
|
if (!wallet.initialized) throw new Error('Wallet not connected.')
|
||||||
|
const amountNeeded = collectionDetails?.updatable
|
||||||
|
? Number(openEditionMinterUpdatableCreationFee)
|
||||||
|
: Number(openEditionMinterCreationFee)
|
||||||
|
await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => {
|
||||||
|
if (amountNeeded >= Number(balance.amount))
|
||||||
|
throw new Error(
|
||||||
|
`Insufficient wallet balance to instantiate the required contracts. Needed amount: ${(
|
||||||
|
amountNeeded / 1000000
|
||||||
|
).toString()} STARS`,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const createOpenEditionMinter = async () => {
|
const createOpenEditionMinter = async () => {
|
||||||
try {
|
try {
|
||||||
setCreationInProgress(true)
|
setCreationInProgress(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user