@ledgerhq/live-common 34.50.0-nightly.1 → 34.50.0-nightly.3

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.
Files changed (250) hide show
  1. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +4 -4
  2. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
  3. package/lib/bridge/generic-alpaca/buildSubAccounts.js +7 -9
  4. package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
  5. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  6. package/lib/bridge/generic-alpaca/getAccountShape.js +4 -6
  7. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  8. package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js +5 -3
  9. package/lib/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
  10. package/lib/e2e/enum/Account.d.ts +6 -0
  11. package/lib/e2e/enum/Account.d.ts.map +1 -1
  12. package/lib/e2e/enum/Account.js +8 -0
  13. package/lib/e2e/enum/Account.js.map +1 -1
  14. package/lib/e2e/enum/AppInfos.d.ts +2 -0
  15. package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
  16. package/lib/e2e/enum/AppInfos.js +2 -0
  17. package/lib/e2e/enum/AppInfos.js.map +1 -1
  18. package/lib/e2e/enum/Currency.d.ts +4 -0
  19. package/lib/e2e/enum/Currency.d.ts.map +1 -1
  20. package/lib/e2e/enum/Currency.js +6 -0
  21. package/lib/e2e/enum/Currency.js.map +1 -1
  22. package/lib/e2e/enum/Network.d.ts +3 -1
  23. package/lib/e2e/enum/Network.d.ts.map +1 -1
  24. package/lib/e2e/enum/Network.js +2 -0
  25. package/lib/e2e/enum/Network.js.map +1 -1
  26. package/lib/e2e/enum/TokenType.d.ts +2 -1
  27. package/lib/e2e/enum/TokenType.d.ts.map +1 -1
  28. package/lib/e2e/enum/TokenType.js +1 -0
  29. package/lib/e2e/enum/TokenType.js.map +1 -1
  30. package/lib/e2e/enum/TransactionStatus.d.ts +4 -1
  31. package/lib/e2e/enum/TransactionStatus.d.ts.map +1 -1
  32. package/lib/e2e/enum/TransactionStatus.js +3 -0
  33. package/lib/e2e/enum/TransactionStatus.js.map +1 -1
  34. package/lib/e2e/families/hedera.d.ts +2 -0
  35. package/lib/e2e/families/hedera.d.ts.map +1 -0
  36. package/lib/e2e/families/hedera.js +11 -0
  37. package/lib/e2e/families/hedera.js.map +1 -0
  38. package/lib/e2e/families/sui.d.ts +2 -0
  39. package/lib/e2e/families/sui.d.ts.map +1 -0
  40. package/lib/e2e/families/sui.js +11 -0
  41. package/lib/e2e/families/sui.js.map +1 -0
  42. package/lib/e2e/speculos.d.ts +1 -0
  43. package/lib/e2e/speculos.d.ts.map +1 -1
  44. package/lib/e2e/speculos.js +35 -1
  45. package/lib/e2e/speculos.js.map +1 -1
  46. package/lib/exchange/platform/types.d.ts +2 -0
  47. package/lib/exchange/platform/types.d.ts.map +1 -1
  48. package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
  49. package/lib/exchange/swap/completeExchange.js +22 -1
  50. package/lib/exchange/swap/completeExchange.js.map +1 -1
  51. package/lib/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
  52. package/lib/exchange/swap/getIncompatibleCurrencyKeys.js +8 -0
  53. package/lib/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
  54. package/lib/families/hedera/exchange.d.ts +9 -0
  55. package/lib/families/hedera/exchange.d.ts.map +1 -0
  56. package/lib/families/hedera/exchange.js +36 -0
  57. package/lib/families/hedera/exchange.js.map +1 -0
  58. package/lib/hw/actions/completeExchange.d.ts +2 -0
  59. package/lib/hw/actions/completeExchange.d.ts.map +1 -1
  60. package/lib/hw/actions/completeExchange.js +1 -0
  61. package/lib/hw/actions/completeExchange.js.map +1 -1
  62. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +7 -0
  63. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -0
  64. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +224 -0
  65. package/lib/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -0
  66. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +4 -3
  67. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
  68. package/lib/modularDrawer/hooks/useRightBalanceAsset.js +13 -47
  69. package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
  70. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +1 -5
  71. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
  72. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +15 -55
  73. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
  74. package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -1
  75. package/lib/modularDrawer/modules/createAssetConfiguration.js +2 -2
  76. package/lib/modularDrawer/modules/createAssetConfiguration.js.map +1 -1
  77. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
  78. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  79. package/lib/modularDrawer/modules/createNetworkConfiguration.js +1 -3
  80. package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  81. package/lib/modularDrawer/utils/currencyUtils.d.ts.map +1 -1
  82. package/lib/modularDrawer/utils/currencyUtils.js.map +1 -1
  83. package/lib/modularDrawer/utils/index.d.ts +3 -6
  84. package/lib/modularDrawer/utils/index.d.ts.map +1 -1
  85. package/lib/modularDrawer/utils/index.js +3 -12
  86. package/lib/modularDrawer/utils/index.js.map +1 -1
  87. package/lib/modularDrawer/utils/index.test.js +0 -26
  88. package/lib/modularDrawer/utils/index.test.js.map +1 -1
  89. package/lib/modularDrawer/utils/type.d.ts +0 -6
  90. package/lib/modularDrawer/utils/type.d.ts.map +1 -1
  91. package/lib/wallet-api/constants.d.ts +1 -1
  92. package/lib/wallet-api/constants.d.ts.map +1 -1
  93. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +4 -4
  94. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -1
  95. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +7 -9
  96. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -1
  97. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  98. package/lib-es/bridge/generic-alpaca/getAccountShape.js +4 -6
  99. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  100. package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js +5 -3
  101. package/lib-es/bridge/generic-alpaca/tests/getAccountShape.test.js.map +1 -1
  102. package/lib-es/e2e/enum/Account.d.ts +6 -0
  103. package/lib-es/e2e/enum/Account.d.ts.map +1 -1
  104. package/lib-es/e2e/enum/Account.js +8 -0
  105. package/lib-es/e2e/enum/Account.js.map +1 -1
  106. package/lib-es/e2e/enum/AppInfos.d.ts +2 -0
  107. package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
  108. package/lib-es/e2e/enum/AppInfos.js +2 -0
  109. package/lib-es/e2e/enum/AppInfos.js.map +1 -1
  110. package/lib-es/e2e/enum/Currency.d.ts +4 -0
  111. package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
  112. package/lib-es/e2e/enum/Currency.js +6 -0
  113. package/lib-es/e2e/enum/Currency.js.map +1 -1
  114. package/lib-es/e2e/enum/Network.d.ts +3 -1
  115. package/lib-es/e2e/enum/Network.d.ts.map +1 -1
  116. package/lib-es/e2e/enum/Network.js +2 -0
  117. package/lib-es/e2e/enum/Network.js.map +1 -1
  118. package/lib-es/e2e/enum/TokenType.d.ts +2 -1
  119. package/lib-es/e2e/enum/TokenType.d.ts.map +1 -1
  120. package/lib-es/e2e/enum/TokenType.js +1 -0
  121. package/lib-es/e2e/enum/TokenType.js.map +1 -1
  122. package/lib-es/e2e/enum/TransactionStatus.d.ts +4 -1
  123. package/lib-es/e2e/enum/TransactionStatus.d.ts.map +1 -1
  124. package/lib-es/e2e/enum/TransactionStatus.js +3 -0
  125. package/lib-es/e2e/enum/TransactionStatus.js.map +1 -1
  126. package/lib-es/e2e/families/hedera.d.ts +2 -0
  127. package/lib-es/e2e/families/hedera.d.ts.map +1 -0
  128. package/lib-es/e2e/families/hedera.js +7 -0
  129. package/lib-es/e2e/families/hedera.js.map +1 -0
  130. package/lib-es/e2e/families/sui.d.ts +2 -0
  131. package/lib-es/e2e/families/sui.d.ts.map +1 -0
  132. package/lib-es/e2e/families/sui.js +7 -0
  133. package/lib-es/e2e/families/sui.js.map +1 -0
  134. package/lib-es/e2e/speculos.d.ts +1 -0
  135. package/lib-es/e2e/speculos.d.ts.map +1 -1
  136. package/lib-es/e2e/speculos.js +33 -0
  137. package/lib-es/e2e/speculos.js.map +1 -1
  138. package/lib-es/exchange/platform/types.d.ts +2 -0
  139. package/lib-es/exchange/platform/types.d.ts.map +1 -1
  140. package/lib-es/exchange/swap/completeExchange.d.ts.map +1 -1
  141. package/lib-es/exchange/swap/completeExchange.js +22 -1
  142. package/lib-es/exchange/swap/completeExchange.js.map +1 -1
  143. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.d.ts.map +1 -1
  144. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js +8 -0
  145. package/lib-es/exchange/swap/getIncompatibleCurrencyKeys.js.map +1 -1
  146. package/lib-es/families/hedera/exchange.d.ts +9 -0
  147. package/lib-es/families/hedera/exchange.d.ts.map +1 -0
  148. package/lib-es/families/hedera/exchange.js +29 -0
  149. package/lib-es/families/hedera/exchange.js.map +1 -0
  150. package/lib-es/hw/actions/completeExchange.d.ts +2 -0
  151. package/lib-es/hw/actions/completeExchange.d.ts.map +1 -1
  152. package/lib-es/hw/actions/completeExchange.js +1 -0
  153. package/lib-es/hw/actions/completeExchange.js.map +1 -1
  154. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts +7 -0
  155. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.d.ts.map +1 -0
  156. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js +217 -0
  157. package/lib-es/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.js.map +1 -0
  158. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +4 -3
  159. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
  160. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +13 -47
  161. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
  162. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +1 -5
  163. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
  164. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +15 -55
  165. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
  166. package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -1
  167. package/lib-es/modularDrawer/modules/createAssetConfiguration.js +2 -2
  168. package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +1 -1
  169. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +1 -1
  170. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  171. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +1 -3
  172. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  173. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js +1 -1
  174. package/lib-es/modularDrawer/utils/__tests__/currencyUtils.test.js.map +1 -1
  175. package/lib-es/modularDrawer/utils/currencyUtils.d.ts.map +1 -1
  176. package/lib-es/modularDrawer/utils/currencyUtils.js.map +1 -1
  177. package/lib-es/modularDrawer/utils/index.d.ts +3 -6
  178. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
  179. package/lib-es/modularDrawer/utils/index.js +3 -10
  180. package/lib-es/modularDrawer/utils/index.js.map +1 -1
  181. package/lib-es/modularDrawer/utils/index.test.js +1 -27
  182. package/lib-es/modularDrawer/utils/index.test.js.map +1 -1
  183. package/lib-es/modularDrawer/utils/type.d.ts +0 -6
  184. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
  185. package/lib-es/wallet-api/constants.d.ts +1 -1
  186. package/lib-es/wallet-api/constants.d.ts.map +1 -1
  187. package/package.json +45 -43
  188. package/src/bridge/generic-alpaca/buildSubAccounts.ts +28 -28
  189. package/src/bridge/generic-alpaca/getAccountShape.ts +9 -12
  190. package/src/bridge/generic-alpaca/tests/getAccountShape.test.ts +5 -3
  191. package/src/e2e/enum/Account.ts +41 -0
  192. package/src/e2e/enum/AppInfos.ts +4 -0
  193. package/src/e2e/enum/Currency.ts +21 -0
  194. package/src/e2e/enum/Network.ts +2 -0
  195. package/src/e2e/enum/TokenType.ts +1 -0
  196. package/src/e2e/enum/TransactionStatus.ts +3 -0
  197. package/src/e2e/families/hedera.ts +7 -0
  198. package/src/e2e/families/sui.ts +7 -0
  199. package/src/e2e/speculos.ts +34 -0
  200. package/src/exchange/platform/types.ts +2 -0
  201. package/src/exchange/swap/completeExchange.ts +32 -2
  202. package/src/exchange/swap/getIncompatibleCurrencyKeys.ts +8 -0
  203. package/src/families/hedera/exchange.ts +48 -0
  204. package/src/hw/actions/completeExchange.ts +3 -0
  205. package/src/modularDrawer/hooks/useCurrenciesUnderFeatureFlag.ts +231 -0
  206. package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +16 -76
  207. package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +25 -95
  208. package/src/modularDrawer/modules/createAssetConfiguration.ts +3 -11
  209. package/src/modularDrawer/modules/createNetworkConfiguration.ts +1 -8
  210. package/src/modularDrawer/utils/__tests__/currencyUtils.test.ts +1 -1
  211. package/src/modularDrawer/utils/currencyUtils.ts +0 -1
  212. package/src/modularDrawer/utils/index.test.ts +1 -32
  213. package/src/modularDrawer/utils/index.ts +4 -23
  214. package/src/modularDrawer/utils/type.ts +0 -6
  215. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +0 -2
  216. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +0 -1
  217. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +0 -28
  218. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +0 -1
  219. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +0 -9
  220. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +0 -1
  221. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js +0 -17
  222. package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js.map +0 -1
  223. package/lib/modularDrawer/utils/getProviderCurrency.d.ts +0 -3
  224. package/lib/modularDrawer/utils/getProviderCurrency.d.ts.map +0 -1
  225. package/lib/modularDrawer/utils/getProviderCurrency.js +0 -14
  226. package/lib/modularDrawer/utils/getProviderCurrency.js.map +0 -1
  227. package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts +0 -11
  228. package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts.map +0 -1
  229. package/lib/modularDrawer/utils/haveOneCommonProvider.js +0 -29
  230. package/lib/modularDrawer/utils/haveOneCommonProvider.js.map +0 -1
  231. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +0 -2
  232. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +0 -1
  233. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +0 -26
  234. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +0 -1
  235. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +0 -9
  236. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +0 -1
  237. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js +0 -13
  238. package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js.map +0 -1
  239. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts +0 -3
  240. package/lib-es/modularDrawer/utils/getProviderCurrency.d.ts.map +0 -1
  241. package/lib-es/modularDrawer/utils/getProviderCurrency.js +0 -10
  242. package/lib-es/modularDrawer/utils/getProviderCurrency.js.map +0 -1
  243. package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts +0 -11
  244. package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts.map +0 -1
  245. package/lib-es/modularDrawer/utils/haveOneCommonProvider.js +0 -25
  246. package/lib-es/modularDrawer/utils/haveOneCommonProvider.js.map +0 -1
  247. package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +0 -34
  248. package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +0 -25
  249. package/src/modularDrawer/utils/getProviderCurrency.ts +0 -13
  250. package/src/modularDrawer/utils/haveOneCommonProvider.ts +0 -31
