@ledgerhq/live-common 34.46.0-nightly.4 → 34.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge/crypto-assets/index.d.ts +1 -1
- package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +1 -1
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/impl.d.ts +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/domain/getTokensWithFunds.test.js +1 -1
- package/lib/domain/getTokensWithFunds.test.js.map +1 -1
- package/lib/e2e/enum/DeviceLabels.d.ts +2 -3
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +1 -2
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +4 -4
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/index.d.ts +0 -3
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/speculos.js +1 -1
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/api/v5/actions.js +1 -1
- package/lib/exchange/swap/api/v5/actions.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +1 -1
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/families/evm/setup.d.ts.map +1 -1
- package/lib/families/evm/setup.js +1 -11
- package/lib/families/evm/setup.js.map +1 -1
- package/lib/families/hedera/setup.d.ts +5 -5
- package/lib/families/hedera/setup.d.ts.map +1 -1
- package/lib/families/hedera/setup.js.map +1 -1
- package/lib/families/solana/setup.d.ts.map +1 -1
- package/lib/families/solana/setup.js +1 -2
- package/lib/families/solana/setup.js.map +1 -1
- package/lib/generated/bridge/js.d.ts +1 -1
- package/lib/market/utils/countervalueFormatter.d.ts.map +1 -1
- package/lib/market/utils/countervalueFormatter.js.map +1 -1
- package/lib/market/utils/types.d.ts +0 -2
- package/lib/market/utils/types.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
- package/lib/modularDrawer/__mocks__/currencies.mock.js +7 -7
- package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
- package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
- package/lib/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
- package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
- package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +1 -1
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/impl.d.ts +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/domain/getTokensWithFunds.test.js +1 -1
- package/lib-es/domain/getTokensWithFunds.test.js.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts +2 -3
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +1 -2
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +4 -4
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/index.d.ts +0 -3
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +1 -1
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/swap/api/v5/actions.js +1 -1
- package/lib-es/exchange/swap/api/v5/actions.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +1 -1
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/families/evm/setup.d.ts.map +1 -1
- package/lib-es/families/evm/setup.js +1 -11
- package/lib-es/families/evm/setup.js.map +1 -1
- package/lib-es/families/hedera/setup.d.ts +5 -5
- package/lib-es/families/hedera/setup.d.ts.map +1 -1
- package/lib-es/families/hedera/setup.js.map +1 -1
- package/lib-es/families/solana/setup.d.ts.map +1 -1
- package/lib-es/families/solana/setup.js +1 -2
- package/lib-es/families/solana/setup.js.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +1 -1
- package/lib-es/market/utils/countervalueFormatter.d.ts.map +1 -1
- package/lib-es/market/utils/countervalueFormatter.js.map +1 -1
- package/lib-es/market/utils/types.d.ts +0 -2
- package/lib-es/market/utils/types.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js +1 -1
- package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +1 -1
- package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -1
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
- package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +1 -1
- package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -1
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +1 -1
- package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -1
- package/package.json +72 -73
- package/src/DataModel.test.ts +1 -1
- package/src/__tests__/accounts/groupPerDay.ts +1 -1
- package/src/__tests__/test-helpers/setup.ts +1 -1
- package/src/account/serialization.test.ts +1 -1
- package/src/bridge/crypto-assets/index.test.ts +1 -1
- package/src/bridge/crypto-assets/index.ts +2 -3
- package/src/bridge/impl.ts +1 -1
- package/src/currencies/sortByMarketcap.test.ts +1 -1
- package/src/domain/getTokensWithFunds.test.ts +1 -1
- package/src/e2e/enum/DeviceLabels.ts +1 -2
- package/src/e2e/families/solana.ts +4 -7
- package/src/e2e/speculos.ts +1 -1
- package/src/exchange/swap/api/v5/actions.ts +1 -1
- package/src/exchange/swap/types.ts +1 -1
- package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +0 -7
- package/src/families/bitcoin/satstack.test.ts +1 -1
- package/src/families/evm/setup.ts +1 -12
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +1135 -464
- package/src/families/hedera/setup.ts +3 -7
- package/src/families/solana/setup.ts +0 -2
- package/src/families/tron/data.mock.ts +1 -1
- package/src/market/utils/countervalueFormatter.ts +1 -0
- package/src/market/utils/types.ts +0 -4
- package/src/modularDrawer/__mocks__/currencies.mock.ts +1 -1
- package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +1 -1
- package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
- package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +2 -2
- package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +1 -1
- package/lib/families/hedera/constants.d.ts +0 -2
- package/lib/families/hedera/constants.d.ts.map +0 -1
- package/lib/families/hedera/constants.js +0 -19
- package/lib/families/hedera/constants.js.map +0 -1
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +0 -2
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +0 -1
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js +0 -496
- package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +0 -1
- package/lib/modularDrawer/utils/calculateProviderTotal.d.ts +0 -9
- package/lib/modularDrawer/utils/calculateProviderTotal.d.ts.map +0 -1
- package/lib/modularDrawer/utils/calculateProviderTotal.js +0 -23
- package/lib/modularDrawer/utils/calculateProviderTotal.js.map +0 -1
- package/lib/modularDrawer/utils/counterValueFormatter.d.ts +0 -14
- package/lib/modularDrawer/utils/counterValueFormatter.d.ts.map +0 -1
- package/lib/modularDrawer/utils/counterValueFormatter.js +0 -107
- package/lib/modularDrawer/utils/counterValueFormatter.js.map +0 -1
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +0 -11
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +0 -1
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +0 -45
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +0 -1
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts +0 -3
- package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +0 -1
- package/lib/modularDrawer/utils/getProviderCurrency.js +0 -14
- package/lib/modularDrawer/utils/getProviderCurrency.js.map +0 -1
- package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts +0 -11
- package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts.map +0 -1
- package/lib/modularDrawer/utils/groupAccountsByAsset.js +0 -32
- package/lib/modularDrawer/utils/groupAccountsByAsset.js.map +0 -1
- package/lib/modularDrawer/utils/parseToBigNumber.d.ts +0 -9
- package/lib/modularDrawer/utils/parseToBigNumber.d.ts.map +0 -1
- package/lib/modularDrawer/utils/parseToBigNumber.js +0 -24
- package/lib/modularDrawer/utils/parseToBigNumber.js.map +0 -1
- package/lib/modularDrawer/utils/type.d.ts +0 -21
- package/lib/modularDrawer/utils/type.d.ts.map +0 -1
- package/lib/modularDrawer/utils/type.js +0 -3
- package/lib/modularDrawer/utils/type.js.map +0 -1
- package/lib-es/families/hedera/constants.d.ts +0 -2
- package/lib-es/families/hedera/constants.d.ts.map +0 -1
- package/lib-es/families/hedera/constants.js +0 -3
- package/lib-es/families/hedera/constants.js.map +0 -1
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +0 -2
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js +0 -494
- package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +0 -1
- package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts +0 -9
- package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/calculateProviderTotal.js +0 -16
- package/lib-es/modularDrawer/utils/calculateProviderTotal.js.map +0 -1
- package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts +0 -14
- package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/counterValueFormatter.js +0 -103
- package/lib-es/modularDrawer/utils/counterValueFormatter.js.map +0 -1
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +0 -11
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +0 -41
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +0 -1
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +0 -3
- package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/getProviderCurrency.js +0 -10
- package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +0 -1
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts +0 -11
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.js +0 -25
- package/lib-es/modularDrawer/utils/groupAccountsByAsset.js.map +0 -1
- package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts +0 -9
- package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/parseToBigNumber.js +0 -17
- package/lib-es/modularDrawer/utils/parseToBigNumber.js.map +0 -1
- package/lib-es/modularDrawer/utils/type.d.ts +0 -21
- package/lib-es/modularDrawer/utils/type.d.ts.map +0 -1
- package/lib-es/modularDrawer/utils/type.js +0 -2
- package/lib-es/modularDrawer/utils/type.js.map +0 -1
- package/src/families/hedera/constants.ts +0 -2
- package/src/modularDrawer/utils/__tests__/counterValueFormatter.test.ts +0 -549
- package/src/modularDrawer/utils/calculateProviderTotal.ts +0 -23
- package/src/modularDrawer/utils/counterValueFormatter.ts +0 -165
- package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +0 -76
- package/src/modularDrawer/utils/getProviderCurrency.ts +0 -13
- package/src/modularDrawer/utils/groupAccountsByAsset.ts +0 -51
- package/src/modularDrawer/utils/parseToBigNumber.ts +0 -17
- package/src/modularDrawer/utils/type.ts +0 -22
@@ -1,549 +0,0 @@
|
|
1
|
-
import { counterValueFormatter } from "../counterValueFormatter";
|
2
|
-
import { TFunction } from "i18next";
|
3
|
-
|
4
|
-
const translations = {
|
5
|
-
"numberCompactNotation.K": "K",
|
6
|
-
"numberCompactNotation.M": "M",
|
7
|
-
"numberCompactNotation.B": "B",
|
8
|
-
};
|
9
|
-
|
10
|
-
const mockT = jest.fn().mockImplementation((key: keyof typeof translations) => {
|
11
|
-
return translations[key] || key;
|
12
|
-
}) as unknown as TFunction;
|
13
|
-
|
14
|
-
describe("counterValueFormatter", () => {
|
15
|
-
it("should return '-' for NaN values", () => {
|
16
|
-
const result = counterValueFormatter({
|
17
|
-
value: NaN,
|
18
|
-
locale: "en-US",
|
19
|
-
});
|
20
|
-
expect(result).toBe("-");
|
21
|
-
});
|
22
|
-
|
23
|
-
it("should format a number as currency", () => {
|
24
|
-
const result = counterValueFormatter({
|
25
|
-
value: 1234.56,
|
26
|
-
currency: "USD",
|
27
|
-
locale: "en-US",
|
28
|
-
});
|
29
|
-
expect(result).toBe("$1,234.56");
|
30
|
-
});
|
31
|
-
|
32
|
-
it("should format a number as decimal when no currency is provided", () => {
|
33
|
-
const result = counterValueFormatter({
|
34
|
-
value: 1234.56,
|
35
|
-
locale: "en-US",
|
36
|
-
});
|
37
|
-
expect(result).toBe("1,234.56");
|
38
|
-
});
|
39
|
-
|
40
|
-
it("should format a number in compact notation when shorten is true", () => {
|
41
|
-
const result = counterValueFormatter({
|
42
|
-
value: 1234567,
|
43
|
-
locale: "en-US",
|
44
|
-
shorten: true,
|
45
|
-
});
|
46
|
-
expect(result).toContain("1.235M");
|
47
|
-
});
|
48
|
-
|
49
|
-
it("should include the ticker in the formatted value", () => {
|
50
|
-
const result = counterValueFormatter({
|
51
|
-
value: 1234.56,
|
52
|
-
locale: "en-US",
|
53
|
-
ticker: "BTC",
|
54
|
-
});
|
55
|
-
expect(result).toBe("1,234.56 BTC");
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should allow zero values when allowZeroValue is true", () => {
|
59
|
-
const result = counterValueFormatter({
|
60
|
-
value: 0,
|
61
|
-
locale: "en-US",
|
62
|
-
allowZeroValue: true,
|
63
|
-
});
|
64
|
-
expect(result).toBe("0.00");
|
65
|
-
});
|
66
|
-
|
67
|
-
it("should format a number with specified decimal places set to 0", () => {
|
68
|
-
const result = counterValueFormatter({
|
69
|
-
value: 10.231023213,
|
70
|
-
locale: "en-US",
|
71
|
-
decimalPlaces: 0,
|
72
|
-
allowZeroValue: true,
|
73
|
-
});
|
74
|
-
expect(result).toBe("10");
|
75
|
-
});
|
76
|
-
|
77
|
-
it("should format a number with specified decimal places set to 4", () => {
|
78
|
-
const result = counterValueFormatter({
|
79
|
-
value: 10.231023213,
|
80
|
-
locale: "en-US",
|
81
|
-
decimalPlaces: 4,
|
82
|
-
allowZeroValue: true,
|
83
|
-
});
|
84
|
-
expect(result).toBe("10.2310");
|
85
|
-
});
|
86
|
-
|
87
|
-
it("should format a number in compact notation with translation", () => {
|
88
|
-
const result = counterValueFormatter({
|
89
|
-
value: 1234567,
|
90
|
-
locale: "en-US",
|
91
|
-
shorten: true,
|
92
|
-
t: mockT,
|
93
|
-
});
|
94
|
-
|
95
|
-
expect(result).toContain("1.235 M");
|
96
|
-
expect(mockT).toHaveBeenCalledWith("numberCompactNotation.M");
|
97
|
-
});
|
98
|
-
|
99
|
-
it("should handle different locales for formatting", () => {
|
100
|
-
const result = counterValueFormatter({
|
101
|
-
value: 1234.56,
|
102
|
-
locale: "fr-FR",
|
103
|
-
});
|
104
|
-
expect(result).toBe("1\u202f234,56");
|
105
|
-
});
|
106
|
-
|
107
|
-
it("should handle invalid currency gracefully", () => {
|
108
|
-
const result = counterValueFormatter({
|
109
|
-
value: 1234.56,
|
110
|
-
currency: "INVALID",
|
111
|
-
locale: "en-US",
|
112
|
-
});
|
113
|
-
expect(result).toBe("1,234.56");
|
114
|
-
});
|
115
|
-
|
116
|
-
it("should return - if value is NaN and it's not discreet mode", () => {
|
117
|
-
const result = counterValueFormatter({
|
118
|
-
value: NaN,
|
119
|
-
locale: "en-US",
|
120
|
-
});
|
121
|
-
expect(result).toBe("-");
|
122
|
-
});
|
123
|
-
|
124
|
-
it("should return sanitized value with *** in discreet mode for NaN", () => {
|
125
|
-
const result = counterValueFormatter({
|
126
|
-
value: NaN,
|
127
|
-
locale: "en-US",
|
128
|
-
discreetMode: true,
|
129
|
-
});
|
130
|
-
expect(result).toBe("***");
|
131
|
-
});
|
132
|
-
it("should return sanitized value with *** in discreet mode for zero value", () => {
|
133
|
-
const result = counterValueFormatter({
|
134
|
-
value: 0,
|
135
|
-
locale: "en-US",
|
136
|
-
discreetMode: true,
|
137
|
-
});
|
138
|
-
expect(result).toBe("***");
|
139
|
-
});
|
140
|
-
it("should return sanitized value with *** in discreet mode for non-zero value", () => {
|
141
|
-
const result = counterValueFormatter({
|
142
|
-
value: 1234.56,
|
143
|
-
locale: "en-US",
|
144
|
-
discreetMode: true,
|
145
|
-
});
|
146
|
-
expect(result).toBe("***");
|
147
|
-
});
|
148
|
-
it("should return sanitized value with *** in discreet mode for zero value with allowZeroValue", () => {
|
149
|
-
const result = counterValueFormatter({
|
150
|
-
value: 0,
|
151
|
-
locale: "en-US",
|
152
|
-
allowZeroValue: true,
|
153
|
-
discreetMode: true,
|
154
|
-
currency: "USD",
|
155
|
-
});
|
156
|
-
expect(result).toBe("$***");
|
157
|
-
});
|
158
|
-
|
159
|
-
describe("Multiple locales", () => {
|
160
|
-
it("should format German locale with EUR currency", () => {
|
161
|
-
const result = counterValueFormatter({
|
162
|
-
value: 1234.56,
|
163
|
-
locale: "de-DE",
|
164
|
-
currency: "EUR",
|
165
|
-
});
|
166
|
-
expect(result).toBe("1.234,56\u00A0€");
|
167
|
-
});
|
168
|
-
|
169
|
-
it("should handle french locale", () => {
|
170
|
-
const result = counterValueFormatter({
|
171
|
-
value: 10.23,
|
172
|
-
locale: "fr-FR",
|
173
|
-
allowZeroValue: true,
|
174
|
-
currency: "EUR",
|
175
|
-
});
|
176
|
-
expect(result).toBe("10,23\u00A0€");
|
177
|
-
});
|
178
|
-
it("should handle french locale with allowZeroValue", () => {
|
179
|
-
const result = counterValueFormatter({
|
180
|
-
value: 0,
|
181
|
-
locale: "fr-FR",
|
182
|
-
allowZeroValue: true,
|
183
|
-
currency: "EUR",
|
184
|
-
});
|
185
|
-
expect(result).toBe("0,00\u00A0€");
|
186
|
-
});
|
187
|
-
it("should handle french locale with USD currency", () => {
|
188
|
-
const result = counterValueFormatter({
|
189
|
-
value: 0,
|
190
|
-
locale: "fr-FR",
|
191
|
-
allowZeroValue: true,
|
192
|
-
currency: "USD",
|
193
|
-
});
|
194
|
-
expect(result).toBe("0,00\u00A0$US");
|
195
|
-
});
|
196
|
-
|
197
|
-
it("should format German locale with zero value", () => {
|
198
|
-
const result = counterValueFormatter({
|
199
|
-
value: 0,
|
200
|
-
locale: "de-DE",
|
201
|
-
currency: "EUR",
|
202
|
-
allowZeroValue: true,
|
203
|
-
});
|
204
|
-
expect(result).toBe("0,00\u00A0€");
|
205
|
-
});
|
206
|
-
|
207
|
-
it("should format Japanese locale with JPY currency", () => {
|
208
|
-
const result = counterValueFormatter({
|
209
|
-
value: 1234.56,
|
210
|
-
locale: "ja-JP",
|
211
|
-
currency: "JPY",
|
212
|
-
});
|
213
|
-
expect(result).toBe("¥1,235");
|
214
|
-
});
|
215
|
-
|
216
|
-
it("should format Japanese locale with zero value", () => {
|
217
|
-
const result = counterValueFormatter({
|
218
|
-
value: 0,
|
219
|
-
locale: "ja-JP",
|
220
|
-
currency: "JPY",
|
221
|
-
allowZeroValue: true,
|
222
|
-
});
|
223
|
-
expect(result).toBe("¥0");
|
224
|
-
});
|
225
|
-
|
226
|
-
it("should format UK locale with GBP currency", () => {
|
227
|
-
const result = counterValueFormatter({
|
228
|
-
value: 1234.56,
|
229
|
-
locale: "en-GB",
|
230
|
-
currency: "GBP",
|
231
|
-
});
|
232
|
-
expect(result).toBe("£1,234.56");
|
233
|
-
});
|
234
|
-
|
235
|
-
it("should format UK locale with zero value", () => {
|
236
|
-
const result = counterValueFormatter({
|
237
|
-
value: 0,
|
238
|
-
locale: "en-GB",
|
239
|
-
currency: "GBP",
|
240
|
-
allowZeroValue: true,
|
241
|
-
});
|
242
|
-
expect(result).toBe("£0.00");
|
243
|
-
});
|
244
|
-
|
245
|
-
it("should format Italian locale with EUR currency", () => {
|
246
|
-
const result = counterValueFormatter({
|
247
|
-
value: 1234.56,
|
248
|
-
locale: "it-IT",
|
249
|
-
currency: "EUR",
|
250
|
-
});
|
251
|
-
expect(result).toBe("1234,56\u00A0€");
|
252
|
-
});
|
253
|
-
|
254
|
-
it("should format Italian locale with zero value", () => {
|
255
|
-
const result = counterValueFormatter({
|
256
|
-
value: 0,
|
257
|
-
locale: "it-IT",
|
258
|
-
currency: "EUR",
|
259
|
-
allowZeroValue: true,
|
260
|
-
});
|
261
|
-
expect(result).toBe("0,00\u00A0€");
|
262
|
-
});
|
263
|
-
|
264
|
-
it("should format Spanish locale with EUR currency", () => {
|
265
|
-
const result = counterValueFormatter({
|
266
|
-
value: 1234.56,
|
267
|
-
locale: "es-ES",
|
268
|
-
currency: "EUR",
|
269
|
-
});
|
270
|
-
expect(result).toBe("1234,56\u00A0€");
|
271
|
-
});
|
272
|
-
|
273
|
-
it("should format Spanish locale with zero value", () => {
|
274
|
-
const result = counterValueFormatter({
|
275
|
-
value: 0,
|
276
|
-
locale: "es-ES",
|
277
|
-
currency: "EUR",
|
278
|
-
allowZeroValue: true,
|
279
|
-
});
|
280
|
-
expect(result).toBe("0,00\u00A0€");
|
281
|
-
});
|
282
|
-
|
283
|
-
it("should format Chinese locale with CNY currency", () => {
|
284
|
-
const result = counterValueFormatter({
|
285
|
-
value: 1234.56,
|
286
|
-
locale: "zh-CN",
|
287
|
-
currency: "CNY",
|
288
|
-
});
|
289
|
-
expect(result).toBe("¥1,234.56");
|
290
|
-
});
|
291
|
-
|
292
|
-
it("should format Chinese locale with zero value", () => {
|
293
|
-
const result = counterValueFormatter({
|
294
|
-
value: 0,
|
295
|
-
locale: "zh-CN",
|
296
|
-
currency: "CNY",
|
297
|
-
allowZeroValue: true,
|
298
|
-
});
|
299
|
-
expect(result).toBe("¥0.00");
|
300
|
-
});
|
301
|
-
|
302
|
-
it("should format Canadian locale with CAD currency", () => {
|
303
|
-
const result = counterValueFormatter({
|
304
|
-
value: 1234.56,
|
305
|
-
locale: "en-CA",
|
306
|
-
currency: "CAD",
|
307
|
-
});
|
308
|
-
expect(result).toBe("$1,234.56");
|
309
|
-
});
|
310
|
-
|
311
|
-
it("should format Canadian locale with zero value", () => {
|
312
|
-
const result = counterValueFormatter({
|
313
|
-
value: 0,
|
314
|
-
locale: "en-CA",
|
315
|
-
currency: "CAD",
|
316
|
-
allowZeroValue: true,
|
317
|
-
});
|
318
|
-
expect(result).toBe("$0.00");
|
319
|
-
});
|
320
|
-
|
321
|
-
it("should format Brazilian locale with BRL currency", () => {
|
322
|
-
const result = counterValueFormatter({
|
323
|
-
value: 1234.56,
|
324
|
-
locale: "pt-BR",
|
325
|
-
currency: "BRL",
|
326
|
-
});
|
327
|
-
expect(result).toBe("R$\u00A01.234,56");
|
328
|
-
});
|
329
|
-
|
330
|
-
it("should format Brazilian locale with zero value", () => {
|
331
|
-
const result = counterValueFormatter({
|
332
|
-
value: 0,
|
333
|
-
locale: "pt-BR",
|
334
|
-
currency: "BRL",
|
335
|
-
allowZeroValue: true,
|
336
|
-
});
|
337
|
-
expect(result).toBe("R$\u00A00,00");
|
338
|
-
});
|
339
|
-
|
340
|
-
it("should format Thai locale with THB currency", () => {
|
341
|
-
const result = counterValueFormatter({
|
342
|
-
value: 1234.56,
|
343
|
-
locale: "th-TH",
|
344
|
-
currency: "THB",
|
345
|
-
});
|
346
|
-
expect(result).toBe("฿1,234.56");
|
347
|
-
});
|
348
|
-
|
349
|
-
it("should format Thai locale with zero value", () => {
|
350
|
-
const result = counterValueFormatter({
|
351
|
-
value: 0,
|
352
|
-
locale: "th-TH",
|
353
|
-
currency: "THB",
|
354
|
-
allowZeroValue: true,
|
355
|
-
});
|
356
|
-
expect(result).toBe("฿0.00");
|
357
|
-
});
|
358
|
-
|
359
|
-
it("should format Turkish locale with TRY currency", () => {
|
360
|
-
const result = counterValueFormatter({
|
361
|
-
value: 1234.56,
|
362
|
-
locale: "tr-TR",
|
363
|
-
currency: "TRY",
|
364
|
-
});
|
365
|
-
expect(result).toBe("₺1.234,56");
|
366
|
-
});
|
367
|
-
|
368
|
-
it("should format Turkish locale with zero value", () => {
|
369
|
-
const result = counterValueFormatter({
|
370
|
-
value: 0,
|
371
|
-
locale: "tr-TR",
|
372
|
-
currency: "TRY",
|
373
|
-
allowZeroValue: true,
|
374
|
-
});
|
375
|
-
expect(result).toBe("₺0,00");
|
376
|
-
});
|
377
|
-
|
378
|
-
it("should format Russian locale with RUB currency", () => {
|
379
|
-
const result = counterValueFormatter({
|
380
|
-
value: 1234.56,
|
381
|
-
locale: "ru-RU",
|
382
|
-
currency: "RUB",
|
383
|
-
});
|
384
|
-
expect(result).toBe("1\u00A0234,56\u00A0₽");
|
385
|
-
});
|
386
|
-
|
387
|
-
it("should format Russian locale with zero value", () => {
|
388
|
-
const result = counterValueFormatter({
|
389
|
-
value: 0,
|
390
|
-
locale: "ru-RU",
|
391
|
-
currency: "RUB",
|
392
|
-
allowZeroValue: true,
|
393
|
-
});
|
394
|
-
expect(result).toBe("0,00\u00A0₽");
|
395
|
-
});
|
396
|
-
|
397
|
-
it("should format Indian locale with INR currency", () => {
|
398
|
-
const result = counterValueFormatter({
|
399
|
-
value: 1234.56,
|
400
|
-
locale: "hi-IN",
|
401
|
-
currency: "INR",
|
402
|
-
});
|
403
|
-
expect(result).toBe("₹1,234.56");
|
404
|
-
});
|
405
|
-
|
406
|
-
it("should format Indian locale with zero value", () => {
|
407
|
-
const result = counterValueFormatter({
|
408
|
-
value: 0,
|
409
|
-
locale: "hi-IN",
|
410
|
-
currency: "INR",
|
411
|
-
allowZeroValue: true,
|
412
|
-
});
|
413
|
-
expect(result).toBe("₹0.00");
|
414
|
-
});
|
415
|
-
|
416
|
-
it("should format Korean locale with KRW currency", () => {
|
417
|
-
const result = counterValueFormatter({
|
418
|
-
value: 1234.56,
|
419
|
-
locale: "ko-KR",
|
420
|
-
currency: "KRW",
|
421
|
-
});
|
422
|
-
expect(result).toBe("₩1,235");
|
423
|
-
});
|
424
|
-
|
425
|
-
it("should format Korean locale with zero value", () => {
|
426
|
-
const result = counterValueFormatter({
|
427
|
-
value: 0,
|
428
|
-
locale: "ko-KR",
|
429
|
-
currency: "KRW",
|
430
|
-
allowZeroValue: true,
|
431
|
-
});
|
432
|
-
expect(result).toBe("₩0");
|
433
|
-
});
|
434
|
-
|
435
|
-
it("should format Mexican locale with MXN currency", () => {
|
436
|
-
const result = counterValueFormatter({
|
437
|
-
value: 1234.56,
|
438
|
-
locale: "es-MX",
|
439
|
-
currency: "MXN",
|
440
|
-
});
|
441
|
-
expect(result).toBe("$1,234.56");
|
442
|
-
});
|
443
|
-
|
444
|
-
it("should format Mexican locale with zero value", () => {
|
445
|
-
const result = counterValueFormatter({
|
446
|
-
value: 0,
|
447
|
-
locale: "es-MX",
|
448
|
-
currency: "MXN",
|
449
|
-
allowZeroValue: true,
|
450
|
-
});
|
451
|
-
expect(result).toBe("$0.00");
|
452
|
-
});
|
453
|
-
|
454
|
-
it("should format South African locale with ZAR currency", () => {
|
455
|
-
const result = counterValueFormatter({
|
456
|
-
value: 1234.56,
|
457
|
-
locale: "en-ZA",
|
458
|
-
currency: "ZAR",
|
459
|
-
});
|
460
|
-
expect(result).toBe("R\u00A01\u00A0234,56");
|
461
|
-
});
|
462
|
-
|
463
|
-
it("should format South African locale with zero value", () => {
|
464
|
-
const result = counterValueFormatter({
|
465
|
-
value: 0,
|
466
|
-
locale: "en-ZA",
|
467
|
-
currency: "ZAR",
|
468
|
-
allowZeroValue: true,
|
469
|
-
});
|
470
|
-
expect(result).toBe("R\u00A00,00");
|
471
|
-
});
|
472
|
-
|
473
|
-
it("should format Swedish locale with SEK currency", () => {
|
474
|
-
const result = counterValueFormatter({
|
475
|
-
value: 1234.56,
|
476
|
-
locale: "sv-SE",
|
477
|
-
currency: "SEK",
|
478
|
-
});
|
479
|
-
expect(result).toBe("1\u00A0234,56\u00A0kr");
|
480
|
-
});
|
481
|
-
|
482
|
-
it("should format Swedish locale with zero value", () => {
|
483
|
-
const result = counterValueFormatter({
|
484
|
-
value: 0,
|
485
|
-
locale: "sv-SE",
|
486
|
-
currency: "SEK",
|
487
|
-
allowZeroValue: true,
|
488
|
-
});
|
489
|
-
expect(result).toBe("0,00\u00A0kr");
|
490
|
-
});
|
491
|
-
|
492
|
-
it("should format Norwegian locale with NOK currency", () => {
|
493
|
-
const result = counterValueFormatter({
|
494
|
-
value: 1234.56,
|
495
|
-
locale: "no-NO",
|
496
|
-
currency: "NOK",
|
497
|
-
});
|
498
|
-
expect(result).toBe("1\u00A0234,56\u00A0kr");
|
499
|
-
});
|
500
|
-
|
501
|
-
it("should format Norwegian locale with zero value", () => {
|
502
|
-
const result = counterValueFormatter({
|
503
|
-
value: 0,
|
504
|
-
locale: "no-NO",
|
505
|
-
currency: "NOK",
|
506
|
-
allowZeroValue: true,
|
507
|
-
});
|
508
|
-
expect(result).toBe("0,00\u00A0kr");
|
509
|
-
});
|
510
|
-
|
511
|
-
it("should format Swiss locale with CHF currency", () => {
|
512
|
-
const result = counterValueFormatter({
|
513
|
-
value: 1234.56,
|
514
|
-
locale: "de-CH",
|
515
|
-
currency: "CHF",
|
516
|
-
});
|
517
|
-
expect(result).toBe("CHF\u00A01’234.56");
|
518
|
-
});
|
519
|
-
|
520
|
-
it("should format Swiss locale with zero value", () => {
|
521
|
-
const result = counterValueFormatter({
|
522
|
-
value: 0,
|
523
|
-
locale: "de-CH",
|
524
|
-
currency: "CHF",
|
525
|
-
allowZeroValue: true,
|
526
|
-
});
|
527
|
-
expect(result).toBe("CHF\u00A00.00");
|
528
|
-
});
|
529
|
-
|
530
|
-
it("should format Vietnamese locale with VND currency", () => {
|
531
|
-
const result = counterValueFormatter({
|
532
|
-
value: 1234.56,
|
533
|
-
locale: "vi-VN",
|
534
|
-
currency: "VND",
|
535
|
-
});
|
536
|
-
expect(result).toBe("1.235\u00A0₫");
|
537
|
-
});
|
538
|
-
|
539
|
-
it("should format Vietnamese locale with zero value", () => {
|
540
|
-
const result = counterValueFormatter({
|
541
|
-
value: 0,
|
542
|
-
locale: "vi-VN",
|
543
|
-
currency: "VND",
|
544
|
-
allowZeroValue: true,
|
545
|
-
});
|
546
|
-
expect(result).toBe("0\u00A0₫");
|
547
|
-
});
|
548
|
-
});
|
549
|
-
});
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
-
import BigNumber from "bignumber.js";
|
3
|
-
import { GroupedAccount } from "./groupAccountsByAsset";
|
4
|
-
|
5
|
-
export const calculateProviderTotals = (
|
6
|
-
currencies: CryptoOrTokenCurrency[],
|
7
|
-
groupedAccountsByAsset: Record<string, GroupedAccount>,
|
8
|
-
) => {
|
9
|
-
let totalBalance = new BigNumber(0);
|
10
|
-
let totalFiatValue = new BigNumber(0);
|
11
|
-
let hasAccounts = false;
|
12
|
-
|
13
|
-
for (const currency of currencies) {
|
14
|
-
const assetGroup = groupedAccountsByAsset[currency.id];
|
15
|
-
if (assetGroup?.accounts.length > 0) {
|
16
|
-
totalBalance = totalBalance.plus(assetGroup.totalBalance);
|
17
|
-
totalFiatValue = totalFiatValue.plus(assetGroup.totalFiatValue);
|
18
|
-
hasAccounts = true;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
return { totalBalance, totalFiatValue, hasAccounts };
|
23
|
-
};
|