@ledgerhq/live-common 34.43.0 → 34.44.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 (218) hide show
  1. package/lib/DataModel.test.js +6 -0
  2. package/lib/DataModel.test.js.map +1 -1
  3. package/lib/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
  4. package/lib/__tests__/accounts/groupPerDay.js +10 -0
  5. package/lib/__tests__/accounts/groupPerDay.js.map +1 -1
  6. package/lib/__tests__/test-helpers/environment.js +1 -0
  7. package/lib/__tests__/test-helpers/environment.js.map +1 -1
  8. package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
  9. package/lib/__tests__/test-helpers/setup.js +6 -0
  10. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  11. package/lib/account/serialization.test.js +17 -1
  12. package/lib/account/serialization.test.js.map +1 -1
  13. package/lib/appSupportsQuitApp.d.ts +1 -0
  14. package/lib/appSupportsQuitApp.d.ts.map +1 -1
  15. package/lib/appSupportsQuitApp.js +1 -0
  16. package/lib/appSupportsQuitApp.js.map +1 -1
  17. package/lib/appSupportsQuitApp.test.js +28 -3
  18. package/lib/appSupportsQuitApp.test.js.map +1 -1
  19. package/lib/bridge/crypto-assets/index.d.ts.map +1 -1
  20. package/lib/bridge/crypto-assets/index.js +5 -5
  21. package/lib/bridge/crypto-assets/index.js.map +1 -1
  22. package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  23. package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  24. package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  25. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
  26. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  27. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  28. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  29. package/lib/bridge/generic-alpaca/getAccountShape.js +5 -6
  30. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  31. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  32. package/lib/bridge/generic-alpaca/utils.d.ts +3 -2
  33. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  34. package/lib/bridge/generic-alpaca/utils.js +6 -2
  35. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  36. package/lib/bridge/generic-alpaca/utils.test.d.ts +2 -0
  37. package/lib/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
  38. package/lib/bridge/generic-alpaca/utils.test.js +20 -0
  39. package/lib/bridge/generic-alpaca/utils.test.js.map +1 -0
  40. package/lib/currencies/sortByMarketcap.test.js +5 -0
  41. package/lib/currencies/sortByMarketcap.test.js.map +1 -1
  42. package/lib/e2e/index.d.ts +3 -0
  43. package/lib/e2e/index.d.ts.map +1 -1
  44. package/lib/e2e/speculos.d.ts.map +1 -1
  45. package/lib/e2e/speculos.js +45 -15
  46. package/lib/e2e/speculos.js.map +1 -1
  47. package/lib/e2e/speculosCI.d.ts.map +1 -1
  48. package/lib/e2e/speculosCI.js +22 -4
  49. package/lib/e2e/speculosCI.js.map +1 -1
  50. package/lib/env.react.d.ts +1 -1
  51. package/lib/env.react.d.ts.map +1 -1
  52. package/lib/families/bitcoin/satstack.test.js +6 -0
  53. package/lib/families/bitcoin/satstack.test.js.map +1 -1
  54. package/lib/families/solana/bridge/mock-data.d.ts.map +1 -1
  55. package/lib/families/solana/bridge/mock-data.js +46 -316
  56. package/lib/families/solana/bridge/mock-data.js.map +1 -1
  57. package/lib/families/solana/bridge/mock.js +2 -2
  58. package/lib/families/solana/bridge/mock.js.map +1 -1
  59. package/lib/families/stellar/ui.d.ts +6 -0
  60. package/lib/families/stellar/ui.d.ts.map +1 -0
  61. package/lib/families/stellar/ui.js +18 -0
  62. package/lib/families/stellar/ui.js.map +1 -0
  63. package/lib/families/tron/data.mock.d.ts.map +1 -1
  64. package/lib/families/tron/data.mock.js +6 -0
  65. package/lib/families/tron/data.mock.js.map +1 -1
  66. package/lib/featureFlags/defaultFeatures.d.ts +1 -0
  67. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  68. package/lib/featureFlags/defaultFeatures.js +1 -0
  69. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  70. package/lib/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
  71. package/lib/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
  72. package/lib/modularDrawer/__mocks__/accounts.mock.js +48 -0
  73. package/lib/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
  74. package/lib/utils/__tests__/composeHooks.test.d.ts +2 -0
  75. package/lib/utils/__tests__/composeHooks.test.d.ts.map +1 -0
  76. package/lib/utils/__tests__/composeHooks.test.js +35 -0
  77. package/lib/utils/__tests__/composeHooks.test.js.map +1 -0
  78. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
  79. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
  80. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +104 -0
  81. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
  82. package/lib/utils/composeHooks.d.ts +11 -0
  83. package/lib/utils/composeHooks.d.ts.map +1 -0
  84. package/lib/utils/composeHooks.js +25 -0
  85. package/lib/utils/composeHooks.js.map +1 -0
  86. package/lib/utils/getAccountTuplesForCurrency.d.ts +8 -0
  87. package/lib/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
  88. package/lib/utils/getAccountTuplesForCurrency.js +19 -0
  89. package/lib/utils/getAccountTuplesForCurrency.js.map +1 -0
  90. package/lib/wallet-api/helpers.d.ts +1 -0
  91. package/lib/wallet-api/helpers.d.ts.map +1 -1
  92. package/lib/wallet-api/helpers.js +16 -1
  93. package/lib/wallet-api/helpers.js.map +1 -1
  94. package/lib-es/DataModel.test.js +6 -0
  95. package/lib-es/DataModel.test.js.map +1 -1
  96. package/lib-es/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
  97. package/lib-es/__tests__/accounts/groupPerDay.js +10 -0
  98. package/lib-es/__tests__/accounts/groupPerDay.js.map +1 -1
  99. package/lib-es/__tests__/test-helpers/environment.js +1 -0
  100. package/lib-es/__tests__/test-helpers/environment.js.map +1 -1
  101. package/lib-es/__tests__/test-helpers/setup.d.ts.map +1 -1
  102. package/lib-es/__tests__/test-helpers/setup.js +6 -0
  103. package/lib-es/__tests__/test-helpers/setup.js.map +1 -1
  104. package/lib-es/account/serialization.test.js +15 -2
  105. package/lib-es/account/serialization.test.js.map +1 -1
  106. package/lib-es/appSupportsQuitApp.d.ts +1 -0
  107. package/lib-es/appSupportsQuitApp.d.ts.map +1 -1
  108. package/lib-es/appSupportsQuitApp.js +1 -0
  109. package/lib-es/appSupportsQuitApp.js.map +1 -1
  110. package/lib-es/appSupportsQuitApp.test.js +6 -1
  111. package/lib-es/appSupportsQuitApp.test.js.map +1 -1
  112. package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
  113. package/lib-es/bridge/crypto-assets/index.js +4 -4
  114. package/lib-es/bridge/crypto-assets/index.js.map +1 -1
  115. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  116. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  117. package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  118. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
  119. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  120. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  121. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  122. package/lib-es/bridge/generic-alpaca/getAccountShape.js +6 -7
  123. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  124. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  125. package/lib-es/bridge/generic-alpaca/utils.d.ts +3 -2
  126. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  127. package/lib-es/bridge/generic-alpaca/utils.js +4 -1
  128. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  129. package/lib-es/bridge/generic-alpaca/utils.test.d.ts +2 -0
  130. package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +1 -0
  131. package/lib-es/bridge/generic-alpaca/utils.test.js +18 -0
  132. package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -0
  133. package/lib-es/currencies/sortByMarketcap.test.js +5 -0
  134. package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
  135. package/lib-es/e2e/index.d.ts +3 -0
  136. package/lib-es/e2e/index.d.ts.map +1 -1
  137. package/lib-es/e2e/speculos.d.ts.map +1 -1
  138. package/lib-es/e2e/speculos.js +45 -15
  139. package/lib-es/e2e/speculos.js.map +1 -1
  140. package/lib-es/e2e/speculosCI.d.ts.map +1 -1
  141. package/lib-es/e2e/speculosCI.js +22 -4
  142. package/lib-es/e2e/speculosCI.js.map +1 -1
  143. package/lib-es/env.react.d.ts +1 -1
  144. package/lib-es/env.react.d.ts.map +1 -1
  145. package/lib-es/families/bitcoin/satstack.test.js +6 -0
  146. package/lib-es/families/bitcoin/satstack.test.js.map +1 -1
  147. package/lib-es/families/solana/bridge/mock-data.d.ts.map +1 -1
  148. package/lib-es/families/solana/bridge/mock-data.js +46 -316
  149. package/lib-es/families/solana/bridge/mock-data.js.map +1 -1
  150. package/lib-es/families/solana/bridge/mock.js +3 -3
  151. package/lib-es/families/solana/bridge/mock.js.map +1 -1
  152. package/lib-es/families/stellar/ui.d.ts +6 -0
  153. package/lib-es/families/stellar/ui.d.ts.map +1 -0
  154. package/lib-es/families/stellar/ui.js +14 -0
  155. package/lib-es/families/stellar/ui.js.map +1 -0
  156. package/lib-es/families/tron/data.mock.d.ts.map +1 -1
  157. package/lib-es/families/tron/data.mock.js +6 -0
  158. package/lib-es/families/tron/data.mock.js.map +1 -1
  159. package/lib-es/featureFlags/defaultFeatures.d.ts +1 -0
  160. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  161. package/lib-es/featureFlags/defaultFeatures.js +1 -0
  162. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  163. package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
  164. package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
  165. package/lib-es/modularDrawer/__mocks__/accounts.mock.js +42 -0
  166. package/lib-es/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
  167. package/lib-es/utils/__tests__/composeHooks.test.d.ts +2 -0
  168. package/lib-es/utils/__tests__/composeHooks.test.d.ts.map +1 -0
  169. package/lib-es/utils/__tests__/composeHooks.test.js +33 -0
  170. package/lib-es/utils/__tests__/composeHooks.test.js.map +1 -0
  171. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
  172. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
  173. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +102 -0
  174. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
  175. package/lib-es/utils/composeHooks.d.ts +11 -0
  176. package/lib-es/utils/composeHooks.d.ts.map +1 -0
  177. package/lib-es/utils/composeHooks.js +21 -0
  178. package/lib-es/utils/composeHooks.js.map +1 -0
  179. package/lib-es/utils/getAccountTuplesForCurrency.d.ts +8 -0
  180. package/lib-es/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
  181. package/lib-es/utils/getAccountTuplesForCurrency.js +15 -0
  182. package/lib-es/utils/getAccountTuplesForCurrency.js.map +1 -0
  183. package/lib-es/wallet-api/helpers.d.ts +1 -0
  184. package/lib-es/wallet-api/helpers.d.ts.map +1 -1
  185. package/lib-es/wallet-api/helpers.js +14 -0
  186. package/lib-es/wallet-api/helpers.js.map +1 -1
  187. package/package.json +37 -37
  188. package/src/DataModel.test.ts +8 -0
  189. package/src/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +53 -0
  190. package/src/__tests__/accounts/groupPerDay.ts +13 -0
  191. package/src/__tests__/test-helpers/environment.ts +1 -0
  192. package/src/__tests__/test-helpers/setup.ts +8 -0
  193. package/src/account/serialization.test.ts +20 -2
  194. package/src/appSupportsQuitApp.test.ts +7 -1
  195. package/src/appSupportsQuitApp.ts +1 -0
  196. package/src/bridge/crypto-assets/index.ts +6 -6
  197. package/src/bridge/generic-alpaca/alpaca/index.ts +3 -3
  198. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +3 -8
  199. package/src/bridge/generic-alpaca/getAccountShape.ts +6 -7
  200. package/src/bridge/generic-alpaca/signOperation.ts +1 -1
  201. package/src/bridge/generic-alpaca/utils.test.ts +19 -0
  202. package/src/bridge/generic-alpaca/utils.ts +7 -6
  203. package/src/currencies/sortByMarketcap.test.ts +7 -0
  204. package/src/e2e/speculos.ts +77 -21
  205. package/src/e2e/speculosCI.ts +32 -10
  206. package/src/families/bitcoin/satstack.test.ts +7 -0
  207. package/src/families/solana/bridge/mock-data.ts +52 -316
  208. package/src/families/solana/bridge/mock.ts +3 -3
  209. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +1930 -94
  210. package/src/families/stellar/ui.ts +15 -0
  211. package/src/families/tron/data.mock.ts +8 -0
  212. package/src/featureFlags/defaultFeatures.ts +1 -0
  213. package/src/modularDrawer/__mocks__/accounts.mock.ts +43 -0
  214. package/src/utils/__tests__/composeHooks.test.ts +46 -0
  215. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +138 -0
  216. package/src/utils/composeHooks.ts +26 -0
  217. package/src/utils/getAccountTuplesForCurrency.ts +34 -0
  218. package/src/wallet-api/helpers.ts +16 -0
