@ledgerhq/live-common 34.42.2-nightly.0 → 34.43.0-nightly.2

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 (120) hide show
  1. package/lib/appSupportsQuitApp.d.ts +1 -0
  2. package/lib/appSupportsQuitApp.d.ts.map +1 -1
  3. package/lib/appSupportsQuitApp.js +1 -0
  4. package/lib/appSupportsQuitApp.js.map +1 -1
  5. package/lib/appSupportsQuitApp.test.js +28 -3
  6. package/lib/appSupportsQuitApp.test.js.map +1 -1
  7. package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  8. package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  9. package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  10. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
  11. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  12. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  13. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  14. package/lib/bridge/generic-alpaca/utils.d.ts +2 -2
  15. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  16. package/lib/bridge/generic-alpaca/utils.js +1 -1
  17. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  18. package/lib/e2e/index.d.ts +1 -0
  19. package/lib/e2e/index.d.ts.map +1 -1
  20. package/lib/e2e/speculos.d.ts.map +1 -1
  21. package/lib/e2e/speculos.js +45 -15
  22. package/lib/e2e/speculos.js.map +1 -1
  23. package/lib/e2e/speculosCI.d.ts.map +1 -1
  24. package/lib/e2e/speculosCI.js +22 -4
  25. package/lib/e2e/speculosCI.js.map +1 -1
  26. package/lib/env.react.d.ts +1 -1
  27. package/lib/env.react.d.ts.map +1 -1
  28. package/lib/families/solana/bridge/mock-data.d.ts.map +1 -1
  29. package/lib/families/solana/bridge/mock-data.js +46 -316
  30. package/lib/families/solana/bridge/mock-data.js.map +1 -1
  31. package/lib/families/solana/bridge/mock.js +2 -2
  32. package/lib/families/solana/bridge/mock.js.map +1 -1
  33. package/lib/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
  34. package/lib/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
  35. package/lib/modularDrawer/__mocks__/accounts.mock.js +48 -0
  36. package/lib/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
  37. package/lib/utils/__tests__/composeHooks.test.d.ts +2 -0
  38. package/lib/utils/__tests__/composeHooks.test.d.ts.map +1 -0
  39. package/lib/utils/__tests__/composeHooks.test.js +35 -0
  40. package/lib/utils/__tests__/composeHooks.test.js.map +1 -0
  41. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
  42. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
  43. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js +104 -0
  44. package/lib/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
  45. package/lib/utils/composeHooks.d.ts +11 -0
  46. package/lib/utils/composeHooks.d.ts.map +1 -0
  47. package/lib/utils/composeHooks.js +25 -0
  48. package/lib/utils/composeHooks.js.map +1 -0
  49. package/lib/utils/getAccountTuplesForCurrency.d.ts +8 -0
  50. package/lib/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
  51. package/lib/utils/getAccountTuplesForCurrency.js +19 -0
  52. package/lib/utils/getAccountTuplesForCurrency.js.map +1 -0
  53. package/lib-es/appSupportsQuitApp.d.ts +1 -0
  54. package/lib-es/appSupportsQuitApp.d.ts.map +1 -1
  55. package/lib-es/appSupportsQuitApp.js +1 -0
  56. package/lib-es/appSupportsQuitApp.js.map +1 -1
  57. package/lib-es/appSupportsQuitApp.test.js +6 -1
  58. package/lib-es/appSupportsQuitApp.test.js.map +1 -1
  59. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  60. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  61. package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  62. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +2 -6
  63. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  64. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  65. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  66. package/lib-es/bridge/generic-alpaca/utils.d.ts +2 -2
  67. package/lib-es/bridge/generic-alpaca/utils.d.ts.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/e2e/index.d.ts +1 -0
  71. package/lib-es/e2e/index.d.ts.map +1 -1
  72. package/lib-es/e2e/speculos.d.ts.map +1 -1
  73. package/lib-es/e2e/speculos.js +45 -15
  74. package/lib-es/e2e/speculos.js.map +1 -1
  75. package/lib-es/e2e/speculosCI.d.ts.map +1 -1
  76. package/lib-es/e2e/speculosCI.js +22 -4
  77. package/lib-es/e2e/speculosCI.js.map +1 -1
  78. package/lib-es/env.react.d.ts +1 -1
  79. package/lib-es/env.react.d.ts.map +1 -1
  80. package/lib-es/families/solana/bridge/mock-data.d.ts.map +1 -1
  81. package/lib-es/families/solana/bridge/mock-data.js +46 -316
  82. package/lib-es/families/solana/bridge/mock-data.js.map +1 -1
  83. package/lib-es/families/solana/bridge/mock.js +3 -3
  84. package/lib-es/families/solana/bridge/mock.js.map +1 -1
  85. package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts +18 -0
  86. package/lib-es/modularDrawer/__mocks__/accounts.mock.d.ts.map +1 -0
  87. package/lib-es/modularDrawer/__mocks__/accounts.mock.js +42 -0
  88. package/lib-es/modularDrawer/__mocks__/accounts.mock.js.map +1 -0
  89. package/lib-es/utils/__tests__/composeHooks.test.d.ts +2 -0
  90. package/lib-es/utils/__tests__/composeHooks.test.d.ts.map +1 -0
  91. package/lib-es/utils/__tests__/composeHooks.test.js +33 -0
  92. package/lib-es/utils/__tests__/composeHooks.test.js.map +1 -0
  93. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts +2 -0
  94. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.d.ts.map +1 -0
  95. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js +102 -0
  96. package/lib-es/utils/__tests__/getAccountTuplesForCurrency.test.js.map +1 -0
  97. package/lib-es/utils/composeHooks.d.ts +11 -0
  98. package/lib-es/utils/composeHooks.d.ts.map +1 -0
  99. package/lib-es/utils/composeHooks.js +21 -0
  100. package/lib-es/utils/composeHooks.js.map +1 -0
  101. package/lib-es/utils/getAccountTuplesForCurrency.d.ts +8 -0
  102. package/lib-es/utils/getAccountTuplesForCurrency.d.ts.map +1 -0
  103. package/lib-es/utils/getAccountTuplesForCurrency.js +15 -0
  104. package/lib-es/utils/getAccountTuplesForCurrency.js.map +1 -0
  105. package/package.json +46 -46
  106. package/src/appSupportsQuitApp.test.ts +7 -1
  107. package/src/appSupportsQuitApp.ts +1 -0
  108. package/src/bridge/generic-alpaca/alpaca/index.ts +3 -3
  109. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +3 -8
  110. package/src/bridge/generic-alpaca/signOperation.ts +1 -1
  111. package/src/bridge/generic-alpaca/utils.ts +3 -10
  112. package/src/e2e/speculos.ts +77 -21
  113. package/src/e2e/speculosCI.ts +32 -10
  114. package/src/families/solana/bridge/mock-data.ts +52 -316
  115. package/src/families/solana/bridge/mock.ts +3 -3
  116. package/src/modularDrawer/__mocks__/accounts.mock.ts +43 -0
  117. package/src/utils/__tests__/composeHooks.test.ts +46 -0
  118. package/src/utils/__tests__/getAccountTuplesForCurrency.test.ts +138 -0
  119. package/src/utils/composeHooks.ts +26 -0
  120. package/src/utils/getAccountTuplesForCurrency.ts +34 -0
