@ledgerhq/live-common 34.42.0 → 34.42.2-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 (161) hide show
  1. package/lib/__tests__/migration/account-migration.js +3 -0
  2. package/lib/__tests__/migration/account-migration.js.map +1 -1
  3. package/lib/__tests__/test-helpers/environment.js +3 -0
  4. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  5. package/lib/bridge/crypto-assets/index.d.ts +4 -0
  6. package/lib/bridge/crypto-assets/index.d.ts.map +1 -0
  7. package/lib/bridge/crypto-assets/index.js +52 -0
  8. package/lib/bridge/crypto-assets/index.js.map +1 -0
  9. package/lib/bridge/crypto-assets/index.test.d.ts +2 -0
  10. package/lib/bridge/crypto-assets/index.test.d.ts.map +1 -0
  11. package/lib/bridge/crypto-assets/index.test.js +85 -0
  12. package/lib/bridge/crypto-assets/index.test.js.map +1 -0
  13. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +3 -1
  14. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  15. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +6 -0
  16. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  17. package/lib/bridge/impl.d.ts +2 -0
  18. package/lib/bridge/impl.d.ts.map +1 -1
  19. package/lib/bridge/impl.js +8 -1
  20. package/lib/bridge/impl.js.map +1 -1
  21. package/lib/bridge/useBridgeTransaction.test.js +1 -1
  22. package/lib/bridge/useBridgeTransaction.test.js.map +1 -1
  23. package/lib/e2e/families/osmosis.d.ts +3 -0
  24. package/lib/e2e/families/osmosis.d.ts.map +1 -0
  25. package/lib/e2e/families/osmosis.js +19 -0
  26. package/lib/e2e/families/osmosis.js.map +1 -0
  27. package/lib/e2e/index.d.ts +8 -0
  28. package/lib/e2e/index.d.ts.map +1 -1
  29. package/lib/e2e/speculos.d.ts.map +1 -1
  30. package/lib/e2e/speculos.js +5 -2
  31. package/lib/e2e/speculos.js.map +1 -1
  32. package/lib/exchange/error.d.ts +2 -1
  33. package/lib/exchange/error.d.ts.map +1 -1
  34. package/lib/exchange/error.js +5 -3
  35. package/lib/exchange/error.js.map +1 -1
  36. package/lib/exchange/swap/completeExchange.js +2 -2
  37. package/lib/exchange/swap/completeExchange.js.map +1 -1
  38. package/lib/families/evm/config.d.ts.map +1 -1
  39. package/lib/families/evm/config.js +51 -0
  40. package/lib/families/evm/config.js.map +1 -1
  41. package/lib/families/evm/walletApiAdapter.js +1 -1
  42. package/lib/featureFlags/defaultFeatures.d.ts +3 -0
  43. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  44. package/lib/featureFlags/defaultFeatures.js +4 -0
  45. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  46. package/lib/featureFlags/useFeature.d.ts +1 -1
  47. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  48. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts +17 -0
  49. package/lib/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -0
  50. package/lib/modularDrawer/__mocks__/currencies.mock.js +60 -0
  51. package/lib/modularDrawer/__mocks__/currencies.mock.js.map +1 -0
  52. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
  53. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
  54. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +41 -0
  55. package/lib/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
  56. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
  57. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
  58. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +28 -0
  59. package/lib/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -0
  60. package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
  61. package/lib/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
  62. package/lib/modularDrawer/utils/haveOneCommonProvider.js +29 -0
  63. package/lib/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
  64. package/lib/modularDrawer/utils/index.d.ts +2 -1
  65. package/lib/modularDrawer/utils/index.d.ts.map +1 -1
  66. package/lib/modularDrawer/utils/index.js +3 -1
  67. package/lib/modularDrawer/utils/index.js.map +1 -1
  68. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  69. package/lib/wallet-api/Exchange/server.js +6 -6
  70. package/lib/wallet-api/Exchange/server.js.map +1 -1
  71. package/lib-es/__tests__/migration/account-migration.js +3 -0
  72. package/lib-es/__tests__/migration/account-migration.js.map +1 -1
  73. package/lib-es/__tests__/test-helpers/environment.js +3 -0
  74. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  75. package/lib-es/bridge/crypto-assets/index.d.ts +4 -0
  76. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -0
  77. package/lib-es/bridge/crypto-assets/index.js +24 -0
  78. package/lib-es/bridge/crypto-assets/index.js.map +1 -0
  79. package/lib-es/bridge/crypto-assets/index.test.d.ts +2 -0
  80. package/lib-es/bridge/crypto-assets/index.test.d.ts.map +1 -0
  81. package/lib-es/bridge/crypto-assets/index.test.js +60 -0
  82. package/lib-es/bridge/crypto-assets/index.test.js.map +1 -0
  83. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +3 -1
  84. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  85. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +6 -0
  86. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  87. package/lib-es/bridge/impl.d.ts +2 -0
  88. package/lib-es/bridge/impl.d.ts.map +1 -1
  89. package/lib-es/bridge/impl.js +6 -0
  90. package/lib-es/bridge/impl.js.map +1 -1
  91. package/lib-es/bridge/useBridgeTransaction.test.js +1 -1
  92. package/lib-es/bridge/useBridgeTransaction.test.js.map +1 -1
  93. package/lib-es/e2e/families/osmosis.d.ts +3 -0
  94. package/lib-es/e2e/families/osmosis.d.ts.map +1 -0
  95. package/lib-es/e2e/families/osmosis.js +12 -0
  96. package/lib-es/e2e/families/osmosis.js.map +1 -0
  97. package/lib-es/e2e/index.d.ts +8 -0
  98. package/lib-es/e2e/index.d.ts.map +1 -1
  99. package/lib-es/e2e/speculos.d.ts.map +1 -1
  100. package/lib-es/e2e/speculos.js +5 -2
  101. package/lib-es/e2e/speculos.js.map +1 -1
  102. package/lib-es/exchange/error.d.ts +2 -1
  103. package/lib-es/exchange/error.d.ts.map +1 -1
  104. package/lib-es/exchange/error.js +5 -3
  105. package/lib-es/exchange/error.js.map +1 -1
  106. package/lib-es/exchange/swap/completeExchange.js +2 -2
  107. package/lib-es/exchange/swap/completeExchange.js.map +1 -1
  108. package/lib-es/families/evm/config.d.ts.map +1 -1
  109. package/lib-es/families/evm/config.js +51 -0
  110. package/lib-es/families/evm/config.js.map +1 -1
  111. package/lib-es/families/evm/walletApiAdapter.js +1 -1
  112. package/lib-es/featureFlags/defaultFeatures.d.ts +3 -0
  113. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  114. package/lib-es/featureFlags/defaultFeatures.js +4 -0
  115. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  116. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  117. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  118. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts +17 -0
  119. package/lib-es/modularDrawer/__mocks__/currencies.mock.d.ts.map +1 -0
  120. package/lib-es/modularDrawer/__mocks__/currencies.mock.js +55 -0
  121. package/lib-es/modularDrawer/__mocks__/currencies.mock.js.map +1 -0
  122. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts +22 -0
  123. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.d.ts.map +1 -0
  124. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js +38 -0
  125. package/lib-es/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.js.map +1 -0
  126. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts +2 -0
  127. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.d.ts.map +1 -0
  128. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js +26 -0
  129. package/lib-es/modularDrawer/utils/__tests__/haveOneCommonProvider.test.js.map +1 -0
  130. package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts +11 -0
  131. package/lib-es/modularDrawer/utils/haveOneCommonProvider.d.ts.map +1 -0
  132. package/lib-es/modularDrawer/utils/haveOneCommonProvider.js +25 -0
  133. package/lib-es/modularDrawer/utils/haveOneCommonProvider.js.map +1 -0
  134. package/lib-es/modularDrawer/utils/index.d.ts +2 -1
  135. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
  136. package/lib-es/modularDrawer/utils/index.js +2 -1
  137. package/lib-es/modularDrawer/utils/index.js.map +1 -1
  138. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  139. package/lib-es/wallet-api/Exchange/server.js +6 -6
  140. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  141. package/package.json +39 -39
  142. package/src/__tests__/migration/account-migration.ts +3 -0
  143. package/src/__tests__/test-helpers/environment.ts +3 -0
  144. package/src/bridge/crypto-assets/index.test.ts +71 -0
  145. package/src/bridge/crypto-assets/index.ts +30 -0
  146. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +8 -1
  147. package/src/bridge/impl.ts +8 -0
  148. package/src/bridge/useBridgeTransaction.test.ts +1 -1
  149. package/src/e2e/families/osmosis.ts +13 -0
  150. package/src/e2e/speculos.ts +5 -2
  151. package/src/exchange/error.ts +5 -3
  152. package/src/exchange/swap/completeExchange.ts +2 -2
  153. package/src/families/evm/config.ts +51 -0
  154. package/src/families/evm/walletApiAdapter.ts +1 -1
  155. package/src/featureFlags/defaultFeatures.ts +4 -0
  156. package/src/modularDrawer/__mocks__/currencies.mock.ts +62 -0
  157. package/src/modularDrawer/__mocks__/useGroupedCurrenciesByProvider.mock.ts +49 -0
  158. package/src/modularDrawer/utils/__tests__/haveOneCommonProvider.test.ts +34 -0
  159. package/src/modularDrawer/utils/haveOneCommonProvider.ts +31 -0
  160. package/src/modularDrawer/utils/index.ts +2 -1
  161. package/src/wallet-api/Exchange/server.ts +7 -6
