53
53
class =" flex flex-grow limit-width"
54
54
variant =" primary"
55
55
size =" large"
56
- :disabled =" !mediaLoaded"
56
+ :disabled =" !mediaLoaded || !hasEnoughBalance "
57
57
@click =" openReviewModal"
58
58
>
59
- <span class =" text-xl" >{{ $t('massmint.mintNFTs') }}
59
+ <span class =" text-xl" >{{ hasEnoughBalance ? $t('massmint.mintNFTs') : $t('confirmPurchase.notEnoughFunds ') }}
60
60
<span
61
- v-if =" numOfValidNFTs"
61
+ v-if =" numOfValidNFTs && !hasEnoughBalance "
62
62
class =" font-bold"
63
63
>
64
64
({{ numOfValidNFTs }})
@@ -130,8 +130,11 @@ const preferencesStore = usePreferencesStore()
130
130
const { $consola, $i18n } = useNuxtApp ()
131
131
const router = useRouter ()
132
132
const { urlPrefix } = usePrefix ()
133
- const { selectedCollection, preselectedCollectionId, onCollectionSelected }
134
- = useCollectionDropdown ()
133
+ const { accountId } = useAuth ()
134
+ const { selectedCollection, preselectedCollectionId, onCollectionSelected } = useCollectionDropdown ()
135
+ const { itemDeposit, metadataDeposit } = useDeposit (urlPrefix )
136
+ const { decimals } = useChain ()
137
+ const { transferableCurrentChainBalance } = useMultipleBalance (true )
135
138
136
139
const NFTS = ref <{ [nftId : string ]: NFT }>({})
137
140
const mediaLoaded = ref (false )
@@ -146,9 +149,13 @@ const mintModalOpen = ref(false)
146
149
const MobileDisclaimerModalOpen = ref (false )
147
150
const smallerThenDesktop = computed (() => width .value < 1024 )
148
151
152
+ const transactionFee = ref (0 )
149
153
const isMinting = ref (false )
150
154
const mintStatus = ref (' ' )
151
155
156
+ const neededAmount = computed (() => ((itemDeposit .value + metadataDeposit .value ) * Object .keys (NFTS .value ).length ) + transactionFee .value )
157
+ const hasEnoughBalance = computed (() => (transferableCurrentChainBalance .value ?? 0 ) >= neededAmount .value )
158
+
152
159
const numberOfMissingNames = computed (
153
160
() => Object .values (NFTS .value ).filter (nft => ! nft .name ).length ,
154
161
)
@@ -275,6 +282,10 @@ const onDescriptionLoaded = (entries: Record<string, Entry>) => {
275
282
onMounted (() => {
276
283
MobileDisclaimerModalOpen .value = smallerThenDesktop .value
277
284
})
285
+
286
+ watch (urlPrefix , async () => {
287
+ transactionFee .value = Number (await estimateTransactionFee (accountId .value , decimals .value ))
288
+ }, { immediate: true })
278
289
</script >
279
290
280
291
<style lang="scss" scoped>
0 commit comments