Skip to content

Commit

Permalink
Remove from NFT minting dapp template due to inefficient indexer query (
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan authored Oct 24, 2024
1 parent 4f0bcc2 commit 5e572b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the create-aptos-dapp tool will be captured in this file.

# Unreleased

- Remove `uniqueHolders` from NFT minting dapp template due to inefficient indexer query

# 0.0.35 (2024-10-23)

- Use Aptos Learn for create-aptos-dapp docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ interface MintQueryResult {
interface MintData {
maxSupply: number;
totalMinted: number;
uniqueHolders: number;
userMintBalance: number;
collection: Collection;
startDate: Date;
Expand Down Expand Up @@ -90,13 +89,7 @@ export function useGetCollectionData(collection_address: string = COLLECTION_ADD
cdn_image_uri
}
}
current_collection_ownership_v2_view_aggregate(
where: { collection_id: { _eq: $collection_id } }
) {
aggregate {
count(distinct: true, columns: owner_address)
}
}
}`,
},
});
Expand All @@ -105,12 +98,12 @@ export function useGetCollectionData(collection_address: string = COLLECTION_ADD
if (!collection) return null;

const mintStageRes = await getActiveOrNextMintStage({ collection_address });

// Only return collection data if no mint stage is found
if (mintStageRes.length === 0) {
return {
maxSupply: collection.max_supply ?? 0,
totalMinted: collection.current_supply ?? 0,
uniqueHolders: res.current_collection_ownership_v2_view_aggregate.aggregate?.count ?? 0,
userMintBalance: 0,
collection,
endDate: new Date(),
Expand All @@ -134,7 +127,6 @@ export function useGetCollectionData(collection_address: string = COLLECTION_ADD
return {
maxSupply: collection.max_supply ?? 0,
totalMinted: collection.current_supply ?? 0,
uniqueHolders: res.current_collection_ownership_v2_view_aggregate.aggregate?.count ?? 0,
userMintBalance,
collection,
endDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ interface StatsSectionProps {}

export const StatsSection: React.FC<StatsSectionProps> = () => {
const { data } = useGetCollectionData();
const { maxSupply = 0, totalMinted = 0, uniqueHolders = 0 } = data ?? {};
const { maxSupply = 0, totalMinted = 0 } = data ?? {};

return (
<section className="stats-container px-4 max-w-screen-xl mx-auto w-full">
<ul className="flex flex-col md:flex-row gap-6">
{[
{ title: "Created NFTs", value: maxSupply },
{ title: "Total Minted", value: totalMinted },
{ title: "Unique Holders", value: uniqueHolders },
].map(({ title, value }) => (
<li className="basis-1/3" key={title + " " + value}>
<li className="basis-1/2" key={title + " " + value}>
<Card className="py-2 px-4" shadow="md">
<p className="label-sm">{title}</p>
<p className="heading-sm">{clampNumber(value)}</p>
Expand Down

0 comments on commit 5e572b9

Please sign in to comment.