@@ -38,6 +38,7 @@ import { delegateMultiversX } from "./families/multiversX";
38
38
  import { NFTTransaction, Transaction } from "./models/Transaction";
39
39
  import { Delegate } from "./models/Delegate";
40
40
  import { Swap } from "./models/Swap";
41
+ import { delegateOsmosis } from "./families/osmosis";
41
42
 
42
43
  const isSpeculosRemote = process.env.REMOTE_SPECULOS === "true";
43
44
 
@@ -414,7 +415,7 @@ interface ResponseData {
414
415
  events: Event[];
415
416
  }
416
417
 
417
- export async function waitFor(text: string, maxAttempts = 10): Promise<string[]> {
418
+ export async function waitFor(text: string, maxAttempts = 15): Promise<string[]> {
418
419
  const port = getEnv("SPECULOS_API_PORT");
419
420
  const address = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
420
421
  const url = `${address}:${port}/events?stream=false&currentscreenonly=true`;
@@ -656,9 +657,11 @@ export async function signDelegationTransaction(delegatingAccount: Delegate) {
656
657
  break;
657
658
  case Account.ATOM_1.currency.name:
658
659
  case Account.INJ_1.currency.name:
659
- case Account.OSMO_1.currency.name:
660
660
  await delegateCosmos(delegatingAccount);
661
661
  break;
662
+ case Account.OSMO_1.currency.name:
663
+ await delegateOsmosis(delegatingAccount);
664
+ break;
662
665
  case Account.MULTIVERS_X_1.currency.name:
663
666
  await delegateMultiversX();
664
667
  break;
@@ -13,10 +13,12 @@ export type CompleteExchangeStep =
13
13
 
14
14
  export class CompleteExchangeError extends Error {
15
15
  step: CompleteExchangeStep;
16
+ title?: string;
16
17
 
17
- constructor(step: CompleteExchangeStep, message?: string) {
18
+ constructor(step: CompleteExchangeStep, title?: string, message?: string) {
18
19
  super(message);
19
20
  this.name = "CompleteExchangeError";
21
+ this.title = title;
20
22
  this.step = step;
21
23
  }
22
24
  }
@@ -26,8 +28,8 @@ export function convertTransportError(
26
28
  err: unknown,
27
29
  ): CompleteExchangeError | unknown {
28
30
  if (err instanceof TransportStatusError) {
29
- const errorMessage = getExchangeErrorMessage(err.statusCode, step);
30
- return new CompleteExchangeError(step, errorMessage);
31
+ const { errorName, errorMessage } = getExchangeErrorMessage(err.statusCode, step);
32
+ return new CompleteExchangeError(step, errorName, errorMessage);
31
33
  }
32
34
  return err;
33
35
  }
@@ -175,7 +175,7 @@ const completeExchange = (
175
175
  } catch (e) {
176
176
  if (e instanceof TransportStatusError && e.statusCode === 0x6a83) {
177
177
  throw new WrongDeviceForAccountPayout(
178
- getExchangeErrorMessage(e.statusCode, currentStep),
178
+ getExchangeErrorMessage(e.statusCode, currentStep).errorMessage,
179
179
  {
180
180
  accountName: getDefaultAccountName(payoutAccount),
181
181
  },
@@ -217,7 +217,7 @@ const completeExchange = (
217
217
  if (e instanceof TransportStatusError && e.statusCode === 0x6a83) {
218
218
  log(COMPLETE_EXCHANGE_LOG, "transport error");
219
219
  throw new WrongDeviceForAccountRefund(
220
- getExchangeErrorMessage(e.statusCode, currentStep),
220
+ getExchangeErrorMessage(e.statusCode, currentStep).errorMessage,
221
221
  {
222
222
  accountName: getDefaultAccountName(refundAccount),
223
223
  },
@@ -612,6 +612,57 @@ const evmConfig: CurrencyLiveConfigDefinition = {
612
612
  showNfts: false,
613
613
  },
614
614
  },
615
+ config_currency_sei_network_evm: {
616
+ type: "object",
617
+ default: {
618
+ status: {
619
+ type: "active",
620
+ },
621
+ node: {
622
+ type: "external",
623
+ uri: "https://sei-evm-rpc.publicnode.com",
624
+ },
625
+ explorer: {
626
+ type: "etherscan",
627
+ uri: "https://proxyetherscan.api.live.ledger.com/v2/api/1329",
628
+ },
629
+ showNfts: false,
630
+ },
631
+ },
632
+ config_currency_berachain: {
633
+ type: "object",
634
+ default: {
635
+ status: {
636
+ type: "active",
637
+ },
638
+ node: {
639
+ type: "external",
640
+ uri: "https://rpc.berachain.com",
641
+ },
642
+ explorer: {
643
+ type: "etherscan",
644
+ uri: "https://proxyetherscan.api.live.ledger.com/v2/api/80094",
645
+ },
646
+ showNfts: false,
647
+ },
648
+ },
649
+ config_currency_hyperevm: {
650
+ type: "object",
651
+ default: {
652
+ status: {
653
+ type: "active",
654
+ },
655
+ node: {
656
+ type: "external",
657
+ uri: "https://rpc.hypurrscan.io",
658
+ },
659
+ explorer: {
660
+ type: "etherscan",
661
+ uri: "https://proxyetherscan.api.live.ledger.com/v2/api/999",
662
+ },
663
+ showNfts: false,
664
+ },
665
+ },
615
666
  config_currency_polygon_zk_evm: {
616
667
  type: "object",
617
668
  default: {
@@ -48,7 +48,7 @@ const convertToLiveTransaction: ConvertToLiveTransaction<
48
48
 
49
49
  /**
50
50
  * We explicitly set unrelated type specific fields to undefined to avoid transaction
51
- * type assertion errors during the `prepareTransaction` logic (libs/coin-evm/src/prepareTransaction.ts)
51
+ * type assertion errors during the `prepareTransaction` logic (libs/coin-modules/coin-evm/src/bridge/prepareTransaction.ts)
52
52
  * when performing an `updateTransaction` with a newly created tx
53
53
  * Which is what happen in this case (in apps/ledger-live-desktop/src/renderer/modals/SignTransaction/Body.tsx):
54
54
  // `createTransaction` will create a type 2 tx by default with `maxFeePerGas` and `maxPriorityFeePerGas` set to 0
@@ -92,6 +92,9 @@ export const CURRENCY_DEFAULT_FEATURES = {
92
92
  currencySui: DEFAULT_FEATURE,
93
93
  currencyMina: DEFAULT_FEATURE,
94
94
  currencyBabylon: DEFAULT_FEATURE,
95
+ currencySeiNetworkEvm: DEFAULT_FEATURE,
96
+ currencyBerachain: DEFAULT_FEATURE,
97
+ currencyHyperevm: DEFAULT_FEATURE,
95
98
  };
96
99
 
97
100
  /**
@@ -619,6 +622,7 @@ export const DEFAULT_FEATURES: Features = {
619
622
  enableModularization: false,
620
623
  },
621
624
  },
625
+ lldModularDrawerBackendData: DEFAULT_FEATURE,
622
626
  llmModularDrawer: {
623
627
  ...DEFAULT_FEATURE,
624
628
  params: {
@@ -0,0 +1,62 @@
1
+ import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index";
2
+ import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
3
+
4
+ export const mockBtcCryptoCurrency = getCryptoCurrencyById("bitcoin");
5
+ export const mockEthCryptoCurrency = getCryptoCurrencyById("ethereum");
6
+ export const mockArbitrumCryptoCurrency = getCryptoCurrencyById("arbitrum");
7
+ export const mockBaseCryptoCurrency = getCryptoCurrencyById("base");
8
+ export const mockScrollCryptoCurrency = getCryptoCurrencyById("scroll");
9
+ export const mockInjectiveCryptoCurrency = getCryptoCurrencyById("injective");
10
+
11
+ export const arbitrumToken: TokenCurrency = {
12
+ type: "TokenCurrency",
13
+ id: "arbitrum/erc20/arbitrum",
14
+ contractAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
15
+ parentCurrency: mockArbitrumCryptoCurrency,
16
+ tokenType: "erc20",
17
+ name: "Arbitrum",
18
+ ticker: "ARB",
19
+ units: [
20
+ {
21
+ name: "Arbitrum",
22
+ code: "ARB",
23
+ magnitude: 18,
24
+ },
25
+ ],
26
+ };
27
+ export const usdcToken: TokenCurrency = {
28
+ type: "TokenCurrency",
29
+ id: "ethereum/erc20/usd__coin",
30
+ contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
31
+ parentCurrency: mockEthCryptoCurrency,
32
+ tokenType: "erc20",
33
+ name: "USD Coin",
34
+ ticker: "USDC",
35
+ units: [
36
+ {
37
+ name: "USD Coin",
38
+ code: "USDC",
39
+ magnitude: 6,
40
+ },
41
+ ],
42
+ };
43
+
44
+ export const findCryptoCurrencyById = (id: string) =>
45
+ [mockBtcCryptoCurrency, mockEthCryptoCurrency, mockArbitrumCryptoCurrency].find(a => a.id === id);
46
+ export const getTokenOrCryptoCurrencyById = (id: string) =>
47
+ [
48
+ mockBtcCryptoCurrency,
49
+ mockEthCryptoCurrency,
50
+ mockArbitrumCryptoCurrency,
51
+ arbitrumToken,
52
+ usdcToken,
53
+ ].find(a => a.id === id);
54
+
55
+ export const mockCurrenciesByProvider = [
56
+ {
57
+ providerId: "ethereum",
58
+ currenciesByNetwork: [mockEthCryptoCurrency],
59
+ },
60
+ ];
61
+
62
+ export const mockCurrencyIds = ["bitcoin", "ethereum", "arbitrum", "base"];
@@ -0,0 +1,49 @@
1
+ import { LoadingStatus } from "@ledgerhq/live-common/deposit/type";
2
+ import {
3
+ arbitrumToken,
4
+ mockArbitrumCryptoCurrency,
5
+ mockBaseCryptoCurrency,
6
+ mockBtcCryptoCurrency,
7
+ mockEthCryptoCurrency,
8
+ mockInjectiveCryptoCurrency,
9
+ mockScrollCryptoCurrency,
10
+ usdcToken,
11
+ } from "./currencies.mock";
12
+
13
+ export const providers = [
14
+ {
15
+ providerId: "bitcoin",
16
+ currenciesByNetwork: [mockBtcCryptoCurrency],
17
+ },
18
+ {
19
+ providerId: "ethereum",
20
+ currenciesByNetwork: [
21
+ mockEthCryptoCurrency,
22
+ mockArbitrumCryptoCurrency,
23
+ mockBaseCryptoCurrency,
24
+ mockScrollCryptoCurrency,
25
+ ],
26
+ },
27
+ { providerId: "arbitrum", currenciesByNetwork: [arbitrumToken] },
28
+ { providerId: "usd-coin", currenciesByNetwork: [usdcToken] },
29
+ { providerId: "injective-protocol", currenciesByNetwork: [mockInjectiveCryptoCurrency] },
30
+ ];
31
+
32
+ export const res = {
33
+ result: {
34
+ currenciesByProvider: providers,
35
+ sortedCryptoCurrencies: [
36
+ mockBtcCryptoCurrency,
37
+ mockEthCryptoCurrency,
38
+ mockArbitrumCryptoCurrency,
39
+ mockBaseCryptoCurrency,
40
+ mockScrollCryptoCurrency,
41
+ mockInjectiveCryptoCurrency,
42
+ ],
43
+ },
44
+ };
45
+
46
+ export const useGroupedCurrenciesByProvider: jest.Mock = jest.fn(() => ({
47
+ ...res,
48
+ loadingStatus: LoadingStatus.Success,
49
+ }));
@@ -0,0 +1,34 @@
1
+ import { haveOneCommonProvider } from "../haveOneCommonProvider";
2
+ import { useGroupedCurrenciesByProvider } from "../../__mocks__/useGroupedCurrenciesByProvider.mock";
3
+ import { LoadingBasedGroupedCurrencies } from "@ledgerhq/live-common/deposit/type";
4
+
5
+ jest.mock("@ledgerhq/live-common/deposit/useGroupedCurrenciesByProvider.hook", () => ({
6
+ useGroupedCurrenciesByProvider: () => useGroupedCurrenciesByProvider(),
7
+ }));
8
+
9
+ describe("haveOneCommonProvider", () => {
10
+ it("should return false for an empty array", () => {
11
+ expect(haveOneCommonProvider([], [])).toBe(false);
12
+ });
13
+
14
+ it("should return true for a single currency with one provider", () => {
15
+ const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
16
+ const { currenciesByProvider } = result;
17
+
18
+ expect(haveOneCommonProvider(["bitcoin"], currenciesByProvider)).toBe(true);
19
+ });
20
+
21
+ it("should return false for multiple currencies with different providers", () => {
22
+ const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
23
+ const { currenciesByProvider } = result;
24
+
25
+ expect(haveOneCommonProvider(["bitcoin", "ethereum"], currenciesByProvider)).toBe(false);
26
+ });
27
+
28
+ it("should return true for multiple currencies with the same provider", () => {
29
+ const { result } = useGroupedCurrenciesByProvider(true) as LoadingBasedGroupedCurrencies;
30
+ const { currenciesByProvider } = result;
31
+
32
+ expect(haveOneCommonProvider(["ethereum", "arbitrum"], currenciesByProvider)).toBe(true);
33
+ });
34
+ });
@@ -0,0 +1,31 @@
1
+ import { CurrenciesByProviderId } from "@ledgerhq/live-common/deposit/type";
2
+
3
+ /**
4
+ * This function checks if all currencies in the provided array
5
+ * it stopped at the first currency that does not match to prevent unnecessary iterations.
6
+ *
7
+ * @param currenciesIdsArray array of currency IDs to check
8
+ * @param currenciesByProvider array of currencies grouped by provider
9
+ * @returns boolean indicating whether all currencies in the array have one common provider
10
+ */
11
+ export const haveOneCommonProvider = (
12
+ currenciesIdsArray: string[],
13
+ currenciesByProvider: CurrenciesByProviderId[],
14
+ ): boolean => {
15
+ if (currenciesIdsArray.length === 0) return false;
16
+
17
+ const providerIds = new Set<string>();
18
+
19
+ for (const currencyId of currenciesIdsArray) {
20
+ for (const provider of currenciesByProvider) {
21
+ if (provider.currenciesByNetwork.some(currency => currency.id === currencyId)) {
22
+ providerIds.add(provider.providerId);
23
+ if (providerIds.size > 1) {
24
+ return false;
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ return true;
31
+ };
@@ -1,5 +1,6 @@
1
1
  import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
2
  import { CurrenciesByProviderId } from "../../deposit/type";
3
+ import { haveOneCommonProvider } from "./haveOneCommonProvider";
3
4
 
4
5
  function isCorrespondingCurrency(
5
6
  elem: CryptoOrTokenCurrency,
@@ -26,4 +27,4 @@ const getEffectiveCurrency = (
26
27
  return provider.currenciesByNetwork.find(elem => currencyIds.includes(elem.id)) ?? currency;
27
28
  };
28
29
 
29
- export { isCorrespondingCurrency, getEffectiveCurrency };
30
+ export { isCorrespondingCurrency, getEffectiveCurrency, haveOneCommonProvider };
@@ -51,6 +51,7 @@ import { getSwapStepFromError } from "../../exchange/error";
51
51
  import { postSwapCancelled } from "../../exchange/swap";
52
52
  import { DeviceModelId } from "@ledgerhq/types-devices";
53
53
  import { setBroadcastTransaction } from "../../exchange/swap/setBroadcastTransaction";
54
+ import { FAMILIES_MAPPING_LL_TO_WAPI } from "../constants";
54
55
 
55
56
  export { ExchangeType };
56
57
 
@@ -485,7 +486,9 @@ export const handlers = ({
485
486
  });
486
487
 
487
488
  const mainFromAccount = getMainAccount(fromAccount, fromParentAccount);
488
- const mainFromAccountFamily = mainFromAccount.currency.family;
489
+ const mainFromAccountFamily =
490
+ FAMILIES_MAPPING_LL_TO_WAPI[mainFromAccount.currency.family] ||
491
+ mainFromAccount.currency.family;
489
492
 
490
493
  if (transaction.family !== mainFromAccountFamily) {
491
494
  return Promise.reject(
@@ -741,9 +744,7 @@ async function getStrategy(
741
744
  customErrorType?: any,
742
745
  ): Promise<Transaction> {
743
746
  const family =
744
- currency.type === "TokenCurrency"
745
- ? (currency.parentCurrency?.family as Transaction["family"])
746
- : (currency.family as Transaction["family"]);
747
+ currency.type === "TokenCurrency" ? currency.parentCurrency?.family : currency.family;
747
748
 
748
749
  if (!family) {
749
750
  throw new Error(`TokenCurrency missing parentCurrency family: ${currency.id}`);
@@ -755,7 +756,7 @@ async function getStrategy(
755
756
  }
756
757
 
757
758
  // Normalize family key for strategy lookup
758
- const familyKey = family === "evm" ? "ethereum" : family;
759
+ const familyKey = FAMILIES_MAPPING_LL_TO_WAPI[family] || family;
759
760
  const strategy = transactionStrategy?.[familyKey];
760
761
 
761
762
  if (!strategy) {
@@ -764,7 +765,7 @@ async function getStrategy(
764
765
 
765
766
  try {
766
767
  return await strategy({
767
- family,
768
+ family: familyKey,
768
769
  amount,
769
770
  recipient,
770
771
  customFeeConfig: customFeeConfig || {},