@ledgerhq/live-common 34.50.0-nightly.6 → 34.51.0-nightly.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.
Files changed (179) hide show
  1. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  2. package/lib/bridge/generic-alpaca/prepareTransaction.js +3 -6
  3. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  4. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +60 -0
  5. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  6. package/lib/bridge/generic-alpaca/types.d.ts +0 -1
  7. package/lib/bridge/generic-alpaca/types.d.ts.map +1 -1
  8. package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
  9. package/lib/exchange/swap/postSwapState.js +19 -23
  10. package/lib/exchange/swap/postSwapState.js.map +1 -1
  11. package/lib/exchange/swap/setBroadcastTransaction.d.ts +4 -4
  12. package/lib/exchange/swap/setBroadcastTransaction.js +7 -7
  13. package/lib/exchange/swap/setBroadcastTransaction.js.map +1 -1
  14. package/lib/exchange/swap/types.d.ts +3 -3
  15. package/lib/exchange/swap/types.d.ts.map +1 -1
  16. package/lib/families/tezos/config.js +2 -2
  17. package/lib/modularDrawer/hooks/modules/useRightMarketTrendModule.js +5 -2
  18. package/lib/modularDrawer/hooks/modules/useRightMarketTrendModule.js.map +1 -1
  19. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +5 -8
  20. package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
  21. package/lib/modularDrawer/hooks/useRightBalanceAsset.js +15 -24
  22. package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
  23. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -25
  24. package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
  25. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +4 -3
  26. package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
  27. package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  28. package/lib/modularDrawer/modules/createNetworkConfiguration.js +8 -4
  29. package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  30. package/lib/modularDrawer/utils/__tests__/calculateProviderTotal.test.d.ts +2 -0
  31. package/lib/modularDrawer/utils/__tests__/calculateProviderTotal.test.d.ts.map +1 -0
  32. package/lib/modularDrawer/utils/__tests__/calculateProviderTotal.test.js +212 -0
  33. package/lib/modularDrawer/utils/__tests__/calculateProviderTotal.test.js.map +1 -0
  34. package/lib/modularDrawer/utils/__tests__/groupAccountsByAsset.test.d.ts +2 -0
  35. package/lib/modularDrawer/utils/__tests__/groupAccountsByAsset.test.d.ts.map +1 -0
  36. package/lib/modularDrawer/utils/__tests__/groupAccountsByAsset.test.js +202 -0
  37. package/lib/modularDrawer/utils/__tests__/groupAccountsByAsset.test.js.map +1 -0
  38. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts +1 -0
  39. package/lib/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -1
  40. package/lib/modularDrawer/utils/calculateProviderTotal.js +10 -2
  41. package/lib/modularDrawer/utils/calculateProviderTotal.js.map +1 -1
  42. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +6 -4
  43. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
  44. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +9 -22
  45. package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
  46. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts +4 -3
  47. package/lib/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -1
  48. package/lib/modularDrawer/utils/groupAccountsByAsset.js +27 -11
  49. package/lib/modularDrawer/utils/groupAccountsByAsset.js.map +1 -1
  50. package/lib/modularDrawer/utils/index.d.ts +0 -1
  51. package/lib/modularDrawer/utils/index.d.ts.map +1 -1
  52. package/lib/modularDrawer/utils/index.js +1 -3
  53. package/lib/modularDrawer/utils/index.js.map +1 -1
  54. package/lib/modularDrawer/utils/sortByBalance.d.ts +1 -3
  55. package/lib/modularDrawer/utils/sortByBalance.d.ts.map +1 -1
  56. package/lib/modularDrawer/utils/sortByBalance.js +6 -18
  57. package/lib/modularDrawer/utils/sortByBalance.js.map +1 -1
  58. package/lib/modularDrawer/utils/type.d.ts +9 -8
  59. package/lib/modularDrawer/utils/type.d.ts.map +1 -1
  60. package/lib/wallet-api/Exchange/server.js +6 -6
  61. package/lib/wallet-api/Exchange/server.js.map +1 -1
  62. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  63. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +3 -6
  64. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  65. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +60 -0
  66. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  67. package/lib-es/bridge/generic-alpaca/types.d.ts +0 -1
  68. package/lib-es/bridge/generic-alpaca/types.d.ts.map +1 -1
  69. package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
  70. package/lib-es/exchange/swap/postSwapState.js +19 -23
  71. package/lib-es/exchange/swap/postSwapState.js.map +1 -1
  72. package/lib-es/exchange/swap/setBroadcastTransaction.d.ts +4 -4
  73. package/lib-es/exchange/swap/setBroadcastTransaction.js +7 -7
  74. package/lib-es/exchange/swap/setBroadcastTransaction.js.map +1 -1
  75. package/lib-es/exchange/swap/types.d.ts +3 -3
  76. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  77. package/lib-es/families/tezos/config.js +2 -2
  78. package/lib-es/modularDrawer/hooks/modules/useRightMarketTrendModule.js +1 -1
  79. package/lib-es/modularDrawer/hooks/modules/useRightMarketTrendModule.js.map +1 -1
  80. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +5 -8
  81. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
  82. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +15 -24
  83. package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
  84. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -25
  85. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
  86. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +4 -3
  87. package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
  88. package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -1
  89. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +8 -4
  90. package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -1
  91. package/lib-es/modularDrawer/utils/__tests__/calculateProviderTotal.test.d.ts +2 -0
  92. package/lib-es/modularDrawer/utils/__tests__/calculateProviderTotal.test.d.ts.map +1 -0
  93. package/lib-es/modularDrawer/utils/__tests__/calculateProviderTotal.test.js +207 -0
  94. package/lib-es/modularDrawer/utils/__tests__/calculateProviderTotal.test.js.map +1 -0
  95. package/lib-es/modularDrawer/utils/__tests__/groupAccountsByAsset.test.d.ts +2 -0
  96. package/lib-es/modularDrawer/utils/__tests__/groupAccountsByAsset.test.d.ts.map +1 -0
  97. package/lib-es/modularDrawer/utils/__tests__/groupAccountsByAsset.test.js +197 -0
  98. package/lib-es/modularDrawer/utils/__tests__/groupAccountsByAsset.test.js.map +1 -0
  99. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts +1 -0
  100. package/lib-es/modularDrawer/utils/calculateProviderTotal.d.ts.map +1 -1
  101. package/lib-es/modularDrawer/utils/calculateProviderTotal.js +10 -2
  102. package/lib-es/modularDrawer/utils/calculateProviderTotal.js.map +1 -1
  103. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +6 -4
  104. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
  105. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +9 -22
  106. package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
  107. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts +4 -3
  108. package/lib-es/modularDrawer/utils/groupAccountsByAsset.d.ts.map +1 -1
  109. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js +27 -11
  110. package/lib-es/modularDrawer/utils/groupAccountsByAsset.js.map +1 -1
  111. package/lib-es/modularDrawer/utils/index.d.ts +0 -1
  112. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
  113. package/lib-es/modularDrawer/utils/index.js +0 -1
  114. package/lib-es/modularDrawer/utils/index.js.map +1 -1
  115. package/lib-es/modularDrawer/utils/sortByBalance.d.ts +1 -3
  116. package/lib-es/modularDrawer/utils/sortByBalance.d.ts.map +1 -1
  117. package/lib-es/modularDrawer/utils/sortByBalance.js +5 -15
  118. package/lib-es/modularDrawer/utils/sortByBalance.js.map +1 -1
  119. package/lib-es/modularDrawer/utils/type.d.ts +9 -8
  120. package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
  121. package/lib-es/wallet-api/Exchange/server.js +6 -6
  122. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  123. package/package.json +70 -70
  124. package/src/bridge/generic-alpaca/prepareTransaction.ts +3 -7
  125. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +78 -0
  126. package/src/bridge/generic-alpaca/types.ts +1 -1
  127. package/src/exchange/swap/postSwapState.ts +28 -32
  128. package/src/exchange/swap/setBroadcastTransaction.ts +12 -12
  129. package/src/exchange/swap/types.ts +3 -3
  130. package/src/families/tezos/config.ts +2 -2
  131. package/src/modularDrawer/hooks/modules/useRightMarketTrendModule.tsx +1 -1
  132. package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +22 -38
  133. package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +5 -7
  134. package/src/modularDrawer/modules/createNetworkConfiguration.ts +10 -5
  135. package/src/modularDrawer/utils/__tests__/calculateProviderTotal.test.ts +237 -0
  136. package/src/modularDrawer/utils/__tests__/groupAccountsByAsset.test.ts +228 -0
  137. package/src/modularDrawer/utils/calculateProviderTotal.ts +13 -2
  138. package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +13 -37
  139. package/src/modularDrawer/utils/groupAccountsByAsset.ts +38 -19
  140. package/src/modularDrawer/utils/index.ts +0 -2
  141. package/src/modularDrawer/utils/sortByBalance.tsx +5 -18
  142. package/src/modularDrawer/utils/type.ts +13 -4
  143. package/src/wallet-api/Exchange/server.ts +6 -6
  144. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +0 -2
  145. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +0 -1
  146. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js +0 -496
  147. package/lib/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +0 -1
  148. package/lib/modularDrawer/utils/counterValueFormatter.d.ts +0 -14
  149. package/lib/modularDrawer/utils/counterValueFormatter.d.ts.map +0 -1
  150. package/lib/modularDrawer/utils/counterValueFormatter.js +0 -107
  151. package/lib/modularDrawer/utils/counterValueFormatter.js.map +0 -1
  152. package/lib/modularDrawer/utils/getBalanceAndFiatValue.d.ts +0 -20
  153. package/lib/modularDrawer/utils/getBalanceAndFiatValue.d.ts.map +0 -1
  154. package/lib/modularDrawer/utils/getBalanceAndFiatValue.js +0 -39
  155. package/lib/modularDrawer/utils/getBalanceAndFiatValue.js.map +0 -1
  156. package/lib/modularDrawer/utils/parseToBigNumber.d.ts +0 -9
  157. package/lib/modularDrawer/utils/parseToBigNumber.d.ts.map +0 -1
  158. package/lib/modularDrawer/utils/parseToBigNumber.js +0 -24
  159. package/lib/modularDrawer/utils/parseToBigNumber.js.map +0 -1
  160. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts +0 -2
  161. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.d.ts.map +0 -1
  162. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js +0 -494
  163. package/lib-es/modularDrawer/utils/__tests__/counterValueFormatter.test.js.map +0 -1
  164. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts +0 -14
  165. package/lib-es/modularDrawer/utils/counterValueFormatter.d.ts.map +0 -1
  166. package/lib-es/modularDrawer/utils/counterValueFormatter.js +0 -103
  167. package/lib-es/modularDrawer/utils/counterValueFormatter.js.map +0 -1
  168. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.d.ts +0 -20
  169. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.d.ts.map +0 -1
  170. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.js +0 -32
  171. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.js.map +0 -1
  172. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts +0 -9
  173. package/lib-es/modularDrawer/utils/parseToBigNumber.d.ts.map +0 -1
  174. package/lib-es/modularDrawer/utils/parseToBigNumber.js +0 -17
  175. package/lib-es/modularDrawer/utils/parseToBigNumber.js.map +0 -1
  176. package/src/modularDrawer/utils/__tests__/counterValueFormatter.test.ts +0 -549
  177. package/src/modularDrawer/utils/counterValueFormatter.ts +0 -165
  178. package/src/modularDrawer/utils/getBalanceAndFiatValue.ts +0 -53
  179. package/src/modularDrawer/utils/parseToBigNumber.ts +0 -17
