Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Phases in drop page #6

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
607e2db
add: new holder of drop iteration
hassnian Jan 16, 2024
cf925a3
ref: move simple minimum-funds
hassnian Jan 16, 2024
6a273c2
ref: holder of collection requirements
hassnian Jan 16, 2024
49b343f
add: holder of collection tooltip
hassnian Jan 17, 2024
4d746f5
add: check if holder of collection nfts are already claimed
hassnian Jan 17, 2024
792d0b2
remove: empy tags
hassnian Jan 17, 2024
5f99825
add: check has minimumFunds amount
hassnian Jan 17, 2024
1a257fc
add: requiremnt check available for mint amount
hassnian Jan 17, 2024
a7f99de
Merge branch 'main' into issue-8886
hassnian Jan 17, 2024
14a49f4
add: missing hasAmount minimumFundsProps
hassnian Jan 17, 2024
a942544
add: mobile version holder of requirements
hassnian Jan 17, 2024
cc92d98
fix: checkAlreadyClaimedNfts wrong collection
hassnian Jan 17, 2024
848884a
ref: use correct transaltion
hassnian Jan 17, 2024
20350eb
ref: transaltion key rename
hassnian Jan 17, 2024
7df5f90
add: check hasMinimumFunds mint button disabled and label
hassnian Jan 17, 2024
502800b
ref: move holder of collection logic
hassnian Jan 17, 2024
7decf03
Merge branch 'main' into issue-8886
hassnian Jan 17, 2024
5c58d26
fix: on wallet disconnect update available nft count
hassnian Jan 17, 2024
439141a
Merge branch 'issue-8886' of https://github.com/hassnian/nft-gallery …
hassnian Jan 17, 2024
37101e0
ref: remove boolean
hassnian Jan 17, 2024
225234e
fix: disabled button if does not have available nfts
hassnian Jan 17, 2024
441529a
ref: rename checkAvailableNfts
hassnian Jan 17, 2024
690dbab
Merge branch 'main' into issue-8886
hassnian Jan 17, 2024
bffc3a2
ref: icon name and class
hassnian Jan 17, 2024
7ee4b5f
Merge branch 'issue-8886' of https://github.com/hassnian/nft-gallery …
hassnian Jan 17, 2024
e587ff7
Merge branch 'main' into issue-8886
hassnian Jan 18, 2024
d46cf0f
add: basic phases drop
hassnian Jan 18, 2024
d73c5b3
add: mint phase state
hassnian Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/collection/drop/Generative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const minimumFundsDescription = computed(() =>
const minimumFundsProps = computed(() => ({
amount: minimumFunds.value,
description: minimumFundsDescription.value,
hasAmount: hasMinimumFunds.value,
}))

const isWalletConnecting = ref(false)
Expand Down Expand Up @@ -157,10 +158,10 @@ const {
defaultImage,
})