@@ -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
  }
@@ -0,0 +1,43 @@
1
+ import { genAccount } from "@ledgerhq/coin-framework/lib/mocks/account";
2
+ import BigNumber from "bignumber.js";
3
+ import { mockBtcCryptoCurrency } from "./currencies.mock";
4
+ import { mockArbitrumCryptoCurrency } from "./currencies.mock";
5
+ import { mockEthCryptoCurrency } from "./currencies.mock";
6
+ import { mockBaseCryptoCurrency } from "./currencies.mock";
7
+ import { mockScrollCryptoCurrency } from "./currencies.mock";
8
+
9
+ export const MOCKED_ARB_ACCOUNT = {
10
+ type: "Account",
11
+ id: "arbitrum1",
12
+ balance: new BigNumber(34455),
13
+ creationDate: "2024-12-10T09:27:22.000Z",
14
+ currency: mockArbitrumCryptoCurrency,
15
+ derivationMode: "",
16
+ freshAddress: "s37rhmi7hsm3i73hsm7i3hm83m8h87hsm87h3s8h33",
17
+ };
18
+
19
+ export const ETH_ACCOUNT = genAccount("ethereum-1", {
20
+ currency: mockEthCryptoCurrency,
21
+ });
22
+ export const ETH_ACCOUNT_2 = genAccount("ethereum-2", {
23
+ currency: mockEthCryptoCurrency,
24
+ });
25
+ export const BTC_ACCOUNT = genAccount("bitcoin-1", {
26
+ currency: mockBtcCryptoCurrency,
27
+ });
28
+ export const ARB_ACCOUNT = genAccount("arbitrum-1", {
29
+ currency: mockArbitrumCryptoCurrency,
30
+ tokenIds: ["arbitrum/erc20/arbitrum"],
31
+ });
32
+ export const ETH_ACCOUNT_WITH_USDC = genAccount("ethereum-usdc", {
33
+ currency: mockEthCryptoCurrency,
34
+ tokenIds: ["ethereum/erc20/usdc"],
35
+ });
36
+ export const BASE_ACCOUNT = genAccount("base-1", {
37
+ currency: mockBaseCryptoCurrency,
38
+ operationsSize: 100,
39
+ });
40
+ export const SCROLL_ACCOUNT = genAccount("scroll-1", {
41
+ currency: mockScrollCryptoCurrency,
42
+ operationsSize: 100,
43
+ });
@@ -0,0 +1,46 @@
1
+ import { composeHooks } from "../composeHooks";
2
+
3
+ describe("composeHooks", () => {
4
+ it("should compose hooks and merge their results", () => {
5
+ const hook1 = (items: Array<{ id: number }>) =>
6
+ items.map(item => ({ id: item.id, extra: item.id * 2 }));
7
+ const hook2 = (items: Array<{ id: number; extra: number }>) =>
8
+ items.map(item => ({ ...item, final: item.extra + 1 }));
9
+
10
+ const composed = composeHooks(hook1, hook2);
11
+
12
+ const input: Array<{ id: number }> = [{ id: 1 }, { id: 2 }];
13
+ const processedInput = input.map(item => ({ id: item.id, extra: item.id * 2 }));
14
+ const result = composed(processedInput);
15
+
16
+ expect(result).toEqual([
17
+ { id: 1, extra: 2, final: 3 },
18
+ { id: 2, extra: 4, final: 5 },
19
+ ]);
20
+ });
21
+
22
+ it("should handle hooks that return undefined", () => {
23
+ const hook1 = (items: Array<{ id: number }>) =>
24
+ items.map(item => ({ id: item.id, extra: item.id * 2 }));
25
+ const hook2 = () => undefined;
26
+
27
+ const composed = composeHooks(hook1, hook2);
28
+
29
+ const input = [{ id: 1 }, { id: 2 }];
30
+ const result = composed(input);
31
+
32
+ expect(result).toEqual([
33
+ { id: 1, extra: 2 },
34
+ { id: 2, extra: 4 },
35
+ ]);
36
+ });
37
+
38
+ it("should return the original items if no hooks are provided", () => {
39
+ const composed = composeHooks();
40
+
41
+ const input = [{ id: 1 }, { id: 2 }];
42
+ const result = composed(input);
43
+
44
+ expect(result).toEqual(input);
45
+ });
46
+ });
@@ -0,0 +1,138 @@
1
+ import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
2
+ import { genAccount } from "@ledgerhq/live-common/mock/account";
3
+ import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
4
+ import type { Account, TokenAccount } from "@ledgerhq/types-live";
5
+ import { getAccountTuplesForCurrency } from "../getAccountTuplesForCurrency";
6
+
7
+ function* accountGenerator(currency: CryptoCurrency): Generator<Account> {
8
+ let id = 0;
9
+ while (true) {
10
+ id += 1;
11
+ yield genAccount(`mocked-account-${id}`, { currency, operationsSize: 0 });
12
+ }
13
+ }
14
+ const getAccountCreator = (currencyId: string) => {
15
+ const generator = accountGenerator(getCryptoCurrencyById(currencyId));
16
+ return () => generator.next().value;
17
+ };
18
+
19
+ describe("getAccountTuplesForCurrency", () => {
20
+ const getEthAccount = getAccountCreator("ethereum");
21
+ const getBtcAccount = getAccountCreator("bitcoin");
22
+ const getPolkadotAccount = getAccountCreator("polkadot");
23
+ const getCosmosAccount = getAccountCreator("cosmos");
24
+
25
+ describe("CryptoCurrency", () => {
26
+ test("returns all accounts associated to the CryptoCurrency", () => {
27
+ const ethCurrency = getCryptoCurrencyById("ethereum");
28
+ const ethAccounts = [getEthAccount(), getEthAccount()];
29
+ const allAccounts: Account[] = [
30
+ getCosmosAccount(),
31
+ ...ethAccounts,
32
+ getBtcAccount(),
33
+ getPolkadotAccount(),
34
+ ];
35
+
36
+ const results = getAccountTuplesForCurrency(ethCurrency, allAccounts);
37
+
38
+ expect(results).toHaveLength(2);
39
+ results.forEach((result, index) => {
40
+ expect(result.account).toEqual(ethAccounts[index]);
41
+ expect(result.subAccount).toBeNull();
42
+ });
43
+ });
44
+
45
+ test("returns an empty array if the CryptoCurrency passed has no associated account", () => {
46
+ const ethCurrency = getCryptoCurrencyById("ethereum");
47
+ const allAccounts: Account[] = [getCosmosAccount(), getBtcAccount(), getPolkadotAccount()];
48
+
49
+ const results = getAccountTuplesForCurrency(ethCurrency, allAccounts);
50
+
51
+ expect(results).toHaveLength(0);
52
+ });
53
+
54
+ test("filters based on the accountId map", () => {
55
+ const ethCurrency = getCryptoCurrencyById("ethereum");
56
+ const ethAccounts = [getEthAccount(), getEthAccount(), getEthAccount(), getEthAccount()];
57
+
58
+ const results = getAccountTuplesForCurrency(
59
+ ethCurrency,
60
+ ethAccounts,
61
+ new Map([[ethAccounts[0].id, true]]),
62
+ );
63
+
64
+ expect(results).toHaveLength(1);
65
+ });
66
+ });
67
+
68
+ describe("TokenCurrency", () => {
69
+ const aaveToken = getTokenById("ethereum/erc20/aave");
70
+
71
+ test("returns correct parent accounts including a new subAccount when a TokenCurrency is provided", () => {
72
+ const ethAccounts = [
73
+ { ...getEthAccount(), subAccounts: [] },
74
+ { ...getEthAccount(), subAccounts: [] },
75
+ ];
76
+ const allAccounts: Account[] = [
77
+ getCosmosAccount(),
78
+ ...ethAccounts,
79
+ getBtcAccount(),
80
+ getPolkadotAccount(),
81
+ ];
82
+
83
+ const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
84
+
85
+ expect(results).toHaveLength(ethAccounts.length);
86
+ results.forEach((result, index) => {
87
+ expect(result.account).toEqual(ethAccounts[index]);
88
+ expect((result.subAccount as TokenAccount & { token: TokenCurrency }).token).toEqual(
89
+ aaveToken,
90
+ );
91
+ });
92
+ });
93
+
94
+ test("returns correct parent accounts including already existing subAccounts when a TokenCurrency is provided", () => {
95
+ const ethAccounts = [{ ...getEthAccount(), subAccounts: [aaveToken] }];
96
+ const allAccounts: Account[] = [
97
+ getCosmosAccount(),
98
+ ...ethAccounts,
99
+ getBtcAccount(),
100
+ getPolkadotAccount(),
101
+ ];
102
+
103
+ const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
104
+
105
+ expect(results).toHaveLength(ethAccounts.length);
106
+ results.forEach((result, index) => {
107
+ expect(result.account).toEqual(ethAccounts[index]);
108
+ expect((result.subAccount as TokenAccount & { token: TokenCurrency }).token).toEqual(
109
+ aaveToken,
110
+ );
111
+ });
112
+ });
113
+
114
+ test("returns an empty array when a TokenCurrency is provided but the accounts list is empty", () => {
115
+ const allAccounts: Account[] = [];
116
+
117
+ const results = getAccountTuplesForCurrency(aaveToken, allAccounts);
118
+ expect(results).toHaveLength(0);
119
+ });
120
+
121
+ test("does not filter based on the accountId map", () => {
122
+ const aaveAccounts = [
123
+ { ...getEthAccount(), subAccounts: [aaveToken] },
124
+ { ...getEthAccount(), subAccounts: [aaveToken] },
125
+ { ...getEthAccount(), subAccounts: [aaveToken] },
126
+ { ...getEthAccount(), subAccounts: [aaveToken] },
127
+ ];
128
+
129
+ const results = getAccountTuplesForCurrency(
130
+ aaveToken,
131
+ aaveAccounts,
132
+ new Map([[aaveAccounts[0].id, true]]),
133
+ );
134
+
135
+ expect(results).toHaveLength(4);
136
+ });
137
+ });
138
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @param hooks - An array of functions that take an array of items of type T and return an array of items of type U or undefined.
4
+ * @template T - The type of the items in the input array.
5
+ * @template U - The type of the items in the output array.
6
+ * @description This function composes multiple hooks into a single hook that processes an array of items of type T and returns an array of items of type T & U.
7
+ * @returns A function that takes an array of items of type T and returns an array of items of type T & U.
8
+ *
9
+ */
10
+
11
+ export function composeHooks<T, U>(
12
+ ...hooks: Array<(items: T[]) => U[] | undefined>
13
+ ): (items: T[]) => (T & U)[] {
14
+ return (items: T[]): (T & U)[] => {
15
+ return hooks.reduce<(T & U)[]>(
16
+ (acc, hook) => {
17
+ const result = hook?.(acc as T[]) ?? [];
18
+ return acc.map((item, i) => ({
19
+ ...item,
20
+ ...result[i],
21
+ }));
22
+ },
23
+ items as (T & U)[],
24
+ );
25
+ };
26
+ }