Skip to content

Commit 5525a0e

Browse files
authored
Filter invalid auction listings on getAllAuctions (#2913)
1 parent 35acbcd commit 5525a0e

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

.changeset/grumpy-colts-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Filter invalid auctions in getAllAuctions

packages/thirdweb/src/extensions/erc20/read/getCurrencyMetadata.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ export async function getCurrencyMetadata(
3636
};
3737
}
3838

39-
const [name_, symbol_, decimals_] = await Promise.all([
40-
name(options),
41-
symbol(options),
42-
decimals(options),
43-
]);
44-
return {
45-
name: name_,
46-
symbol: symbol_,
47-
decimals: decimals_,
48-
};
39+
try {
40+
const [name_, symbol_, decimals_] = await Promise.all([
41+
name(options),
42+
symbol(options),
43+
decimals(options),
44+
]);
45+
46+
return {
47+
name: name_,
48+
symbol: symbol_,
49+
decimals: decimals_,
50+
};
51+
} catch (e) {
52+
throw new Error("Invalid currency token");
53+
}
4954
}

packages/thirdweb/src/extensions/marketplace/english-auctions/read/getAllAuctions.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ export async function getAllAuctions(
6767
}),
6868
]);
6969

70-
return await Promise.all(
71-
rawAuctions.map((rawAuction) =>
72-
mapEnglishAuction({
73-
contract: options.contract,
74-
latestBlock,
75-
rawAuction,
76-
}),
77-
),
78-
);
70+
const auctions = (
71+
await Promise.all(
72+
rawAuctions.map((rawAuction) =>
73+
mapEnglishAuction({
74+
contract: options.contract,
75+
latestBlock,
76+
rawAuction,
77+
}).catch(() => null),
78+
),
79+
)
80+
).filter((auction) => auction !== null);
81+
82+
return auctions as EnglishAuction[]; // TODO: Fix when TS 5.5 is out
7983
}

0 commit comments

Comments
 (0)