From aceacee4512ff055223de38dee5ddead93f373e5 Mon Sep 17 00:00:00 2001 From: AshutoshSingh00001 Date: Fri, 1 Dec 2023 23:38:03 +0530 Subject: [PATCH 1/3] Total. Supply --- components/collection/CollectionInfo.vue | 1 + components/collection/utils/types.ts | 1 + components/collection/utils/useCollectionDetails.ts | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/collection/CollectionInfo.vue b/components/collection/CollectionInfo.vue index 09552aa925..4ba47f07c9 100644 --- a/components/collection/CollectionInfo.vue +++ b/components/collection/CollectionInfo.vue @@ -34,6 +34,7 @@ :value="stats.uniqueOwners" />
+ { const { urlPrefix } = usePrefix() + const { apiInstance } = useApi() const { data } = useGraphql({ queryPrefix: 'subsquid', queryName: chainsSupportingOffers.includes(urlPrefix.value) @@ -24,7 +25,7 @@ export const useCollectionDetails = ({ collectionId }) => { }) const stats = ref({}) - watch(data, () => { + watch(data, async () => { if (data.value?.stats) { const uniqueOwnerCount = [ ...new Set(data.value.stats.base.map((item) => item.currentOwner)), @@ -47,8 +48,14 @@ export const useCollectionDetails = ({ collectionId }) => { }) const listedNfts = data.value.stats.listed + const api = await apiInstance.value + const supply = await api.query.nfts.collectionConfigOf(collectionId) + const supplyString = supply.toString() + const supplyJsonParse = JSON.parse(supplyString) + const getTotalSupply = supplyJsonParse.maxSupply || 'Unlimited' stats.value = { + maxSupply: getTotalSupply, listedCount: data.value.stats.listed.length, collectionLength: data.value.stats.base.length, collectionFloorPrice: From bb69f11b78b1c67293e3ccf52341962245614369 Mon Sep 17 00:00:00 2001 From: AshutoshSingh00001 Date: Sat, 2 Dec 2023 00:06:34 +0530 Subject: [PATCH 2/3] totalSupplyonAssetHub --- components/collection/CollectionInfo.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/collection/CollectionInfo.vue b/components/collection/CollectionInfo.vue index 4ba47f07c9..d1bd9a1b75 100644 --- a/components/collection/CollectionInfo.vue +++ b/components/collection/CollectionInfo.vue @@ -34,7 +34,10 @@ :value="stats.uniqueOwners" />
- + chain.value === route.params.prefix) ?.text, ) +const { isAssetHub } = useIsChain(urlPrefix) const address = computed(() => collectionInfo.value?.currentOwner) const seeAllDescription = ref(false) const DESCRIPTION_MAX_LENGTH = 210 From 18f04a9dff48644ebdd4153ac92eea8ad7a4b547 Mon Sep 17 00:00:00 2001 From: AshutoshSingh00001 Date: Sun, 3 Dec 2023 02:26:02 +0530 Subject: [PATCH 3/3] Fix_JSON.parse --- components/collection/utils/useCollectionDetails.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/collection/utils/useCollectionDetails.ts b/components/collection/utils/useCollectionDetails.ts index 86cd56fc54..167bb45169 100644 --- a/components/collection/utils/useCollectionDetails.ts +++ b/components/collection/utils/useCollectionDetails.ts @@ -50,9 +50,15 @@ export const useCollectionDetails = ({ collectionId }) => { const listedNfts = data.value.stats.listed const api = await apiInstance.value const supply = await api.query.nfts.collectionConfigOf(collectionId) + + // Check if supply string is not empty before parsing const supplyString = supply.toString() - const supplyJsonParse = JSON.parse(supplyString) - const getTotalSupply = supplyJsonParse.maxSupply || 'Unlimited' + const supplyJsonParse = supplyString ? JSON.parse(supplyString) : null + + // Check if supplyJsonParse is not null before accessing properties + const getTotalSupply = supplyJsonParse + ? supplyJsonParse.maxSupply || 'Unlimited' + : 'Unlimited' stats.value = { maxSupply: getTotalSupply,