@@ -11,7 +11,7 @@ import { createSpeculosDeviceCI, releaseSpeculosDeviceCI } from "./speculosCI";
11
11
  import type { AppCandidate } from "@ledgerhq/coin-framework/bot/types";
12
12
  import { DeviceModelId } from "@ledgerhq/devices";
13
13
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
14
- import axios from "axios";
14
+ import axios, { AxiosError, AxiosResponse } from "axios";
15
15
  import { getEnv } from "@ledgerhq/live-env";
16
16
  import { getCryptoCurrencyById } from "../currencies";
17
17
  import { DeviceLabels } from "../e2e/enum/DeviceLabels";
@@ -415,13 +415,59 @@ interface ResponseData {
415
415
  events: Event[];
416
416
  }
417
417
 
418
+ function getSpeculosAddress(): string {
419
+ const speculosAddress = process.env.SPECULOS_ADDRESS;
420
+ return speculosAddress || "http://127.0.0.1";
421
+ }
422
+
423
+ async function retryAxiosRequest<T>(
424
+ requestFn: () => Promise<AxiosResponse<T>>,
425
+ maxRetries: number = 5,
426
+ baseDelay: number = 1000,
427
+ retryableStatusCodes: number[] = [500, 502, 503, 504],
428
+ ): Promise<AxiosResponse<T>> {
429
+ let lastError: AxiosError | Error;
430
+
431
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
432
+ try {
433
+ return await requestFn();
434
+ } catch (error) {
435
+ lastError = error as AxiosError | Error;
436
+
437
+ const isRetryable =
438
+ axios.isAxiosError(error) &&
439
+ error.response &&
440
+ retryableStatusCodes.includes(error.response.status);
441
+
442
+ const isNetworkError = axios.isAxiosError(error) && !error.response;
443
+
444
+ if ((isRetryable || isNetworkError) && attempt < maxRetries) {
445
+ const delay = baseDelay * (attempt + 1);
446
+ console.warn(
447
+ `Axios request failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms...`,
448
+ {
449
+ status: axios.isAxiosError(error) ? error.response?.status : "network error",
450
+ message: error.message,
451
+ },
452
+ );
453
+ await new Promise(resolve => setTimeout(resolve, delay));
454
+ continue;
455
+ }
456
+
457
+ throw lastError;
458
+ }
459
+ }
460
+
461
+ throw lastError!;
462
+ }
463
+
418
464
  export async function waitFor(text: string, maxAttempts = 15): Promise<string[]> {
419
465
  const port = getEnv("SPECULOS_API_PORT");
420
- const address = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
466
+ const address = getSpeculosAddress();
421
467
  const url = `${address}:${port}/events?stream=false&currentscreenonly=true`;
422
468
 
423
469
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
424
- const { data } = await axios.get<ResponseData>(url);
470
+ const { data } = await retryAxiosRequest(() => axios.get<ResponseData>(url));
425
471
  const texts = data.events.map(event => event.text);
426
472
 
427
473
  if (texts?.some(t => t?.toLowerCase().includes(text.toLowerCase()))) {
@@ -436,10 +482,12 @@ export async function waitFor(text: string, maxAttempts = 15): Promise<string[]>
436
482
 
437
483
  export async function pressBoth() {
438
484
  const speculosApiPort = getEnv("SPECULOS_API_PORT");
439
- const speculosAddress = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
440
- await axios.post(`${speculosAddress}:${speculosApiPort}/button/both`, {
441
- action: "press-and-release",
442
- });
485
+ const speculosAddress = getSpeculosAddress();
486
+ await retryAxiosRequest(() =>
487
+ axios.post(`${speculosAddress}:${speculosApiPort}/button/both`, {
488
+ action: "press-and-release",
489
+ }),
490
+ );
443
491
  }
444
492
 
445
493
  export async function pressUntilTextFound(
@@ -465,27 +513,33 @@ export async function pressUntilTextFound(
465
513
  }
466
514
 
467
515
  async function fetchCurrentScreenTexts(speculosApiPort: number): Promise<string> {
468
- const speculosAddress = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
469
- const response = await axios.get<ResponseData>(
470
- `${speculosAddress}:${speculosApiPort}/events?stream=false&currentscreenonly=true`,
516
+ const speculosAddress = getSpeculosAddress();
517
+ const response = await retryAxiosRequest(() =>
518
+ axios.get<ResponseData>(
519
+ `${speculosAddress}:${speculosApiPort}/events?stream=false&currentscreenonly=true`,
520
+ ),
471
521
  );
472
522
  return response.data.events.map(event => event.text).join("");
473
523
  }
474
524
 
475
525
  async function fetchAllEvents(speculosApiPort: number): Promise<string[]> {
476
- const speculosAddress = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
477
- const response = await axios.get<ResponseData>(
478
- `${speculosAddress}:${speculosApiPort}/events?stream=false&currentscreenonly=false`,
526
+ const speculosAddress = getSpeculosAddress();
527
+ const response = await retryAxiosRequest(() =>
528
+ axios.get<ResponseData>(
529
+ `${speculosAddress}:${speculosApiPort}/events?stream=false&currentscreenonly=false`,
530
+ ),
479
531
  );
480
532
  return response.data.events.map(event => event.text);
481
533
  }
482
534
 
483
535
  export async function pressRightButton(): Promise<void> {
484
536
  const speculosApiPort = getEnv("SPECULOS_API_PORT");
485
- const speculosAddress = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
486
- await axios.post(`${speculosAddress}:${speculosApiPort}/button/right`, {
487
- action: "press-and-release",
488
- });
537
+ const speculosAddress = getSpeculosAddress();
538
+ await retryAxiosRequest(() =>
539
+ axios.post(`${speculosAddress}:${speculosApiPort}/button/right`, {
540
+ action: "press-and-release",
541
+ }),
542
+ );
489
543
  }
490
544
 
491
545
  export function containsSubstringInEvent(targetString: string, events: string[]): boolean {
@@ -503,12 +557,14 @@ export function containsSubstringInEvent(targetString: string, events: string[])
503
557
  }
504
558
 
505
559
  export async function takeScreenshot(port?: number): Promise<Buffer | undefined> {
506
- const speculosAddress = process.env.SPECULOS_ADDRESS || "http://127.0.0.1";
560
+ const speculosAddress = getSpeculosAddress();
507
561
  const speculosApiPort = port ?? getEnv("SPECULOS_API_PORT");
508
562
  try {
509
- const response = await axios.get(`${speculosAddress}:${speculosApiPort}/screenshot`, {
510
- responseType: "arraybuffer",
511
- });
563
+ const response = await retryAxiosRequest(() =>
564
+ axios.get(`${speculosAddress}:${speculosApiPort}/screenshot`, {
565
+ responseType: "arraybuffer",
566
+ }),
567
+ );
512
568
  return response.data;
513
569
  } catch (error) {
514
570
  console.error("Error downloading speculos screenshot:", error);
@@ -61,22 +61,44 @@ async function githubApiRequest<T = unknown>({
61
61
  function waitForSpeculosReady(url: string, { interval = 2000, timeout = 300_000 } = {}) {
62
62
  return new Promise((resolve, reject) => {
63
63
  const startTime = Date.now();
64
+ let currentRequest: ReturnType<typeof https.get> | null = null;
65
+
66
+ function cleanup() {
67
+ if (currentRequest) {
68
+ currentRequest.destroy();
69
+ currentRequest = null;
70
+ }
71
+ }
64
72
 
65
73
  function check() {
66
- https
67
- .get(url, res => {
68
- if (res.statusCode && res.statusCode >= 200 && res.statusCode < 400) {
69
- process.env.SPECULOS_ADDRESS = url;
70
- resolve(true);
71
- } else {
72
- retry();
73
- }
74
- })
75
- .on("error", retry);
74
+ cleanup();
75
+
76
+ currentRequest = https.get(url, { timeout: 10000 }, res => {
77
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 400) {
78
+ process.env.SPECULOS_ADDRESS = url;
79
+ cleanup();
80
+ console.warn(`Speculos is ready at ${url}`);
81
+ resolve(true);
82
+ } else {
83
+ console.warn(`Speculos not ready yet, status: ${res.statusCode}`);
84
+ retry();
85
+ }
86
+ });
87
+
88
+ currentRequest.on("error", error => {
89
+ console.error(`Request error: ${error.message}`);
90
+ retry();
91
+ });
92
+
93
+ currentRequest.on("timeout", () => {
94
+ console.error("Request timeout");
95
+ retry();
96
+ });
76
97
  }
77
98
 
78
99
  function retry() {
79
100
  if (Date.now() - startTime >= timeout) {
101
+ cleanup();
80
102
  reject(new Error(`Timeout: ${url} did not become available within ${timeout}ms`));
81
103
  } else {
82
104
  setTimeout(check, interval);
@@ -18,6 +18,8 @@ import { inferDescriptorFromAccount, AccountDescriptor } from "@ledgerhq/coin-bi
18
18
  import { setEnv } from "@ledgerhq/live-env";
19
19
  import { fromAccountRaw } from "../../account";
20
20
  import { setSupportedCurrencies } from "../../currencies";
21
+ import { setCryptoAssetsStore as setCryptoAssetsStoreForCoinFramework } from "@ledgerhq/coin-framework/crypto-assets/index";
22
+ import { CryptoAssetsStore } from "@ledgerhq/coin-framework/crypto-assets/type";
21
23
 
22
24
  setSupportedCurrencies(["bitcoin"]);
23
25
  jest.setTimeout(10000);
@@ -230,6 +232,11 @@ describe("stringifySatStackConfig", () => {
230
232
  });
231
233
  });
232
234
  describe("editSatStackConfig", () => {
235
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
236
+ setCryptoAssetsStoreForCoinFramework({
237
+ findTokenById: (_: string) => undefined,
238
+ findTokenByAddressInCurrency: (_: string, __: string) => undefined,
239
+ } as CryptoAssetsStore);
233
240
  const config = {
234
241
  node: { ...mockConfig, tls: false },
235
242
  extra: {
@@ -7,6 +7,34 @@ import {
7
7
  } from "@ledgerhq/coin-solana/network/index";
8
8
  import { Functions } from "@ledgerhq/coin-solana/utils";
9
9
 
10
+ // Helper function to generate mock prioritization fees
11
+ const generatePrioritizationFees = (
12
+ startSlot: number,
13
+ count: number = 150,
14
+ prioritizationFee: number = 0,
15
+ ) => {
16
+ return Array.from({ length: count }, (_, index) => ({
17
+ prioritizationFee,
18
+ slot: startSlot + index,
19
+ }));
20
+ };
21
+
22
+ // Helper function to generate nested prioritization fees format
23
+ const generateNestedPrioritizationFees = (slot: number, prioritizationFee: number = 0) => {
24
+ return [
25
+ [
26
+ {
27
+ slot,
28
+ prioritizationFee,
29
+ },
30
+ {
31
+ slot,
32
+ prioritizationFee,
33
+ },
34
+ ],
35
+ ];
36
+ };
37
+
10
38
  export const getMockedMethods = (): {
11
39
  method: Functions<ChainAPI>;
12
40
  params: any[];
@@ -889,18 +917,7 @@ export const getMockedMethods = (): {
889
917
  {
890
918
  method: "getRecentPrioritizationFees",
891
919
  params: [["AQbkEagmPgmsdAfS4X8V8UyJnXXjVPMvjeD15etqQ3Jh"]],
892
- answer: [
893
- [
894
- {
895
- slot: 122422797,
896
- prioritizationFee: 0,
897
- },
898
- {
899
- slot: 122422797,
900
- prioritizationFee: 0,
901
- },
902
- ],
903
- ],
920
+ answer: generateNestedPrioritizationFees(122422797),
904
921
  },
905
922
  {
906
923
  method: "getAccountInfo",
@@ -946,158 +963,7 @@ export const getMockedMethods = (): {
946
963
  {
947
964
  method: "getRecentPrioritizationFees",
948
965
  params: [["4iWtrn54zi89sHQv6xHyYwDsrPJvqcSKRJGBLrbErCsx"]],
949
- answer: [
950
- { prioritizationFee: 0, slot: 349496453 },
951
- { prioritizationFee: 0, slot: 349496454 },
952
- { prioritizationFee: 0, slot: 349496455 },
953
- { prioritizationFee: 0, slot: 349496456 },
954
- { prioritizationFee: 0, slot: 349496457 },
955
- { prioritizationFee: 0, slot: 349496458 },
956
- { prioritizationFee: 0, slot: 349496459 },
957
- { prioritizationFee: 0, slot: 349496460 },
958
- { prioritizationFee: 0, slot: 349496461 },
959
- { prioritizationFee: 0, slot: 349496462 },
960
- { prioritizationFee: 0, slot: 349496463 },
961
- { prioritizationFee: 0, slot: 349496464 },
962
- { prioritizationFee: 0, slot: 349496465 },
963
- { prioritizationFee: 0, slot: 349496466 },
964
- { prioritizationFee: 0, slot: 349496467 },
965
- { prioritizationFee: 0, slot: 349496468 },
966
- { prioritizationFee: 0, slot: 349496469 },
967
- { prioritizationFee: 0, slot: 349496470 },
968
- { prioritizationFee: 0, slot: 349496471 },
969
- { prioritizationFee: 0, slot: 349496472 },
970
- { prioritizationFee: 0, slot: 349496473 },
971
- { prioritizationFee: 0, slot: 349496474 },
972
- { prioritizationFee: 0, slot: 349496475 },
973
- { prioritizationFee: 0, slot: 349496476 },
974
- { prioritizationFee: 0, slot: 349496477 },
975
- { prioritizationFee: 0, slot: 349496478 },
976
- { prioritizationFee: 0, slot: 349496479 },
977
- { prioritizationFee: 0, slot: 349496480 },
978
- { prioritizationFee: 0, slot: 349496481 },
979
- { prioritizationFee: 0, slot: 349496482 },
980
- { prioritizationFee: 0, slot: 349496483 },
981
- { prioritizationFee: 0, slot: 349496484 },
982
- { prioritizationFee: 0, slot: 349496485 },
983
- { prioritizationFee: 0, slot: 349496486 },
984
- { prioritizationFee: 0, slot: 349496487 },
985
- { prioritizationFee: 0, slot: 349496488 },
986
- { prioritizationFee: 0, slot: 349496489 },
987
- { prioritizationFee: 0, slot: 349496490 },
988
- { prioritizationFee: 0, slot: 349496491 },
989
- { prioritizationFee: 0, slot: 349496492 },
990
- { prioritizationFee: 0, slot: 349496493 },
991
- { prioritizationFee: 0, slot: 349496494 },
992
- { prioritizationFee: 0, slot: 349496495 },
993
- { prioritizationFee: 0, slot: 349496496 },
994
- { prioritizationFee: 0, slot: 349496497 },
995
- { prioritizationFee: 0, slot: 349496498 },
996
- { prioritizationFee: 0, slot: 349496499 },
997
- { prioritizationFee: 0, slot: 349496500 },
998
- { prioritizationFee: 0, slot: 349496501 },
999
- { prioritizationFee: 0, slot: 349496502 },
1000
- { prioritizationFee: 0, slot: 349496503 },
1001
- { prioritizationFee: 0, slot: 349496504 },
1002
- { prioritizationFee: 0, slot: 349496505 },
1003
- { prioritizationFee: 0, slot: 349496506 },
1004
- { prioritizationFee: 0, slot: 349496507 },
1005
- { prioritizationFee: 0, slot: 349496508 },
1006
- { prioritizationFee: 0, slot: 349496509 },
1007
- { prioritizationFee: 0, slot: 349496510 },
1008
- { prioritizationFee: 0, slot: 349496511 },
1009
- { prioritizationFee: 0, slot: 349496512 },
1010
- { prioritizationFee: 0, slot: 349496513 },
1011
- { prioritizationFee: 0, slot: 349496514 },
1012
- { prioritizationFee: 0, slot: 349496515 },
1013
- { prioritizationFee: 0, slot: 349496516 },
1014
- { prioritizationFee: 0, slot: 349496517 },
1015
- { prioritizationFee: 0, slot: 349496518 },
1016
- { prioritizationFee: 0, slot: 349496519 },
1017
- { prioritizationFee: 0, slot: 349496520 },
1018
- { prioritizationFee: 0, slot: 349496521 },
1019
- { prioritizationFee: 0, slot: 349496522 },
1020
- { prioritizationFee: 0, slot: 349496523 },
1021
- { prioritizationFee: 0, slot: 349496524 },
1022
- { prioritizationFee: 0, slot: 349496525 },
1023
- { prioritizationFee: 0, slot: 349496526 },
1024
- { prioritizationFee: 0, slot: 349496527 },
1025
- { prioritizationFee: 0, slot: 349496528 },
1026
- { prioritizationFee: 0, slot: 349496529 },
1027
- { prioritizationFee: 0, slot: 349496530 },
1028
- { prioritizationFee: 0, slot: 349496531 },
1029
- { prioritizationFee: 0, slot: 349496532 },
1030
- { prioritizationFee: 0, slot: 349496533 },
1031
- { prioritizationFee: 0, slot: 349496534 },
1032
- { prioritizationFee: 0, slot: 349496535 },
1033
- { prioritizationFee: 0, slot: 349496536 },
1034
- { prioritizationFee: 0, slot: 349496537 },
1035
- { prioritizationFee: 0, slot: 349496538 },
1036
- { prioritizationFee: 0, slot: 349496539 },
1037
- { prioritizationFee: 0, slot: 349496540 },
1038
- { prioritizationFee: 0, slot: 349496541 },
1039
- { prioritizationFee: 0, slot: 349496542 },
1040
- { prioritizationFee: 0, slot: 349496543 },
1041
- { prioritizationFee: 0, slot: 349496544 },
1042
- { prioritizationFee: 0, slot: 349496545 },
1043
- { prioritizationFee: 0, slot: 349496546 },
1044
- { prioritizationFee: 0, slot: 349496547 },
1045
- { prioritizationFee: 0, slot: 349496548 },
1046
- { prioritizationFee: 0, slot: 349496549 },
1047
- { prioritizationFee: 0, slot: 349496550 },
1048
- { prioritizationFee: 0, slot: 349496551 },
1049
- { prioritizationFee: 0, slot: 349496552 },
1050
- { prioritizationFee: 0, slot: 349496553 },
1051
- { prioritizationFee: 0, slot: 349496554 },
1052
- { prioritizationFee: 0, slot: 349496555 },
1053
- { prioritizationFee: 0, slot: 349496556 },
1054
- { prioritizationFee: 0, slot: 349496557 },
1055
- { prioritizationFee: 0, slot: 349496558 },
1056
- { prioritizationFee: 0, slot: 349496559 },
1057
- { prioritizationFee: 0, slot: 349496560 },
1058
- { prioritizationFee: 0, slot: 349496561 },
1059
- { prioritizationFee: 0, slot: 349496562 },
1060
- { prioritizationFee: 0, slot: 349496563 },
1061
- { prioritizationFee: 0, slot: 349496564 },
1062
- { prioritizationFee: 0, slot: 349496565 },
1063
- { prioritizationFee: 0, slot: 349496566 },
1064
- { prioritizationFee: 0, slot: 349496567 },
1065
- { prioritizationFee: 0, slot: 349496568 },
1066
- { prioritizationFee: 0, slot: 349496569 },
1067
- { prioritizationFee: 0, slot: 349496570 },
1068
- { prioritizationFee: 0, slot: 349496571 },
1069
- { prioritizationFee: 0, slot: 349496572 },
1070
- { prioritizationFee: 0, slot: 349496573 },
1071
- { prioritizationFee: 0, slot: 349496574 },
1072
- { prioritizationFee: 0, slot: 349496575 },
1073
- { prioritizationFee: 0, slot: 349496576 },
1074
- { prioritizationFee: 0, slot: 349496577 },
1075
- { prioritizationFee: 0, slot: 349496578 },
1076
- { prioritizationFee: 0, slot: 349496579 },
1077
- { prioritizationFee: 0, slot: 349496580 },
1078
- { prioritizationFee: 0, slot: 349496581 },
1079
- { prioritizationFee: 0, slot: 349496582 },
1080
- { prioritizationFee: 0, slot: 349496583 },
1081
- { prioritizationFee: 0, slot: 349496584 },
1082
- { prioritizationFee: 0, slot: 349496585 },
1083
- { prioritizationFee: 0, slot: 349496586 },
1084
- { prioritizationFee: 0, slot: 349496587 },
1085
- { prioritizationFee: 0, slot: 349496588 },
1086
- { prioritizationFee: 0, slot: 349496589 },
1087
- { prioritizationFee: 0, slot: 349496590 },
1088
- { prioritizationFee: 0, slot: 349496591 },
1089
- { prioritizationFee: 0, slot: 349496592 },
1090
- { prioritizationFee: 0, slot: 349496593 },
1091
- { prioritizationFee: 0, slot: 349496594 },
1092
- { prioritizationFee: 0, slot: 349496595 },
1093
- { prioritizationFee: 0, slot: 349496596 },
1094
- { prioritizationFee: 0, slot: 349496597 },
1095
- { prioritizationFee: 0, slot: 349496598 },
1096
- { prioritizationFee: 0, slot: 349496599 },
1097
- { prioritizationFee: 0, slot: 349496600 },
1098
- { prioritizationFee: 0, slot: 349496601 },
1099
- { prioritizationFee: 0, slot: 349496602 },
1100
- ],
966
+ answer: generatePrioritizationFees(349496453),
1101
967
  },
1102
968
  {
1103
969
  method: "getSimulationComputeUnits",
@@ -1139,158 +1005,7 @@ export const getMockedMethods = (): {
1139
1005
  "63M7kPJvLsG46jbR2ZriEU8xwPqkMNKNoBBQ46pobbvo",
1140
1006
  ],
1141
1007
  ],
1142
- answer: [
1143
- { prioritizationFee: 0, slot: 349496454 },
1144
- { prioritizationFee: 0, slot: 349496455 },
1145
- { prioritizationFee: 0, slot: 349496456 },
1146
- { prioritizationFee: 0, slot: 349496457 },
1147
- { prioritizationFee: 0, slot: 349496458 },
1148
- { prioritizationFee: 0, slot: 349496459 },
1149
- { prioritizationFee: 0, slot: 349496460 },
1150
- { prioritizationFee: 0, slot: 349496461 },
1151
- { prioritizationFee: 0, slot: 349496462 },
1152
- { prioritizationFee: 0, slot: 349496463 },
1153
- { prioritizationFee: 0, slot: 349496464 },
1154
- { prioritizationFee: 0, slot: 349496465 },
1155
- { prioritizationFee: 0, slot: 349496466 },
1156
- { prioritizationFee: 0, slot: 349496467 },
1157
- { prioritizationFee: 0, slot: 349496468 },
1158
- { prioritizationFee: 0, slot: 349496469 },
1159
- { prioritizationFee: 0, slot: 349496470 },
1160
- { prioritizationFee: 0, slot: 349496471 },
1161
- { prioritizationFee: 0, slot: 349496472 },
1162
- { prioritizationFee: 0, slot: 349496473 },
1163
- { prioritizationFee: 0, slot: 349496474 },
1164
- { prioritizationFee: 0, slot: 349496475 },
1165
- { prioritizationFee: 0, slot: 349496476 },
1166
- { prioritizationFee: 0, slot: 349496477 },
1167
- { prioritizationFee: 0, slot: 349496478 },
1168
- { prioritizationFee: 0, slot: 349496479 },
1169
- { prioritizationFee: 0, slot: 349496480 },
1170
- { prioritizationFee: 0, slot: 349496481 },
1171
- { prioritizationFee: 0, slot: 349496482 },
1172
- { prioritizationFee: 0, slot: 349496483 },
1173
- { prioritizationFee: 0, slot: 349496484 },
1174
- { prioritizationFee: 0, slot: 349496485 },
1175
- { prioritizationFee: 0, slot: 349496486 },
1176
- { prioritizationFee: 0, slot: 349496487 },
1177
- { prioritizationFee: 0, slot: 349496488 },
1178
- { prioritizationFee: 0, slot: 349496489 },
1179
- { prioritizationFee: 0, slot: 349496490 },
1180
- { prioritizationFee: 0, slot: 349496491 },
1181
- { prioritizationFee: 0, slot: 349496492 },
1182
- { prioritizationFee: 0, slot: 349496493 },
1183
- { prioritizationFee: 0, slot: 349496494 },
1184
- { prioritizationFee: 0, slot: 349496495 },
1185
- { prioritizationFee: 0, slot: 349496496 },
1186
- { prioritizationFee: 0, slot: 349496497 },
1187
- { prioritizationFee: 0, slot: 349496498 },
1188
- { prioritizationFee: 0, slot: 349496499 },
1189
- { prioritizationFee: 0, slot: 349496500 },
1190
- { prioritizationFee: 0, slot: 349496501 },
1191
- { prioritizationFee: 0, slot: 349496502 },
1192
- { prioritizationFee: 0, slot: 349496503 },
1193
- { prioritizationFee: 0, slot: 349496504 },
1194
- { prioritizationFee: 0, slot: 349496505 },
1195
- { prioritizationFee: 0, slot: 349496506 },
1196
- { prioritizationFee: 0, slot: 349496507 },
1197
- { prioritizationFee: 0, slot: 349496508 },
1198
- { prioritizationFee: 0, slot: 349496509 },
1199
- { prioritizationFee: 0, slot: 349496510 },
1200
- { prioritizationFee: 0, slot: 349496511 },
1201
- { prioritizationFee: 0, slot: 349496512 },
1202
- { prioritizationFee: 0, slot: 349496513 },
1203
- { prioritizationFee: 0, slot: 349496514 },
1204
- { prioritizationFee: 0, slot: 349496515 },
1205
- { prioritizationFee: 0, slot: 349496516 },
1206
- { prioritizationFee: 0, slot: 349496517 },
1207
- { prioritizationFee: 0, slot: 349496518 },
1208
- { prioritizationFee: 0, slot: 349496519 },
1209
- { prioritizationFee: 0, slot: 349496520 },
1210
- { prioritizationFee: 0, slot: 349496521 },
1211
- { prioritizationFee: 0, slot: 349496522 },
1212
- { prioritizationFee: 0, slot: 349496523 },
1213
- { prioritizationFee: 0, slot: 349496524 },
1214
- { prioritizationFee: 0, slot: 349496525 },
1215
- { prioritizationFee: 0, slot: 349496526 },
1216
- { prioritizationFee: 0, slot: 349496527 },
1217
- { prioritizationFee: 0, slot: 349496528 },
1218
- { prioritizationFee: 0, slot: 349496529 },
1219
- { prioritizationFee: 0, slot: 349496530 },
1220
- { prioritizationFee: 0, slot: 349496531 },
1221
- { prioritizationFee: 0, slot: 349496532 },
1222
- { prioritizationFee: 0, slot: 349496533 },
1223
- { prioritizationFee: 0, slot: 349496534 },
1224
- { prioritizationFee: 0, slot: 349496535 },
1225
- { prioritizationFee: 0, slot: 349496536 },
1226
- { prioritizationFee: 0, slot: 349496537 },
1227
- { prioritizationFee: 0, slot: 349496538 },
1228
- { prioritizationFee: 0, slot: 349496539 },
1229
- { prioritizationFee: 0, slot: 349496540 },
1230
- { prioritizationFee: 0, slot: 349496541 },
1231
- { prioritizationFee: 0, slot: 349496542 },
1232
- { prioritizationFee: 0, slot: 349496543 },
1233
- { prioritizationFee: 0, slot: 349496544 },
1234
- { prioritizationFee: 0, slot: 349496545 },
1235
- { prioritizationFee: 0, slot: 349496546 },
1236
- { prioritizationFee: 0, slot: 349496547 },
1237
- { prioritizationFee: 0, slot: 349496548 },
1238
- { prioritizationFee: 0, slot: 349496549 },
1239
- { prioritizationFee: 0, slot: 349496550 },
1240
- { prioritizationFee: 0, slot: 349496551 },
1241
- { prioritizationFee: 0, slot: 349496552 },
1242
- { prioritizationFee: 0, slot: 349496553 },
1243
- { prioritizationFee: 0, slot: 349496554 },
1244
- { prioritizationFee: 0, slot: 349496555 },
1245
- { prioritizationFee: 0, slot: 349496556 },
1246
- { prioritizationFee: 0, slot: 349496557 },
1247
- { prioritizationFee: 0, slot: 349496558 },
1248
- { prioritizationFee: 0, slot: 349496559 },
1249
- { prioritizationFee: 0, slot: 349496560 },
1250
- { prioritizationFee: 0, slot: 349496561 },
1251
- { prioritizationFee: 0, slot: 349496562 },
1252
- { prioritizationFee: 0, slot: 349496563 },
1253
- { prioritizationFee: 0, slot: 349496564 },
1254
- { prioritizationFee: 0, slot: 349496565 },
1255
- { prioritizationFee: 0, slot: 349496566 },
1256
- { prioritizationFee: 0, slot: 349496567 },
1257
- { prioritizationFee: 0, slot: 349496568 },
1258
- { prioritizationFee: 0, slot: 349496569 },
1259
- { prioritizationFee: 0, slot: 349496570 },
1260
- { prioritizationFee: 0, slot: 349496571 },
1261
- { prioritizationFee: 0, slot: 349496572 },
1262
- { prioritizationFee: 0, slot: 349496573 },
1263
- { prioritizationFee: 0, slot: 349496574 },
1264
- { prioritizationFee: 0, slot: 349496575 },
1265
- { prioritizationFee: 0, slot: 349496576 },
1266
- { prioritizationFee: 0, slot: 349496577 },
1267
- { prioritizationFee: 0, slot: 349496578 },
1268
- { prioritizationFee: 0, slot: 349496579 },
1269
- { prioritizationFee: 0, slot: 349496580 },
1270
- { prioritizationFee: 0, slot: 349496581 },
1271
- { prioritizationFee: 0, slot: 349496582 },
1272
- { prioritizationFee: 0, slot: 349496583 },
1273
- { prioritizationFee: 0, slot: 349496584 },
1274
- { prioritizationFee: 0, slot: 349496585 },
1275
- { prioritizationFee: 0, slot: 349496586 },
1276
- { prioritizationFee: 0, slot: 349496587 },
1277
- { prioritizationFee: 0, slot: 349496588 },
1278
- { prioritizationFee: 0, slot: 349496589 },
1279
- { prioritizationFee: 0, slot: 349496590 },
1280
- { prioritizationFee: 0, slot: 349496591 },
1281
- { prioritizationFee: 0, slot: 349496592 },
1282
- { prioritizationFee: 0, slot: 349496593 },
1283
- { prioritizationFee: 0, slot: 349496594 },
1284
- { prioritizationFee: 0, slot: 349496595 },
1285
- { prioritizationFee: 0, slot: 349496596 },
1286
- { prioritizationFee: 0, slot: 349496597 },
1287
- { prioritizationFee: 0, slot: 349496598 },
1288
- { prioritizationFee: 0, slot: 349496599 },
1289
- { prioritizationFee: 0, slot: 349496600 },
1290
- { prioritizationFee: 0, slot: 349496601 },
1291
- { prioritizationFee: 0, slot: 349496602 },
1292
- { prioritizationFee: 0, slot: 349496603 },
1293
- ],
1008
+ answer: generatePrioritizationFees(349496454),
1294
1009
  },
1295
1010
  {
1296
1011
  method: "getSimulationComputeUnits",
@@ -1317,4 +1032,25 @@ export const getMockedMethods = (): {
1317
1032
  ],
1318
1033
  answer: 300,
1319
1034
  },
1035
+ {
1036
+ method: "getFeeForMessage",
1037
+ params: [
1038
+ "gAEAAwo3NaziKyCZH4sQdjxlyAEEsycLhyQPWK6FJrb9j7r0jyRhB0FkC3pA/3bwHKZzD9v7Rt2mGOXiT8AiHUK2gDwsRJgSfTDFH6xNF2pMhFGZxLZWMl8EsYB3Ro87lHwnuWJUb9EWTtCgOsaT9mU8t4D2GHpAPhkXU2fcZBXT6D+pjfj05KOdlS9AiDNsbZdFpLzbJQ+lmsMa+8nfR2JZTeC89UIrAvAD7ZOgJ4wimZg0XyXSOCz2YXE8kINJuux17h3+Z4YL4MPru92uqdoO9qUoSbP2t3tFyBv0piXrLPXBPgMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABHnVW/IxwG7udMVuzmgVB/2xst6j9I5RArHNola8E48G3fbh12Whk9nL4UbO63msHLSF7V9bN5E6jPWFfv8AqRa6MXuFOieWIcE2CMOB5dDllphXzarmndZ4yX86tmlPBQcABQL1qAQABwAJA5PxAgAAAAAACAUFAB0JGAmT8Xtk9ISudv0IPwkbAAMKCwUaHQgIGQghGwoLDA4NDyAiHycJJhsaKQoEExIQESQlIycJHioXKhUUBAsdKRYqGwkJKCoGAgEIHCzBIJszQdacgQADAAAAOV0AA08HAAImZAIDgIQeAAAAAAAxibAAAAAAADIAAAkDBQAAAQkEKb+VBypPvwTfcXWT5zi8zCEnKBXCRxqA2fn1VbDUhCUCKRgHEwAoAwIXFVl9OSuqqDQaRb6IYUBogcRuGRFfhgIEuha8cjU4fZPaBGAGBWUEAwkCAX3AxxcCHMtm5xM+0XoyZnzQ09ar0YPXd26YYBeNqWxqBHj0dPIF8W95dfO3dNOoPmZnmihT46QbLY1Y/HoBFLJX/wryNAMqjbbuHQTj5MrHA87Gyw==",
1039
+ ],
1040
+ answer: 5126,
1041
+ },
1042
+ {
1043
+ method: "getFeeForMessage",
1044
+ params: [
1045
+ "AQABAzc1rOIrIJkfixB2PGXIAQSzJwuHJA9YroUmtv2PuvSPdaMhhWgGf/cOLK4MfSqKoh7TzOlbq+4eA+l1aEoKxIQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC7eSTZPjADfAV2K5ZMTBC9Qv7DN/mRWMGcOHqHwTiqeAQICAAEMAgAAAICWmAAAAAAA",
1046
+ ],
1047
+ answer: 5000,
1048
+ },
1049
+ {
1050
+ method: "getFeeForMessage",
1051
+ params: [
1052
+ "gAEAAQM3NaziKyCZH4sQdjxlyAEEsycLhyQPWK6FJrb9j7r0j3WjIYVoBn/3DiyuDH0qiqIe08zpW6vuHgPpdWhKCsSEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXy8ypDosdfEh+2iQdH7SMOBblSXabBjQnkjkz87PSigECAgABDAIAAACAlpgAAAAAAAA=",
1053
+ ],
1054
+ answer: 5000,
1055
+ },
1320
1056
  ];
@@ -11,7 +11,7 @@ import { Functions } from "@ledgerhq/coin-solana/utils";
11
11
  import { makeBridges } from "@ledgerhq/coin-solana/bridge/bridge";
12
12
  import { PubKeyDisplayMode, SolanaSigner } from "@ledgerhq/coin-solana/signer";
13
13
  import { makeLRUCache, minutes } from "@ledgerhq/live-network/cache";
14
- import { Message } from "@solana/web3.js";
14
+ import { Message, MessageV0 } from "@solana/web3.js";
15
15
  import { flow, isArray, isEqual, isObject, isUndefined, mapValues, omitBy } from "lodash/fp";
16
16
  import { getMockedMethods } from "./mock-data";
17
17
  import { scanAccounts, sync } from "../../../bridge/mockHelpers";
@@ -59,8 +59,8 @@ function removeUndefineds(input: unknown): unknown {
59
59
  function preprocessArgs(method: keyof ChainAPI, args: any) {
60
60
  if (method === "getFeeForMessage") {
61
61
  // getFeeForMessage needs some args preprocessing
62
- if (args.length === 1 && args[0] instanceof Message) {
63
- return [args[0].serialize().toString("base64")];
62
+ if (args.length === 1 && (args[0] instanceof Message || args[0] instanceof MessageV0)) {
63
+ return [Buffer.from(args[0].serialize()).toString("base64")];
64
64
  } else {
65
65
  throw new Error("unexpected getFeeForMessage function signature");
66
66
  }