Merge pull request #185 from public-awesome/wallet-balance-check-update
This commit is contained in:
commit
7c6ca46400
@ -1,4 +1,4 @@
|
|||||||
APP_VERSION=0.7.0
|
APP_VERSION=0.7.1
|
||||||
|
|
||||||
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
|
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
|
||||||
NEXT_PUBLIC_SG721_CODE_ID=2595
|
NEXT_PUBLIC_SG721_CODE_ID=2595
|
||||||
|
@ -294,7 +294,7 @@ export const OffChainMetadataUploadDetails = ({
|
|||||||
<div>
|
<div>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
backgroundColor="bg-blue-500"
|
backgroundColor="bg-blue-500"
|
||||||
className="mb-2 ml-28"
|
className="mb-2 ml-4"
|
||||||
label="The token URI that points directly to the metadata file stored on IPFS."
|
label="The token URI that points directly to the metadata file stored on IPFS."
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stargaze-studio",
|
"name": "stargaze-studio",
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
|
@ -147,8 +147,15 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
checkWhitelistDetails()
|
checkWhitelistDetails()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
checkwalletBalance()
|
void checkwalletBalance()
|
||||||
setReadyToCreateVm(true)
|
.then(() => {
|
||||||
|
setReadyToCreateVm(true)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
|
||||||
|
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
|
||||||
|
setReadyToCreateVm(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (String(error.message).includes('Insufficient wallet balance')) {
|
if (String(error.message).includes('Insufficient wallet balance')) {
|
||||||
@ -191,8 +198,15 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
checkWhitelistDetails()
|
checkWhitelistDetails()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
checkwalletBalance()
|
void checkwalletBalance()
|
||||||
setReadyToCreateBm(true)
|
.then(() => {
|
||||||
|
setReadyToCreateBm(true)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
|
||||||
|
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
|
||||||
|
setReadyToCreateVm(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
|
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
|
||||||
@ -524,7 +538,11 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
whitelist,
|
whitelist,
|
||||||
},
|
},
|
||||||
collection_params: {
|
collection_params: {
|
||||||
code_id: collectionDetails?.updatable ? SG721_UPDATABLE_CODE_ID : SG721_CODE_ID,
|
code_id: collectionDetails?.updatable
|
||||||
|
? whitelistDetails?.whitelistType === 'flex'
|
||||||
|
? SG721_CODE_ID
|
||||||
|
: SG721_UPDATABLE_CODE_ID
|
||||||
|
: SG721_CODE_ID,
|
||||||
name: collectionDetails?.name,
|
name: collectionDetails?.name,
|
||||||
symbol: collectionDetails?.symbol,
|
symbol: collectionDetails?.symbol,
|
||||||
info: {
|
info: {
|
||||||
@ -1104,40 +1122,41 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkwalletBalance = () => {
|
const checkwalletBalance = async () => {
|
||||||
if (!wallet.initialized) throw new Error('Wallet not connected.')
|
const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => {
|
||||||
if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) {
|
if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) {
|
||||||
const amountNeeded =
|
const amountNeeded =
|
||||||
Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 +
|
Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 +
|
||||||
(whitelistDetails.whitelistType === 'flex'
|
(whitelistDetails.whitelistType === 'flex'
|
||||||
? Number(vendingMinterFlexCreationFee)
|
|
||||||
: collectionDetails?.updatable
|
|
||||||
? Number(vendingMinterUpdatableCreationFee)
|
|
||||||
: Number(vendingMinterCreationFee))
|
|
||||||
if (amountNeeded >= Number(wallet.balance[0].amount))
|
|
||||||
throw new Error(
|
|
||||||
`Insufficient wallet balance to instantiate the required contracts. Needed amount: ${(
|
|
||||||
amountNeeded / 1000000
|
|
||||||
).toString()} STARS`,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
const amountNeeded =
|
|
||||||
minterType === 'vending'
|
|
||||||
? whitelistDetails?.whitelistState === 'existing' && whitelistDetails.whitelistType === 'flex'
|
|
||||||
? Number(vendingMinterFlexCreationFee)
|
? Number(vendingMinterFlexCreationFee)
|
||||||
: collectionDetails?.updatable
|
: collectionDetails?.updatable
|
||||||
? Number(vendingMinterUpdatableCreationFee)
|
? Number(vendingMinterUpdatableCreationFee)
|
||||||
: Number(vendingMinterCreationFee)
|
: Number(vendingMinterCreationFee))
|
||||||
: collectionDetails?.updatable
|
if (amountNeeded >= Number(balance.amount))
|
||||||
? Number(baseMinterUpdatableCreationFee)
|
throw new Error(
|
||||||
: Number(baseMinterCreationFee)
|
`Insufficient wallet balance to instantiate the required contracts. Needed amount: ${(
|
||||||
if (amountNeeded >= Number(wallet.balance[0].amount))
|
amountNeeded / 1000000
|
||||||
throw new Error(
|
).toString()} STARS`,
|
||||||
`Insufficient wallet balance to instantiate the required contracts. Needed amount: ${(
|
)
|
||||||
amountNeeded / 1000000
|
} else {
|
||||||
).toString()} STARS`,
|
const amountNeeded =
|
||||||
)
|
minterType === 'vending'
|
||||||
}
|
? whitelistDetails?.whitelistState === 'existing' && whitelistDetails.whitelistType === 'flex'
|
||||||
|
? Number(vendingMinterFlexCreationFee)
|
||||||
|
: collectionDetails?.updatable
|
||||||
|
? Number(vendingMinterUpdatableCreationFee)
|
||||||
|
: Number(vendingMinterCreationFee)
|
||||||
|
: collectionDetails?.updatable
|
||||||
|
? Number(baseMinterUpdatableCreationFee)
|
||||||
|
: Number(baseMinterCreationFee)
|
||||||
|
if (amountNeeded >= Number(balance.amount))
|
||||||
|
throw new Error(
|
||||||
|
`Insufficient wallet balance to instantiate the required contracts. Needed amount: ${(
|
||||||
|
amountNeeded / 1000000
|
||||||
|
).toString()} STARS`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncCollections = useCallback(async () => {
|
const syncCollections = useCallback(async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user