From 609b7fce4792a9d28e8ef2245915f37f8ab70a5a Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 5 Jul 2023 09:01:10 +0300 Subject: [PATCH 1/4] Check wallet balance in real time during collection creation --- pages/collections/create.tsx | 85 +++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index c732ef3..082fe2b 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -147,8 +147,15 @@ const CollectionCreationPage: NextPage = () => { .then(() => { checkWhitelistDetails() .then(() => { - checkwalletBalance() - setReadyToCreateVm(true) + void checkwalletBalance() + .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) => { if (String(error.message).includes('Insufficient wallet balance')) { @@ -191,8 +198,15 @@ const CollectionCreationPage: NextPage = () => { .then(() => { checkWhitelistDetails() .then(() => { - checkwalletBalance() - setReadyToCreateBm(true) + void checkwalletBalance() + .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) => { toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) @@ -1104,40 +1118,41 @@ const CollectionCreationPage: NextPage = () => { } } - const checkwalletBalance = () => { - if (!wallet.initialized) throw new Error('Wallet not connected.') - if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) { - const amountNeeded = - Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 + - (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' + const checkwalletBalance = async () => { + const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => { + if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) { + const amountNeeded = + Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 + + (whitelistDetails.whitelistType === 'flex' ? Number(vendingMinterFlexCreationFee) : collectionDetails?.updatable ? Number(vendingMinterUpdatableCreationFee) - : Number(vendingMinterCreationFee) - : collectionDetails?.updatable - ? Number(baseMinterUpdatableCreationFee) - : Number(baseMinterCreationFee) - if (amountNeeded >= Number(wallet.balance[0].amount)) - throw new Error( - `Insufficient wallet balance to instantiate the required contracts. Needed amount: ${( - amountNeeded / 1000000 - ).toString()} STARS`, - ) - } + : Number(vendingMinterCreationFee)) + if (amountNeeded >= Number(balance.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) + : 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 () => { From 975161bb704481f67a377f1d33eb12a2dcdac663 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 5 Jul 2023 09:03:57 +0300 Subject: [PATCH 2/4] Update tooltip position for open edition existing token URI --- components/openEdition/OffChainMetadataUploadDetails.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/openEdition/OffChainMetadataUploadDetails.tsx b/components/openEdition/OffChainMetadataUploadDetails.tsx index 3c785bb..184435e 100644 --- a/components/openEdition/OffChainMetadataUploadDetails.tsx +++ b/components/openEdition/OffChainMetadataUploadDetails.tsx @@ -294,7 +294,7 @@ export const OffChainMetadataUploadDetails = ({
From 660fef4440a3e995c575b728dfd033bc232b1747 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 5 Jul 2023 09:09:58 +0300 Subject: [PATCH 3/4] Temporarily disable the updatable option for flexible collections on testnet --- pages/collections/create.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 082fe2b..6a99323 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -538,7 +538,11 @@ const CollectionCreationPage: NextPage = () => { whitelist, }, 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, symbol: collectionDetails?.symbol, info: { From 862137f51ccf013063a8a2ff5a4655a3ec42cd78 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 5 Jul 2023 09:13:51 +0300 Subject: [PATCH 4/4] Bump Studio version --- .env.example | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index fe5b903..f796894 100644 --- a/.env.example +++ b/.env.example @@ -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_SG721_CODE_ID=2595 diff --git a/package.json b/package.json index f35e212..003929a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stargaze-studio", - "version": "0.7.0", + "version": "0.7.1", "workspaces": [ "packages/*" ],