@ledgerhq/live-common 34.44.0-nightly.4 → 34.44.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 (99) hide show
  1. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +1 -3
  2. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  3. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +0 -6
  4. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  5. package/lib/device/use-cases/listAppsUseCase.test.js +2 -2
  6. package/lib/device/use-cases/listAppsUseCase.test.js.map +1 -1
  7. package/lib/e2e/index.d.ts +0 -2
  8. package/lib/e2e/index.d.ts.map +1 -1
  9. package/lib/exchange/swap/hooks/usePickDefaultAccount.test.js +10 -22
  10. package/lib/exchange/swap/hooks/usePickDefaultAccount.test.js.map +1 -1
  11. package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
  12. package/lib/exchange/swap/postSwapState.js +4 -63
  13. package/lib/exchange/swap/postSwapState.js.map +1 -1
  14. package/lib/exchange/swap/setBroadcastTransaction.d.ts +1 -4
  15. package/lib/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
  16. package/lib/exchange/swap/setBroadcastTransaction.js +1 -7
  17. package/lib/exchange/swap/setBroadcastTransaction.js.map +1 -1
  18. package/lib/exchange/swap/types.d.ts +0 -7
  19. package/lib/exchange/swap/types.d.ts.map +1 -1
  20. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  21. package/lib/featureFlags/defaultFeatures.js +0 -1
  22. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  23. package/lib/featureFlags/useFeature.d.ts +1 -1
  24. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  25. package/lib/hw/customLockScreenLoad.d.ts +9 -1
  26. package/lib/hw/customLockScreenLoad.d.ts.map +1 -1
  27. package/lib/hw/customLockScreenLoad.js +1 -5
  28. package/lib/hw/customLockScreenLoad.js.map +1 -1
  29. package/lib/modularDrawer/utils/index.d.ts +1 -2
  30. package/lib/modularDrawer/utils/index.d.ts.map +1 -1
  31. package/lib/modularDrawer/utils/index.js +1 -3
  32. package/lib/modularDrawer/utils/index.js.map +1 -1
  33. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  34. package/lib/wallet-api/Exchange/server.js +0 -10
  35. package/lib/wallet-api/Exchange/server.js.map +1 -1
  36. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +1 -3
  37. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  38. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +0 -6
  39. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  40. package/lib-es/device/use-cases/listAppsUseCase.test.js +1 -1
  41. package/lib-es/device/use-cases/listAppsUseCase.test.js.map +1 -1
  42. package/lib-es/e2e/index.d.ts +0 -2
  43. package/lib-es/e2e/index.d.ts.map +1 -1
  44. package/lib-es/exchange/swap/hooks/usePickDefaultAccount.test.js +9 -21
  45. package/lib-es/exchange/swap/hooks/usePickDefaultAccount.test.js.map +1 -1
  46. package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
  47. package/lib-es/exchange/swap/postSwapState.js +4 -63
  48. package/lib-es/exchange/swap/postSwapState.js.map +1 -1
  49. package/lib-es/exchange/swap/setBroadcastTransaction.d.ts +1 -4
  50. package/lib-es/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
  51. package/lib-es/exchange/swap/setBroadcastTransaction.js +1 -7
  52. package/lib-es/exchange/swap/setBroadcastTransaction.js.map +1 -1
  53. package/lib-es/exchange/swap/types.d.ts +0 -7
  54. package/lib-es/exchange/swap/types.d.ts.map +1 -1
  55. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  56. package/lib-es/featureFlags/defaultFeatures.js +0 -1
  57. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  58. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  59. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  60. package/lib-es/hw/customLockScreenLoad.d.ts +9 -1
  61. package/lib-es/hw/customLockScreenLoad.d.ts.map +1 -1
  62. package/lib-es/hw/customLockScreenLoad.js +1 -5
  63. package/lib-es/hw/customLockScreenLoad.js.map +1 -1
  64. package/lib-es/modularDrawer/utils/index.d.ts +1 -2
  65. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
  66. package/lib-es/modularDrawer/utils/index.js +1 -2
  67. package/lib-es/modularDrawer/utils/index.js.map +1 -1
  68. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  69. package/lib-es/wallet-api/Exchange/server.js +0 -10
  70. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  71. package/package.json +74 -74
  72. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +0 -10
  73. package/src/device/use-cases/listAppsUseCase.test.ts +1 -1
  74. package/src/exchange/swap/hooks/usePickDefaultAccount.test.ts +12 -25
  75. package/src/exchange/swap/postSwapState.ts +2 -97
  76. package/src/exchange/swap/setBroadcastTransaction.ts +0 -12
  77. package/src/exchange/swap/types.ts +0 -7
  78. package/src/featureFlags/defaultFeatures.ts +0 -1
  79. package/src/hw/customLockScreenLoad.ts +11 -7
  80. package/src/modularDrawer/utils/index.ts +1 -7
  81. package/src/wallet-api/Exchange/server.ts +0 -10
  82. package/lib/exchange/swap/hooks/wrapper.d.ts +0 -3
  83. package/lib/exchange/swap/hooks/wrapper.d.ts.map +0 -1
  84. package/lib/exchange/swap/hooks/wrapper.js +0 -40
  85. package/lib/exchange/swap/hooks/wrapper.js.map +0 -1
  86. package/lib/modularDrawer/utils/getBalanceAndFiatValue.d.ts +0 -20
  87. package/lib/modularDrawer/utils/getBalanceAndFiatValue.d.ts.map +0 -1
  88. package/lib/modularDrawer/utils/getBalanceAndFiatValue.js +0 -39
  89. package/lib/modularDrawer/utils/getBalanceAndFiatValue.js.map +0 -1
  90. package/lib-es/exchange/swap/hooks/wrapper.d.ts +0 -3
  91. package/lib-es/exchange/swap/hooks/wrapper.d.ts.map +0 -1
  92. package/lib-es/exchange/swap/hooks/wrapper.js +0 -13
  93. package/lib-es/exchange/swap/hooks/wrapper.js.map +0 -1
  94. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.d.ts +0 -20
  95. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.d.ts.map +0 -1
  96. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.js +0 -32
  97. package/lib-es/modularDrawer/utils/getBalanceAndFiatValue.js.map +0 -1
  98. package/src/exchange/swap/hooks/wrapper.tsx +0 -18
  99. package/src/modularDrawer/utils/getBalanceAndFiatValue.ts +0 -53
