Skip to content

Commit a07a7ff

Browse files
stephancilldavidfurlong
authored andcommitted
fix/miniapp: nft collection stats should not be optional
1 parent 489b7af commit a07a7ff

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

examples/api/src/app/api/open-graph/lib/util.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ export async function fetchNFTMetadata({
121121
`https://api.opensea.io/api/v1/collection/${collectionSlug}/stats`,
122122
authOptions
123123
);
124-
let collectionStats: any = {};
125-
if (collectionStatsResponse.ok) {
126-
collectionStats = await collectionStatsResponse.json();
127-
}
124+
// Collection stats should exist if the collection exists
125+
const collectionStats = await collectionStatsResponse.json();
128126

129127
const fcUser = await fetchUserData(collectionData.owner);
130128

@@ -150,8 +148,8 @@ export async function fetchNFTMetadata({
150148
id: caip19Uri,
151149
name: collectionData.name,
152150
description: collectionData.description,
153-
itemCount: collectionStats?.stats.count,
154-
ownerCount: collectionStats?.stats.num_owners,
151+
itemCount: collectionStats.stats.count,
152+
ownerCount: collectionStats.stats.num_owners,
155153
imageUrl: image,
156154
mintUrl: mintUrl || collectionData.opensea_url,
157155
openSeaUrl: collectionData.opensea_url,

packages/core/src/embeds.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export type NFTMetadata = {
2929
id: string;
3030
name: string;
3131
description: string;
32-
itemCount?: number;
33-
ownerCount?: number;
32+
itemCount: number;
33+
ownerCount: number;
3434
imageUrl: string;
3535
mintUrl: string;
3636
openSeaUrl?: string;

0 commit comments

Comments
 (0)