From 3de576c145633ff56d7f535fd7e2026d868a2151 Mon Sep 17 00:00:00 2001 From: hassnian <44554284+hassnian@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:27:25 +0500 Subject: [PATCH 1/5] fix(en.json): typo in `confirmPurchase.notEnoughFuns` --- components/create/CreateCollection.vue | 2 +- locales/en.json | 2 +- locales/hi.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/create/CreateCollection.vue b/components/create/CreateCollection.vue index 5a12402763..14f2d14e96 100644 --- a/components/create/CreateCollection.vue +++ b/components/create/CreateCollection.vue @@ -288,7 +288,7 @@ const submitButtonLabel = computed(() => { ? $i18n.t('mint.nft.connect') : canDeposit.value ? $i18n.t('mint.collection.create') - : $i18n.t('confirmPurchase.notEnoughFuns') + : $i18n.t('confirmPurchase.notEnoughFunds') }) const currentChain = computed(() => { diff --git a/locales/en.json b/locales/en.json index 81b104fc97..94c092c7b2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -271,7 +271,7 @@ "confirmPurchase": { "action": "Confirm Purchase", "connectedWith": "Connected as", - "notEnoughFuns": "Not Enough Funds", + "notEnoughFunds": "Not Enough Funds", "priceForNFTs": "Price for NFT(s)", "royalties": "Royalties", "youWillPay": "You Will Pay" diff --git a/locales/hi.json b/locales/hi.json index 61d59b0eb0..caa86a4c6a 100644 --- a/locales/hi.json +++ b/locales/hi.json @@ -199,7 +199,7 @@ "confirmPurchase": { "action": "खरीदी की पुष्टि करें", "connectedWith": "के साथ कनेक्ट किया गया है", - "notEnoughFuns": "पर्याप्त धन नहीं है", + "notEnoughFunds": "पर्याप्त धन नहीं है", "priceForNFTs": "NFT(s) के लिए मूल्य", "royalties": "Royalty", "youWillPay": "आपको भुगतान करना होगा" From abcd2cadf99617c0493eb194c7d3cb1b5f8538a7 Mon Sep 17 00:00:00 2001 From: hassnian <44554284+hassnian@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:31:09 +0500 Subject: [PATCH 2/5] ref: remove duplication make util function `estimateTransactionFee` --- components/create/Confirm/MintConfirmModal.vue | 3 +-- composables/useMigrate.ts | 2 +- utils/transactionExecutor.ts | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/create/Confirm/MintConfirmModal.vue b/components/create/Confirm/MintConfirmModal.vue index ae58614c56..b5d104ef85 100644 --- a/components/create/Confirm/MintConfirmModal.vue +++ b/components/create/Confirm/MintConfirmModal.vue @@ -55,7 +55,6 @@ import { CreateComponent } from '@/composables/useCreate' import { useFiatStore } from '@/stores/fiat' import { usePreferencesStore } from '@/stores/preferences' import { availablePrefixes } from '@/utils/chain' -import { getTransitionFee } from '@/utils/transactionExecutor' import { calculateBalanceUsdValue } from '@/utils/format/balance' import { BASE_FEE } from '@/utils/support' import type { AutoTeleportAction } from '@/composables/autoTeleport/types' @@ -183,7 +182,7 @@ const confirm = (params) => { watchEffect(async () => { networkFee.value = 0 - const fee = await getTransitionFee(accountId.value, [''], decimals.value) + const fee = await estimateTransactionFee(accountId.value, decimals.value) networkFee.value = props.nftInformation.listForSale ? Number(fee) * 2 : Number(fee) diff --git a/composables/useMigrate.ts b/composables/useMigrate.ts index 5234927473..5b9d3dd2a2 100644 --- a/composables/useMigrate.ts +++ b/composables/useMigrate.ts @@ -158,7 +158,7 @@ export function useMigrateDeposit( const chainNetworkFee = computedAsync(async () => { if (account) { - const fee = await getTransitionFee(account, [''], chainDecimals.value) + const fee = await estimateTransactionFee(account, chainDecimals.value) return parseDeposit( parseInt(fee) * itemCount * itemCount, chainDecimals.value, diff --git a/utils/transactionExecutor.ts b/utils/transactionExecutor.ts index 86b73f42f0..7fa39bf16c 100644 --- a/utils/transactionExecutor.ts +++ b/utils/transactionExecutor.ts @@ -187,6 +187,8 @@ export const getActionTransactionFee = ({ }) } +export const estimateTransactionFee = async (account: string, decimals: number) => getTransitionFee(account, [''], decimals) + export const getTransitionFee = async ( accountId: string, targetAddresses: Array, From 35ea656742a2b91a553b33fbee6bbe28649d4b5c Mon Sep 17 00:00:00 2001 From: hassnian <44554284+hassnian@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:37:36 +0500 Subject: [PATCH 3/5] fix(massmint): not checking required amount to mint tokens --- components/massmint/Massmint.vue | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/components/massmint/Massmint.vue b/components/massmint/Massmint.vue index f81f9f381e..c245f71ec9 100644 --- a/components/massmint/Massmint.vue +++ b/components/massmint/Massmint.vue @@ -53,12 +53,12 @@ class="flex flex-grow limit-width" variant="primary" size="large" - :disabled="!mediaLoaded" + :disabled="!mediaLoaded || !hasEnoughBalance" @click="openReviewModal" > - {{ $t('massmint.mintNFTs') }} + {{ hasEnoughBalance ? $t('massmint.mintNFTs') : $t('confirmPurchase.notEnoughFunds') }} ({{ numOfValidNFTs }}) @@ -130,8 +130,11 @@ const preferencesStore = usePreferencesStore() const { $consola, $i18n } = useNuxtApp() const router = useRouter() const { urlPrefix } = usePrefix() -const { selectedCollection, preselectedCollectionId, onCollectionSelected } - = useCollectionDropdown() +const { accountId } = useAuth() +const { selectedCollection, preselectedCollectionId, onCollectionSelected } = useCollectionDropdown() +const { itemDeposit } = useDeposit(urlPrefix) +const { decimals } = useChain() +const { transferableCurrentChainBalance } = useMultipleBalance(true) const NFTS = ref<{ [nftId: string]: NFT }>({}) const mediaLoaded = ref(false) @@ -146,9 +149,13 @@ const mintModalOpen = ref(false) const MobileDisclaimerModalOpen = ref(false) const smallerThenDesktop = computed(() => width.value < 1024) +const transactionFee = ref(0) const isMinting = ref(false) const mintStatus = ref('') +const neededAmount = computed(() => (itemDeposit.value * Object.keys(NFTS.value).length) + transactionFee.value) +const hasEnoughBalance = computed(() => (transferableCurrentChainBalance.value ?? 0) >= neededAmount.value) + const numberOfMissingNames = computed( () => Object.values(NFTS.value).filter(nft => !nft.name).length, ) @@ -275,6 +282,10 @@ const onDescriptionLoaded = (entries: Record) => { onMounted(() => { MobileDisclaimerModalOpen.value = smallerThenDesktop.value }) + +watch(urlPrefix, async () => { + transactionFee.value = Number(await estimateTransactionFee(accountId.value, decimals.value)) +}, { immediate: true })