Skip to content

Commit

Permalink
fix(massmint): not checking required amount to mint tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian committed Nov 26, 2024
1 parent abcd2ca commit 35ea656
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions components/massmint/Massmint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
class="flex flex-grow limit-width"
variant="primary"
size="large"
:disabled="!mediaLoaded"
:disabled="!mediaLoaded || !hasEnoughBalance"
@click="openReviewModal"
>
<span class="text-xl">{{ $t('massmint.mintNFTs') }}
<span class="text-xl">{{ hasEnoughBalance ? $t('massmint.mintNFTs') : $t('confirmPurchase.notEnoughFunds') }}
<span
v-if="numOfValidNFTs"
v-if="numOfValidNFTs && !hasEnoughBalance"
class="font-bold"
>
({{ numOfValidNFTs }})
Expand Down Expand Up @@ -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)
Expand All @@ -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,
)
Expand Down Expand Up @@ -275,6 +282,10 @@ const onDescriptionLoaded = (entries: Record<string, Entry>) => {
onMounted(() => {
MobileDisclaimerModalOpen.value = smallerThenDesktop.value
})
watch(urlPrefix, async () => {
transactionFee.value = Number(await estimateTransactionFee(accountId.value, decimals.value))
}, { immediate: true })
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 35ea656

Please sign in to comment.