|
1 | 1 | import { ECoinSelectPreference, EProtocol, TServer } from 'beignet'; |
2 | 2 | import cloneDeep from 'lodash/cloneDeep'; |
| 3 | +import { getCurrencies } from 'react-native-localize'; |
3 | 4 |
|
4 | 5 | import { |
| 6 | + __E2E__, |
5 | 7 | __ELECTRUM_REGTEST_HOST__, |
6 | 8 | __ELECTRUM_REGTEST_PROTO__, |
7 | 9 | __ELECTRUM_REGTEST_SSL_PORT__, |
8 | 10 | __ELECTRUM_REGTEST_TCP_PORT__, |
9 | 11 | __WEB_RELAY__, |
10 | 12 | } from '../../constants/env'; |
| 13 | +import { currencies } from '../../utils/exchange-rate/currencies'; |
11 | 14 | import { EAvailableNetwork } from '../../utils/networks'; |
12 | 15 | import { TSettings } from '../slices/settings'; |
13 | 16 | import { ETransactionSpeed } from '../types/settings'; |
14 | 17 | import { EDenomination, EUnit } from '../types/wallet'; |
15 | 18 |
|
| 19 | +const getDefaultCurrency = (): string => { |
| 20 | + if (__E2E__) { |
| 21 | + return 'USD'; |
| 22 | + } |
| 23 | + |
| 24 | + const localCurrencies = getCurrencies(); |
| 25 | + |
| 26 | + // Find the first currency that matches the user's preference |
| 27 | + const preferredCurrency = localCurrencies.find((currency) => { |
| 28 | + return currencies.includes(currency); |
| 29 | + }); |
| 30 | + |
| 31 | + return preferredCurrency ?? 'USD'; |
| 32 | +}; |
| 33 | + |
16 | 34 | export const defaultElectrumPeer: Record<EAvailableNetwork, TServer[]> = { |
17 | 35 | bitcoin: [ |
18 | 36 | { |
@@ -82,7 +100,7 @@ export const initialSettingsState: TSettings = { |
82 | 100 | theme: 'dark', |
83 | 101 | unit: EUnit.BTC, |
84 | 102 | denomination: EDenomination.modern, |
85 | | - selectedCurrency: 'USD', |
| 103 | + selectedCurrency: getDefaultCurrency(), |
86 | 104 | selectedLanguage: 'english', |
87 | 105 | customElectrumPeers: defaultElectrumPeer, |
88 | 106 | rapidGossipSyncUrl: 'https://rgs.blocktank.to/snapshot/', |
|
0 commit comments