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/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/components/massmint/Massmint.vue b/components/massmint/Massmint.vue index fcd8f3d610..451b03ac8e 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, metadataDeposit } = 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 + metadataDeposit.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 })