const mintButtonDisabled = computed(
const mintButtonDisabled = computed<boolean>(
() =>
!mintCountAvailable.value ||
disabledByBackend.value ||
Boolean(disabledByBackend.value) ||
(isLogIn.value && Boolean(!selectedImage.value)),
)

Expand Down
10 changes: 7 additions & 3 deletions components/collection/drop/GenerativeLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:disabled-by-backend="drop.disabled"
:mint-button="mintButton"
:holder-of-collection="holderOfCollection"
:mint-phases="mintPhases"
@mint="handleSubmitMint" />
</div>

Expand All @@ -49,6 +50,7 @@
:disabled-by-backend="drop.disabled"
:mint-button="mintButton"
:holder-of-collection="holderOfCollection"
:mint-phases="mintPhases"
@mint="handleSubmitMint" />
</div>

Expand All @@ -64,6 +66,7 @@

<script setup lang="ts">
import { DropItem } from '@/params/types'
import { HolderOfCollectionProp, MintPhase } from './types'

withDefaults(
defineProps<{
Expand All @@ -74,20 +77,21 @@ 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
holderOfCollection?: HolderOfCollectionProp
userMintedNftId?: string
holderOfCollection?: { id?: string; isHolderOfTargetCollection?: boolean }
mintPhases: MintPhase[]

handleSelectImage: (image: string) => void
handleSubmitMint: () => void
}>(),
{
description: '',
userMintedNftId: undefined,
holderOfCollection: () => ({ id: '', isHolderOfTargetCollection: false }),
mintPhases: () => [],
},
)

Expand Down
51 changes: 0 additions & 51 deletions components/collection/drop/HolderOfCollection.vue

This file was deleted.

61 changes: 49 additions & 12 deletions components/collection/drop/HolderOfGenerative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
import { createUnlockableMetadata } from '../unlockable/utils'
import { DropItem } from '@/params/types'
import { claimDropItem } from '@/services/waifu'
import { useDropMinimumFunds, useDropStatus } from '@/components/drops/useDrops'
import {
useDropMinimumFunds,
useDropStatus,
useHolderOfCollectionDrop,
} from '@/components/drops/useDrops'
import { fetchNft } from '@/components/items/ItemsGrid/useNftActions'
import holderOfCollectionById from '@/queries/subsquid/general/holderOfCollectionById.graphql'
import unlockableCollectionById from '@/queries/subsquid/general/unlockableCollectionById.graphql'
Expand All @@ -44,6 +48,16 @@ import useGenerativeDropDetails from '@/composables/drop/useGenerativeDropDetail

const holderOfCollectionId = '50' // ChaosFlakes | todo: mock for testing, should be fetched from backend

export type HolderOfCollectionProp = {
id: string
isHolder: boolean
hasAvailable: boolean
amount: {
total: number
available: number
}
}

const props = withDefaults(
defineProps<{
drop: DropItem
Expand All @@ -58,7 +72,7 @@ const { fetchMultipleBalance } = useMultipleBalance()
const { hasMinimumFunds, formattedMinimumFunds, minimumFunds } =
useDropMinimumFunds(props.drop)
const minimumFundsDescription = computed(() =>
$i18n.t('mint.unlockable.minimumFundsDescription', [
$i18n.t('mint.unlockable.holderOfCollectionMinimumFundsDescription', [
formattedMinimumFunds.value,
chainName.value,
]),
Expand All @@ -67,11 +81,13 @@ const minimumFundsDescription = computed(() =>
const minimumFundsProps = computed(() => ({
amount: minimumFunds.value,
description: minimumFundsDescription.value,
hasAmount: hasMinimumFunds.value,
}))

const isWalletConnecting = ref(false)
const { currentAccountMintedToken, mintedDropCount, fetchDropStatus } =
useDropStatus(props.drop.alias)
const { isNftClaimed } = useHolderOfCollectionDrop()
const instance = getCurrentInstance()
const mintNftSN = ref('0')
const { doAfterLogin } = useDoAfterlogin(instance)
Expand All @@ -84,6 +100,7 @@ const { client } = usePrefix()
const isLoading = ref(false)
const isImageFetching = ref(false)
const isAddFundModalActive = ref(false)
const availableNfts = ref(0)

const {
defaultName,
Expand Down Expand Up @@ -137,6 +154,7 @@ const {
userMintedNftId,
mintedCount,
mintCountAvailable,
mintedAmountForCurrentUser,
selectedImage,
description,
collectionName,
Expand Down Expand Up @@ -167,10 +185,6 @@ const { data: holderOfCollectionData } = await useAsyncData(
},
)

const mintedAmountForCurrentUser = computed(
() => collectionData.value?.nftEntitiesConnection?.totalCount || 0, // todo: fetch from backend
)

const maxMintLimitForCurrentUser = computed(
() => holderOfCollectionData.value?.nftEntitiesConnection?.totalCount || 0,
)
Expand All @@ -179,32 +193,44 @@ const isHolderOfTargetCollection = computed(
() => maxMintLimitForCurrentUser.value > 0,
)

const holderOfCollection = computed(() => ({
const hasAvailableNfts = computed(() => availableNfts.value !== 0)

const holderOfCollection = computed<HolderOfCollectionProp>(() => ({
id: holderOfCollectionId,
isHolderOfTargetCollection: isHolderOfTargetCollection.value,
isHolder: isHolderOfTargetCollection.value,
hasAvailable: hasAvailableNfts.value,
amount: {
total: maxMintLimitForCurrentUser.value,
available: availableNfts.value,
},
}))

const mintButtonLabel = computed(() => {
return isWalletConnecting.value
? $i18n.t('shoppingCart.wallet')
: isLogIn.value
? isHolderOfTargetCollection.value &&
maxMintLimitForCurrentUser.value > mintedAmountForCurrentUser.value
maxMintLimitForCurrentUser.value > mintedAmountForCurrentUser.value &&
hasMinimumFunds.value &&
hasAvailableNfts.value
? $i18n.t('mint.unlockable.claimPaidNft', [
`${depositAmount.value} ${depositChainSymbol.value}`,
])
: $i18n.t('mint.unlockable.notEligibility')
: $i18n.t('mint.unlockable.checkEligibility')
})
const mintButtonDisabled = computed(
const mintButtonDisabled = computed<boolean>(
() =>
!mintCountAvailable.value ||
disabledByBackend.value ||
Boolean(disabledByBackend.value) ||
(isLogIn.value &&
Boolean(
!selectedImage.value ||
!isHolderOfTargetCollection.value ||
maxMintLimitForCurrentUser.value <= mintedAmountForCurrentUser.value,
maxMintLimitForCurrentUser.value <=
mintedAmountForCurrentUser.value ||
!hasMinimumFunds.value ||
!hasAvailableNfts.value,
)),
)

Expand Down Expand Up @@ -340,10 +366,21 @@ const submitMint = async (sn: string) => {
}
}

const checkAvailableNfts = async () => {
const nftEntities = holderOfCollectionData.value?.nftEntities || []
const nftIds = nftEntities.map((nft) => nft.sn)
const claimed = await Promise.all(
nftIds.map((sn) => isNftClaimed(sn, holderOfCollectionId)),
)
availableNfts.value = claimed.filter((x) => !x).length
}

const handleDropAddModalConfirm = () => {
closeAddFundModal()
fetchMultipleBalance([urlPrefix.value])
}

watch(holderOfCollectionData, checkAvailableNfts, { immediate: true })
</script>

<style scoped lang="scss">
Expand Down
Loading