File tree Expand file tree Collapse file tree
packages/checkout/sdk/src/balances Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -238,20 +238,19 @@ export const getBalances = async (
238238 } ) ;
239239
240240 const balanceResults = await Promise . allSettled ( allBalancePromises ) ;
241- const balances = ( balanceResults . filter (
242- ( result ) => result . status === 'fulfilled' ,
243- ) as PromiseFulfilledResult < GetBalanceResult > [ ]
244- ) . map ( ( result ) => {
245- const resp = result ;
246- const { token } = resp . value ;
247- // For some reason isNativeToken always returns undefined.
248- // We have spent way too much time figuring out why this is happening.
249- // That we have given up -- keep it as it is for now.
250- if ( ! token . address || isMatchingAddress ( token . address , NATIVE ) ) resp . value . token . address = NATIVE ;
251- return resp . value ;
252- } ) ;
253241
254- return { balances } ;
242+ return balanceResults . reduce ( ( acc , resp ) => {
243+ if ( resp . status !== 'fulfilled' || resp . value . balance === 0n ) return acc ;
244+
245+ const { value : result } = resp ;
246+
247+ if ( ! result . token . address || isMatchingAddress ( result . token . address , NATIVE ) ) {
248+ result . token . address = NATIVE ;
249+ }
250+
251+ acc . balances . push ( result ) ;
252+ return acc ;
253+ } , { balances : new Array < GetBalanceResult > ( ) } ) ;
255254} ;
256255
257256const getTokenBalances = async (
You can’t perform that action at this time.
0 commit comments