@@ -1,20 +0,0 @@
1
- import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
2
- import { Currency } from "@ledgerhq/types-cryptoassets";
3
- import { Account, TokenAccount } from "@ledgerhq/types-live";
4
- /**
5
- *
6
- * @param account - The account to get the balance and fiat value for
7
- * @param state - The current state of countervalues
8
- * @param toCurrency - The currency to convert to
9
- * @param discreet - Whether to show the balance in discreet mode
10
- * @param showCode - Whether to show the currency code in the formatted balance
11
- * @returns An object containing the balance and fiat value
12
- */
13
- export declare const getBalanceAndFiatValue: (account: Account | TokenAccount, state: CounterValuesState, toCurrency: Currency, discreet?: boolean, showCode?: boolean) => {
14
- balance: string;
15
- fiatValue: undefined;
16
- } | {
17
- balance: string;
18
- fiatValue: string;
19
- };
20
- //# sourceMappingURL=getBalanceAndFiatValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBalanceAndFiatValue.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getBalanceAndFiatValue.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,YACxB,OAAO,GAAG,YAAY,SACxB,kBAAkB,cACb,QAAQ,aACV,OAAO,aACP,OAAO;;;;;;CA2BlB,CAAC"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBalanceAndFiatValue = void 0;
7
- const formatCurrencyUnit_1 = require("@ledgerhq/coin-framework/currencies/formatCurrencyUnit");
8
- const helpers_1 = require("@ledgerhq/coin-framework/account/helpers");
9
- const portfolio_1 = require("@ledgerhq/live-countervalues/portfolio");
10
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
11
- /**
12
- *
13
- * @param account - The account to get the balance and fiat value for
14
- * @param state - The current state of countervalues
15
- * @param toCurrency - The currency to convert to
16
- * @param discreet - Whether to show the balance in discreet mode
17
- * @param showCode - Whether to show the currency code in the formatted balance
18
- * @returns An object containing the balance and fiat value
19
- */
20
- const getBalanceAndFiatValue = (account, state, toCurrency, discreet = false, showCode = true) => {
21
- const isAnAccount = (0, helpers_1.isAccount)(account);
22
- const details = isAnAccount ? account.currency : account.token;
23
- const balance = (0, formatCurrencyUnit_1.formatCurrencyUnit)(details.units[0], account.balance, {
24
- showCode,
25
- discreet,
26
- });
27
- const count = (0, portfolio_1.getPortfolioCount)([account], "day");
28
- const { history, countervalueAvailable } = (0, portfolio_1.getBalanceHistoryWithCountervalue)(account, "day", count, state, toCurrency);
29
- if (!countervalueAvailable)
30
- return { balance, fiatValue: undefined };
31
- const { countervalue } = history[history.length - 1] ?? {};
32
- const fiatValue = (0, formatCurrencyUnit_1.formatCurrencyUnit)(toCurrency.units[0], (0, bignumber_js_1.default)(countervalue ?? 0), {
33
- showCode,
34
- discreet,
35
- });
36
- return { balance, fiatValue };
37
- };
38
- exports.getBalanceAndFiatValue = getBalanceAndFiatValue;
39
- //# sourceMappingURL=getBalanceAndFiatValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBalanceAndFiatValue.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getBalanceAndFiatValue.ts"],"names":[],"mappings":";;;;;;AAAA,+FAA4F;AAC5F,sEAAqE;AACrE,sEAGgD;AAIhD,gEAAqC;AAErC;;;;;;;;GAQG;AACI,MAAM,sBAAsB,GAAG,CACpC,OAA+B,EAC/B,KAAyB,EACzB,UAAoB,EACpB,WAAoB,KAAK,EACzB,WAAoB,IAAI,EACxB,EAAE;IACF,MAAM,WAAW,GAAG,IAAA,mBAAS,EAAC,OAAO,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/D,MAAM,OAAO,GAAG,IAAA,uCAAkB,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE;QACpE,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,IAAA,6BAAiB,EAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IAClD,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,IAAA,6CAAiC,EAC1E,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,CACX,CAAC;IAEF,IAAI,CAAC,qBAAqB;QAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAErE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3D,MAAM,SAAS,GAAG,IAAA,uCAAkB,EAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAA,sBAAS,EAAC,YAAY,IAAI,CAAC,CAAC,EAAE;QACtF,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC;AAhCW,QAAA,sBAAsB,0BAgCjC"}
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- export declare const Wrapper: React.FC<React.PropsWithChildren>;
3
- //# sourceMappingURL=wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../../src/exchange/swap/hooks/wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAcrD,CAAC"}
@@ -1,13 +0,0 @@
1
- import React, { useMemo } from "react";
2
- import { CountervaluesMarketcapProvider } from "@ledgerhq/live-countervalues-react";
3
- export const Wrapper = ({ children }) => {
4
- const bridge = useMemo(() => ({
5
- setError: () => { },
6
- setIds: () => { },
7
- setLoading: () => { },
8
- useIds: () => [],
9
- useLastUpdated: () => 0,
10
- }), []);
11
- return (React.createElement(CountervaluesMarketcapProvider, { bridge: bridge }, children));
12
- };
13
- //# sourceMappingURL=wrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../../src/exchange/swap/hooks/wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAEpF,MAAM,CAAC,MAAM,OAAO,GAAsC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;QAClB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;QAChB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;QACpB,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE;QAChB,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;KACxB,CAAC,EACF,EAAE,CACH,CAAC;IACF,OAAO,CACL,oBAAC,8BAA8B,IAAC,MAAM,EAAE,MAAM,IAAG,QAAQ,CAAkC,CAC5F,CAAC;AACJ,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { CounterValuesState } from "@ledgerhq/live-countervalues/types";
2
- import { Currency } from "@ledgerhq/types-cryptoassets";
3
- import { Account, TokenAccount } from "@ledgerhq/types-live";
4
- /**
5
- *
6
- * @param account - The account to get the balance and fiat value for
7
- * @param state - The current state of countervalues
8
- * @param toCurrency - The currency to convert to
9
- * @param discreet - Whether to show the balance in discreet mode
10
- * @param showCode - Whether to show the currency code in the formatted balance
11
- * @returns An object containing the balance and fiat value
12
- */
13
- export declare const getBalanceAndFiatValue: (account: Account | TokenAccount, state: CounterValuesState, toCurrency: Currency, discreet?: boolean, showCode?: boolean) => {
14
- balance: string;
15
- fiatValue: undefined;
16
- } | {
17
- balance: string;
18
- fiatValue: string;
19
- };
20
- //# sourceMappingURL=getBalanceAndFiatValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBalanceAndFiatValue.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getBalanceAndFiatValue.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,YACxB,OAAO,GAAG,YAAY,SACxB,kBAAkB,cACb,QAAQ,aACV,OAAO,aACP,OAAO;;;;;;CA2BlB,CAAC"}
@@ -1,32 +0,0 @@
1
- import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
2
- import { isAccount } from "@ledgerhq/coin-framework/account/helpers";
3
- import { getPortfolioCount, getBalanceHistoryWithCountervalue, } from "@ledgerhq/live-countervalues/portfolio";
4
- import BigNumber from "bignumber.js";
5
- /**
6
- *
7
- * @param account - The account to get the balance and fiat value for
8
- * @param state - The current state of countervalues
9
- * @param toCurrency - The currency to convert to
10
- * @param discreet - Whether to show the balance in discreet mode
11
- * @param showCode - Whether to show the currency code in the formatted balance
12
- * @returns An object containing the balance and fiat value
13
- */
14
- export const getBalanceAndFiatValue = (account, state, toCurrency, discreet = false, showCode = true) => {
15
- const isAnAccount = isAccount(account);
16
- const details = isAnAccount ? account.currency : account.token;
17
- const balance = formatCurrencyUnit(details.units[0], account.balance, {
18
- showCode,
19
- discreet,
20
- });
21
- const count = getPortfolioCount([account], "day");
22
- const { history, countervalueAvailable } = getBalanceHistoryWithCountervalue(account, "day", count, state, toCurrency);
23
- if (!countervalueAvailable)
24
- return { balance, fiatValue: undefined };
25
- const { countervalue } = history[history.length - 1] ?? {};
26
- const fiatValue = formatCurrencyUnit(toCurrency.units[0], BigNumber(countervalue ?? 0), {
27
- showCode,
28
- discreet,
29
- });
30
- return { balance, fiatValue };
31
- };
32
- //# sourceMappingURL=getBalanceAndFiatValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBalanceAndFiatValue.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/getBalanceAndFiatValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,iCAAiC,GAClC,MAAM,wCAAwC,CAAC;AAIhD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAA+B,EAC/B,KAAyB,EACzB,UAAoB,EACpB,WAAoB,KAAK,EACzB,WAAoB,IAAI,EACxB,EAAE;IACF,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/D,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE;QACpE,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IAClD,MAAM,EAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,iCAAiC,CAC1E,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,UAAU,CACX,CAAC;IAEF,IAAI,CAAC,qBAAqB;QAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAErE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3D,MAAM,SAAS,GAAG,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE;QACtF,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC"}
@@ -1,18 +0,0 @@
1
- import React, { useMemo } from "react";
2
- import { CountervaluesMarketcapProvider } from "@ledgerhq/live-countervalues-react";
3
-
4
- export const Wrapper: React.FC<React.PropsWithChildren> = ({ children }) => {
5
- const bridge = useMemo(
6
- () => ({
7
- setError: () => {},
8
- setIds: () => {},
9
- setLoading: () => {},
10
- useIds: () => [],
11
- useLastUpdated: () => 0,
12
- }),
13
- [],
14
- );
15
- return (
16
- <CountervaluesMarketcapProvider bridge={bridge}>{children}</CountervaluesMarketcapProvider>
17
- );
18
- };
@@ -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
- };