@ledgerhq/live-common 34.41.0-nightly.2 → 34.41.0-nightly.4

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 (188) hide show
  1. package/lib/DataModel.js +2 -2
  2. package/lib/DataModel.js.map +1 -1
  3. package/lib/DataModel.test.js +4 -4
  4. package/lib/DataModel.test.js.map +1 -1
  5. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  6. package/lib/bridge/generic-alpaca/signOperation.js +3 -4
  7. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  8. package/lib/e2e/enum/DeviceLabels.d.ts +2 -4
  9. package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
  10. package/lib/e2e/enum/DeviceLabels.js +2 -4
  11. package/lib/e2e/enum/DeviceLabels.js.map +1 -1
  12. package/lib/e2e/families/aptos.d.ts +2 -0
  13. package/lib/e2e/families/aptos.d.ts.map +1 -1
  14. package/lib/e2e/families/aptos.js +13 -1
  15. package/lib/e2e/families/aptos.js.map +1 -1
  16. package/lib/e2e/families/cardano.d.ts.map +1 -1
  17. package/lib/e2e/families/cardano.js +29 -26
  18. package/lib/e2e/families/cardano.js.map +1 -1
  19. package/lib/e2e/families/celo.js +1 -1
  20. package/lib/e2e/families/celo.js.map +1 -1
  21. package/lib/e2e/families/evm.js +1 -1
  22. package/lib/e2e/families/evm.js.map +1 -1
  23. package/lib/e2e/index.d.ts +1 -0
  24. package/lib/e2e/index.d.ts.map +1 -1
  25. package/lib/e2e/speculos.d.ts.map +1 -1
  26. package/lib/e2e/speculos.js +24 -21
  27. package/lib/e2e/speculos.js.map +1 -1
  28. package/lib/env.react.d.ts +1 -1
  29. package/lib/env.react.d.ts.map +1 -1
  30. package/lib/families/aptos/config.d.ts +4 -0
  31. package/lib/families/aptos/config.d.ts.map +1 -0
  32. package/lib/families/aptos/config.js +13 -0
  33. package/lib/families/aptos/config.js.map +1 -0
  34. package/lib/families/aptos/constants.d.ts +2 -0
  35. package/lib/families/aptos/constants.d.ts.map +1 -0
  36. package/lib/families/aptos/constants.js +19 -0
  37. package/lib/families/aptos/constants.js.map +1 -0
  38. package/lib/families/aptos/logic.d.ts +2 -0
  39. package/lib/families/aptos/logic.d.ts.map +1 -0
  40. package/lib/families/aptos/logic.js +19 -0
  41. package/lib/families/aptos/logic.js.map +1 -0
  42. package/lib/families/aptos/react.d.ts +10 -0
  43. package/lib/families/aptos/react.d.ts.map +1 -0
  44. package/lib/families/aptos/react.js +56 -0
  45. package/lib/families/aptos/react.js.map +1 -0
  46. package/lib/families/aptos/setup.d.ts +1 -1
  47. package/lib/families/aptos/setup.d.ts.map +1 -1
  48. package/lib/families/aptos/setup.js +1 -1
  49. package/lib/families/aptos/setup.js.map +1 -1
  50. package/lib/families/aptos/staking.d.ts +2 -0
  51. package/lib/families/aptos/staking.d.ts.map +1 -0
  52. package/lib/families/aptos/staking.js +19 -0
  53. package/lib/families/aptos/staking.js.map +1 -0
  54. package/lib/families/aptos/types.d.ts +2 -0
  55. package/lib/families/aptos/types.d.ts.map +1 -0
  56. package/lib/families/aptos/types.js +19 -0
  57. package/lib/families/aptos/types.js.map +1 -0
  58. package/lib/families/aptos/utils.d.ts +2 -0
  59. package/lib/families/aptos/utils.d.ts.map +1 -0
  60. package/lib/families/aptos/utils.js +19 -0
  61. package/lib/families/aptos/utils.js.map +1 -0
  62. package/lib/generated/bridge/js.d.ts +1 -1
  63. package/lib/generated/cli-transaction.d.ts +2 -2
  64. package/lib/generated/deviceTransactionConfig.d.ts +1 -2
  65. package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
  66. package/lib/generated/specs.d.ts +1 -1
  67. package/lib/generated/transaction.d.ts +3 -3
  68. package/lib/modularDrawer/utils/index.d.ts +6 -0
  69. package/lib/modularDrawer/utils/index.d.ts.map +1 -0
  70. package/lib/modularDrawer/utils/index.js +21 -0
  71. package/lib/modularDrawer/utils/index.js.map +1 -0
  72. package/lib/modularDrawer/utils/index.test.d.ts +2 -0
  73. package/lib/modularDrawer/utils/index.test.d.ts.map +1 -0
  74. package/lib/modularDrawer/utils/index.test.js +64 -0
  75. package/lib/modularDrawer/utils/index.test.js.map +1 -0
  76. package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
  77. package/lib/wallet-api/Exchange/server.js +0 -1
  78. package/lib/wallet-api/Exchange/server.js.map +1 -1
  79. package/lib-es/DataModel.js +1 -1
  80. package/lib-es/DataModel.js.map +1 -1
  81. package/lib-es/DataModel.test.js +2 -2
  82. package/lib-es/DataModel.test.js.map +1 -1
  83. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  84. package/lib-es/bridge/generic-alpaca/signOperation.js +3 -4
  85. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  86. package/lib-es/e2e/enum/DeviceLabels.d.ts +2 -4
  87. package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
  88. package/lib-es/e2e/enum/DeviceLabels.js +2 -4
  89. package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
  90. package/lib-es/e2e/families/aptos.d.ts +2 -0
  91. package/lib-es/e2e/families/aptos.d.ts.map +1 -1
  92. package/lib-es/e2e/families/aptos.js +9 -1
  93. package/lib-es/e2e/families/aptos.js.map +1 -1
  94. package/lib-es/e2e/families/cardano.d.ts.map +1 -1
  95. package/lib-es/e2e/families/cardano.js +29 -26
  96. package/lib-es/e2e/families/cardano.js.map +1 -1
  97. package/lib-es/e2e/families/celo.js +1 -1
  98. package/lib-es/e2e/families/celo.js.map +1 -1
  99. package/lib-es/e2e/families/evm.js +1 -1
  100. package/lib-es/e2e/families/evm.js.map +1 -1
  101. package/lib-es/e2e/index.d.ts +1 -0
  102. package/lib-es/e2e/index.d.ts.map +1 -1
  103. package/lib-es/e2e/speculos.d.ts.map +1 -1
  104. package/lib-es/e2e/speculos.js +24 -21
  105. package/lib-es/e2e/speculos.js.map +1 -1
  106. package/lib-es/env.react.d.ts +1 -1
  107. package/lib-es/env.react.d.ts.map +1 -1
  108. package/lib-es/families/aptos/config.d.ts +4 -0
  109. package/lib-es/families/aptos/config.d.ts.map +1 -0
  110. package/lib-es/families/aptos/config.js +10 -0
  111. package/lib-es/families/aptos/config.js.map +1 -0
  112. package/lib-es/families/aptos/constants.d.ts +2 -0
  113. package/lib-es/families/aptos/constants.d.ts.map +1 -0
  114. package/lib-es/families/aptos/constants.js +3 -0
  115. package/lib-es/families/aptos/constants.js.map +1 -0
  116. package/lib-es/families/aptos/logic.d.ts +2 -0
  117. package/lib-es/families/aptos/logic.d.ts.map +1 -0
  118. package/lib-es/families/aptos/logic.js +3 -0
  119. package/lib-es/families/aptos/logic.js.map +1 -0
  120. package/lib-es/families/aptos/react.d.ts +10 -0
  121. package/lib-es/families/aptos/react.d.ts.map +1 -0
  122. package/lib-es/families/aptos/react.js +49 -0
  123. package/lib-es/families/aptos/react.js.map +1 -0
  124. package/lib-es/families/aptos/setup.d.ts +1 -1
  125. package/lib-es/families/aptos/setup.d.ts.map +1 -1
  126. package/lib-es/families/aptos/setup.js +1 -1
  127. package/lib-es/families/aptos/setup.js.map +1 -1
  128. package/lib-es/families/aptos/staking.d.ts +2 -0
  129. package/lib-es/families/aptos/staking.d.ts.map +1 -0
  130. package/lib-es/families/aptos/staking.js +3 -0
  131. package/lib-es/families/aptos/staking.js.map +1 -0
  132. package/lib-es/families/aptos/types.d.ts +2 -0
  133. package/lib-es/families/aptos/types.d.ts.map +1 -0
  134. package/lib-es/families/aptos/types.js +3 -0
  135. package/lib-es/families/aptos/types.js.map +1 -0
  136. package/lib-es/families/aptos/utils.d.ts +2 -0
  137. package/lib-es/families/aptos/utils.d.ts.map +1 -0
  138. package/lib-es/families/aptos/utils.js +3 -0
  139. package/lib-es/families/aptos/utils.js.map +1 -0
  140. package/lib-es/generated/bridge/js.d.ts +1 -1
  141. package/lib-es/generated/cli-transaction.d.ts +2 -2
  142. package/lib-es/generated/deviceTransactionConfig.d.ts +1 -2
  143. package/lib-es/generated/deviceTransactionConfig.d.ts.map +1 -1
  144. package/lib-es/generated/specs.d.ts +1 -1
  145. package/lib-es/generated/transaction.d.ts +3 -3
  146. package/lib-es/modularDrawer/utils/index.d.ts +6 -0
  147. package/lib-es/modularDrawer/utils/index.d.ts.map +1 -0
  148. package/lib-es/modularDrawer/utils/index.js +17 -0
  149. package/lib-es/modularDrawer/utils/index.js.map +1 -0
  150. package/lib-es/modularDrawer/utils/index.test.d.ts +2 -0
  151. package/lib-es/modularDrawer/utils/index.test.d.ts.map +1 -0
  152. package/lib-es/modularDrawer/utils/index.test.js +62 -0
  153. package/lib-es/modularDrawer/utils/index.test.js.map +1 -0
  154. package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
  155. package/lib-es/wallet-api/Exchange/server.js +0 -1
  156. package/lib-es/wallet-api/Exchange/server.js.map +1 -1
  157. package/package.json +62 -62
  158. package/src/DataModel.test.ts +5 -4
  159. package/src/DataModel.ts +1 -1
  160. package/src/bridge/generic-alpaca/signOperation.ts +5 -7
  161. package/src/e2e/enum/DeviceLabels.ts +2 -4
  162. package/src/e2e/families/aptos.ts +11 -1
  163. package/src/e2e/families/cardano.ts +31 -29
  164. package/src/e2e/families/celo.ts +1 -1
  165. package/src/e2e/families/evm.ts +1 -1
  166. package/src/e2e/speculos.ts +28 -25
  167. package/src/families/aptos/__snapshots__/bridge.integration.test.ts.snap +84 -3
  168. package/src/families/aptos/config.ts +12 -0
  169. package/src/families/aptos/constants.ts +2 -0
  170. package/src/families/aptos/logic.ts +2 -0
  171. package/src/families/aptos/react.ts +89 -0
  172. package/src/families/aptos/setup.ts +2 -7
  173. package/src/families/aptos/staking.ts +2 -0
  174. package/src/families/aptos/types.ts +2 -0
  175. package/src/families/aptos/utils.ts +2 -0
  176. package/src/generated/deviceTransactionConfig.ts +0 -2
  177. package/src/modularDrawer/utils/index.test.ts +74 -0
  178. package/src/modularDrawer/utils/index.ts +29 -0
  179. package/src/wallet-api/Exchange/server.ts +0 -2
  180. package/lib/families/aptos/consts.d.ts +0 -4
  181. package/lib/families/aptos/consts.d.ts.map +0 -1
  182. package/lib/families/aptos/consts.js +0 -7
  183. package/lib/families/aptos/consts.js.map +0 -1
  184. package/lib-es/families/aptos/consts.d.ts +0 -4
  185. package/lib-es/families/aptos/consts.d.ts.map +0 -1
  186. package/lib-es/families/aptos/consts.js +0 -4
  187. package/lib-es/families/aptos/consts.js.map +0 -1
  188. package/src/families/aptos/consts.ts +0 -3
