From 607e2db444654af23da741642edd13bbb22d1f83 Mon Sep 17 00:00:00 2001 From: hassnian Date: Tue, 16 Jan 2024 17:24:21 +0500 Subject: [PATCH 01/29] add: new holder of drop iteration --- components/collection/drop/Generative.vue | 9 +- .../collection/drop/GenerativeLayout.vue | 8 +- .../collection/drop/HolderOfGenerative.vue | 10 +- .../drop/MintSection/MintRequirementItem.vue | 37 ++++ .../drop/MintSection/MintRequirements.vue | 188 ++++++++++++++++++ .../drop/{ => MintSection}/MintSection.vue | 65 ++---- components/collection/drop/PaidGenerative.vue | 7 +- composables/drop/useGenerativeDropMint.ts | 5 + locales/en.json | 12 +- 9 files changed, 279 insertions(+), 62 deletions(-) create mode 100644 components/collection/drop/MintSection/MintRequirementItem.vue create mode 100644 components/collection/drop/MintSection/MintRequirements.vue rename components/collection/drop/{ => MintSection}/MintSection.vue (70%) diff --git a/components/collection/drop/Generative.vue b/components/collection/drop/Generative.vue index cf4f41a397..85b2012da5 100644 --- a/components/collection/drop/Generative.vue +++ b/components/collection/drop/Generative.vue @@ -1,13 +1,15 @@ @@ -111,8 +84,11 @@ const props = withDefaults( isLoading: boolean mintButton: { label: string; disabled: boolean } userMintedNftId?: string + userMaxAvailableToMint: number + userMintedCount: number holderOfCollection?: { id?: string; isHolderOfTargetCollection?: boolean } collectionId: string + availableToMint?: number }>(), { userMintedNftId: undefined, @@ -125,6 +101,9 @@ const emit = defineEmits(['mint']) const { $i18n } = useNuxtApp() const { urlPrefix } = usePrefix() +// make dynmic when dynamic stages is added +const useRequirements = true + const loading = computed( () => props.isImageFetching || props.isWalletConnecting || props.isLoading, ) @@ -155,17 +134,11 @@ const handleMint = () => { emit('mint') } - -const showHolderOfCollection = computed(() => !!props.holderOfCollection.id) + diff --git a/components/collection/drop/MintSection/MintSection.vue b/components/collection/drop/MintSection/MintSection.vue index 8974bf604c..5bffd1b7db 100644 --- a/components/collection/drop/MintSection/MintSection.vue +++ b/components/collection/drop/MintSection/MintSection.vue @@ -41,8 +41,8 @@ :to="`/${urlPrefix}/gallery/${userMintedNftId}`" /> - - + + +
+
+ +
+
+ + +
@@ -69,6 +88,7 @@ + + diff --git a/components/collection/drop/MintSection/HolderOfGenerativeMintRequirements.vue b/components/collection/drop/MintSection/HolderOfGenerativeMintRequirements.vue deleted file mode 100644 index bb54da858e..0000000000 --- a/components/collection/drop/MintSection/HolderOfGenerativeMintRequirements.vue +++ /dev/null @@ -1,147 +0,0 @@ - - - - - diff --git a/components/collection/drop/MintSection/MintSection.vue b/components/collection/drop/MintSection/MintSection.vue index 5bffd1b7db..ca9681505f 100644 --- a/components/collection/drop/MintSection/MintSection.vue +++ b/components/collection/drop/MintSection/MintSection.vue @@ -41,17 +41,12 @@ :to="`/${urlPrefix}/gallery/${userMintedNftId}`" /> - + :is-minted-out="isMintedOut"> - +
@@ -88,7 +83,7 @@ diff --git a/components/collection/drop/MintSection/MintRequirementItem.vue b/components/collection/drop/MintSection/MintRequirementItem.vue index 7dda833e9a..be8ec5a8a3 100644 --- a/components/collection/drop/MintSection/MintRequirementItem.vue +++ b/components/collection/drop/MintSection/MintRequirementItem.vue @@ -31,5 +31,3 @@ const iconClass = computed(() => { return props.fulfilled ? 'text-k-green' : 'text-k-red' }) - - From 5f9982512757cdc2e83ad9f5696a23ac896371f4 Mon Sep 17 00:00:00 2001 From: hassnian Date: Wed, 17 Jan 2024 11:23:16 +0500 Subject: [PATCH 07/29] add: check has minimumFunds amount --- components/collection/drop/GenerativeLayout.vue | 2 +- components/collection/drop/HolderOfGenerative.vue | 1 + .../HolderOfCollectionMintRequirements.vue | 13 +++++++++---- .../collection/drop/MintSection/MintSection.vue | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/components/collection/drop/GenerativeLayout.vue b/components/collection/drop/GenerativeLayout.vue index 239bb8f3b2..1e6711054a 100644 --- a/components/collection/drop/GenerativeLayout.vue +++ b/components/collection/drop/GenerativeLayout.vue @@ -74,7 +74,7 @@ withDefaults( mintedCount: number mintCountAvailable: boolean maxCount: number - minimumFunds: { amount: number; description: string } + minimumFunds: { amount: number; description: string; hasAmount: boolean } isImageFetching: boolean isWalletConnecting: boolean isLoading: boolean diff --git a/components/collection/drop/HolderOfGenerative.vue b/components/collection/drop/HolderOfGenerative.vue index 6c3ef5a0ef..cef72ed2b1 100644 --- a/components/collection/drop/HolderOfGenerative.vue +++ b/components/collection/drop/HolderOfGenerative.vue @@ -71,6 +71,7 @@ const minimumFundsDescription = computed(() => const minimumFundsProps = computed(() => ({ amount: minimumFunds.value, description: minimumFundsDescription.value, + hasAmount: hasMinimumFunds.value, })) const isWalletConnecting = ref(false) diff --git a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue index 641013b944..f2302926d7 100644 --- a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue +++ b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue @@ -14,7 +14,7 @@

Holder of NFT from {{ collection?.name }} @@ -58,7 +58,9 @@

- +

@@ -98,7 +100,7 @@ const props = defineProps<{ used: number } } - minimumFunds: { amount: number; description: string } + minimumFunds: { amount: number; description: string; hasAmount: boolean } isMintedOut: boolean }>() @@ -115,7 +117,10 @@ const showHolderOfCollection = computed(() => !!props.holderOfCollection.id) const checkMinimumFunds = computed(() => Boolean(props.minimumFunds.amount)) const readyToMint = computed( - () => Boolean(props.holderOfCollection.isHolder) && checkMinimumFunds.value, + () => + Boolean(props.holderOfCollection.isHolder) && + checkMinimumFunds.value && + props.minimumFunds.hasAmount, ) const availableForMint = computed( diff --git a/components/collection/drop/MintSection/MintSection.vue b/components/collection/drop/MintSection/MintSection.vue index ca9681505f..025f8534f9 100644 --- a/components/collection/drop/MintSection/MintSection.vue +++ b/components/collection/drop/MintSection/MintSection.vue @@ -93,7 +93,7 @@ const props = withDefaults( mintCountAvailable: boolean disabledByBackend: number maxCount: number - minimumFunds: { amount: number; description: string } + minimumFunds: { amount: number; description: string; hasAmount: boolean } isImageFetching: boolean isWalletConnecting: boolean isLoading: boolean From 1a257fc2cf63d20456d2ba3dd8e9fdb910419e92 Mon Sep 17 00:00:00 2001 From: hassnian Date: Wed, 17 Jan 2024 11:33:22 +0500 Subject: [PATCH 08/29] add: requiremnt check available for mint amount --- .../drop/MintSection/HolderOfCollectionMintRequirements.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue index f2302926d7..83b6c9d190 100644 --- a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue +++ b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue @@ -120,7 +120,8 @@ const readyToMint = computed( () => Boolean(props.holderOfCollection.isHolder) && checkMinimumFunds.value && - props.minimumFunds.hasAmount, + props.minimumFunds.hasAmount && + availableForMint.value !== 0, ) const availableForMint = computed( From 14a49f4c2b2db8c340d3c0204c696ba9c059686f Mon Sep 17 00:00:00 2001 From: hassnian Date: Wed, 17 Jan 2024 11:41:13 +0500 Subject: [PATCH 09/29] add: missing hasAmount minimumFundsProps --- components/collection/drop/Generative.vue | 3 +- .../collection/drop/HolderOfCollection.vue | 51 ------------------- components/collection/drop/PaidGenerative.vue | 1 + 3 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 components/collection/drop/HolderOfCollection.vue diff --git a/components/collection/drop/Generative.vue b/components/collection/drop/Generative.vue index 2e11f13233..7fd0794b03 100644 --- a/components/collection/drop/Generative.vue +++ b/components/collection/drop/Generative.vue @@ -7,7 +7,7 @@ :minimum-funds="minimumFundsProps" :max-count="maxCount" :minted-count="mintedCount" - :mint-count-available="mintCountAvailable && !disabledByBackend" + :mint-count-available="mintCountAvailable || !disabledByBackend" :mint-button="mintButtonProps" :collection-id="collectionId" :description="description" @@ -119,6 +119,7 @@ const minimumFundsDescription = computed(() => const minimumFundsProps = computed(() => ({ amount: minimumFunds.value, description: minimumFundsDescription.value, + hasAmount: hasMinimumFunds.value, })) const isWalletConnecting = ref(false) diff --git a/components/collection/drop/HolderOfCollection.vue b/components/collection/drop/HolderOfCollection.vue deleted file mode 100644 index 4013dce39f..0000000000 --- a/components/collection/drop/HolderOfCollection.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - diff --git a/components/collection/drop/PaidGenerative.vue b/components/collection/drop/PaidGenerative.vue index 42a6a8ff35..60c4054402 100644 --- a/components/collection/drop/PaidGenerative.vue +++ b/components/collection/drop/PaidGenerative.vue @@ -93,6 +93,7 @@ const toMintNft = computed(() => ({ const minimumFundsProps = computed(() => ({ amount: minimumFunds.value, description: minimumFundsDescription.value, + hasAmount: hasMinimumFunds.value, })) const isWalletConnecting = ref(false) From a9425441af1635840a4fe646d29ee33b7cf8f926 Mon Sep 17 00:00:00 2001 From: hassnian Date: Wed, 17 Jan 2024 12:06:45 +0500 Subject: [PATCH 10/29] add: mobile version holder of requirements --- .../drop/MintSection/HolderOfCollectionMintRequirements.vue | 6 ++++-- components/collection/drop/MintSection/MintSection.vue | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue index 83b6c9d190..21de6e44a6 100644 --- a/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue +++ b/components/collection/drop/MintSection/HolderOfCollectionMintRequirements.vue @@ -67,7 +67,7 @@

- +
+ +
diff --git a/components/collection/drop/MintSection/MintSection.vue b/components/collection/drop/MintSection/MintSection.vue index 025f8534f9..7f9ae6afb6 100644 --- a/components/collection/drop/MintSection/MintSection.vue +++ b/components/collection/drop/MintSection/MintSection.vue @@ -49,7 +49,7 @@ :is-minted-out="isMintedOut"> Date: Wed, 17 Jan 2024 13:18:55 +0500 Subject: [PATCH 11/29] fix: checkAlreadyClaimedNfts wrong collection --- .../collection/drop/HolderOfGenerative.vue | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/collection/drop/HolderOfGenerative.vue b/components/collection/drop/HolderOfGenerative.vue index cef72ed2b1..ca30a2468f 100644 --- a/components/collection/drop/HolderOfGenerative.vue +++ b/components/collection/drop/HolderOfGenerative.vue @@ -348,23 +348,21 @@ const submitMint = async (sn: string) => { } } +const checkAlreadyClaimedNfts = async () => { + const nftIds = holderOfCollectionData.value.nftEntities.map((nft) => nft.sn) + const claimed = await Promise.all( + nftIds.map((sn) => isNftClaimed(sn, holderOfCollectionId)), + ) + + amountClaimedNfts.value = claimed.filter(Boolean).length +} + const handleDropAddModalConfirm = () => { closeAddFundModal() fetchMultipleBalance([urlPrefix.value]) } -watch( - holderOfCollectionData, - async () => { - const nftIds = holderOfCollectionData.value.nftEntities.map((nft) => nft.sn) - const claimed = await Promise.all( - nftIds.map((sn) => isNftClaimed(sn, collectionId.value)), - ) - - amountClaimedNfts.value = claimed.filter(Boolean).length - }, - { immediate: true }, -) +watch(holderOfCollectionData, checkAlreadyClaimedNfts, { immediate: true })