@ledgerhq/live-common 34.53.0-nightly.20251120023735 → 34.53.0-nightly.20251121023744

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 (226) hide show
  1. package/lib/__tests__/test-helpers/setup.integration.d.ts +2 -0
  2. package/lib/__tests__/test-helpers/setup.integration.d.ts.map +1 -0
  3. package/lib/__tests__/test-helpers/{setup.js → setup.integration.js} +4 -8
  4. package/lib/__tests__/test-helpers/setup.integration.js.map +1 -0
  5. package/lib/account/helpers.d.ts.map +1 -1
  6. package/lib/account/helpers.js +21 -17
  7. package/lib/account/helpers.js.map +1 -1
  8. package/lib/bridge/generic-alpaca/utils.js +1 -1
  9. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  10. package/lib/bridge/impl.d.ts +0 -2
  11. package/lib/bridge/impl.d.ts.map +1 -1
  12. package/lib/bridge/impl.js +4 -8
  13. package/lib/bridge/impl.js.map +1 -1
  14. package/lib/currencies/index.d.ts +1 -1
  15. package/lib/currencies/index.d.ts.map +1 -1
  16. package/lib/currencies/index.js +1 -4
  17. package/lib/currencies/index.js.map +1 -1
  18. package/lib/e2e/index.d.ts +3 -0
  19. package/lib/e2e/index.d.ts.map +1 -1
  20. package/lib/exchange/swap/getCompleteSwapHistory.js +2 -2
  21. package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
  22. package/lib/exchange/swap/hooks/useSelectableCurrencies.js +2 -2
  23. package/lib/exchange/swap/hooks/useSelectableCurrencies.js.map +1 -1
  24. package/lib/families/cosmos/datasets/dydx.integration.FIXME.d.ts +1 -1
  25. package/lib/families/cosmos/datasets/dydx.integration.FIXME.d.ts.map +1 -1
  26. package/lib/families/cosmos/datasets/dydx.integration.FIXME.js +1 -1
  27. package/lib/families/cosmos/datasets/dydx.integration.FIXME.js.map +1 -1
  28. package/lib/families/cosmos/datasets/secretNetwork.integration.FIXME.d.ts +1 -1
  29. package/lib/families/cosmos/datasets/secretNetwork.integration.FIXME.d.ts.map +1 -1
  30. package/lib/families/cosmos/datasets/secretNetwork.integration.FIXME.js +1 -1
  31. package/lib/families/cosmos/datasets/secretNetwork.integration.FIXME.js.map +1 -1
  32. package/lib/families/evm/setup.d.ts.map +1 -1
  33. package/lib/families/evm/setup.js +1 -11
  34. package/lib/families/evm/setup.js.map +1 -1
  35. package/lib/families/solana/setup.d.ts +8 -0
  36. package/lib/families/solana/setup.d.ts.map +1 -1
  37. package/lib/families/solana/setup.js +29 -16
  38. package/lib/families/solana/setup.js.map +1 -1
  39. package/lib/families/tron/data.mock.d.ts.map +1 -1
  40. package/lib/families/tron/data.mock.js +3 -6
  41. package/lib/families/tron/data.mock.js.map +1 -1
  42. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  43. package/lib/featureFlags/defaultFeatures.js +1 -0
  44. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  45. package/lib/featureFlags/useFeature.d.ts +1 -1
  46. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  47. package/lib/test-helpers/cryptoAssetsStore.d.ts +2 -0
  48. package/lib/test-helpers/cryptoAssetsStore.d.ts.map +1 -0
  49. package/lib/test-helpers/cryptoAssetsStore.js +8 -0
  50. package/lib/test-helpers/cryptoAssetsStore.js.map +1 -0
  51. package/lib/wallet-api/ACRE/server.js +5 -5
  52. package/lib/wallet-api/ACRE/server.js.map +1 -1
  53. package/lib/wallet-api/Exchange/server.js +4 -4
  54. package/lib/wallet-api/Exchange/server.js.map +1 -1
  55. package/lib/wallet-api/logic.js +8 -8
  56. package/lib/wallet-api/logic.js.map +1 -1
  57. package/lib/wallet-api/react.js +2 -2
  58. package/lib/wallet-api/react.js.map +1 -1
  59. package/lib/wallet-api/useDappLogic.js +2 -2
  60. package/lib/wallet-api/useDappLogic.js.map +1 -1
  61. package/lib-es/__tests__/test-helpers/setup.integration.d.ts +2 -0
  62. package/lib-es/__tests__/test-helpers/setup.integration.d.ts.map +1 -0
  63. package/lib-es/__tests__/test-helpers/setup.integration.js +14 -0
  64. package/lib-es/__tests__/test-helpers/setup.integration.js.map +1 -0
  65. package/lib-es/account/helpers.d.ts.map +1 -1
  66. package/lib-es/account/helpers.js +5 -1
  67. package/lib-es/account/helpers.js.map +1 -1
  68. package/lib-es/bridge/generic-alpaca/utils.js +1 -1
  69. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  70. package/lib-es/bridge/impl.d.ts +0 -2
  71. package/lib-es/bridge/impl.d.ts.map +1 -1
  72. package/lib-es/bridge/impl.js +3 -6
  73. package/lib-es/bridge/impl.js.map +1 -1
  74. package/lib-es/currencies/index.d.ts +1 -1
  75. package/lib-es/currencies/index.d.ts.map +1 -1
  76. package/lib-es/currencies/index.js +1 -1
  77. package/lib-es/currencies/index.js.map +1 -1
  78. package/lib-es/e2e/index.d.ts +3 -0
  79. package/lib-es/e2e/index.d.ts.map +1 -1
  80. package/lib-es/exchange/swap/getCompleteSwapHistory.js +1 -1
  81. package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
  82. package/lib-es/exchange/swap/hooks/useSelectableCurrencies.js +1 -1
  83. package/lib-es/exchange/swap/hooks/useSelectableCurrencies.js.map +1 -1
  84. package/lib-es/families/cosmos/datasets/dydx.integration.FIXME.d.ts +1 -1
  85. package/lib-es/families/cosmos/datasets/dydx.integration.FIXME.d.ts.map +1 -1
  86. package/lib-es/families/cosmos/datasets/dydx.integration.FIXME.js +1 -1
  87. package/lib-es/families/cosmos/datasets/dydx.integration.FIXME.js.map +1 -1
  88. package/lib-es/families/cosmos/datasets/secretNetwork.integration.FIXME.d.ts +1 -1
  89. package/lib-es/families/cosmos/datasets/secretNetwork.integration.FIXME.d.ts.map +1 -1
  90. package/lib-es/families/cosmos/datasets/secretNetwork.integration.FIXME.js +1 -1
  91. package/lib-es/families/cosmos/datasets/secretNetwork.integration.FIXME.js.map +1 -1
  92. package/lib-es/families/evm/setup.d.ts.map +1 -1
  93. package/lib-es/families/evm/setup.js +1 -11
  94. package/lib-es/families/evm/setup.js.map +1 -1
  95. package/lib-es/families/solana/setup.d.ts +8 -0
  96. package/lib-es/families/solana/setup.d.ts.map +1 -1
  97. package/lib-es/families/solana/setup.js +28 -17
  98. package/lib-es/families/solana/setup.js.map +1 -1
  99. package/lib-es/families/tron/data.mock.d.ts.map +1 -1
  100. package/lib-es/families/tron/data.mock.js +3 -6
  101. package/lib-es/families/tron/data.mock.js.map +1 -1
  102. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  103. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  104. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  105. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  106. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  107. package/lib-es/test-helpers/cryptoAssetsStore.d.ts +2 -0
  108. package/lib-es/test-helpers/cryptoAssetsStore.d.ts.map +1 -0
  109. package/lib-es/test-helpers/cryptoAssetsStore.js +2 -0
  110. package/lib-es/test-helpers/cryptoAssetsStore.js.map +1 -0
  111. package/lib-es/wallet-api/ACRE/server.js +1 -1
  112. package/lib-es/wallet-api/ACRE/server.js.map +1 -1
  113. package/lib-es/wallet-api/Exchange/server.js +1 -1
  114. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  115. package/lib-es/wallet-api/logic.js +1 -1
  116. package/lib-es/wallet-api/logic.js.map +1 -1
  117. package/lib-es/wallet-api/react.js +1 -1
  118. package/lib-es/wallet-api/react.js.map +1 -1
  119. package/lib-es/wallet-api/useDappLogic.js +1 -1
  120. package/lib-es/wallet-api/useDappLogic.js.map +1 -1
  121. package/package.json +68 -55
  122. package/src/DataModel.test.ts +2 -8
  123. package/src/__tests__/__snapshots__/csvExport.ts.snap +0 -718
  124. package/src/__tests__/accounts/groupPerDay.ts +2 -4
  125. package/src/__tests__/csvExport.ts +3 -3
  126. package/src/__tests__/currencies.ts +0 -38
  127. package/src/__tests__/test-helpers/setup.integration.ts +17 -0
  128. package/src/__tests__/test-helpers/setup.ts +3 -8
  129. package/src/account/helpers.test.ts +2 -2
  130. package/src/account/helpers.ts +5 -1
  131. package/src/account/serialization.test.ts +2 -2
  132. package/src/bridge/crypto-assets/index.test.ts +15 -44
  133. package/src/bridge/generic-alpaca/utils.test.ts +1 -2
  134. package/src/bridge/generic-alpaca/utils.ts +1 -1
  135. package/src/bridge/impl.ts +3 -7
  136. package/src/currencies/cryptoIcons.test.ts +23 -4
  137. package/src/currencies/helpers.test.ts +13 -0
  138. package/src/currencies/index.ts +0 -3
  139. package/src/currencies/sortByMarketcap.test.ts +0 -26
  140. package/src/domain/getTokensWithFunds.test.ts +32 -3
  141. package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
  142. package/src/exchange/swap/hooks/useSelectableCurrencies.test.ts +4 -0
  143. package/src/exchange/swap/hooks/useSelectableCurrencies.ts +1 -1
  144. package/src/families/algorand/__snapshots__/bridge.integration.test.ts.snap +11 -11
  145. package/src/families/algorand/bridge.integration.test.ts +1 -1
  146. package/src/families/aptos/__snapshots__/bridge.integration.test.ts.snap +111 -1
  147. package/src/families/aptos/bridge.integration.test.ts +1 -1
  148. package/src/families/bitcoin/bridge.integration.test.ts +1 -1
  149. package/src/families/bitcoin/satstack.test.ts +5 -8
  150. package/src/families/cardano/__snapshots__/bridge.integration.test.ts.snap +2 -2
  151. package/src/families/cardano/bridge.integration.test.ts +1 -1
  152. package/src/families/casper/bridge.integration.test.ts +1 -1
  153. package/src/families/celo/bridge.integration.test.ts +1 -1
  154. package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +1 -1
  155. package/src/families/cosmos/datasets/axelar.integration.test.ts +1 -1
  156. package/src/families/cosmos/datasets/babylon.integration.test.ts +1 -1
  157. package/src/families/cosmos/datasets/coreum.integration.test.ts +1 -1
  158. package/src/families/cosmos/datasets/cosmos.integration.test.ts +1 -1
  159. package/src/families/cosmos/datasets/cryptoOrg.integration.test.ts +1 -1
  160. package/src/families/cosmos/datasets/desmos.integration.test.ts +1 -1
  161. package/src/families/cosmos/datasets/dydx.integration.FIXME.ts +1 -1
  162. package/src/families/cosmos/datasets/injective.integration.test.ts +1 -1
  163. package/src/families/cosmos/datasets/mantra.integration.test.ts +1 -1
  164. package/src/families/cosmos/datasets/onomy.integration.test.ts +1 -1
  165. package/src/families/cosmos/datasets/osmosis.integration.test.ts +1 -1
  166. package/src/families/cosmos/datasets/persistence.integration.test.ts +1 -1
  167. package/src/families/cosmos/datasets/quicksilver.integration.test.ts +1 -1
  168. package/src/families/cosmos/datasets/secretNetwork.integration.FIXME.ts +1 -1
  169. package/src/families/cosmos/datasets/seiNetwork.integration.test.ts +1 -1
  170. package/src/families/cosmos/datasets/stargaze.integration.test.ts +1 -1
  171. package/src/families/cosmos/datasets/umee.integration.test.ts +1 -1
  172. package/src/families/cosmos/datasets/xion.integration.test.ts +1 -1
  173. package/src/families/cosmos/datasets/zenrock.integration.test.ts +1 -1
  174. package/src/families/evm/bridge.integration.test.ts +1 -1
  175. package/src/families/evm/setup.ts +0 -12
  176. package/src/families/filecoin/bridge.integration.test.ts +1 -1
  177. package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +191 -596
  178. package/src/families/hedera/bridge.integration.test.ts +1 -1
  179. package/src/families/icon/bridge.integration.test.ts +1 -1
  180. package/src/families/internet_computer/bridge.integration.test.ts +1 -1
  181. package/src/families/kaspa/bridge.integration.test.ts +1 -1
  182. package/src/families/mina/bridge.integration.test.ts +1 -1
  183. package/src/families/multiversx/bridge.integration.test.ts +1 -1
  184. package/src/families/multiversx/synchronisation.integration.test.ts +1 -1
  185. package/src/families/near/bridge.integration.test.ts +1 -1
  186. package/src/families/polkadot/bridge.integration.test.ts +1 -1
  187. package/src/families/solana/__snapshots__/bridge.integration.test.ts.snap +14 -44
  188. package/src/families/solana/bridge.integration.test.ts +1 -1
  189. package/src/families/solana/setup.ts +37 -24
  190. package/src/families/stacks/__tests__/sync.integration.test.ts +1 -1
  191. package/src/families/stacks/bridge.integration.test.ts +1 -1
  192. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +198 -6
  193. package/src/families/stellar/bridge.integration.test.ts +1 -1
  194. package/src/families/sui/bridge.integration.test.ts +1 -1
  195. package/src/families/tezos/bridge.integration.test.ts +1 -1
  196. package/src/families/ton/bridge.integration.test.ts +1 -1
  197. package/src/families/tron/bridge.integration.test.ts +1 -1
  198. package/src/families/tron/data.mock.ts +4 -8
  199. package/src/families/vechain/bridge.integration.test.ts +1 -1
  200. package/src/families/xrp/bridge.integration.test.ts +1 -1
  201. package/src/featureFlags/defaultFeatures.ts +1 -0
  202. package/src/test-helpers/cryptoAssetsStore.ts +5 -0
  203. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +3 -3
  204. package/src/wallet-api/ACRE/server.test.ts +3 -4
  205. package/src/wallet-api/ACRE/server.ts +1 -1
  206. package/src/wallet-api/Exchange/server.ts +1 -1
  207. package/src/wallet-api/logic.test.ts +3 -3
  208. package/src/wallet-api/logic.ts +1 -1
  209. package/src/wallet-api/react.ts +1 -1
  210. package/src/wallet-api/useDappLogic.ts +1 -1
  211. package/lib/__tests__/test-helpers/setup.d.ts +0 -2
  212. package/lib/__tests__/test-helpers/setup.d.ts.map +0 -1
  213. package/lib/__tests__/test-helpers/setup.js.map +0 -1
  214. package/lib/bridge/crypto-assets/index.d.ts +0 -4
  215. package/lib/bridge/crypto-assets/index.d.ts.map +0 -1
  216. package/lib/bridge/crypto-assets/index.js +0 -22
  217. package/lib/bridge/crypto-assets/index.js.map +0 -1
  218. package/lib-es/__tests__/test-helpers/setup.d.ts +0 -2
  219. package/lib-es/__tests__/test-helpers/setup.d.ts.map +0 -1
  220. package/lib-es/__tests__/test-helpers/setup.js +0 -18
  221. package/lib-es/__tests__/test-helpers/setup.js.map +0 -1
  222. package/lib-es/bridge/crypto-assets/index.d.ts +0 -4
  223. package/lib-es/bridge/crypto-assets/index.d.ts.map +0 -1
  224. package/lib-es/bridge/crypto-assets/index.js +0 -17
  225. package/lib-es/bridge/crypto-assets/index.js.map +0 -1
  226. package/src/bridge/crypto-assets/index.ts +0 -23