@@ -3,6 +3,12 @@
3
3
  exports[`aptos currency bridge scanAccounts aptos seed 1 1`] = `
4
4
  [
5
5
  {
6
+ "aptosResources": {
7
+ "activeBalance": "0",
8
+ "inactiveBalance": "0",
9
+ "pendingInactiveBalance": "0",
10
+ "stakingPositions": [],
11
+ },
6
12
  "balance": "19949100",
7
13
  "currencyId": "aptos",
8
14
  "derivationMode": "aptos",
@@ -21,17 +27,23 @@ exports[`aptos currency bridge scanAccounts aptos seed 1 1`] = `
21
27
  "xpub": "d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956",
22
28
  },
23
29
  {
24
- "balance": "20020000",
30
+ "aptosResources": {
31
+ "activeBalance": "0",
32
+ "inactiveBalance": "0",
33
+ "pendingInactiveBalance": "0",
34
+ "stakingPositions": [],
35
+ },
36
+ "balance": "20050000",
25
37
  "currencyId": "aptos",
26
38
  "derivationMode": "aptos",
27
39
  "freshAddress": "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
28
40
  "freshAddressPath": "44'/637'/1'/0'/0'",
29
41
  "id": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
30
42
  "index": 1,
31
- "operationsCount": 2,
43
+ "operationsCount": 5,
32
44
  "pendingOperations": [],
33
45
  "seedIdentifier": "d6816f4f22f867b56cf9304b776f452a16d107835d73ee8a33c4ced210300583",
34
- "spendableBalance": "20020000",
46
+ "spendableBalance": "20050000",
35
47
  "subAccounts": [],
36
48
  "swapHistory": [],
37
49
  "syncHash": undefined,
@@ -39,6 +51,12 @@ exports[`aptos currency bridge scanAccounts aptos seed 1 1`] = `
39
51
  "xpub": "6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e",
40
52
  },
41
53
  {
54
+ "aptosResources": {
55
+ "activeBalance": "0",
56
+ "inactiveBalance": "0",
57
+ "pendingInactiveBalance": "0",
58
+ "stakingPositions": [],
59
+ },
42
60
  "balance": "0",
43
61
  "currencyId": "aptos",
44
62
  "derivationMode": "aptos",
@@ -211,6 +229,27 @@ exports[`aptos currency bridge scanAccounts aptos seed 1 2`] = `
211
229
  },
