diff --git a/.changeset/shaggy-tables-care.md b/.changeset/shaggy-tables-care.md new file mode 100644 index 00000000000..f67fe36eabb --- /dev/null +++ b/.changeset/shaggy-tables-care.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Fallback to insight response if RPC request fails in ERC721 & ERC1155 `getNFTs` extension diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/marketplace-table.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/marketplace-table.tsx index 8441a7bf64d..1cc24abf148 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/marketplace-table.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/marketplace-table.tsx @@ -237,7 +237,7 @@ export const MarketplaceTable: React.FC<MarketplaceTableProps> = ({ </Th> ))} {/* // Need to add an empty header for the drawer button */} - <Th border="none" /> + <Th border="none" key="drawer" /> </Tr> ))} </Thead> diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx index 8ac468e2325..ca42ff04ea3 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/table.tsx @@ -278,7 +278,7 @@ export const NFTGetAllTable: React.FC<ContractOverviewNFTGetAllProps> = ({ </Th> ))} {/* Need to add an empty header for the drawer button */} - <Th border="none" /> + <Th border="none" key="drawer" /> </Tr> ))} </Thead> diff --git a/packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts b/packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts index 7f4280e452f..dcf7715d39c 100644 --- a/packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts +++ b/packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts @@ -84,8 +84,14 @@ async function getNFTsFromInsight( Math.max(0, Number(supply) - currentOffset), ); if (result.length < expectedResultLength) { - // fresh contracts might be delayed in indexing, so we fallback to RPC - return getNFTsFromRPC(options); + try { + // fresh contracts might be delayed in indexing, so we fallback to RPC + // must use await here + return await getNFTsFromRPC(options); + } catch { + // if RPC fails, we return the result from insight + return result; + } } return result; } diff --git a/packages/thirdweb/src/extensions/erc721/read/getNFTs.ts b/packages/thirdweb/src/extensions/erc721/read/getNFTs.ts index 611a01b9642..dd6a8c26558 100644 --- a/packages/thirdweb/src/extensions/erc721/read/getNFTs.ts +++ b/packages/thirdweb/src/extensions/erc721/read/getNFTs.ts @@ -132,8 +132,14 @@ async function getNFTsFromInsight( ), ); if (result.length < expectedResultLength) { - // fresh contracts might be delayed in indexing, so we fallback to RPC - return getNFTsFromRPC(options); + try { + // fresh contracts might be delayed in indexing, so we fallback to RPC + // must use await here + return await getNFTsFromRPC(options); + } catch { + // if RPC fails, we return the result from insight + return result; + } } return result;