@@ -2,8 +2,7 @@ import flatMap from "lodash/flatMap";
2
2
  import { fromAccountRaw, groupAccountOperationsByDay } from "../../account";
3
3
  import { TezosAccountRaw } from "../../families/tezos/types";
4
4
  import { setSupportedCurrencies } from "../../currencies";
5
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
6
- import { setup } from "../../bridge/impl";
5
+ import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
7
6
  import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
8
7
  setSupportedCurrencies(["tezos"]);
9
8
 
@@ -14,8 +13,7 @@ LiveConfig.setConfig({
14
13
  },
15
14
  });
16
15
 
17
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
18
- setup({} as CryptoAssetsStore);
16
+ setupMockCryptoAssetsStore();
19
17
 
20
18
  let account: Awaited<ReturnType<typeof fromAccountRaw>>;
21
19
 
@@ -5,10 +5,10 @@ import { getCryptoCurrencyById } from "../currencies";
5
5
  import { accountsOpToCSV } from "../csvExport";
6
6
  import { initialState, loadCountervalues } from "@ledgerhq/live-countervalues/logic";
7
7
  import { getFiatCurrencyByTicker, setSupportedCurrencies } from "../currencies";
8
- import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
9
- import { addTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
8
+ import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
10
9
 
11
- initializeLegacyTokens(addTokens);
10
+ // Setup mock store for unit tests
11
+ setupMockCryptoAssetsStore();
12
12
  setSupportedCurrencies(["ethereum", "ripple"]);
13
13
  setEnv("MOCK", "1");
14
14
  setEnv("MOCK_COUNTERVALUES", "1");
@@ -1,6 +1,5 @@
1
1
  import { BigNumber } from "bignumber.js";
2
2
  import {
3
- listTokens,
4
3
  getCryptoCurrencyById,
5
4
  getFiatCurrencyByTicker,
6
5
  formatCurrencyUnit,
@@ -10,43 +9,6 @@ import {
10
9
  encodeURIScheme,
11
10
  sanitizeValueString,
12
11
  } from "../currencies";
13
- import { byContractAddressAndChainId } from "@ledgerhq/hw-app-eth/erc20";
14
-
15
- /*
16
- skipped because ledgerjs data is now lighter (from the POV of hw-app-eth)
17
- (using cryptoassets-evm-signatures instead of cryptoassets)
18
- */
19
- test.skip("erc20 are all consistent with those on ledgerjs side", () => {
20
- const normalList = listTokens();
21
- const delistedList = listTokens({
22
- withDelisted: true,
23
- });
24
- expect(delistedList.length).toBeGreaterThan(normalList.length);
25
-
26
- for (const token of delistedList) {
27
- if (token.delisted) {
28
- expect(normalList.find(o => o.id === token.id)).toBeUndefined();
29
- }
30
-
31
- if (token.tokenType === "erc20") {
32
- if (token.parentCurrency.family === "filecoin") {
33
- continue;
34
- }
35
- const tokenData = byContractAddressAndChainId(
36
- token.contractAddress,
37
- token.parentCurrency.ethereumLikeInfo?.chainId || 0,
38
- );
39
-
40
- if (!tokenData) {
41
- throw new Error(token.name + " not available in ledgerjs data");
42
- }
43
-
44
- expect(token.ticker.toLowerCase()).toBe(tokenData.ticker.toLowerCase());
45
- expect(token.contractAddress.toLowerCase()).toBe(tokenData.contractAddress.toLowerCase());
46
- expect(token.units[0].magnitude).toBe(tokenData.decimals);
47
- }
48
- }
49
- });
50
12
 
51
13
  test("can format a currency unit", () => {
52
14
  const btc = getCryptoCurrencyById("bitcoin").units[0];
@@ -0,0 +1,17 @@
1
+ import { setupCalClientStore } from "../../test-helpers/cryptoAssetsStore";
2
+ import "./environment";
3
+ import BigNumber from "bignumber.js";
4
+
5
+ // Integration tests use the real CAL API
6
+ setupCalClientStore();
7
+
8
+ jest.setTimeout(360000);
9
+
10
+ expect.extend({
11
+ toBeBigNumber(value) {
12
+ const pass = BigNumber.isBigNumber(value);
13
+ const message = pass ? () => `${value} is a BigNumber` : () => `${value} is not a BigNumber`;
14
+
15
+ return { message, pass };
16
+ },
17
+ });
@@ -1,11 +1,9 @@
1
- import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
2
- import { legacyCryptoAssetsStore } from "@ledgerhq/cryptoassets/legacy/legacy-store";
3
- import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
4
- import { addTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
1
+ import { setupMockCryptoAssetsStore } from "../../test-helpers/cryptoAssetsStore";
5
2
  import "./environment";
6
3
  import BigNumber from "bignumber.js";
7
4
 
8
- initializeLegacyTokens(addTokens);
5
+ // Unit tests use mock store
6
+ setupMockCryptoAssetsStore();
9
7
 
10
8
  jest.setTimeout(360000);
11
9
 
@@ -17,6 +15,3 @@ expect.extend({
17
15
  return { message, pass };
18
16
  },
19
17
  });
20
-
21
- // Use legacyCryptoAssetsStore for integration tests so tokens can be found
22
- setCryptoAssetsStoreForCoinFramework(legacyCryptoAssetsStore);
@@ -1,8 +1,8 @@
1
1
  import { loadBlacklistedTokenSections } from "./helpers";
2
- import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
2
+ import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
3
3
  import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
4
4
 
5
- jest.mock("../bridge/crypto-assets/index");
5
+ jest.mock("@ledgerhq/cryptoassets/state");
6
6
 
7
7
  const mockGetCryptoAssetsStore = getCryptoAssetsStore as jest.MockedFunction<
8
8
  typeof getCryptoAssetsStore
@@ -12,10 +12,11 @@ import {
12
12
  type TronAccount,
13
13
  } from "@ledgerhq/coin-tron/index";
14
14
  import { isAccountEmpty as isVechainAccountEmpty } from "@ledgerhq/coin-vechain/index";
15
+ import { isAccountEmpty as isCantonAccountEmpty } from "@ledgerhq/coin-canton";
15
16
  import type { Account, AccountLike } from "@ledgerhq/types-live";
16
17
  import { isAccountDelegating } from "../families/tezos/staking";
17
18
  import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
18
- import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
19
+ import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
19
20
 
20
21
  // TODO: remove this export and prefer import from root file.
21
22
  export {
@@ -46,6 +47,9 @@ export const isAccountEmpty = (a: AccountLike): boolean => {
46
47
  if (a.currency.family == "vechain") {
47
48
  return isVechainAccountEmpty(a);
48
49
  }
50
+ if (a.currency.family == "canton") {
51
+ return isCantonAccountEmpty(a);
52
+ }
49
53
  }
50
54
 
51
55
  return commonIsAccountEmpty(a);
@@ -3,7 +3,7 @@ import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/mocks/acco
3
3
  import { toAccountRaw, fromAccountRaw } from "./serialization";
4
4
  import { setWalletAPIVersion } from "../wallet-api/version";
5
5
  import { WALLET_API_VERSION } from "../wallet-api/constants";
6
- import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
6
+ import { setCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
7
7
  import type { CryptoAssetsStore } from "@ledgerhq/types-live";
8
8
  import solanaSplTokenData from "../__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json";
9
9
  import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
@@ -17,7 +17,7 @@ const Solana = getCryptoCurrencyById("solana");
17
17
  const USDC = solanaSplTokenData as TokenCurrency;
18
18
 
19
19
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
20
- setCryptoAssetsStoreForCoinFramework({
20
+ setCryptoAssetsStore({
21
21
  findTokenById: async (id: string) => {
22
22
  if (id === "solana/spl/epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v") {
23
23
  return USDC;
@@ -1,54 +1,19 @@
1
- import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
2
- import { getCryptoAssetsStore, setCryptoAssetsStore } from ".";
3
- import { legacyCryptoAssetsStore } from "@ledgerhq/cryptoassets/legacy/legacy-store";
1
+ import { getCryptoAssetsStore, setCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
4
2
  import type { CryptoAssetsStore } from "@ledgerhq/types-live";
3
+ import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
5
4
 
6
5
  describe("Testing CryptoAssetStore", () => {
7
- it("should return the default methods from cryptoassets libs when feature flag does not exists", () => {
8
- LiveConfig.setConfig({
9
- some_other_feature: {
10
- type: "boolean",
11
- default: true,
12
- },
13
- });
14
-
15
- const store = getCryptoAssetsStore();
16
- expect(store).toBe(legacyCryptoAssetsStore);
17
- });
18
-
19
- it("should return the default methods from cryptoassets libs when feature flag is disabled", () => {
20
- LiveConfig.setConfig({
21
- feature_cal_lazy_loading: {
22
- type: "boolean",
23
- default: false,
24
- },
25
- });
26
-
27
- const store = getCryptoAssetsStore();
28
- expect(store).toBe(legacyCryptoAssetsStore);
6
+ beforeEach(() => {
7
+ // Reset the store before each test
8
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
9
+ setCryptoAssetsStore(undefined as unknown as CryptoAssetsStore);
29
10
  });
30
11
 
31
- it("should throw an error when no store is set and feature flag is enabled", () => {
32
- LiveConfig.setConfig({
33
- feature_cal_lazy_loading: {
34
- type: "boolean",
35
- default: true,
36
- },
37
- });
38
-
39
- expect(() => getCryptoAssetsStore()).toThrow(
40
- "CryptoAssetsStore is not set. Please call setCryptoAssetsStore first.",
41
- );
12
+ it("should throw an error when no store is set", () => {
13
+ expect(() => getCryptoAssetsStore()).toThrow("CryptoAssetsStore is not set");
42
14
  });
43
15
 
44
- it("should throw return the new store when feature flag is enabled", () => {
45
- LiveConfig.setConfig({
46
- feature_cal_lazy_loading: {
47
- type: "boolean",
48
- default: true,
49
- },
50
- });
51
-
16
+ it("should return the store when it is set", () => {
52
17
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
53
18
  const newStore = {} as unknown as CryptoAssetsStore;
54
19
  setCryptoAssetsStore(newStore);
@@ -56,4 +21,10 @@ describe("Testing CryptoAssetStore", () => {
56
21
  const store = getCryptoAssetsStore();
57
22
  expect(store).toBe(newStore);
58
23
  });
24
+
25
+ it("should work with mock store", () => {
26
+ const mockStore = setupMockCryptoAssetsStore();
27
+ const store = getCryptoAssetsStore();
28
+ expect(store).toBe(mockStore);
29
+ });
59
30
  });
@@ -466,8 +466,7 @@ describe("Alpaca utils", () => {
466
466
  ...baseOp,
467
467
  type: "OUT",
468
468
  value: BigInt(100),
469
- tx: { ...baseOp.tx, fees: BigInt(25) },
470
- details: { status: "failed" },
469
+ tx: { ...baseOp.tx, fees: BigInt(25), failed: true },
471
470
  };
472
471
 
473
472
  const result = adaptCoreOperationToLiveOperation(accountId, failedOp);
@@ -107,7 +107,7 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
107
107
  extra.memo = op.details.memo as string;
108
108
  }
109
109
  const bnFees = new BigNumber(op.tx.fees.toString());
110
- const hasFailed = op.details?.status === "failed";
110
+ const hasFailed = op.tx.failed;
111
111
 
112
112
  let value: BigNumber;
113
113
  if (hasFailed) {
@@ -20,9 +20,7 @@ import {
20
20
  import { getAlpacaAccountBridge } from "./generic-alpaca/accountBridge";
21
21
  import { getAlpacaCurrencyBridge } from "./generic-alpaca/currencyBridge";
22
22
  import { AddressesSanctionedError } from "@ledgerhq/coin-framework/sanction/errors";
23
- import type { CryptoAssetsStore } from "@ledgerhq/types-live";
24
- import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
25
- import { getCryptoAssetsStore, setCryptoAssetsStore } from "./crypto-assets";
23
+ // Removed: stores are now managed globally by @ledgerhq/cryptoassets/cal-client/store
26
24
 
27
25
  const alpacaized = {
28
26
  xrp: true,
@@ -105,10 +103,8 @@ export function getAccountBridgeByFamily(family: string, accountId?: string): Ac
105
103
  return wrapAccountBridge(jsBridge.accountBridge);
106
104
  }
107
105
 
108
- export function setup(store: CryptoAssetsStore) {
109
- setCryptoAssetsStore(store);
110
- setCryptoAssetsStoreForCoinFramework(getCryptoAssetsStore());
111
- }
106
+ // Removed: setup() is no longer needed. The store is now managed globally by @ledgerhq/cryptoassets/cal-client/store.
107
+ // Use setupCalClientStore() or setupMockCryptoAssetsStore() from @ledgerhq/cryptoassets/cal-client/test-helpers instead.
112
108
 
113
109
  function wrapAccountBridge<T extends TransactionCommon>(
114
110
  bridge: AccountBridge<T>,
@@ -1,11 +1,30 @@
1
1
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
2
- import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
3
- import { addTokens as addTokensLegacy } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
2
+ import { setupMockCryptoAssetsStore } from "../test-helpers/cryptoAssetsStore";
4
3
  import { inferCryptoCurrencyIcon } from "./cryptoIcons";
5
- import { getCryptoAssetsStore } from "../bridge/crypto-assets/index";
4
+ import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
6
5
 
7
6
  beforeAll(() => {
8
- initializeLegacyTokens(addTokensLegacy);
7
+ // Setup mock store for unit tests
8
+ setupMockCryptoAssetsStore({
9
+ findTokenById: async (id: string) => {
10
+ // Return a mock token for the test
11
+ if (id === "ethereum/erc20/usd_tether__erc20_") {
12
+ return {
13
+ type: "TokenCurrency",
14
+ id: "ethereum/erc20/usd_tether__erc20_",
15
+ contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7",
16
+ parentCurrency: getCryptoCurrencyById("ethereum"),
17
+ tokenType: "erc20",
18
+ name: "Tether USD",
19
+ ticker: "USDT",
20
+ delisted: false,
21
+ disableCountervalue: false,
22
+ units: [{ name: "USDT", code: "USDT", magnitude: 6 }],
23
+ } as any;
24
+ }
25
+ return undefined;
26
+ },
27
+ });
9
28
  });
10
29
 
11
30
  describe("inferCryptoCurrencyIcon", () => {
@@ -0,0 +1,13 @@
1
+ import "../__tests__/test-helpers/setup";
2
+ import { isCryptoCurrency } from "./helpers";
3
+ import { listCryptoCurrencies } from ".";
4
+
5
+ describe("Currencies helpers", () => {
6
+ test("listCryptoCurrencies returns only crypto currencies", () => {
7
+ const currencies = listCryptoCurrencies();
8
+
9
+ currencies.forEach(currency => {
10
+ expect(isCryptoCurrency(currency)).toBeTruthy();
11
+ });
12
+ });
13
+ });
@@ -11,9 +11,6 @@ export {
11
11
  findCryptoCurrencyByScheme,
12
12
  findCryptoCurrencyByKeyword,
13
13
  findCryptoCurrencyByTicker,
14
- listTokens,
15
- listTokensForCryptoCurrency,
16
- listTokenTypesForCryptoCurrency,
17
14
  getAbandonSeedAddress,
18
15
  } from "@ledgerhq/cryptoassets";
19
16
  export {
@@ -1,31 +1,5 @@
1
1
  import { sortCurrenciesByIds } from "./sortByMarketcap";
2
- import { listCryptoCurrencies, listTokens } from ".";
3
- import { getBTCValues } from "@ledgerhq/live-countervalues/mock";
4
2
  import { CURRENCIES_LIST, IDS } from "./mock";
5
- import { findCryptoCurrencyByTicker, findFiatCurrencyByTicker } from "@ledgerhq/cryptoassets/index";
6
- import { getCryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/index";
7
- import { legacyCryptoAssetsStore } from "@ledgerhq/cryptoassets/legacy/legacy-store";
8
- import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
9
- import { addTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
10
- import { setup } from "../bridge/impl";
11
-
12
- initializeLegacyTokens(addTokens);
13
- setup(legacyCryptoAssetsStore);
14
-
15
- test("sortCurrenciesByIds snapshot", async () => {
16
- const list = [...listCryptoCurrencies(), ...listTokens()];
17
- const ids: string[] = [];
18
- for (const k in getBTCValues()) {
19
- const c =
20
- findCryptoCurrencyByTicker(k) ||
21
- findFiatCurrencyByTicker(k) ||
22
- (await getCryptoAssetsStore().findTokenById(k));
23
- if (c && (c.type == "CryptoCurrency" || c.type == "TokenCurrency")) {
24
- ids.push(c.id);
25
- }
26
- }
27
- expect(sortCurrenciesByIds(list, ids).map(c => c.id)[0]).toEqual("bitcoin");
28
- });
29
3
 
30
4
  test("sortCurrenciesByIds simulate staking from portfolio", () => {
31
5
  expect(sortCurrenciesByIds(CURRENCIES_LIST, IDS).map(c => c.id)).toEqual([
@@ -1,18 +1,47 @@
1
1
  import { genAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
2
2
  import { getCryptoCurrencyById } from "../currencies/index";
3
3
  import { Account } from "@ledgerhq/types-live";
4
+ import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
4
5
  import BigNumber from "bignumber.js";
5
6
  import { getTokensWithFunds } from "./getTokensWithFunds";
6
- import { initializeLegacyTokens } from "@ledgerhq/cryptoassets/legacy/legacy-data";
7
- import { addTokens } from "@ledgerhq/cryptoassets/legacy/legacy-utils";
7
+ import { setupMockCryptoAssetsStore } from "@ledgerhq/cryptoassets/cal-client/test-helpers";
8
8
 
9
- initializeLegacyTokens(addTokens);
9
+ // Setup mock store for unit tests
10
+ setupMockCryptoAssetsStore();
10
11
 
11
12
  const ETH = getCryptoCurrencyById("ethereum");
12
13
 
14
+ // Create mock tokens for tests
15
+ const ZRX_TOKEN: TokenCurrency = {
16
+ type: "TokenCurrency",
17
+ id: "ethereum/erc20/0x_project",
18
+ contractAddress: "0xE41d2489571d322189246DaFA5ebDe1F4699F498",
19
+ parentCurrency: ETH,
20
+ tokenType: "erc20",
21
+ name: "0x Project",
22
+ ticker: "ZRX",
23
+ delisted: false,
24
+ disableCountervalue: false,
25
+ units: [{ name: "ZRX", code: "ZRX", magnitude: 18 }],
26
+ };
27
+
28
+ const REP_TOKEN: TokenCurrency = {
29
+ type: "TokenCurrency",
30
+ id: "ethereum/erc20/augur",
31
+ contractAddress: "0x1985365e9f78359a9B6AD760e32412f4a445E862",
32
+ parentCurrency: ETH,
33
+ tokenType: "erc20",
34
+ name: "Augur",
35
+ ticker: "REP",
36
+ delisted: false,
37
+ disableCountervalue: false,
38
+ units: [{ name: "REP", code: "REP", magnitude: 18 }],
39
+ };
40
+
13
41
  const mockedAccounts: Account[] = [
14
42
  genAccount("mocked-account-2", {
15
43
  currency: ETH,
44
+ tokensData: [ZRX_TOKEN, REP_TOKEN],
16
45
  }),
17
46
  ];
18
47
 
@@ -1,4 +1,4 @@
1
- import { getCryptoAssetsStore } from "../../bridge/crypto-assets/index";
1
+ import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
2
2
  import type { AccountLike, SwapOperation } from "@ledgerhq/types-live";
3
3
  import { accountWithMandatoryTokens, getAccountCurrency } from "../../account";
4
4
  import type { MappedSwapOperation, SwapHistorySection } from "./types";
@@ -5,6 +5,10 @@ import { renderHook, waitFor } from "@testing-library/react";
5
5
 
6
6
  import { useSelectableCurrencies } from "./useSelectableCurrencies";
7
7
  import { getCryptoCurrencyById } from "../../../currencies";
8
+ import { setupMockCryptoAssetsStore } from "../../../test-helpers/cryptoAssetsStore";
9
+
10
+ // Setup mock store for unit tests
11
+ setupMockCryptoAssetsStore();
8
12
 
9
13
  describe("useSelectableCurrencies", () => {
10
14
  test("returns an empty array when empty list are passed", async () => {
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { findCryptoCurrencyById } from "@ledgerhq/cryptoassets";
3
- import { getCryptoAssetsStore } from "../../../bridge/crypto-assets/index";
3
+ import { getCryptoAssetsStore } from "@ledgerhq/cryptoassets/state";
4
4
  import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
5
5
 
6
6
  export const useSelectableCurrencies = ({
@@ -22,39 +22,39 @@ exports[`algorand currency bridge scanAccounts algorand seed 1 1`] = `
22
22
  "xpub": "ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q",
23
23
  },
24
24
  {
25
- "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+312769",
26
- "operationsCount": 11,
25
+ "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+438828",
26
+ "operationsCount": 0,
27
27
  "parentId": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:",
28
28
  "pendingOperations": [],
29
29
  "swapHistory": [],
30
- "tokenId": "algorand/asa/312769",
30
+ "tokenId": "algorand/asa/438828",
31
31
  "type": "TokenAccountRaw",
32
32
  },
33
33
  {
34
- "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+438828",
35
- "operationsCount": 0,
34
+ "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+312769",
35
+ "operationsCount": 11,
36
36
  "parentId": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:",
37
37
  "pendingOperations": [],
38
38
  "swapHistory": [],
39
- "tokenId": "algorand/asa/438828",
39
+ "tokenId": "algorand/asa/312769",
40
40
  "type": "TokenAccountRaw",
41
41
  },
42
42
  {
43
- "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+438837",
43
+ "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+2757561",
44
44
  "operationsCount": 0,
45
45
  "parentId": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:",
46
46
  "pendingOperations": [],
47
47
  "swapHistory": [],
48
- "tokenId": "algorand/asa/438837",
48
+ "tokenId": "algorand/asa/2757561",
49
49
  "type": "TokenAccountRaw",
50
50
  },
51
51
  {
52
- "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+2757561",
52
+ "id": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+438837",
53
53
  "operationsCount": 0,
54
54
  "parentId": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:",
55
55
  "pendingOperations": [],
56
56
  "swapHistory": [],
57
- "tokenId": "algorand/asa/2757561",
57
+ "tokenId": "algorand/asa/438837",
58
58
  "type": "TokenAccountRaw",
59
59
  },
60
60
  {
@@ -2772,6 +2772,7 @@ exports[`algorand currency bridge scanAccounts algorand seed 1 2`] = `
2772
2772
  "value": "1010",
2773
2773
  },
2774
2774
  ],
2775
+ [],
2775
2776
  [
2776
2777
  {
2777
2778
  "accountId": "js:2:algorand:ZC3HFULMJF53BF5ER4E2TTGPBRGH2Y4RVS32JZ6NH4RW7LN67HCE6UBS3Q:+312769",
@@ -2965,7 +2966,6 @@ exports[`algorand currency bridge scanAccounts algorand seed 1 2`] = `
2965
2966
  [],
2966
2967
  [],
2967
2968
  [],
2968
- [],
2969
2969
  [
2970
2970
  {
2971
2971
  "accountId": "js:2:algorand:EGZQNDFCXGR3BMP4NDM6ZPLBMY7WSV6GRKOHM6VBJKFLWQ3RQDTE3JYNFE:",
@@ -1,4 +1,4 @@
1
- import "../../__tests__/test-helpers/setup";
1
+ import "../../__tests__/test-helpers/setup.integration";
2
2
  import { testBridge } from "../../__tests__/test-helpers/bridge";
3
3
  import { dataset } from "@ledgerhq/coin-algorand/test/bridge.dataset";
4
4