@@ -17,18 +17,18 @@ export { type NativeTokenBalance, type TokenBalance }
17
17
const defaultPage = { page : 1 , pageSize : 10 , more : false }
18
18
19
19
// Type guard for native token balance
20
- function isNativeToken ( token : TokenBalance | NativeTokenBalance ) : boolean {
20
+ function isNativeToken ( token : TokenBalance | NativeTokenBalance ) : token is NativeTokenBalance {
21
21
if ( 'contractAddress' in token ) {
22
22
return false
23
23
}
24
24
return true
25
25
}
26
26
27
27
export function useTokenBalances ( address : Address . Address ) : {
28
- tokenBalancesData : any // TODO: Add proper type
28
+ tokenBalancesData : GetTokenBalancesSummaryReturn | undefined
29
29
isLoadingBalances : boolean
30
30
balanceError : Error | null
31
- sortedTokens : any [ ] // TODO: Add proper type
31
+ sortedTokens : ( TokenBalance | NativeTokenBalance ) [ ]
32
32
} {
33
33
const indexerClient = useIndexerGatewayClient ( )
34
34
@@ -58,11 +58,10 @@ export function useTokenBalances(address: Address.Address): {
58
58
} ,
59
59
} )
60
60
61
- // Transform the raw gateway response to match GetTokenBalancesSummaryReturn
62
61
return {
63
62
page : summaryFromGateway . page ,
64
- balances : summaryFromGateway . balances . flatMap ( ( b : any ) => b . results ) ,
65
- nativeBalances : summaryFromGateway . nativeBalances . flatMap ( ( b : any ) => b . results ) ,
63
+ balances : summaryFromGateway . balances . flatMap ( ( b ) => b . results ) ,
64
+ nativeBalances : summaryFromGateway . nativeBalances . flatMap ( ( b ) => b . results ) ,
66
65
}
67
66
} catch ( error ) {
68
67
console . error ( 'Failed to fetch token balances:' , error )
@@ -79,16 +78,11 @@ export function useTokenBalances(address: Address.Address): {
79
78
} )
80
79
81
80
const sortedTokens = useMemo ( ( ) => {
82
- if ( ! tokenBalancesData ?. balances ) {
81
+ if ( ! tokenBalancesData ) {
83
82
return [ ]
84
83
}
85
84
86
- // Flatten both native and token balances
87
- const nativeBalances = tokenBalancesData . nativeBalances . flatMap (
88
- ( b : any ) => b . results , // TODO: Add proper type
89
- )
90
- const tokenBalances = tokenBalancesData . balances . flatMap ( ( b : any ) => b . results ) // TODO: Add proper type
91
- const balances = [ ...nativeBalances , ...tokenBalances ]
85
+ const balances = [ ...tokenBalancesData . nativeBalances , ...tokenBalancesData . balances ]
92
86
93
87
return [ ...balances ]
94
88
. filter ( ( token ) => {
0 commit comments