Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-rings-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix native token fallback when insight query fails
19 changes: 19 additions & 0 deletions packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@
.filter((result) => result.status === "fulfilled")
.map((result) => result.value)
.filter((balance) => balance.value > 0n);

// Convert to our format
const tokensWithBalance = batch.map((b) => ({
balance: b.value,
originToken: {
address: b.tokenAddress,
chainId: b.chainId,
decimals: b.decimals,
iconUri: "",
name: b.name,
prices: {
USD: 0,
},
symbol: b.symbol,
} as Token,
}));

Check warning on line 137 in packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts#L124-L137

Added lines #L124 - L137 were not covered by tests

allOwnedTokens = [...allOwnedTokens, ...tokensWithBalance];
break;

Check warning on line 140 in packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts#L139-L140

Added lines #L139 - L140 were not covered by tests
}

if (batch.length === 0) {
Expand Down
Loading