File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
packages/thirdweb/src/react/core/hooks Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Fix native token fallback when insight query fails
Original file line number Diff line number Diff line change @@ -70,10 +70,10 @@ export function usePaymentMethods(options: {
7070 getInsightEnabledChainIds ( ) ,
7171 ] ) ;
7272
73- // 2. Check insight availability for all chains
74- const insightEnabledChains = allChains . filter ( ( c ) =>
75- insightEnabledChainIds . includes ( c . chainId ) ,
76- ) ;
73+ // 2. Check insight availability for all chains, limited to 50 chains (FIXME move this logic to the backend)
74+ const insightEnabledChains = allChains
75+ . filter ( ( c ) => insightEnabledChainIds . includes ( c . chainId ) )
76+ . slice ( 0 , 50 ) ;
7777
7878 // 3. Get all owned tokens for insight-enabled chains
7979 let allOwnedTokens : Array < {
@@ -119,6 +119,25 @@ export function usePaymentMethods(options: {
119119 . filter ( ( result ) => result . status === "fulfilled" )
120120 . map ( ( result ) => result . value )
121121 . filter ( ( balance ) => balance . value > 0n ) ;
122+
123+ // Convert to our format
124+ const tokensWithBalance = batch . map ( ( b ) => ( {
125+ balance : b . value ,
126+ originToken : {
127+ address : b . tokenAddress ,
128+ chainId : b . chainId ,
129+ decimals : b . decimals ,
130+ iconUri : "" ,
131+ name : b . name ,
132+ prices : {
133+ USD : 0 ,
134+ } ,
135+ symbol : b . symbol ,
136+ } as Token ,
137+ } ) ) ;
138+
139+ allOwnedTokens = [ ...allOwnedTokens , ...tokensWithBalance ] ;
140+ break ;
122141 }
123142
124143 if ( batch . length === 0 ) {
You can’t perform that action at this time.
0 commit comments