@@ -4,15 +4,14 @@ import { setTokenNetworkFilter } from '../../../../../store/actions';
4
4
import {
5
5
getCurrentChainId ,
6
6
getCurrentNetwork ,
7
- getIsTestnet ,
8
7
getPreferences ,
9
8
getSelectedInternalAccount ,
10
9
getShouldHideZeroBalanceTokens ,
11
10
getNetworkConfigurationsByChainId ,
11
+ getChainIdsToPoll ,
12
12
} from '../../../../../selectors' ;
13
13
import { useI18nContext } from '../../../../../hooks/useI18nContext' ;
14
14
import { SelectableListItem } from '../sort-control/sort-control' ;
15
- import { useAccountTotalFiatBalance } from '../../../../../hooks/useAccountTotalFiatBalance' ;
16
15
import { Text } from '../../../../component-library/text/text' ;
17
16
import {
18
17
Display ,
@@ -24,6 +23,8 @@ import { Box } from '../../../../component-library/box/box';
24
23
import { AvatarNetwork } from '../../../../component-library' ;
25
24
import UserPreferencedCurrencyDisplay from '../../../user-preferenced-currency-display' ;
26
25
import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP } from '../../../../../../shared/constants/network' ;
26
+ import { useGetFormattedTokensPerChain } from '../../../../../hooks/useGetFormattedTokensPerChain' ;
27
+ import { useAccountTotalCrossChainFiatBalance } from '../../../../../hooks/useAccountTotalCrossChainFiatBalance' ;
27
28
28
29
type SortControlProps = {
29
30
handleClose : ( ) => void ;
@@ -36,15 +37,35 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {
36
37
const selectedAccount = useSelector ( getSelectedInternalAccount ) ;
37
38
const currentNetwork = useSelector ( getCurrentNetwork ) ;
38
39
const allNetworks = useSelector ( getNetworkConfigurationsByChainId ) ;
39
- const isTestnet = useSelector ( getIsTestnet ) ;
40
- const { tokenNetworkFilter, showNativeTokenAsMainBalance } =
41
- useSelector ( getPreferences ) ;
40
+ const { tokenNetworkFilter } = useSelector ( getPreferences ) ;
42
41
const shouldHideZeroBalanceTokens = useSelector (
43
42
getShouldHideZeroBalanceTokens ,
44
43
) ;
45
-
44
+ const allChainIDs = useSelector ( getChainIdsToPoll ) ;
45
+ const { formattedTokensWithBalancesPerChain } = useGetFormattedTokensPerChain (
46
+ selectedAccount ,
47
+ shouldHideZeroBalanceTokens ,
48
+ true , // true to get formattedTokensWithBalancesPerChain for the current chain
49
+ allChainIDs ,
50
+ ) ;
46
51
const { totalFiatBalance : selectedAccountBalance } =
47
- useAccountTotalFiatBalance ( selectedAccount , shouldHideZeroBalanceTokens ) ;
52
+ useAccountTotalCrossChainFiatBalance (
53
+ selectedAccount ,
54
+ formattedTokensWithBalancesPerChain ,
55
+ ) ;
56
+
57
+ const { formattedTokensWithBalancesPerChain : formattedTokensForAllNetworks } =
58
+ useGetFormattedTokensPerChain (
59
+ selectedAccount ,
60
+ shouldHideZeroBalanceTokens ,
61
+ false , // false to get the value for all networks
62
+ allChainIDs ,
63
+ ) ;
64
+ const { totalFiatBalance : selectedAccountBalanceForAllNetworks } =
65
+ useAccountTotalCrossChainFiatBalance (
66
+ selectedAccount ,
67
+ formattedTokensForAllNetworks ,
68
+ ) ;
48
69
49
70
// TODO: fetch balances across networks
50
71
// const multiNetworkAccountBalance = useMultichainAccountBalance()
@@ -78,7 +99,15 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {
78
99
color = { TextColor . textDefault }
79
100
>
80
101
{ /* TODO: Should query cross chain account balance */ }
81
- $1,000.00
102
+
103
+ < UserPreferencedCurrencyDisplay
104
+ value = { selectedAccountBalanceForAllNetworks }
105
+ type = "PRIMARY"
106
+ ethNumberOfDecimals = { 4 }
107
+ hideTitle
108
+ showFiat
109
+ isAggregatedFiatOverviewBalance
110
+ />
82
111
</ Text >
83
112
</ Box >
84
113
< Box display = { Display . Flex } >
@@ -120,16 +149,19 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {
120
149
>
121
150
{ t ( 'currentNetwork' ) }
122
151
</ Text >
123
- < UserPreferencedCurrencyDisplay
124
- value = { selectedAccountBalance }
125
- type = "PRIMARY"
126
- ethNumberOfDecimals = { 4 }
127
- hideTitle
128
- shouldCheckShowNativeToken
129
- isAggregatedFiatOverviewBalance = {
130
- ! showNativeTokenAsMainBalance && ! isTestnet
131
- }
132
- />
152
+ < Text
153
+ variant = { TextVariant . bodySmMedium }
154
+ color = { TextColor . textAlternative }
155
+ >
156
+ < UserPreferencedCurrencyDisplay
157
+ value = { selectedAccountBalance }
158
+ type = "PRIMARY"
159
+ ethNumberOfDecimals = { 4 }
160
+ hideTitle
161
+ showFiat
162
+ isAggregatedFiatOverviewBalance
163
+ />
164
+ </ Text >
133
165
</ Box >
134
166
< AvatarNetwork
135
167
name = "Current"
0 commit comments