Skip to content

Commit

Permalink
[TOOL-3581] Dashboard: Fix project overview page crashing because of …
Browse files Browse the repository at this point in the history
…ContractDistributionCard
  • Loading branch information
MananTank committed Mar 3, 2025
1 parent cbc0eff commit 6f1293b
Showing 1 changed file with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function ChainDistributionCard({ data }: { data: TransactionStats[] }) {
async function ContractDistributionCard({
data,
}: { data: TransactionStats[] }) {
const reducedData = await Promise.all(
const _reducedData = await Promise.all(
Object.entries(
data
.filter((d) => d.contractAddress)
Expand All @@ -83,25 +83,36 @@ async function ContractDistributionCard({
.sort((a, b) => b[1] - a[1])
.slice(0, 10) // only top ten
.map(async ([key, value]) => {
const [chainId, contractAddress] = key.split(":");
// eslint-disable-next-line no-restricted-syntax
const chain = defineChain(Number(chainId));
const chainMeta = await getChainMetadata(chain).catch(() => undefined);
const contractData = await fetchDashboardContractMetadata(
getContract({
chain,
address: contractAddress as string, // we filter above
client: getThirdwebClient(),
}),
).catch(() => undefined);
return {
label: `${contractData?.name} (${chainMeta?.slug || chainId})`,
link: `/${chainId}/${contractAddress}`,
value,
};
try {
const [chainId, contractAddress] = key.split(":");
if (Number(chainId) === 0) {
return undefined;
}
// eslint-disable-next-line no-restricted-syntax
const chain = defineChain(Number(chainId));
const chainMeta = await getChainMetadata(chain).catch(
() => undefined,
);
const contractData = await fetchDashboardContractMetadata(
getContract({
chain,
address: contractAddress as string, // we filter above
client: getThirdwebClient(),
}),
).catch(() => undefined);
return {
label: `${contractData?.name} (${chainMeta?.slug || chainId})`,
link: `/${chainId}/${contractAddress}`,
value,
};
} catch {
return undefined;
}
}),
);

const reducedData = _reducedData.filter((d) => !!d);

const aggregateFn = () =>
new Set(
data
Expand Down

0 comments on commit 6f1293b

Please sign in to comment.