@@ -1,53 +0,0 @@
1
- import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
2
- import { isAccount } from "@ledgerhq/coin-framework/account/helpers";
3
- import {
4
- getPortfolioCount,
5
- getBalanceHistoryWithCountervalue,
6
- } from "@ledgerhq/live-countervalues/portfolio";
7
- import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
8
- import { Currency } from "@ledgerhq/types-cryptoassets";
9
- import { Account, TokenAccount } from "@ledgerhq/types-live";
10
- import BigNumber from "bignumber.js";
11
-
12
- /**
13
- *
14
- * @param account - The account to get the balance and fiat value for
15
- * @param state - The current state of countervalues
16
- * @param toCurrency - The currency to convert to
17
- * @param discreet - Whether to show the balance in discreet mode
18
- * @param showCode - Whether to show the currency code in the formatted balance
19
- * @returns An object containing the balance and fiat value
20
- */
21
- export const getBalanceAndFiatValue = (
22
- account: Account | TokenAccount,
23
- state: CounterValuesState,
24
- toCurrency: Currency,
25
- discreet: boolean = false,
26
- showCode: boolean = true,
27
- ) => {
28
- const isAnAccount = isAccount(account);
29
- const details = isAnAccount ? account.currency : account.token;
30
- const balance = formatCurrencyUnit(details.units[0], account.balance, {
31
- showCode,
32
- discreet,
33
- });
34
-
35
- const count = getPortfolioCount([account], "day");
36
- const { history, countervalueAvailable } = getBalanceHistoryWithCountervalue(
37
- account,
38
- "day",
39
- count,
40
- state,
41
- toCurrency,
42
- );
43
-
44
- if (!countervalueAvailable) return { balance, fiatValue: undefined };
45
-
46
- const { countervalue } = history[history.length - 1] ?? {};
47
- const fiatValue = formatCurrencyUnit(toCurrency.units[0], BigNumber(countervalue ?? 0), {
48
- showCode,
49
- discreet,
50
- });
51
-
52
- return { balance, fiatValue };
53
- };
@@ -1,17 +0,0 @@
1
- import BigNumber from "bignumber.js";
2
-
3
- /**
4
- *
5
- * @param value - The value to parse into a BigNumber. It can be a string, number, or an existing BigNumber instance.
6
- * @template T - The type of the value, which can be string, number, or BigNumber.
7
- * @returns A BigNumber instance representing the parsed value.
8
- */
9
- export const parseToBigNumber = <T extends string | number | BigNumber>(value: T): BigNumber => {
10
- if (value instanceof BigNumber) {
11
- return value;
12
- }
13
- if (typeof value === "string") {
14
- return new BigNumber(value.replace(/,/g, ""));
15
- }
16
- return new BigNumber(value);
17
- };