Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16190 we show network symbol in place of display symbol #16325

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UNIT_ABBREVIATIONS } from '@suite-common/suite-constants';
import { getNetwork, NetworkSymbol } from '@suite-common/wallet-config';
import { getNetwork, getNetworkDisplaySymbol, NetworkSymbol } from '@suite-common/wallet-config';

import { FormatterConfig } from '../types';
import { makeFormatter } from '../makeFormatter';
@@ -14,13 +14,13 @@ export const prepareNetworkSymbolFormatter = (config: FormatterConfig) =>

const { features: networkFeatures, testnet: isTestnet } = getNetwork(symbol);
const areAmountUnitsSupported = !!networkFeatures?.includes('amount-unit');
let formattedSymbol = symbol.toUpperCase();
let formattedSymbol = getNetworkDisplaySymbol(symbol);

// convert to different units if needed
if (areAmountUnitsEnabled && areAmountUnitsSupported) {
const unitAbbreviation = UNIT_ABBREVIATIONS[bitcoinAmountUnit];
formattedSymbol = isTestnet
? `${unitAbbreviation} ${symbol.toUpperCase()}`
? `${unitAbbreviation} ${formattedSymbol}`
: unitAbbreviation;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { PROTO } from '@trezor/connect';
import { NetworkSymbol } from '@suite-common/wallet-config';

import { prepareNetworkSymbolFormatter } from '../prepareNetworkSymbolFormatter';

describe('prepareNetworkSymbolFormatter', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

let networkSymbolFormatter: ReturnType<typeof prepareNetworkSymbolFormatter>;

beforeEach(() => {
networkSymbolFormatter = prepareNetworkSymbolFormatter({
coins: [],
locale: 'en',
bitcoinAmountUnit: PROTO.AmountUnit.BITCOIN,
// @ts-expect-error - no need to test it with Intl for now
intl: {},
});
});

it.each([
['bsc', 'BNB'],
['arb', 'ETH'],
['base', 'ETH'],
['btc', 'BTC'],
] as [NetworkSymbol, string][])(
'should display symbolName (#16190) case %#',
(symbol: NetworkSymbol, expectedValue: string) => {
expect(networkSymbolFormatter.format(symbol, {})).toBe(expectedValue);
},
);
});
6 changes: 6 additions & 0 deletions suite-native/intl/src/en.ts
Original file line number Diff line number Diff line change
@@ -835,6 +835,12 @@ export const en = {
coinLabel: 'Coin label',
},
},
accountDetailContentScreen: {
coinPriceCard: {
changeIn24h: '24h change',
coinPrice: '{coinName} price',
},
},
},
moduleAccounts: {
accountDetail: {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import { getNetworkDisplaySymbolName } from '@suite-common/wallet-config';
import { FiatAmountFormatter } from '@suite-native/formatters';
import { AccountKey } from '@suite-common/wallet-types';
import { AccountsRootState, selectAccountNetworkSymbol } from '@suite-common/wallet-core';
import { Translation } from '@suite-native/intl';

import { useDayCoinPriceChange } from '../hooks/useDayCoinPriceChange';

@@ -53,7 +54,7 @@ const PriceChangeIndicator = ({ valuePercentageChange }: PriceChangeIndicatorPro
return (
<Box style={applyStyle(indicatorContainer)}>
<Text variant="label" color="textSubdued">
24h change
<Translation id="moduleAccountManagement.accountDetailContentScreen.coinPriceCard.changeIn24h" />
</Text>
<Box justifyContent="center" alignItems="center" flexDirection="row">
{valuePercentageChange ? (
@@ -92,7 +93,10 @@ export const CoinPriceCard = ({ accountKey }: CoinPriceCardProps) => {
</Box>
<Box style={applyStyle(cardContentStyle)}>
<Text variant="label" color="textSubdued">
{coinName} price
<Translation
id="moduleAccountManagement.accountDetailContentScreen.coinPriceCard.coinPrice"
values={{ coinName }}
/>
</Text>
{currentValue && (
<FiatAmountFormatter