212
230
  ],
213
231
  [
232
+ {
233
+ "accountId": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
234
+ "blockHash": "0xb71a59a5f43dc73c945da97ef88043721dab81f658df7a4a4207f95ce7cad0ee",
235
+ "blockHeight": 366009981,
236
+ "extra": {
237
+ "version": "2901622402",
238
+ },
239
+ "fee": "1100",
240
+ "hasFailed": false,
241
+ "hash": "0x1acd500f32be88a62692698502a296dcb977e5629bbbf12e448bc69737c18c40",
242
+ "id": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos-0x1acd500f32be88a62692698502a296dcb977e5629bbbf12e448bc69737c18c40-IN",
243
+ "recipients": [
244
+ "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
245
+ ],
246
+ "senders": [
247
+ "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390",
248
+ ],
249
+ "transactionSequenceNumber": 179,
250
+ "type": "IN",
251
+ "value": "10000",
252
+ },
214
253
  {
215
254
  "accountId": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
216
255
  "blockHash": "0x27db591a136924b48d10e6e152a3e856a5c38b332654767da252851adbb454b2",
@@ -232,6 +271,48 @@ exports[`aptos currency bridge scanAccounts aptos seed 1 2`] = `
232
271
  "type": "IN",
233
272
  "value": "20000000",
234
273
  },
274
+ {
275
+ "accountId": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
276
+ "blockHash": "0xadfce17fba19584616fec77888c41c1bacd18ef8702dfe07ccfbfeafd8edfd17",
277
+ "blockHeight": 366013582,
278
+ "extra": {
279
+ "version": "2901672541",
280
+ },
281
+ "fee": "1100",
282
+ "hasFailed": false,
283
+ "hash": "0x494582adf8f3e2748a30453a687106524f18296bf5924e3c1ead8a2503894970",
284
+ "id": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos-0x494582adf8f3e2748a30453a687106524f18296bf5924e3c1ead8a2503894970-IN",
285
+ "recipients": [
286
+ "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
287
+ ],
288
+ "senders": [
289
+ "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390",
290
+ ],
291
+ "transactionSequenceNumber": 182,
292
+ "type": "IN",
293
+ "value": "10000",
294
+ },
295
+ {
296
+ "accountId": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
297
+ "blockHash": "0x1647b469fb104624e4e0a9b7f0b0368facec96a232cde5f83be1235c1068b038",
298
+ "blockHeight": 366012016,
299
+ "extra": {
300
+ "version": "2901651004",
301
+ },
302
+ "fee": "1100",
303
+ "hasFailed": false,
304
+ "hash": "0x4f42472b8c92d3d6083d05a3a357f38ed97491f5e0750058da49cc04cef82794",
305
+ "id": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos-0x4f42472b8c92d3d6083d05a3a357f38ed97491f5e0750058da49cc04cef82794-IN",
306
+ "recipients": [
307
+ "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
308
+ ],
309
+ "senders": [
310
+ "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390",
311
+ ],
312
+ "transactionSequenceNumber": 181,
313
+ "type": "IN",
314
+ "value": "10000",
315
+ },
235
316
  {
236
317
  "accountId": "js:2:aptos:6a7712fdac0cb4ed27076c707e7798be52cf6c93a2d43d5cf9b874d0a45a111e:aptos",
237
318
  "blockHash": "0xf37ce698cf2e6d9e4a0048cd6d09fb3f19f417ab8251a3cc1f19b8d0e503538f",
@@ -0,0 +1,12 @@
1
+ import { CurrencyLiveConfigDefinition } from "../../config";
2
+
3
+ const aptosConfig: CurrencyLiveConfigDefinition = {
4
+ config_currency_aptos: {
5
+ type: "object",
6
+ default: {
7
+ status: { type: "active" },
8
+ },
9
+ },
10
+ };
11
+
12
+ export { aptosConfig };
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD and LLM
2
+ export * from "@ledgerhq/coin-aptos/constants";
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD and LLM
2
+ export * from "@ledgerhq/coin-aptos/bridge/logic";
@@ -0,0 +1,89 @@
1
+ import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import { useMemo } from "react";
3
+ import { getCurrentAptosPreloadData, getAptosPreloadData } from "@ledgerhq/coin-aptos/preload-data";
4
+ import type {
5
+ AptosAccount,
6
+ AptosMappedStakingPosition,
7
+ AptosPreloadData,
8
+ AptosValidator,
9
+ Transaction,
10
+ } from "./types";
11
+ import { useObservable } from "../../observable";
12
+ import { getAccountCurrency } from "../../account";
13
+ import { mapStakingPositions } from "./staking";
14
+
15
+ export function useAptosPreloadData(currency: CryptoCurrency): AptosPreloadData | undefined | null {
16
+ return useObservable(getAptosPreloadData(currency), getCurrentAptosPreloadData(currency));
17
+ }
18
+
19
+ export function useAptosValidators(currency: CryptoCurrency, search?: string): AptosValidator[] {
20
+ const data = useAptosPreloadData(currency);
21
+
22
+ return useMemo(() => {
23
+ const validators = data?.validators ?? [];
24
+
25
+ if (validators.length === 0 || !search || search === "") {
26
+ return validators;
27
+ }
28
+
29
+ const lowercaseSearch = search.toLowerCase();
30
+
31
+ const filtered = validators.filter(
32
+ validator =>
33
+ validator.name?.toLowerCase().includes(lowercaseSearch) ||
34
+ validator.address.toLowerCase().includes(lowercaseSearch),
35
+ );
36
+
37
+ const flags = [];
38
+ const output: AptosValidator[] = [];
39
+ for (let i = 0; i < filtered.length; i++) {
40
+ if (flags[filtered[i].address]) continue;
41
+ flags[filtered[i].address] = true;
42
+ output.push(filtered[i]);
43
+ }
44
+ return output;
45
+ }, [data, search]);
46
+ }
47
+
48
+ export function useAptosMappedStakingPositions(
49
+ account: AptosAccount,
50
+ ): AptosMappedStakingPosition[] {
51
+ const validators = useAptosValidators(account.currency, "");
52
+ const stakingPositions = account.aptosResources?.stakingPositions;
53
+
54
+ const unit = getAccountCurrency(account).units[0];
55
+
56
+ return useMemo(() => {
57
+ const mappedStakingPositions = mapStakingPositions(stakingPositions || [], validators, unit);
58
+ return mappedStakingPositions;
59
+ }, [stakingPositions, validators, unit]);
60
+ }
61
+
62
+ export function useAptosStakingPositionsQuerySelector(
63
+ account: AptosAccount,
64
+ transaction: Transaction,
65
+ ): {
66
+ options: AptosMappedStakingPosition[];
67
+ value: AptosMappedStakingPosition | undefined;
68
+ } {
69
+ const stakingPositions = useAptosMappedStakingPositions(account);
70
+ const options = useMemo<AptosMappedStakingPosition[]>(
71
+ () =>
72
+ stakingPositions.filter(sp =>
73
+ transaction.mode === "unstake" ? sp.active.gt(0) : sp.inactive.gt(0),
74
+ ),
75
+ [stakingPositions, transaction],
76
+ );
77
+
78
+ const selectedValidatorAddress = transaction.recipient;
79
+
80
+ const value = useMemo(
81
+ () => stakingPositions.find(({ validatorId }) => validatorId === selectedValidatorAddress),
82
+ [stakingPositions, selectedValidatorAddress],
83
+ );
84
+
85
+ return {
86
+ options,
87
+ value,
88
+ };
89
+ }
@@ -1,11 +1,6 @@
1
1
  // Goal of this file is to inject all necessary device/signer dependency to coin-modules
2
-
3
- import {
4
- AptosAccount,
5
- TransactionStatus,
6
- createBridges,
7
- type Transaction,
8
- } from "@ledgerhq/coin-aptos";
2
+ import { createBridges } from "@ledgerhq/coin-aptos";
3
+ import { AptosAccount, TransactionStatus, type Transaction } from "@ledgerhq/coin-aptos/types";
9
4
  import Transport from "@ledgerhq/hw-transport";
10
5
  import Aptos from "@ledgerhq/hw-app-aptos";
11
6
  import type { Bridge } from "@ledgerhq/types-live";
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD et LLM
2
+ export * from "@ledgerhq/coin-aptos/logic/staking";
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD and LLM
2
+ export * from "@ledgerhq/coin-aptos/types";
@@ -0,0 +1,2 @@
1
+ // Encapsulate for LLD and LLM
2
+ export * from "@ledgerhq/coin-aptos/utils";
@@ -47,7 +47,6 @@ export default {
47
47
  xrp,
48
48
  mina,
49
49
  };
50
- import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_aptos } from "@ledgerhq/coin-aptos/bridge/deviceTransactionConfig";
51
50
  import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_casper } from "@ledgerhq/coin-casper/bridge/deviceTransactionConfig";
52
51
  import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_filecoin } from "@ledgerhq/coin-filecoin/bridge/deviceTransactionConfig";
53
52
  import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_stacks } from "@ledgerhq/coin-stacks/bridge/deviceTransactionConfig";
@@ -55,7 +54,6 @@ import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_polkadot } f
55
54
  import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_tron } from "@ledgerhq/coin-tron/bridge/deviceTransactionConfig";
56
55
 
57
56
  export type ExtraDeviceTransactionField =
58
- | ExtraDeviceTransactionField_aptos
59
57
  | ExtraDeviceTransactionField_casper
60
58
  | ExtraDeviceTransactionField_filecoin
61
59
  | ExtraDeviceTransactionField_stacks
@@ -0,0 +1,74 @@
1
+ import { isCorrespondingCurrency, getEffectiveCurrency } from "./index";
2
+
3
+ import { createFixtureCryptoCurrency } from "../../mock/fixtures/cryptoCurrencies";
4
+ import { cryptocurrenciesById } from "@ledgerhq/cryptoassets";
5
+ import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
6
+ import type { CurrenciesByProviderId } from "../../deposit/type";
7
+
8
+ describe("isCorrespondingCurrency", () => {
9
+ const evmCurrency = createFixtureCryptoCurrency("evm");
10
+ const usdcToken: CryptoOrTokenCurrency = {
11
+ type: "TokenCurrency",
12
+ id: "ethereum/erc20/usdc",
13
+ contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
14
+ parentCurrency: evmCurrency,
15
+ tokenType: "erc20",
16
+ name: "USD Coin",
17
+ ticker: "USDC",
18
+ units: [{ name: "USD Coin", code: "USDC", magnitude: 6 }],
19
+ };
20
+ const evmCrypto: CryptoOrTokenCurrency = evmCurrency;
21
+
22
+ it("returns true for a token whose parentCurrency.id matches the reference crypto", () => {
23
+ expect(isCorrespondingCurrency(usdcToken, evmCurrency)).toBe(true);
24
+ });
25
+
26
+ it("returns true for a token whose id matches the reference crypto", () => {
27
+ expect(isCorrespondingCurrency(usdcToken, usdcToken)).toBe(true);
28
+ });
29
+
30
+ it("returns true for a crypto whose id matches the reference crypto", () => {
31
+ expect(isCorrespondingCurrency(evmCrypto, evmCurrency)).toBe(true);
32
+ });
33
+
34
+ it("returns false for a token whose parentCurrency is different", () => {
35
+ const bitcoinCurrency = cryptocurrenciesById["bitcoin"];
36
+ const tokenWithOtherParent = { ...usdcToken, parentCurrency: bitcoinCurrency };
37
+ expect(isCorrespondingCurrency(tokenWithOtherParent, evmCurrency)).toBe(false);
38
+ });
39
+
40
+ it("returns false for a crypto whose id is different", () => {
41
+ const bitcoinCurrency = cryptocurrenciesById["bitcoin"];
42
+ expect(isCorrespondingCurrency(bitcoinCurrency, evmCurrency)).toBe(false);
43
+ });
44
+ });
45
+
46
+ describe("getEffectiveCurrency", () => {
47
+ const parent = createFixtureCryptoCurrency("evm");
48
+ const token: CryptoOrTokenCurrency = {
49
+ type: "TokenCurrency",
50
+ id: "ethereum/erc20/usdc",
51
+ contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
52
+ parentCurrency: parent,
53
+ tokenType: "erc20",
54
+ name: "USD Coin",
55
+ ticker: "USDC",
56
+ units: [{ name: "USD Coin", code: "USDC", magnitude: 6 }],
57
+ };
58
+ const provider: CurrenciesByProviderId = {
59
+ providerId: "provider1",
60
+ currenciesByNetwork: [parent, token],
61
+ };
62
+
63
+ it("returns currency if id is in currencyIds", () => {
64
+ expect(getEffectiveCurrency(token, provider, [token.id])).toBe(token);
65
+ });
66
+
67
+ it("returns first matching currency from provider if id not in currencyIds", () => {
68
+ expect(getEffectiveCurrency(token, provider, [parent.id])).toBe(parent);
69
+ });
70
+
71
+ it("returns currency if no match in provider", () => {
72
+ expect(getEffectiveCurrency(token, provider, ["notfound"])).toBe(token);
73
+ });
74
+ });
@@ -0,0 +1,29 @@
1
+ import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import { CurrenciesByProviderId } from "../../deposit/type";
3
+
4
+ function isCorrespondingCurrency(
5
+ elem: CryptoOrTokenCurrency,
6
+ network: CryptoOrTokenCurrency,
7
+ ): boolean {
8
+ if (elem.type === "TokenCurrency") {
9
+ return elem.parentCurrency?.id === network.id || elem.id === network.id;
10
+ }
11
+ if (elem.type === "CryptoCurrency") {
12
+ return elem.id === network.id;
13
+ }
14
+ return false;
15
+ }
16
+
17
+ const getEffectiveCurrency = (
18
+ currency: CryptoOrTokenCurrency,
19
+ provider: CurrenciesByProviderId,
20
+ currencyIds: string[],
21
+ ) => {
22
+ const isCurrencyFiltered = currencyIds.includes(currency.id);
23
+
24
+ if (isCurrencyFiltered) return currency;
25
+
26
+ return provider.currenciesByNetwork.find(elem => currencyIds.includes(elem.id)) ?? currency;
27
+ };
28
+
29
+ export { isCorrespondingCurrency, getEffectiveCurrency };
@@ -423,8 +423,6 @@ export const handlers = ({
423
423
 
424
424
  // Step 1: Open the drawer and open exchange app
425
425
  const startExchange = async () => {
426
- console.log("LLD custom.exchange.swap uiExchangeStart", exchangeStartParams);
427
-
428
426
  return new Promise<{ transactionId: string; device?: ExchangeStartResult["device"] }>(
429
427
  (resolve, reject) => {
430
428
  uiExchangeStart({
@@ -1,4 +0,0 @@
1
- export declare const APTOS_NON_HARDENED_DERIVATION_PATH_REGEX: RegExp;
2
- export declare const APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
3
- export declare const APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";
4
- //# sourceMappingURL=consts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/families/aptos/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wCAAwC,QAAyC,CAAC;AAC/F,eAAO,MAAM,kCAAkC,oBAAoB,CAAC;AACpE,eAAO,MAAM,8BAA8B,sBAAsB,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APTOS_HARDENED_DERIVATION_PATH = exports.APTOS_NON_HARDENED_DERIVATION_PATH = exports.APTOS_NON_HARDENED_DERIVATION_PATH_REGEX = void 0;
4
- exports.APTOS_NON_HARDENED_DERIVATION_PATH_REGEX = /^44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/;
5
- exports.APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
6
- exports.APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";
7
- //# sourceMappingURL=consts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/families/aptos/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,wCAAwC,GAAG,sCAAsC,CAAC;AAClF,QAAA,kCAAkC,GAAG,iBAAiB,CAAC;AACvD,QAAA,8BAA8B,GAAG,mBAAmB,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const APTOS_NON_HARDENED_DERIVATION_PATH_REGEX: RegExp;
2
- export declare const APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
3
- export declare const APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";
4
- //# sourceMappingURL=consts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/families/aptos/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wCAAwC,QAAyC,CAAC;AAC/F,eAAO,MAAM,kCAAkC,oBAAoB,CAAC;AACpE,eAAO,MAAM,8BAA8B,sBAAsB,CAAC"}
@@ -1,4 +0,0 @@
1
- export const APTOS_NON_HARDENED_DERIVATION_PATH_REGEX = /^44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/;
2
- export const APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
3
- export const APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";
4
- //# sourceMappingURL=consts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/families/aptos/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wCAAwC,GAAG,sCAAsC,CAAC;AAC/F,MAAM,CAAC,MAAM,kCAAkC,GAAG,iBAAiB,CAAC;AACpE,MAAM,CAAC,MAAM,8BAA8B,GAAG,mBAAmB,CAAC"}
@@ -1,3 +0,0 @@
1
- export const APTOS_NON_HARDENED_DERIVATION_PATH_REGEX = /^44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/;
2
- export const APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
3
- export const APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";