@@ -1,15 +1,11 @@
1
- import { useMemo } from "react";
2
- import type { ReactNode } from "react";
1
+ import { useMemo, type ReactNode } from "react";
3
2
  import type { CryptoOrTokenCurrency, Currency } from "@ledgerhq/types-cryptoassets";
4
3
  import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
5
4
  import BigNumber from "bignumber.js";
6
5
  import { counterValueFormatter } from "../utils/counterValueFormatter";
7
6
  import { compareByBalanceThenFiat } from "../utils/sortByBalance";
8
7
  import { UseBalanceDeps } from "../utils/type";
9
- import { buildProviderCurrenciesMap } from "../utils/buildProviderCurrenciesMap";
10
- import { CurrenciesByProviderId } from "../../deposit/type";
11
8
  import { calculateProviderTotals } from "../utils/calculateProviderTotal";
12
- import { getProviderCurrency } from "../utils/getProviderCurrency";
13
9
  import { groupAccountsByAsset } from "../utils/groupAccountsByAsset";
14
10
 
15
11
  export type AssetDeps = {
@@ -43,10 +39,7 @@ export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem, assets
43
39
  return { balance, fiatValue };
44
40
  };
45
41
 
46
- return function useRightBalanceAsset(
47
- assets: CryptoOrTokenCurrency[],
48
- currenciesByProvider: CurrenciesByProviderId[],
49
- ) {
42
+ return function useRightBalanceAsset(assets: CryptoOrTokenCurrency[]) {
50
43
  const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
51
44
 
52
45
  const grouped = useMemo(
@@ -54,92 +47,39 @@ export function createUseRightBalanceAsset({ useBalanceDeps, balanceItem, assets
54
47
  [flattenedAccounts, state, counterValueCurrency, discreet],
55
48
  );
56
49
 
57
- const providerMap = useMemo(
58
- () => buildProviderCurrenciesMap(currenciesByProvider),
59
- [currenciesByProvider],
60
- );
61
-
62
50
  return useMemo(() => {
63
- if (!providerMap) {
64
- const balanceMap = new Map();
65
-
66
- for (const [, { currencies, mainCurrency }] of assetsMap) {
67
- const { totalBalance, totalFiatValue } = calculateProviderTotals(currencies, grouped);
51
+ const balanceMap = new Map();
68
52
 
69
- const { balance, fiatValue } = formatProviderResult(
70
- mainCurrency,
71
- totalBalance,
72
- totalFiatValue,
73
- counterValueCurrency,
74
- locale,
75
- discreet,
76
- );
77
-
78
- balanceMap.set(mainCurrency.id, {
79
- balance: balance,
80
- fiatValue: fiatValue,
81
- });
82
- }
83
-
84
- const assetsWithBalanceData = assets.map(asset => {
85
- const balanceData = balanceMap.get(asset.id) || {};
86
- return {
87
- asset,
88
- balanceData,
89
- };
90
- });
91
-
92
- assetsWithBalanceData.sort((a, b) =>
93
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
94
- );
95
-
96
- return assetsWithBalanceData.map(({ asset, balanceData }) => ({
97
- ...asset,
98
- rightElement: balanceItem(balanceData),
99
- }));
100
- }
101
-
102
- const assetsSet = new Set(assets.map(a => a.id));
103
- const providerResultsMap = new Map<string, { balance?: string; fiatValue?: string }>();
104
-
105
- for (const [, { currencies, mainCurrency }] of providerMap) {
106
- if (!assetsSet.has(mainCurrency.id)) continue;
107
- const providerCurrency = getProviderCurrency(mainCurrency, currencies);
108
- if (!providerCurrency) continue;
109
-
110
- const { totalBalance, totalFiatValue, hasAccounts } = calculateProviderTotals(
111
- currencies,
112
- grouped,
113
- );
114
- if (!hasAccounts) continue;
53
+ for (const [, { currencies, mainCurrency }] of assetsMap) {
54
+ const { totalBalance, totalFiatValue } = calculateProviderTotals(currencies, grouped);
115
55
 
116
56
  const { balance, fiatValue } = formatProviderResult(
117
- providerCurrency,
57
+ mainCurrency,
118
58
  totalBalance,
119
59
  totalFiatValue,
120
60
  counterValueCurrency,
121
61
  locale,
122
62
  discreet,
123
63
  );
124
- providerResultsMap.set(mainCurrency.id, { balance, fiatValue });
64
+
65
+ balanceMap.set(mainCurrency.id, {
66
+ balance: balance,
67
+ fiatValue: fiatValue,
68
+ });
125
69
  }
126
70
 
127
71
  const assetsWithBalanceData = assets.map(asset => {
128
- const balanceData = providerResultsMap.get(asset.id) || {};
72
+ const balanceData = balanceMap.get(asset.id) || {};
129
73
  return {
130
- asset,
74
+ ...asset,
131
75
  balanceData,
76
+ rightElement: balanceItem(balanceData),
132
77
  };
133
78
  });
134
79
 
135
- assetsWithBalanceData.sort((a, b) =>
80
+ return assetsWithBalanceData.sort((a, b) =>
136
81
  compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
137
82
  );
138
-
139
- return assetsWithBalanceData.map(({ asset, balanceData }) => ({
140
- ...asset,
141
- rightElement: balanceItem(balanceData),
142
- }));
143
- }, [providerMap, assets, grouped, counterValueCurrency, locale, discreet]);
83
+ }, [assets, grouped, counterValueCurrency, locale, discreet]);
144
84
  };
145
85
  }
@@ -1,8 +1,7 @@
1
- import { useMemo, type ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
3
3
  import { compareByBalanceThenFiat } from "../utils/sortByBalance";
4
- import { BalanceUI, UseBalanceDeps } from "../utils/type";
5
- import { CurrenciesByProviderId } from "../../deposit/type";
4
+ import { UseBalanceDeps } from "../utils/type";
6
5
  import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
7
6
 
8
7
  export type NetworkDeps = {
@@ -11,108 +10,39 @@ export type NetworkDeps = {
11
10
  };
12
11
 
13
12
  type Params = {
14
- assets: CryptoOrTokenCurrency[];
15
13
  networks: CryptoOrTokenCurrency[];
16
- selectedAssetId: string;
17
- currenciesByProvider: CurrenciesByProviderId[];
18
14
  };
19
15
 
20
16
  export function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }: NetworkDeps) {
21
- return function useRightBalanceNetwork({
22
- assets: networks,
23
- selectedAssetId,
24
- currenciesByProvider,
25
- networks: actualNetworks,
26
- }: Params) {
17
+ return function useRightBalanceNetwork({ networks }: Params) {
27
18
  const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
28
19
 
29
- return useMemo(() => {
30
- if (currenciesByProvider && currenciesByProvider.length > 0) {
31
- const providerOfSelectedAsset = currenciesByProvider.find(provider =>
32
- provider.currenciesByNetwork.some(currency => currency.id === selectedAssetId),
33
- );
34
-
35
- if (providerOfSelectedAsset) {
36
- const pairs = networks.map(network => ({
37
- network,
38
- asset: providerOfSelectedAsset.currenciesByNetwork.find(currency =>
39
- currency.type === "TokenCurrency"
40
- ? currency.parentCurrency.id === network.id
41
- : currency.id === network.id,
42
- ),
43
- }));
44
-
45
- const validAssets = pairs.filter(p => p.asset).map(p => p.asset!);
46
-
47
- const allBalanceData =
48
- validAssets.length > 0
49
- ? getBalanceAndFiatValueByAssets(
50
- flattenedAccounts,
51
- validAssets,
52
- state,
53
- counterValueCurrency,
54
- discreet,
55
- locale,
56
- )
57
- : [];
58
-
59
- const balanceMap = new Map(allBalanceData.map(b => [b.id, b]));
60
-
61
- const networkWithBalanceData = pairs.map(({ network, asset }) => {
62
- const balanceData: BalanceUI = asset ? balanceMap.get(asset.id) || {} : {};
63
- return {
64
- network,
65
- balanceData,
66
- };
67
- });
68
-
69
- networkWithBalanceData.sort((a, b) =>
70
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
71
- );
72
-
73
- return networkWithBalanceData.map(({ network, balanceData }) => ({
74
- ...network,
75
- rightElement: balanceItem(balanceData),
76
- }));
77
- }
78
- }
79
-
80
- const networkBalanceData = getBalanceAndFiatValueByAssets(
81
- flattenedAccounts,
82
- actualNetworks,
83
- state,
84
- counterValueCurrency,
85
- discreet,
86
- locale,
87
- );
88
-
89
- const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
90
-
91
- const networksWithBalance = actualNetworks.map(network => {
92
- const balanceData = balanceMap.get(network.id) || {};
93
- return {
94
- network,
95
- balanceData,
96
- };
97
- });
98
-
99
- networksWithBalance.sort((a, b) =>
100
- compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
101
- );
102
-
103
- return networksWithBalance.map(({ network, balanceData }) => ({
104
- ...network,
105
- rightElement: balanceItem(balanceData),
106
- }));
107
- }, [
108
- networks,
109
- selectedAssetId,
110
- currenciesByProvider,
20
+ const networkBalanceData = getBalanceAndFiatValueByAssets(
111
21
  flattenedAccounts,
22
+ networks,
112
23
  state,
113
24
  counterValueCurrency,
114
25
  discreet,
115
26
  locale,
116
- ]);
27
+ );
28
+
29
+ const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
30
+
31
+ const networksWithBalance = networks.map(network => {
32
+ const balanceData = balanceMap.get(network.id) || {};
33
+ return {
34
+ network,
35
+ balanceData,
36
+ };
37
+ });
38
+
39
+ networksWithBalance.sort((a, b) =>
40
+ compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet),
41
+ );
42
+
43
+ return networksWithBalance.map(({ network, balanceData }) => ({
44
+ ...network,
45
+ rightElement: balanceItem(balanceData),
46
+ }));
117
47
  };
118
48
  }
@@ -1,6 +1,5 @@
1
1
  import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
2
  import { AssetType, CreateAssetConfigurationHook, AssetConfigurationDeps } from "../utils/type";
3
- import { CurrenciesByProviderId } from "../../deposit/type";
4
3
  import { composeHooks } from "../../utils/composeHooks";
5
4
  import { useLeftApyModule } from "../hooks/modules/useLeftApyModule";
6
5
  import { createUseRightBalanceAsset } from "../hooks/useRightBalanceAsset";
@@ -46,7 +45,7 @@ const getLeftElement =
46
45
 
47
46
  const createAssetConfigurationHook: CreateAssetConfigurationHook =
48
47
  deps =>
49
- ({ assetsConfiguration, currenciesByProvider }) => {
48
+ ({ assetsConfiguration }) => {
50
49
  const { rightElement, leftElement } = assetsConfiguration ?? {};
51
50
 
52
51
  const rightHook = getRightElement(deps)(rightElement);
@@ -54,18 +53,11 @@ const createAssetConfigurationHook: CreateAssetConfigurationHook =
54
53
 
55
54
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
56
55
  const hooks = [rightHook, leftHook].filter(Boolean) as Array<
57
- (
58
- assets: CryptoOrTokenCurrency[],
59
- currenciesByProvider?: CurrenciesByProviderId[],
60
- ) => AssetType[]
56
+ (assets: CryptoOrTokenCurrency[]) => AssetType[]
61
57
  >;
62
58
 
63
59
  return (assets: CryptoOrTokenCurrency[]) => {
64
- const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(
65
- ...hooks.map(
66
- hook => (assets: CryptoOrTokenCurrency[]) => hook(assets, currenciesByProvider),
67
- ),
68
- );
60
+ const composedHook = composeHooks<CryptoOrTokenCurrency, AssetType>(...hooks);
69
61
  return composedHook(assets);
70
62
  };
71
63
  };
@@ -53,12 +53,7 @@ export const getRightElement =
53
53
 
54
54
  export const createNetworkConfigurationHook =
55
55
  (NetworkConfigurationDeps: NetworkConfigurationDeps) =>
56
- ({
57
- networksConfig,
58
- selectedAssetId,
59
- currenciesByProvider,
60
- accounts$,
61
- }: CreateNetworkConfigurationHookProps) => {
56
+ ({ networksConfig, accounts$ }: CreateNetworkConfigurationHookProps) => {
62
57
  const { leftElement, rightElement } = networksConfig ?? {};
63
58
  const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
64
59
  const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
@@ -75,8 +70,6 @@ export const createNetworkConfigurationHook =
75
70
  hook => () =>
76
71
  hook({
77
72
  assets,
78
- selectedAssetId,
79
- currenciesByProvider: currenciesByProvider || [],
80
73
  accounts$,
81
74
  networks,
82
75
  }),
@@ -10,10 +10,10 @@ import {
10
10
  safeCurrencyLookup,
11
11
  } from "../currencyUtils";
12
12
  import {
13
- usdcToken,
14
13
  mockBaseCryptoCurrency,
15
14
  mockBtcCryptoCurrency,
16
15
  mockEthCryptoCurrency,
16
+ usdcToken,
17
17
  } from "../../__mocks__/currencies.mock";
18
18
 
19
19
  describe("safeCurrencyLookup", () => {
@@ -4,7 +4,6 @@ import { isTokenCurrency } from "../../currencies";
4
4
  import { CurrenciesByProviderId } from "../../deposit/type";
5
5
 
6
6
  export type ProviderCoverageMap = Map<string, Set<string>>;
7
-
8
7
  export const safeCurrencyLookup = (id: string): CryptoOrTokenCurrency | null => {
9
8
  try {
10
9
  return getTokenOrCryptoCurrencyById(id);
@@ -1,9 +1,8 @@
1
- import { isCorrespondingCurrency, getEffectiveCurrency } from "./index";
1
+ import { isCorrespondingCurrency } from "./index";
2
2
 
3
3
  import { createFixtureCryptoCurrency } from "../../mock/fixtures/cryptoCurrencies";
4
4
  import { cryptocurrenciesById } from "@ledgerhq/cryptoassets";
5
5
  import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
6
- import type { CurrenciesByProviderId } from "../../deposit/type";
7
6
 
8
7
  describe("isCorrespondingCurrency", () => {
9
8
  const evmCurrency = createFixtureCryptoCurrency("evm");
@@ -42,33 +41,3 @@ describe("isCorrespondingCurrency", () => {
42
41
  expect(isCorrespondingCurrency(bitcoinCurrency, evmCurrency)).toBe(false);
43
42
  });
44
43
  });
45
-
46
- describe("getEffectiveCurrency", () => {
47
- const parent = createFixtureCryptoCurrency("evm");
48
- const token: CryptoOrTokenCurrency = {
49
- type: "TokenCurrency",
50
- id: "ethereum/erc20/usdc",
51
- contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
52
- parentCurrency: parent,
53
- tokenType: "erc20",
54
- name: "USD Coin",
55
- ticker: "USDC",
56
- units: [{ name: "USD Coin", code: "USDC", magnitude: 6 }],
57
- };
58
- const provider: CurrenciesByProviderId = {
59
- providerId: "provider1",
60
- currenciesByNetwork: [parent, token],
61
- };
62
-
63
- it("returns currency if id is in currencyIds", () => {
64
- expect(getEffectiveCurrency(token, provider, [token.id])).toBe(token);
65
- });
66
-
67
- it("returns first matching currency from provider if id not in currencyIds", () => {
68
- expect(getEffectiveCurrency(token, provider, [parent.id])).toBe(parent);
69
- });
70
-
71
- it("returns currency if no match in provider", () => {
72
- expect(getEffectiveCurrency(token, provider, ["notfound"])).toBe(token);
73
- });
74
- });
@@ -1,8 +1,7 @@
1
1
  import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- import { CurrenciesByProviderId } from "../../deposit/type";
3
- import { haveOneCommonProvider } from "./haveOneCommonProvider";
4
- import { getBalanceAndFiatValue } from "./getBalanceAndFiatValue";
5
- import { groupCurrenciesByProvider } from "./groupCurrenciesByProvider";
2
+
3
+ export { getBalanceAndFiatValue } from "./getBalanceAndFiatValue";
4
+ export { groupCurrenciesByProvider } from "./groupCurrenciesByProvider";
6
5
 
7
6
  function isCorrespondingCurrency(
8
7
  elem: CryptoOrTokenCurrency,
@@ -17,22 +16,4 @@ function isCorrespondingCurrency(
17
16
  return false;
18
17
  }
19
18
 
20
- const getEffectiveCurrency = (
21
- currency: CryptoOrTokenCurrency,
22
- provider: CurrenciesByProviderId,
23
- currencyIds: string[],
24
- ) => {
25
- const isCurrencyFiltered = currencyIds.includes(currency.id);
26
-
27
- if (isCurrencyFiltered) return currency;
28
-
29
- return provider.currenciesByNetwork.find(elem => currencyIds.includes(elem.id)) ?? currency;
30
- };
31
-
32
- export {
33
- isCorrespondingCurrency,
34
- getEffectiveCurrency,
35
- haveOneCommonProvider,
36
- getBalanceAndFiatValue,
37
- groupCurrenciesByProvider,
38
- };
19
+ export { isCorrespondingCurrency };
@@ -4,7 +4,6 @@ import { AccountLike } from "@ledgerhq/types-live";
4
4
  import { ReactNode } from "react";
5
5
  import { Observable } from "rxjs";
6
6
  import { WalletAPIAccount } from "../../wallet-api/types";
7
- import { CurrenciesByProviderId } from "../../deposit/type";
8
7
  import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
9
8
  import { InterestRate } from "../data/entities";
10
9
  import { MarketItemResponse } from "../../market/utils/types";
@@ -74,8 +73,6 @@ export type UseAccountData = (params: AccountModuleParams) => AccountDataItem[];
74
73
  export type NetworkHookParams = {
75
74
  assets: CryptoOrTokenCurrency[];
76
75
  networks: CryptoOrTokenCurrency[];
77
- selectedAssetId: string;
78
- currenciesByProvider: CurrenciesByProviderId[];
79
76
  accounts$?: Observable<WalletAPIAccount[]>;
80
77
  };
81
78
  export type NetworkHook = (params: NetworkHookParams) => Array<CryptoOrTokenCurrency & Network>;
@@ -101,14 +98,11 @@ export type Network = {
101
98
 
102
99
  export type CreateNetworkConfigurationHookProps = {
103
100
  networksConfig: EnhancedModularDrawerConfiguration["networks"];
104
- currenciesByProvider?: CurrenciesByProviderId[];
105
- selectedAssetId: string;
106
101
  accounts$?: Observable<WalletAPIAccount[]>;
107
102
  };
108
103
 
109
104
  type Props = {
110
105
  assetsConfiguration: EnhancedModularDrawerConfiguration["assets"];
111
- currenciesByProvider?: CurrenciesByProviderId[];
112
106
  };
113
107
 
114
108
  export type AssetConfigurationDeps = {
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=haveOneCommonProvider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"haveOneCommonProvider.test.d.ts","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":""}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const haveOneCommonProvider_1 = require("../haveOneCommonProvider");
4
- const useGroupedCurrenciesByProvider_mock_1 = require("../../__mocks__/useGroupedCurrenciesByProvider.mock");
5
- jest.mock("../../../deposit/useGroupedCurrenciesByProvider.hook", () => ({
6
- useGroupedCurrenciesByProvider: () => (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(),
7
- }));
8
- describe("haveOneCommonProvider", () => {
9
- it("should return false for an empty array", () => {
10
- expect((0, haveOneCommonProvider_1.haveOneCommonProvider)([], [])).toBe(false);
11
- });
12
- it("should return true for a single currency with one provider", () => {
13
- const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
14
- const { currenciesByProvider } = result;
15
- expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["bitcoin"], currenciesByProvider)).toBe(true);
16
- });
17
- it("should return false for multiple currencies with different providers", () => {
18
- const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
19
- const { currenciesByProvider } = result;
20
- expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["bitcoin", "ethereum"], currenciesByProvider)).toBe(false);
21
- });
22
- it("should return true for multiple currencies with the same provider", () => {
23
- const { result } = (0, useGroupedCurrenciesByProvider_mock_1.useGroupedCurrenciesByProvider)(true);
24
- const { currenciesByProvider } = result;
25
- expect((0, haveOneCommonProvider_1.haveOneCommonProvider)(["ethereum", "arbitrum"], currenciesByProvider)).toBe(true);
26
- });
27
- });
28
- //# sourceMappingURL=haveOneCommonProvider.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"haveOneCommonProvider.test.js","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":";;AAAA,oEAAiE;AACjE,6GAAqG;AAGrG,IAAI,CAAC,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE,CAAC,CAAC;IACvE,8BAA8B,EAAE,GAAG,EAAE,CAAC,IAAA,oEAA8B,GAAE;CACvE,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,IAAA,6CAAqB,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC9E,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,oEAA8B,EAAC,IAAI,CAAkC,CAAC;QACzF,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAAC;QAExC,MAAM,CAAC,IAAA,6CAAqB,EAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- export declare const buildProviderCurrenciesMap: (currenciesByProvider?: Array<{
3
- providerId: string;
4
- currenciesByNetwork?: CryptoOrTokenCurrency[];
5
- }>) => Map<string, {
6
- mainCurrency: CryptoOrTokenCurrency;
7
- currencies: CryptoOrTokenCurrency[];
8
- }> | null;
9
- //# sourceMappingURL=buildProviderCurrenciesMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildProviderCurrenciesMap.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/buildProviderCurrenciesMap.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,eAAO,MAAM,0BAA0B,0BACd,MAAM;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC/C,CAAC;kBAMgB,qBAAqB;gBAAc,qBAAqB,EAAE;SAY7E,CAAC"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProviderCurrenciesMap = void 0;
4
- const buildProviderCurrenciesMap = (currenciesByProvider) => {
5
- if (!currenciesByProvider?.length)
6
- return null;
7
- const map = new Map();
8
- currenciesByProvider.forEach(({ providerId, currenciesByNetwork = [] }) => {
9
- if (currenciesByNetwork.length > 0) {
10
- const mainCurrency = currenciesByNetwork.find(c => c.id === providerId) ?? currenciesByNetwork[0];
11
- map.set(providerId, { mainCurrency, currencies: currenciesByNetwork });
12
- }
13
- });
14
- return map;
15
- };
16
- exports.buildProviderCurrenciesMap = buildProviderCurrenciesMap;
17
- //# sourceMappingURL=buildProviderCurrenciesMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildProviderCurrenciesMap.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/buildProviderCurrenciesMap.tsx"],"names":[],"mappings":";;;AAEO,MAAM,0BAA0B,GAAG,CACxC,oBAGE,EACF,EAAE;IACF,IAAI,CAAC,oBAAoB,EAAE,MAAM;QAAE,OAAO,IAAI,CAAC;IAE/C,MAAM,GAAG,GAAG,IAAI,GAAG,EAGhB,CAAC;IAEJ,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,mBAAmB,GAAG,EAAE,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE;YAClC,MAAM,YAAY,GAChB,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAC/E,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,CAAC;SACxE;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC"}
@@ -1,3 +0,0 @@
1
- import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
- export declare const getProviderCurrency: (mainCurrency: CryptoOrTokenCurrency, currencies: CryptoOrTokenCurrency[]) => CryptoOrTokenCurrency;
3
- //# sourceMappingURL=getProviderCurrency.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProviderCurrency.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getProviderCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,eAAO,MAAM,mBAAmB,iBAChB,qBAAqB,cACvB,qBAAqB,EAAE,0BAOpC,CAAC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProviderCurrency = void 0;
4
- const helper_1 = require("../../deposit/helper");
5
- const getProviderCurrency = (mainCurrency, currencies) => {
6
- try {
7
- return (0, helper_1.getTokenOrCryptoCurrencyById)(mainCurrency.id);
8
- }
9
- catch {
10
- return (0, helper_1.getTokenOrCryptoCurrencyById)(currencies[0].id);
11
- }
12
- };
13
- exports.getProviderCurrency = getProviderCurrency;
14
- //# sourceMappingURL=getProviderCurrency.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getProviderCurrency.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getProviderCurrency.ts"],"names":[],"mappings":";;;AACA,iDAAoE;AAE7D,MAAM,mBAAmB,GAAG,CACjC,YAAmC,EACnC,UAAmC,EACnC,EAAE;IACF,IAAI;QACF,OAAO,IAAA,qCAA4B,EAAC,YAAY,CAAC,EAAE,CAAC,CAAC;KACtD;IAAC,MAAM;QACN,OAAO,IAAA,qCAA4B,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KACvD;AACH,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B"}
@@ -1,11 +0,0 @@
1
- import { CurrenciesByProviderId } from "../../deposit/type";
2
- /**
3
- * This function checks if all currencies in the provided array
4
- * it stopped at the first currency that does not match to prevent unnecessary iterations.
5
- *
6
- * @param currenciesIdsArray array of currency IDs to check
7
- * @param currenciesByProvider array of currencies grouped by provider
8
- * @returns boolean indicating whether all currencies in the array have one common provider
9
- */
10
- export declare const haveOneCommonProvider: (currenciesIdsArray: string[], currenciesByProvider: CurrenciesByProviderId[]) => boolean;
11
- //# sourceMappingURL=haveOneCommonProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"haveOneCommonProvider.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,uBACZ,MAAM,EAAE,wBACN,sBAAsB,EAAE,KAC7C,OAiBF,CAAC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.haveOneCommonProvider = void 0;
4
- /**
5
- * This function checks if all currencies in the provided array
6
- * it stopped at the first currency that does not match to prevent unnecessary iterations.
7
- *
8
- * @param currenciesIdsArray array of currency IDs to check
9
- * @param currenciesByProvider array of currencies grouped by provider
10
- * @returns boolean indicating whether all currencies in the array have one common provider
11
- */
12
- const haveOneCommonProvider = (currenciesIdsArray, currenciesByProvider) => {
13
- if (currenciesIdsArray.length === 0)
14
- return false;
15
- const providerIds = new Set();
16
- for (const currencyId of currenciesIdsArray) {
17
- for (const provider of currenciesByProvider) {
18
- if (provider.currenciesByNetwork.some(currency => currency.id === currencyId)) {
19
- providerIds.add(provider.providerId);
20
- if (providerIds.size > 1) {
21
- return false;
22
- }
23
- }
24
- }
25
- }
26
- return true;
27
- };
28
- exports.haveOneCommonProvider = haveOneCommonProvider;
29
- //# sourceMappingURL=haveOneCommonProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"haveOneCommonProvider.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/haveOneCommonProvider.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACI,MAAM,qBAAqB,GAAG,CACnC,kBAA4B,EAC5B,oBAA8C,EACrC,EAAE;IACX,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAElD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,KAAK,MAAM,UAAU,IAAI,kBAAkB,EAAE;QAC3C,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE;YAC3C,IAAI,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE;gBAC7E,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACrC,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE;oBACxB,OAAO,KAAK,CAAC;iBACd;aACF;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AApBW,QAAA,qBAAqB,yBAoBhC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=haveOneCommonProvider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"haveOneCommonProvider.test.d.ts","sourceRoot":"","sources":["../../../../src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts"],"names":[],"mappings":""}