@@ -61,17 +61,26 @@ const createUserBalancesSlice = (
6161 sliceState . setStateByKey ( 'loading' , true )
6262
6363 // This gets multicall batched by Wagmi and Viem internally
64- const balances = await Promise . all (
64+ const balances = await Promise . allSettled (
6565 filteredBadTokens . map ( ( token ) =>
6666 fetchTokenBalance ( config , {
6767 chainId,
6868 userAddress : signerAddress ,
6969 tokenAddress : token as Address ,
70- } ) . then ( ( balance ) => [ token , balance ] ) ,
70+ } ) . then ( ( balance ) => [ token , balance ] as const ) ,
7171 ) ,
7272 )
7373
74- const userBalancesMapper = Object . fromEntries ( balances )
74+ balances . forEach ( ( result , index ) => {
75+ if ( result . status === 'rejected' ) {
76+ console . warn ( `Failed to fetch balance for token ${ filteredBadTokens [ index ] } :` , result . reason )
77+ }
78+ } )
79+
80+ const userBalancesMapper = Object . fromEntries (
81+ balances . filter ( ( x ) => x . status === 'fulfilled' ) . map ( ( x ) => x . value ) ,
82+ )
83+
7584 sliceState . setStateByKeys ( {
7685 userBalancesMapper : { ...storedUserBalancesMapper , ...userBalancesMapper } ,
7786 loading : false ,
0 commit comments