diff --git a/suite-common/formatters/src/utils/convert.ts b/suite-common/formatters/src/utils/convert.ts index d20cca3f7f71..0c3b3a37245c 100644 --- a/suite-common/formatters/src/utils/convert.ts +++ b/suite-common/formatters/src/utils/convert.ts @@ -1,4 +1,4 @@ -import { networks, NetworkSymbol } from '@suite-common/wallet-config'; +import { getNetwork, type NetworkSymbol } from '@suite-common/wallet-config'; import { amountToSmallestUnit, formatNetworkAmount, @@ -9,14 +9,14 @@ import { BigNumber } from '@trezor/utils/src/bigNumber'; type ConvertInput = { amount: string | null; - networkSymbol: NetworkSymbol; + symbol: NetworkSymbol; isAmountInSats?: boolean; rate?: number; }; export const convertCryptoToFiatAmount = ({ amount, - networkSymbol, + symbol, isAmountInSats = true, rate, }: ConvertInput): string | null => { @@ -24,14 +24,14 @@ export const convertCryptoToFiatAmount = ({ return null; } - const networkAmount = isAmountInSats ? formatNetworkAmount(amount, networkSymbol) : amount; + const networkAmount = isAmountInSats ? formatNetworkAmount(amount, symbol) : amount; return toFiatCurrency(networkAmount, rate); }; export const convertFiatToCryptoAmount = ({ amount, - networkSymbol, + symbol, isAmountInSats = true, rate, }: ConvertInput): string | null => { @@ -39,7 +39,7 @@ export const convertFiatToCryptoAmount = ({ return null; } - const { decimals } = networks[networkSymbol]; + const { decimals } = getNetwork(symbol); const cryptoAmount = fromFiatCurrency(amount, decimals, rate); if (!cryptoAmount || !isAmountInSats) { diff --git a/suite-common/formatters/src/utils/tests/convert.test.ts b/suite-common/formatters/src/utils/tests/convert.test.ts index eed65e0f7b53..e459647ec5e1 100644 --- a/suite-common/formatters/src/utils/tests/convert.test.ts +++ b/suite-common/formatters/src/utils/tests/convert.test.ts @@ -21,7 +21,7 @@ describe('convertCryptoToFiatAmount', () => { expect( convertCryptoToFiatAmount({ amount, - networkSymbol: 'btc', + symbol: 'btc', isAmountInSats, rate: 22666, }), @@ -47,7 +47,7 @@ describe('convertFiatToCryptoAmount', () => { expect( convertFiatToCryptoAmount({ amount, - networkSymbol: 'btc', + symbol: 'btc', isAmountInSats, rate: 22666, }), diff --git a/suite-common/token-definitions/src/tokenDefinitionsMiddleware.ts b/suite-common/token-definitions/src/tokenDefinitionsMiddleware.ts index c98f926252b8..7e03f16b85b9 100644 --- a/suite-common/token-definitions/src/tokenDefinitionsMiddleware.ts +++ b/suite-common/token-definitions/src/tokenDefinitionsMiddleware.ts @@ -12,16 +12,16 @@ export const prepareTokenDefinitionsMiddleware = createMiddlewareWithExtraDeps( next(action); if (action.type === CHANGE_NETWORKS) { - action.payload.forEach((networkSymbol: NetworkSymbol) => { - const tokenDefinitions = selectNetworkTokenDefinitions(getState(), networkSymbol); + action.payload.forEach((symbol: NetworkSymbol) => { + const tokenDefinitions = selectNetworkTokenDefinitions(getState(), symbol); if (!tokenDefinitions) { - const definitionTypes = getSupportedDefinitionTypes(networkSymbol); + const definitionTypes = getSupportedDefinitionTypes(symbol); definitionTypes.forEach(type => { dispatch( getTokenDefinitionThunk({ - networkSymbol, + symbol, type, }), ); diff --git a/suite-common/token-definitions/src/tokenDefinitionsReducer.ts b/suite-common/token-definitions/src/tokenDefinitionsReducer.ts index d0a8ef9d6f21..cc012d975a6a 100644 --- a/suite-common/token-definitions/src/tokenDefinitionsReducer.ts +++ b/suite-common/token-definitions/src/tokenDefinitionsReducer.ts @@ -11,10 +11,10 @@ export const prepareTokenDefinitionsReducer = createReducerWithExtraDeps( (builder, extra) => { builder .addCase(getTokenDefinitionThunk.pending, (state, action) => { - const { networkSymbol } = action.meta.arg; + const { symbol } = action.meta.arg; - if (!state[networkSymbol]) { - state[networkSymbol] = { + if (!state[symbol]) { + state[symbol] = { coin: { error: false, data: undefined, @@ -33,9 +33,9 @@ export const prepareTokenDefinitionsReducer = createReducerWithExtraDeps( } }) .addCase(getTokenDefinitionThunk.fulfilled, (state, action) => { - const { networkSymbol, type } = action.meta.arg; + const { symbol, type } = action.meta.arg; - const definitions = state[networkSymbol]; + const definitions = state[symbol]; if (definitions) { definitions[type] = { @@ -48,9 +48,9 @@ export const prepareTokenDefinitionsReducer = createReducerWithExtraDeps( } }) .addCase(getTokenDefinitionThunk.rejected, (state, action) => { - const { networkSymbol, type } = action.meta.arg; + const { symbol, type } = action.meta.arg; - const definitions = state[networkSymbol]; + const definitions = state[symbol]; if (definitions) { definitions[type] = { diff --git a/suite-common/token-definitions/src/tokenDefinitionsThunks.ts b/suite-common/token-definitions/src/tokenDefinitionsThunks.ts index 2e851ed6fc38..8446c9497669 100644 --- a/suite-common/token-definitions/src/tokenDefinitionsThunks.ts +++ b/suite-common/token-definitions/src/tokenDefinitionsThunks.ts @@ -21,13 +21,13 @@ export const getTokenDefinitionThunk = createThunk( `${TOKEN_DEFINITIONS_MODULE}/getNftTokenDefinition`, async ( params: { - networkSymbol: NetworkSymbol; + symbol: NetworkSymbol; type: DefinitionType; }, { fulfillWithValue, rejectWithValue }, ) => { - const { networkSymbol, type } = params; - const coingeckoId = getCoingeckoId(networkSymbol); + const { symbol, type } = params; + const coingeckoId = getCoingeckoId(symbol); try { if (!coingeckoId) { @@ -86,10 +86,10 @@ export const initTokenDefinitionsThunk = createThunk( const enabledNetworks = extra.selectors.selectTokenDefinitionsEnabledNetworks(getState()); const promises = enabledNetworks - .map((networkSymbol: NetworkSymbol) => { - let definitionTypes = getSupportedDefinitionTypes(networkSymbol); + .map(symbol => { + let definitionTypes = getSupportedDefinitionTypes(symbol); - const tokenDefinitions = selectNetworkTokenDefinitions(getState(), networkSymbol); + const tokenDefinitions = selectNetworkTokenDefinitions(getState(), symbol); if (tokenDefinitions) { // Filter out definition types that have data or are in a loading state @@ -105,7 +105,7 @@ export const initTokenDefinitionsThunk = createThunk( return definitionTypes.map(type => dispatch( getTokenDefinitionThunk({ - networkSymbol, + symbol, type, }), ), diff --git a/suite-native/accounts/src/components/AccountsList/AccountsListItem.tsx b/suite-native/accounts/src/components/AccountsList/AccountsListItem.tsx index d9c7b367540b..d105dce6ba48 100644 --- a/suite-native/accounts/src/components/AccountsList/AccountsListItem.tsx +++ b/suite-native/accounts/src/components/AccountsList/AccountsListItem.tsx @@ -100,7 +100,7 @@ export const AccountsListItem = ({ showDivider={showDivider} onPress={handleOnPress} disabled={disabled} - icon={} + icon={} title={ shouldShowAccountLabel ? ( accountLabel @@ -125,7 +125,7 @@ export const AccountsListItem = ({ value={fiatBalance} /> ) : ( - + ) } secondaryValue={ diff --git a/suite-native/accounts/src/components/AccountsList/AccountsListStakingItem.tsx b/suite-native/accounts/src/components/AccountsList/AccountsListStakingItem.tsx index b524f70c1f1f..0388f0a780f6 100644 --- a/suite-native/accounts/src/components/AccountsList/AccountsListStakingItem.tsx +++ b/suite-native/accounts/src/components/AccountsList/AccountsListStakingItem.tsx @@ -31,7 +31,7 @@ export const AccountsListStakingItem = ({ mainValue={ } diff --git a/suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx b/suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx index 09500a56bd0b..59c906168681 100644 --- a/suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx +++ b/suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx @@ -36,11 +36,11 @@ export const AccountsListTokenItem = ({ isFirst={isFirst} isLast={isLast} onPress={onSelectAccount} - icon={} + icon={} title={getTokenName(token.name)} mainValue={ @@ -48,7 +48,7 @@ export const AccountsListTokenItem = ({ secondaryValue={ diff --git a/suite-native/accounts/src/components/SelectableNetworkItem.tsx b/suite-native/accounts/src/components/SelectableNetworkItem.tsx index 4a6cac000f2e..dc1310d9ff3d 100644 --- a/suite-native/accounts/src/components/SelectableNetworkItem.tsx +++ b/suite-native/accounts/src/components/SelectableNetworkItem.tsx @@ -46,7 +46,7 @@ export const SelectableNetworkItem = ({ symbol, onPress, rightIcon }: Selectable testID={`@onboarding/select-coin/${symbol}`} > - + {networkName} diff --git a/suite-native/assets/src/components/AssetItem.tsx b/suite-native/assets/src/components/AssetItem.tsx index 2d9ab407bf67..fa5ce7315c8a 100644 --- a/suite-native/assets/src/components/AssetItem.tsx +++ b/suite-native/assets/src/components/AssetItem.tsx @@ -59,10 +59,10 @@ const CryptoAmount = React.memo(({ network }: { network: NetworkSymbol }) => { ); }); -const FiatAmount = React.memo(({ network }: { network: NetworkSymbol }) => { - const fiatValue = useSelector((state: AssetsRootState) => selectAssetFiatValue(state, network)); +const FiatAmount = React.memo(({ symbol }: { symbol: NetworkSymbol }) => { + const fiatValue = useSelector((state: AssetsRootState) => selectAssetFiatValue(state, symbol)); - return ; + return ; }); const PercentageIcon = React.memo(({ network }: { network: NetworkSymbol }) => { @@ -129,7 +129,7 @@ export const AssetItem = React.memo(({ cryptoCurrencySymbol, onPress }: AssetIte )} } - mainValue={} + mainValue={} secondaryValue={} /> ); diff --git a/suite-native/atoms/src/RoundedIcon.tsx b/suite-native/atoms/src/RoundedIcon.tsx index 0e591a9c45a3..549ffcdfe83d 100644 --- a/suite-native/atoms/src/RoundedIcon.tsx +++ b/suite-native/atoms/src/RoundedIcon.tsx @@ -10,7 +10,7 @@ import { Box, BoxProps } from './Box'; export type RoundedIconProps = { name?: IconName; - networkSymbol?: NetworkSymbol; + symbol?: NetworkSymbol; contractAddress?: TokenAddress; color?: Color; iconSize?: IconSize; @@ -40,7 +40,7 @@ const iconContainerStyle = prepareNativeStyle<{ backgroundColor?: Color; contain export const RoundedIcon = ({ name, - networkSymbol, + symbol, contractAddress, color, iconSize, @@ -59,9 +59,7 @@ export const RoundedIcon = ({ {name && name in icons ? ( ) : ( - networkSymbol && ( - - ) + symbol && )} ); diff --git a/suite-native/formatters/src/components/CoinAmountFormatter.tsx b/suite-native/formatters/src/components/CoinAmountFormatter.tsx index 1c2cb3d64121..65d06cb49254 100644 --- a/suite-native/formatters/src/components/CoinAmountFormatter.tsx +++ b/suite-native/formatters/src/components/CoinAmountFormatter.tsx @@ -51,7 +51,7 @@ export const CoinAmountFormatter = ({ ); diff --git a/suite-native/formatters/src/components/CoinToFiatAmountFormatter.tsx b/suite-native/formatters/src/components/CoinToFiatAmountFormatter.tsx index 083ae5e6f03a..8bc88246ce9b 100644 --- a/suite-native/formatters/src/components/CoinToFiatAmountFormatter.tsx +++ b/suite-native/formatters/src/components/CoinToFiatAmountFormatter.tsx @@ -26,7 +26,7 @@ export const CoinToFiatAmountFormatter = ({ decimals, ...restProps }: CoinToFiatAmountFormatterProps) => { - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -34,7 +34,7 @@ export const CoinToFiatAmountFormatter = ({ selectAccountTokenInfo(state, accountKey, tokenContract), ); - if (!networkSymbol) { + if (!symbol) { return null; } @@ -43,12 +43,12 @@ export const CoinToFiatAmountFormatter = ({ ); } - return ; + return ; }; diff --git a/suite-native/formatters/src/components/CryptoToFiatAmountFormatter.tsx b/suite-native/formatters/src/components/CryptoToFiatAmountFormatter.tsx index 7d60264379b4..6fd2ab8824c7 100644 --- a/suite-native/formatters/src/components/CryptoToFiatAmountFormatter.tsx +++ b/suite-native/formatters/src/components/CryptoToFiatAmountFormatter.tsx @@ -7,7 +7,7 @@ import { FiatAmountFormatter } from './FiatAmountFormatter'; type CryptoToFiatAmountFormatterProps = FormatterProps & TextProps & { - network: NetworkSymbol; + symbol: NetworkSymbol; historicRate?: number; useHistoricRate?: boolean; isBalance?: boolean; @@ -17,7 +17,7 @@ type CryptoToFiatAmountFormatterProps = FormatterProps & export const CryptoToFiatAmountFormatter = ({ value, - network, + symbol, historicRate, useHistoricRate, isBalance = false, @@ -25,7 +25,7 @@ export const CryptoToFiatAmountFormatter = ({ ...otherProps }: CryptoToFiatAmountFormatterProps) => { const fiatValue = useFiatFromCryptoValue({ - network, + symbol, historicRate, useHistoricRate, isBalance, @@ -34,7 +34,7 @@ export const CryptoToFiatAmountFormatter = ({ return ( & TextProps & { - network?: NetworkSymbol; + symbol?: NetworkSymbol; isDiscreetText?: boolean; isForcedDiscreetMode?: boolean; isLoading?: boolean; @@ -20,7 +20,7 @@ type FiatAmountFormatterProps = FormatterProps & export const FiatAmountFormatter = React.memo( ({ - network, + symbol, value, isDiscreetText = true, isLoading = false, @@ -28,7 +28,7 @@ export const FiatAmountFormatter = React.memo( }: FiatAmountFormatterProps) => { const { FiatAmountFormatter: formatter } = useFormatters(); - if (!!network && isTestnet(network)) { + if (!!symbol && isTestnet(symbol)) { return ; } if (isLoading || value === null) { diff --git a/suite-native/formatters/src/components/TokenAmountFormatter.tsx b/suite-native/formatters/src/components/TokenAmountFormatter.tsx index f6e29c9f1d36..ad34017f4efe 100644 --- a/suite-native/formatters/src/components/TokenAmountFormatter.tsx +++ b/suite-native/formatters/src/components/TokenAmountFormatter.tsx @@ -7,7 +7,7 @@ import { AmountText } from './AmountText'; import { convertTokenValueToDecimal } from '../utils'; type TokenAmountFormatterProps = { - symbol: TokenSymbol | null; + tokenSymbol: TokenSymbol | null; isDiscreetText?: boolean; decimals?: number; isForcedDiscreetMode?: boolean; @@ -16,7 +16,7 @@ type TokenAmountFormatterProps = { export const TokenAmountFormatter = ({ value, - symbol, + tokenSymbol, isDiscreetText = true, decimals = 0, variant = 'hint', @@ -25,7 +25,7 @@ export const TokenAmountFormatter = ({ }: TokenAmountFormatterProps) => { const decimalValue = convertTokenValueToDecimal(value, decimals); - const formattedValue = `${localizeNumber(decimalValue)} ${symbol}`; + const formattedValue = `${localizeNumber(decimalValue)} ${tokenSymbol}`; return ( { +}: UseConvertFiatToCryptoParams) => { + const symbolHelper = symbol ?? 'btc'; // handles passing the value to selectors const isAmountInSats = useSelector((state: SettingsSliceRootState) => - selectIsAmountInSats(state, networkSymbol), + selectIsAmountInSats(state, symbolHelper), ); + const fiatCurrencyCode = useSelector(selectFiatCurrencyCode); - const fiatRateKey = getFiatRateKey(networkSymbol, fiatCurrencyCode, tokenContract); + const fiatRateKey = getFiatRateKey(symbolHelper, fiatCurrencyCode, tokenContract); const currentRate = useSelector((state: FiatRatesRootState) => selectFiatRatesByFiatRateKey(state, fiatRateKey), ); const rate = useHistoricRate ? historicRate : currentRate?.rate; - const isTestnetCoin = isTestnet(networkSymbol); + const isTestnetCoin = isTestnet(symbolHelper); - if (!rate || currentRate?.error || isTestnetCoin) return null; + if (!rate || currentRate?.error || isTestnetCoin || !symbol) return null; return { convertFiatToCrypto: (amount: string) => convertFiatToCryptoAmount({ amount, - networkSymbol, + symbol, isAmountInSats, rate, }), convertCryptoToFiat: (amount: string) => convertCryptoToFiatAmount({ amount, - networkSymbol, + symbol, isAmountInSats, rate, }), diff --git a/suite-native/formatters/src/hooks/useFiatFromCryptoValue.ts b/suite-native/formatters/src/hooks/useFiatFromCryptoValue.ts index 35a3143b6bf8..976d4bf81ef9 100644 --- a/suite-native/formatters/src/hooks/useFiatFromCryptoValue.ts +++ b/suite-native/formatters/src/hooks/useFiatFromCryptoValue.ts @@ -11,7 +11,7 @@ import { convertTokenValueToDecimal } from '../utils'; type useFiatFromCryptoValueParams = { cryptoValue: string | null; - network: NetworkSymbol; + symbol: NetworkSymbol; tokenAddress?: TokenAddress; tokenDecimals?: number; historicRate?: number; @@ -21,7 +21,7 @@ type useFiatFromCryptoValueParams = { export const useFiatFromCryptoValue = ({ cryptoValue, - network, + symbol, tokenAddress, historicRate, useHistoricRate, @@ -29,14 +29,14 @@ export const useFiatFromCryptoValue = ({ tokenDecimals = 0, }: useFiatFromCryptoValueParams) => { const fiatCurrencyCode = useSelector(selectFiatCurrencyCode); - const fiatRateKey = getFiatRateKey(network, fiatCurrencyCode, tokenAddress); + const fiatRateKey = getFiatRateKey(symbol, fiatCurrencyCode, tokenAddress); const currentRate = useSelector((state: FiatRatesRootState) => selectFiatRatesByFiatRateKey(state, fiatRateKey), ); const rate = useHistoricRate ? historicRate : currentRate?.rate; - const isTestnetCoin = isTestnet(network); + const isTestnetCoin = isTestnet(symbol); if (!cryptoValue || !rate || currentRate?.error || isTestnetCoin) return null; @@ -48,7 +48,7 @@ export const useFiatFromCryptoValue = ({ return convertCryptoToFiatAmount({ amount: cryptoValue, - networkSymbol: network, + symbol, isAmountInSats: !isBalance, rate, }); diff --git a/suite-native/graph/src/components/TransactionEventTooltip.tsx b/suite-native/graph/src/components/TransactionEventTooltip.tsx index 0691dd89f94e..dc799cb99a75 100644 --- a/suite-native/graph/src/components/TransactionEventTooltip.tsx +++ b/suite-native/graph/src/components/TransactionEventTooltip.tsx @@ -16,11 +16,7 @@ import { EventTooltipComponentProps } from '@suite-native/react-native-graph/src import { SignValue } from '@suite-common/suite-types'; import { NetworkSymbol, getNetworkType } from '@suite-common/wallet-config'; import { AccountKey, TokenAddress } from '@suite-common/wallet-types'; -import { - selectAccountTokenInfo, - selectAccountTokenSymbol, - TokensRootState, -} from '@suite-native/tokens'; +import { selectAccountTokenInfo, TokensRootState } from '@suite-native/tokens'; export type TransactionEventTooltipProps = EventTooltipComponentProps; @@ -70,15 +66,12 @@ const TokenAmountTooltipFormatter = ({ networkSymbol: NetworkSymbol; value: number; }) => { - const tokenInfo = useSelector((state: TokensRootState) => + const token = useSelector((state: TokensRootState) => selectAccountTokenInfo(state, accountKey, tokenAddress), ); - const tokenSymbol = useSelector((state: TokensRootState) => - selectAccountTokenSymbol(state, accountKey, tokenAddress), - ); - const tokenDecimals = tokenInfo?.decimals; + const tokenDecimals = token?.decimals; - if (!tokenSymbol || !tokenDecimals) { + if (!token?.symbol || !tokenDecimals) { return null; } @@ -89,7 +82,7 @@ const TokenAmountTooltipFormatter = ({ color="textDefault" variant="label" value={value} - symbol={tokenSymbol} + tokenSymbol={token.symbol} // decimals are already formatted in getAccountHistoryMovementItemETH decimals={0} /> diff --git a/suite-native/module-accounts-import/src/accountsImportThunks.ts b/suite-native/module-accounts-import/src/accountsImportThunks.ts index b1853793ce9a..e0380a1897e9 100644 --- a/suite-native/module-accounts-import/src/accountsImportThunks.ts +++ b/suite-native/module-accounts-import/src/accountsImportThunks.ts @@ -83,19 +83,16 @@ export const importAccountThunk = createThunk( export const getAccountInfoThunk = createThunk< AccountInfo, - { networkSymbol: NetworkSymbol; fiatCurrency: FiatCurrencyCode; xpubAddress: string }, + { symbol: NetworkSymbol; fiatCurrency: FiatCurrencyCode; xpubAddress: string }, { rejectValue: string } >( `${ACCOUNTS_IMPORT_MODULE_PREFIX}/getAccountInfo`, - async ( - { networkSymbol, fiatCurrency, xpubAddress }, - { dispatch, rejectWithValue, getState }, - ) => { + async ({ symbol, fiatCurrency, xpubAddress }, { dispatch, rejectWithValue, getState }) => { try { const [fetchedAccountInfo] = await Promise.all([ TrezorConnect.getAccountInfo({ - coin: networkSymbol, - identity: shouldUseIdentities(networkSymbol) + coin: symbol, + identity: shouldUseIdentities(symbol) ? getAccountIdentity({ deviceState: PORTFOLIO_TRACKER_DEVICE_STATE, }) @@ -108,7 +105,7 @@ export const getAccountInfoThunk = createThunk< updateFiatRatesThunk({ tickers: [ { - symbol: networkSymbol, + symbol, }, ], rateType: 'current', @@ -119,16 +116,16 @@ export const getAccountInfoThunk = createThunk< ]); if (fetchedAccountInfo?.success) { - const tokenDefinitions = selectNetworkTokenDefinitions(getState(), networkSymbol); + const tokenDefinitions = selectNetworkTokenDefinitions(getState(), symbol); // fetch token definitions for this network in case they are needed if (!tokenDefinitions) { - const definitionTypes = getSupportedDefinitionTypes(networkSymbol); + const definitionTypes = getSupportedDefinitionTypes(symbol); definitionTypes.forEach(async type => { await dispatch( getTokenDefinitionThunk({ - networkSymbol, + symbol, type, }), ); @@ -138,12 +135,12 @@ export const getAccountInfoThunk = createThunk< // Even that there is check in updateFiatRatesThunk, it is better to do it here and do not dispatch thunk at all because it has some overhead and sometimes there could be lot of tokens const knownTokens = selectFilterKnownTokens( getState(), - networkSymbol, + symbol, fetchedAccountInfo.payload.tokens ?? [], ); const tickers = knownTokens.map(token => ({ - symbol: networkSymbol, + symbol, tokenAddress: token.contract as TokenAddress, })); diff --git a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx index bda03dffdb04..8177d67512ca 100644 --- a/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx +++ b/suite-native/module-accounts-import/src/components/AccountImportConfirmFormScreen.tsx @@ -102,8 +102,8 @@ export const AccountImportConfirmFormScreen = ({ ({ item }: { item: TokenInfo }) => ( { const fiatBalanceValue = useFiatFromCryptoValue({ cryptoValue: balance, - network: networkSymbol, + symbol: networkSymbol, }); return ( } + icon={} coinName={networks[networkSymbol].name} cryptoAmount={ { const isSpecificCoinDefinitionKnown = useSelector((state: TokenDefinitionsRootState) => - selectIsSpecificCoinDefinitionKnown(state, networkSymbol, contract), + selectIsSpecificCoinDefinitionKnown(state, symbol, contract), ); - if (!symbol || !balance || !name || !isSpecificCoinDefinitionKnown) return null; + if (!tokenSymbol || !balance || !name || !isSpecificCoinDefinitionKnown) return null; return ( } - icon={} + icon={} > ) => { - const { xpubAddress, networkSymbol } = route.params; + const { xpubAddress, networkSymbol: symbol } = route.params; const dispatch = useDispatch(); - const showImportError = useShowImportError(networkSymbol, navigation); + const showImportError = useShowImportError(symbol, navigation); const [accountInfo, setAccountInfo] = useState(null); const fiatCurrency = useSelector(selectFiatCurrencyCode); const [error, setError] = useState(); @@ -39,7 +39,7 @@ export const AccountImportLoadingScreen = ({ const fetchAccountInfo = useCallback(async () => { try { const response = await dispatch( - getAccountInfoThunk({ networkSymbol, fiatCurrency, xpubAddress }), + getAccountInfoThunk({ symbol, fiatCurrency, xpubAddress }), ).unwrap(); if (response) { @@ -50,7 +50,7 @@ export const AccountImportLoadingScreen = ({ setError(response); setAccountInfoFetchResult('error'); } - }, [dispatch, fiatCurrency, networkSymbol, xpubAddress]); + }, [dispatch, fiatCurrency, symbol, xpubAddress]); const safelyShowImportError = useCallback( async (onRetry?: () => Promise) => { @@ -90,7 +90,7 @@ export const AccountImportLoadingScreen = ({ } else { navigation.navigate(AccountsImportStackRoutes.AccountImportSummary, { accountInfo, - networkSymbol, + networkSymbol: symbol, }); } }; diff --git a/suite-native/module-accounts-management/src/components/AccountDetailCryptoValue.tsx b/suite-native/module-accounts-management/src/components/AccountDetailCryptoValue.tsx index 1e93d7ae8678..017043f9b183 100644 --- a/suite-native/module-accounts-management/src/components/AccountDetailCryptoValue.tsx +++ b/suite-native/module-accounts-management/src/components/AccountDetailCryptoValue.tsx @@ -26,7 +26,11 @@ export const AccountDetailCryptoValue = memo( {tokenSymbol ? ( - + ) : ( { const { applyStyle } = useNativeStyles(); - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); - const { currentValue, valuePercentageChange } = useDayCoinPriceChange(networkSymbol); + const { currentValue, valuePercentageChange } = useDayCoinPriceChange(symbol); - if (!networkSymbol) return null; + if (!symbol) return null; - const coinName = networks[networkSymbol].name; + const coinName = getNetwork(symbol).name; return ( - + @@ -96,7 +96,7 @@ export const CoinPriceCard = ({ accountKey }: CoinPriceCardProps) => { {currentValue && ( { ); const isFiatDisplayed = !isTestnet; - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -119,7 +119,7 @@ export const AmountInputs = ({ index }: AmountInputProps) => { ); }; - if (!networkSymbol) return null; + if (!symbol) return null; return ( @@ -147,7 +147,7 @@ export const AmountInputs = ({ index }: AmountInputProps) => { inputRef={cryptoRef} accountKey={accountKey} isDisabled={!isCryptoSelected} - networkSymbol={networkSymbol} + symbol={symbol} onPress={!isCryptoSelected ? handleSwitchInputs : undefined} onFocus={handleInputFocus} tokenContract={tokenContract} @@ -161,7 +161,7 @@ export const AmountInputs = ({ index }: AmountInputProps) => { translateValue={fiatTranslateY} inputRef={fiatRef} isDisabled={isCryptoSelected} - networkSymbol={networkSymbol} + symbol={symbol} tokenContract={tokenContract} onPress={isCryptoSelected ? handleSwitchInputs : undefined} onFocus={handleInputFocus} diff --git a/suite-native/module-send/src/components/CryptoAmountInput.tsx b/suite-native/module-send/src/components/CryptoAmountInput.tsx index 65f93c359a2f..f56126328dd2 100644 --- a/suite-native/module-send/src/components/CryptoAmountInput.tsx +++ b/suite-native/module-send/src/components/CryptoAmountInput.tsx @@ -43,7 +43,7 @@ export const CryptoAmountInput = ({ inputRef, scaleValue, translateValue, - networkSymbol, + symbol, tokenContract, accountKey, onPress, @@ -52,7 +52,7 @@ export const CryptoAmountInput = ({ }: SendAmountInputProps) => { const { applyStyle } = useNativeStyles(); const { setValue, trigger } = useFormContext(); - const { cryptoAmountTransformer } = useSendAmountTransformers(networkSymbol); + const { cryptoAmountTransformer } = useSendAmountTransformers(symbol); const { NetworkSymbolFormatter: formatter } = useFormatters(); const debounce = useDebounce(); @@ -68,7 +68,7 @@ export const CryptoAmountInput = ({ valueTransformer: cryptoAmountTransformer, }); - const converters = useCryptoFiatConverters({ networkSymbol, tokenContract }); + const converters = useCryptoFiatConverters({ symbol, tokenContract }); const cryptoAnimatedStyle = useAnimatedStyle( () => ({ @@ -115,7 +115,7 @@ export const CryptoAmountInput = ({ hasError={!isDisabled && hasError} rightIcon={ - {tokenSymbol ?? formatter.format(networkSymbol)} + {tokenSymbol ?? formatter.format(symbol)} } /> diff --git a/suite-native/module-send/src/components/CustomFeeBottomSheet.tsx b/suite-native/module-send/src/components/CustomFeeBottomSheet.tsx index ea81ae6002b3..96bb0fb7c968 100644 --- a/suite-native/module-send/src/components/CustomFeeBottomSheet.tsx +++ b/suite-native/module-send/src/components/CustomFeeBottomSheet.tsx @@ -39,7 +39,7 @@ export const CustomFeeBottomSheet = ({ isVisible, onClose }: CustomFeeBottomShee tokenContract, }); - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -65,7 +65,7 @@ export const CustomFeeBottomSheet = ({ isVisible, onClose }: CustomFeeBottomShee [isSubmittable, isVisible], ); - if (!networkSymbol) return null; + if (!symbol) return null; return ( - + { (); const fiatCurrencyCode = useSelector(selectFiatCurrencyCode); - const { fiatAmountTransformer } = useSendAmountTransformers(networkSymbol); - const converters = useCryptoFiatConverters({ networkSymbol, tokenContract }); + const { fiatAmountTransformer } = useSendAmountTransformers(symbol); + const converters = useCryptoFiatConverters({ symbol, tokenContract }); const cryptoFieldName = getOutputFieldName(recipientIndex, 'amount'); const fiatFieldName = getOutputFieldName(recipientIndex, 'fiat'); diff --git a/suite-native/module-send/src/components/SendMaxButton.tsx b/suite-native/module-send/src/components/SendMaxButton.tsx index b5515d6ec287..5049c0a9ac41 100644 --- a/suite-native/module-send/src/components/SendMaxButton.tsx +++ b/suite-native/module-send/src/components/SendMaxButton.tsx @@ -28,7 +28,7 @@ export const SendMaxButton = ({ outputIndex, accountKey, tokenContract }: SendMa const dispatch = useDispatch(); const debounce = useDebounce(); - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -42,7 +42,7 @@ export const SendMaxButton = ({ outputIndex, accountKey, tokenContract }: SendMa const [maxAmountValue, setMaxAmountValue] = useState(); - const converters = useCryptoFiatConverters({ networkSymbol: networkSymbol!, tokenContract }); + const converters = useCryptoFiatConverters({ symbol, tokenContract }); const { setValue, watch } = useFormContext(); const formValues = watch(); diff --git a/suite-native/module-send/src/types.ts b/suite-native/module-send/src/types.ts index 42776ee80d80..3444485e0865 100644 --- a/suite-native/module-send/src/types.ts +++ b/suite-native/module-send/src/types.ts @@ -9,7 +9,7 @@ import { ReviewOutputState, TokenAddress, } from '@suite-common/wallet-types'; -import { NetworkSymbol } from '@suite-common/wallet-config'; +import type { NetworkSymbol } from '@suite-common/wallet-config'; export type StatefulReviewOutput = ReviewOutput & { state: ReviewOutputState }; @@ -17,7 +17,7 @@ export type NativeSupportedFeeLevel = Exclude; export type SendAmountInputProps = { recipientIndex: number; - networkSymbol: NetworkSymbol; + symbol: NetworkSymbol; inputRef: RefObject; scaleValue: SharedValue; translateValue: SharedValue; diff --git a/suite-native/module-staking-management/src/components/StakePendingCard.tsx b/suite-native/module-staking-management/src/components/StakePendingCard.tsx index 92605728a511..f1e0d5b9e38e 100644 --- a/suite-native/module-staking-management/src/components/StakePendingCard.tsx +++ b/suite-native/module-staking-management/src/components/StakePendingCard.tsx @@ -58,7 +58,7 @@ export const StakePendingCard = ({ }: StakePendingCardProps) => { const { applyStyle } = useNativeStyles(); - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -78,7 +78,7 @@ export const StakePendingCard = ({ [isStakeConfirming, isStakePending], ); - if (!networkSymbol || !cardAlertProps.alertVariant) return null; + if (!symbol || !cardAlertProps.alertVariant) return null; return ( handleToggleBottomSheet(true)}> @@ -92,7 +92,7 @@ export const StakePendingCard = ({ diff --git a/suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx b/suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx index 9b30de2bc330..2288937d4c92 100644 --- a/suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx +++ b/suite-native/module-staking-management/src/components/StakingBalancesOverviewCard.tsx @@ -50,7 +50,7 @@ export const StakingBalancesOverviewCard = ({ }: StakingBalancesCardProps) => { const { applyStyle } = useNativeStyles(); - const networkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), ); @@ -65,7 +65,7 @@ export const StakingBalancesOverviewCard = ({ selectRewardsBalanceByAccountKey(state, accountKey), ); - if (!networkSymbol) return null; + if (!symbol) return null; return ( handleToggleBottomSheet(true)}> @@ -80,7 +80,7 @@ export const StakingBalancesOverviewCard = ({ @@ -104,7 +104,7 @@ export const StakingBalancesOverviewCard = ({ diff --git a/suite-native/receive/src/components/TokenReceiveCard.tsx b/suite-native/receive/src/components/TokenReceiveCard.tsx index f0ac3ba786f0..bb0c03184894 100644 --- a/suite-native/receive/src/components/TokenReceiveCard.tsx +++ b/suite-native/receive/src/components/TokenReceiveCard.tsx @@ -9,12 +9,7 @@ import { selectAccountLabel, selectAccountNetworkSymbol, } from '@suite-common/wallet-core'; -import { - getTokenName, - selectAccountTokenInfo, - selectAccountTokenSymbol, - TokensRootState, -} from '@suite-native/tokens'; +import { getTokenName, selectAccountTokenInfo, TokensRootState } from '@suite-native/tokens'; import { Translation } from '@suite-native/intl'; type TokenReceiveCardProps = { @@ -39,22 +34,14 @@ export const TokenReceiveCard = ({ contract, accountKey }: TokenReceiveCardProps const accountLabel = useSelector((state: AccountsRootState) => selectAccountLabel(state, accountKey), ); - const accountNetworkSymbol = useSelector((state: AccountsRootState) => + const symbol = useSelector((state: AccountsRootState) => selectAccountNetworkSymbol(state, accountKey), - )!; + ); const token = useSelector((state: TokensRootState) => selectAccountTokenInfo(state, accountKey, contract), ); - const tokenSymbol = useSelector((state: TokensRootState) => - selectAccountTokenSymbol(state, accountKey, contract), - ); - - const network = useSelector((state: AccountsRootState) => - selectAccountNetworkSymbol(state, accountKey), - ); - - if (!token || !network) { + if (!token || !symbol) { return ( } /> ); @@ -67,7 +54,7 @@ export const TokenReceiveCard = ({ contract, accountKey }: TokenReceiveCardProps - + {tokenName} @@ -78,7 +65,7 @@ export const TokenReceiveCard = ({ contract, accountKey }: TokenReceiveCardProps values={{ accountLabel }} /> } - icon={accountNetworkSymbol} + icon={symbol} size="small" iconSize="extraSmall" /> @@ -88,11 +75,11 @@ export const TokenReceiveCard = ({ contract, accountKey }: TokenReceiveCardProps diff --git a/suite-native/transactions/src/components/TransactionDetail/TransactionDetailData.tsx b/suite-native/transactions/src/components/TransactionDetail/TransactionDetailData.tsx index 9da597fb6f4a..7cc0ead86654 100644 --- a/suite-native/transactions/src/components/TransactionDetail/TransactionDetailData.tsx +++ b/suite-native/transactions/src/components/TransactionDetail/TransactionDetailData.tsx @@ -99,7 +99,7 @@ export const TransactionDetailData = ({ ≈ {tokenTransfer ? ( diff --git a/suite-native/transactions/src/components/TransactionDetail/TransactionDetailValuesSheet.tsx b/suite-native/transactions/src/components/TransactionDetail/TransactionDetailValuesSheet.tsx index 8220e65db9c0..32f5d88afd84 100644 --- a/suite-native/transactions/src/components/TransactionDetail/TransactionDetailValuesSheet.tsx +++ b/suite-native/transactions/src/components/TransactionDetail/TransactionDetailValuesSheet.tsx @@ -45,7 +45,7 @@ const TodayHeaderCell = ({ cryptoValue, network, historicRate }: TodayHeaderCell const fiatTotalHistoryNumeric = pipe( convertCryptoToFiatAmount({ amount: cryptoValue, - networkSymbol: network, + symbol: network, rate: historicRate, }) ?? 0, Number, @@ -53,7 +53,7 @@ const TodayHeaderCell = ({ cryptoValue, network, historicRate }: TodayHeaderCell const fiatTotalActualNumeric = pipe( convertCryptoToFiatAmount({ amount: cryptoValue, - networkSymbol: network, + symbol: network, rate: currentRates?.rate, }), Number, @@ -119,7 +119,7 @@ export const TransactionDetailValuesSheet = ({ @@ -142,7 +142,7 @@ export const TransactionDetailValuesSheet = ({ @@ -165,7 +165,7 @@ export const TransactionDetailValuesSheet = ({ diff --git a/suite-native/transactions/src/components/TransactionsList/TokenTransferListItem.tsx b/suite-native/transactions/src/components/TransactionsList/TokenTransferListItem.tsx index 52f7543be328..a8e88fb61978 100644 --- a/suite-native/transactions/src/components/TransactionsList/TokenTransferListItem.tsx +++ b/suite-native/transactions/src/components/TransactionsList/TokenTransferListItem.tsx @@ -62,7 +62,7 @@ export const TokenTransferListItemValues = ({ return ( <>