@ledgerhq/live-common 24.1.0 → 25.0.0-next.1

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 (235) hide show
  1. package/lib/apps/support.js +1 -1
  2. package/lib/apps/support.js.map +1 -1
  3. package/lib/bot/index.d.ts.map +1 -1
  4. package/lib/bot/index.js +4 -2
  5. package/lib/bot/index.js.map +1 -1
  6. package/lib/bot/specs.d.ts +1 -0
  7. package/lib/bot/specs.d.ts.map +1 -1
  8. package/lib/bot/specs.js +6 -1
  9. package/lib/bot/specs.js.map +1 -1
  10. package/lib/currencies/support.d.ts +1 -1
  11. package/lib/currencies/support.d.ts.map +1 -1
  12. package/lib/env.d.ts +15 -5
  13. package/lib/env.d.ts.map +1 -1
  14. package/lib/env.js +10 -0
  15. package/lib/env.js.map +1 -1
  16. package/lib/env.react.d.ts +1 -1
  17. package/lib/env.react.d.ts.map +1 -1
  18. package/lib/errors.d.ts +101 -306
  19. package/lib/errors.d.ts.map +1 -1
  20. package/lib/errors.js +3 -4
  21. package/lib/errors.js.map +1 -1
  22. package/lib/errors.test.d.ts +2 -0
  23. package/lib/errors.test.d.ts.map +1 -0
  24. package/lib/errors.test.js +20 -0
  25. package/lib/errors.test.js.map +1 -0
  26. package/lib/exchange/swap/utils/index.test.js +2 -2
  27. package/lib/exchange/swap/utils/index.test.js.map +1 -1
  28. package/lib/families/bitcoin/datasets/bitcoin.d.ts.map +1 -1
  29. package/lib/families/bitcoin/datasets/bitcoin.js +2 -4
  30. package/lib/families/bitcoin/datasets/bitcoin.js.map +1 -1
  31. package/lib/families/bitcoin/descriptor.d.ts.map +1 -1
  32. package/lib/families/bitcoin/descriptor.js +3 -1
  33. package/lib/families/bitcoin/descriptor.js.map +1 -1
  34. package/lib/families/bitcoin/errors.d.ts +1 -3
  35. package/lib/families/bitcoin/errors.d.ts.map +1 -1
  36. package/lib/families/bitcoin/exchange.js +1 -1
  37. package/lib/families/bitcoin/exchange.js.map +1 -1
  38. package/lib/families/bitcoin/hw-getAddress.d.ts +1 -1
  39. package/lib/families/bitcoin/hw-getAddress.d.ts.map +1 -1
  40. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  41. package/lib/families/bitcoin/js-synchronisation.js +20 -2
  42. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  43. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts +0 -36
  44. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
  45. package/lib/families/bitcoin/wallet-btc/storage/index.js +14 -14
  46. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  47. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts +1 -0
  48. package/lib/families/bitcoin/wallet-btc/storage/types.d.ts.map +1 -1
  49. package/lib/families/bitcoin/xpub.txs.loadExport.unit.test.d.ts +2 -0
  50. package/lib/families/bitcoin/xpub.txs.loadExport.unit.test.d.ts.map +1 -0
  51. package/lib/families/bitcoin/xpub.txs.loadExport.unit.test.js +146 -0
  52. package/lib/families/bitcoin/xpub.txs.loadExport.unit.test.js.map +1 -0
  53. package/lib/families/cardano/errors.d.ts +1 -3
  54. package/lib/families/cardano/errors.d.ts.map +1 -1
  55. package/lib/families/crypto_org/errors.d.ts +3 -9
  56. package/lib/families/crypto_org/errors.d.ts.map +1 -1
  57. package/lib/families/ethereum/exchange.js +1 -1
  58. package/lib/families/ethereum/exchange.js.map +1 -1
  59. package/lib/families/ethereum/modules/index.d.ts +1 -1
  60. package/lib/families/ethereum/modules/index.d.ts.map +1 -1
  61. package/lib/families/ethereum/signOperation.js +2 -2
  62. package/lib/families/ethereum/signOperation.js.map +1 -1
  63. package/lib/families/ethereum/specs.d.ts +1 -1
  64. package/lib/families/ethereum/specs.js +5 -5
  65. package/lib/families/ethereum/specs.js.map +1 -1
  66. package/lib/families/polkadot/errors.d.ts +12 -36
  67. package/lib/families/polkadot/errors.d.ts.map +1 -1
  68. package/lib/families/ripple/exchange.js +1 -1
  69. package/lib/families/ripple/exchange.js.map +1 -1
  70. package/lib/families/solana/api/chain/instruction/token/types.d.ts +3 -3
  71. package/lib/families/solana/errors.d.ts +20 -60
  72. package/lib/families/solana/errors.d.ts.map +1 -1
  73. package/lib/families/stellar/api/horizon.d.ts +29 -7
  74. package/lib/families/stellar/api/horizon.d.ts.map +1 -1
  75. package/lib/families/stellar/api/horizon.js +114 -58
  76. package/lib/families/stellar/api/horizon.js.map +1 -1
  77. package/lib/families/stellar/api/index.d.ts +1 -1
  78. package/lib/families/stellar/api/index.d.ts.map +1 -1
  79. package/lib/families/stellar/api/index.js +5 -1
  80. package/lib/families/stellar/api/index.js.map +1 -1
  81. package/lib/families/stellar/bridge/mock.d.ts.map +1 -1
  82. package/lib/families/stellar/bridge/mock.js +4 -1
  83. package/lib/families/stellar/bridge/mock.js.map +1 -1
  84. package/lib/families/stellar/bridge.integration.test.js +12 -4
  85. package/lib/families/stellar/bridge.integration.test.js.map +1 -1
  86. package/lib/families/stellar/cli-transaction.d.ts +3 -1
  87. package/lib/families/stellar/cli-transaction.d.ts.map +1 -1
  88. package/lib/families/stellar/cli-transaction.js +48 -2
  89. package/lib/families/stellar/cli-transaction.js.map +1 -1
  90. package/lib/families/stellar/deviceTransactionConfig.d.ts +7 -1
  91. package/lib/families/stellar/deviceTransactionConfig.d.ts.map +1 -1
  92. package/lib/families/stellar/deviceTransactionConfig.js +12 -1
  93. package/lib/families/stellar/deviceTransactionConfig.js.map +1 -1
  94. package/lib/families/stellar/errors.d.ts +12 -0
  95. package/lib/families/stellar/errors.d.ts.map +1 -0
  96. package/lib/families/stellar/errors.js +16 -0
  97. package/lib/families/stellar/errors.js.map +1 -0
  98. package/lib/families/stellar/exchange.js +1 -1
  99. package/lib/families/stellar/exchange.js.map +1 -1
  100. package/lib/families/stellar/js-buildTransaction.d.ts.map +1 -1
  101. package/lib/families/stellar/js-buildTransaction.js +34 -16
  102. package/lib/families/stellar/js-buildTransaction.js.map +1 -1
  103. package/lib/families/stellar/js-createTransaction.d.ts.map +1 -1
  104. package/lib/families/stellar/js-createTransaction.js +4 -1
  105. package/lib/families/stellar/js-createTransaction.js.map +1 -1
  106. package/lib/families/stellar/js-estimateMaxSpendable.js +2 -1
  107. package/lib/families/stellar/js-estimateMaxSpendable.js.map +1 -1
  108. package/lib/families/stellar/js-getTransactionStatus.d.ts.map +1 -1
  109. package/lib/families/stellar/js-getTransactionStatus.js +127 -57
  110. package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
  111. package/lib/families/stellar/js-prepareTransaction.d.ts.map +1 -1
  112. package/lib/families/stellar/js-prepareTransaction.js +25 -7
  113. package/lib/families/stellar/js-prepareTransaction.js.map +1 -1
  114. package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
  115. package/lib/families/stellar/js-signOperation.js +33 -6
  116. package/lib/families/stellar/js-signOperation.js.map +1 -1
  117. package/lib/families/stellar/js-synchronization.d.ts +1 -1
  118. package/lib/families/stellar/js-synchronization.d.ts.map +1 -1
  119. package/lib/families/stellar/js-synchronization.js +42 -16
  120. package/lib/families/stellar/js-synchronization.js.map +1 -1
  121. package/lib/families/stellar/logic.d.ts +21 -14
  122. package/lib/families/stellar/logic.d.ts.map +1 -1
  123. package/lib/families/stellar/logic.js +158 -57
  124. package/lib/families/stellar/logic.js.map +1 -1
  125. package/lib/families/stellar/specs.d.ts.map +1 -1
  126. package/lib/families/stellar/specs.js +182 -7
  127. package/lib/families/stellar/specs.js.map +1 -1
  128. package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
  129. package/lib/families/stellar/speculos-deviceActions.js +60 -28
  130. package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
  131. package/lib/families/stellar/tokens.d.ts +11 -0
  132. package/lib/families/stellar/tokens.d.ts.map +1 -0
  133. package/lib/families/stellar/tokens.js +82 -0
  134. package/lib/families/stellar/tokens.js.map +1 -0
  135. package/lib/families/stellar/transaction.d.ts +2 -2
  136. package/lib/families/stellar/transaction.d.ts.map +1 -1
  137. package/lib/families/stellar/transaction.js +32 -6
  138. package/lib/families/stellar/transaction.js.map +1 -1
  139. package/lib/families/stellar/types.d.ts +45 -0
  140. package/lib/families/stellar/types.d.ts.map +1 -1
  141. package/lib/families/stellar/types.js +7 -1
  142. package/lib/families/stellar/types.js.map +1 -1
  143. package/lib/families/tezos/exchange.js +1 -1
  144. package/lib/families/tezos/exchange.js.map +1 -1
  145. package/lib/generated/cli-transaction.d.ts +1 -0
  146. package/lib/generated/cli-transaction.d.ts.map +1 -1
  147. package/lib/generated/specs.d.ts +1 -1
  148. package/lib/generated/transaction.d.ts +1 -1
  149. package/lib/hw/signMessage/index.d.ts +4 -3
  150. package/lib/hw/signMessage/index.d.ts.map +1 -1
  151. package/lib/hw/signMessage/index.js +25 -11
  152. package/lib/hw/signMessage/index.js.map +1 -1
  153. package/lib/hw/signMessage/index.test.d.ts +2 -0
  154. package/lib/hw/signMessage/index.test.d.ts.map +1 -0
  155. package/lib/hw/signMessage/index.test.js +126 -0
  156. package/lib/hw/signMessage/index.test.js.map +1 -0
  157. package/lib/load/speculos.d.ts.map +1 -1
  158. package/lib/load/speculos.js +1 -3
  159. package/lib/load/speculos.js.map +1 -1
  160. package/lib/mock/Btc.d.ts +1 -1
  161. package/lib/mock/Btc.d.ts.map +1 -1
  162. package/lib/performance.d.ts +10 -0
  163. package/lib/performance.d.ts.map +1 -0
  164. package/lib/performance.js +72 -0
  165. package/lib/performance.js.map +1 -0
  166. package/lib/performance.test.d.ts +2 -0
  167. package/lib/performance.test.d.ts.map +1 -0
  168. package/lib/performance.test.js +28 -0
  169. package/lib/performance.test.js.map +1 -0
  170. package/lib/platform/providers/RemoteLiveAppProvider/api/index.d.ts.map +1 -1
  171. package/lib/platform/providers/RemoteLiveAppProvider/api/index.js +28 -0
  172. package/lib/platform/providers/RemoteLiveAppProvider/api/index.js.map +1 -1
  173. package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +0 -31
  174. package/lib/types/currencies.d.ts +1 -1
  175. package/lib/types/currencies.d.ts.map +1 -1
  176. package/lib/walletconnect/Provider.d.ts.map +1 -1
  177. package/lib/walletconnect/Provider.js +1 -3
  178. package/lib/walletconnect/Provider.js.map +1 -1
  179. package/package.json +71 -19
  180. package/src/apps/support.ts +1 -1
  181. package/src/bot/index.ts +3 -1
  182. package/src/bot/specs.ts +7 -1
  183. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +34 -6
  184. package/src/currencies/support.ts +1 -1
  185. package/src/env.ts +10 -0
  186. package/src/errors.test.ts +21 -0
  187. package/src/errors.ts +1 -6
  188. package/src/exchange/swap/utils/index.test.ts +1 -1
  189. package/src/families/bitcoin/datasets/bitcoin.ts +0 -2
  190. package/src/families/bitcoin/descriptor.ts +4 -1
  191. package/src/families/bitcoin/exchange.ts +1 -1
  192. package/src/families/bitcoin/hw-getAddress.ts +1 -1
  193. package/src/families/bitcoin/js-synchronisation.ts +23 -1
  194. package/src/families/bitcoin/wallet-btc/storage/index.ts +17 -31
  195. package/src/families/bitcoin/wallet-btc/storage/types.ts +1 -0
  196. package/src/families/bitcoin/wallet-btc/wallet.ts +1 -1
  197. package/src/families/bitcoin/xpub.txs.loadExport.unit.test.ts +101 -0
  198. package/src/families/ethereum/exchange.ts +1 -1
  199. package/src/families/ethereum/modules/index.ts +1 -1
  200. package/src/families/ethereum/signOperation.ts +2 -2
  201. package/src/families/ethereum/specs.ts +5 -5
  202. package/src/families/ripple/exchange.ts +1 -1
  203. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +765 -339
  204. package/src/families/stellar/api/horizon.ts +115 -33
  205. package/src/families/stellar/api/index.ts +4 -0
  206. package/src/families/stellar/bridge/mock.ts +3 -0
  207. package/src/families/stellar/bridge.integration.test.ts +10 -2
  208. package/src/families/stellar/cli-transaction.ts +75 -2
  209. package/src/families/stellar/deviceTransactionConfig.ts +22 -0
  210. package/src/families/stellar/errors.ts +34 -0
  211. package/src/families/stellar/exchange.ts +1 -1
  212. package/src/families/stellar/js-buildTransaction.ts +56 -16
  213. package/src/families/stellar/js-createTransaction.ts +3 -0
  214. package/src/families/stellar/js-estimateMaxSpendable.ts +1 -1
  215. package/src/families/stellar/js-getTransactionStatus.ts +152 -60
  216. package/src/families/stellar/js-prepareTransaction.ts +4 -3
  217. package/src/families/stellar/js-signOperation.ts +37 -6
  218. package/src/families/stellar/js-synchronization.ts +53 -11
  219. package/src/families/stellar/logic.ts +198 -62
  220. package/src/families/stellar/specs.ts +227 -8
  221. package/src/families/stellar/speculos-deviceActions.ts +66 -22
  222. package/src/families/stellar/tokens.ts +118 -0
  223. package/src/families/stellar/transaction.ts +31 -3
  224. package/src/families/stellar/types.ts +52 -0
  225. package/src/families/tezos/exchange.ts +1 -1
  226. package/src/hw/signMessage/index.test.ts +128 -0
  227. package/src/hw/signMessage/index.ts +37 -15
  228. package/src/load/speculos.ts +1 -3
  229. package/src/mock/Btc.ts +1 -1
  230. package/src/performance.test.ts +26 -0
  231. package/src/performance.ts +61 -0
  232. package/src/platform/providers/RemoteLiveAppProvider/api/index.ts +6 -0
  233. package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +1 -32
  234. package/src/types/currencies.ts +1 -1
  235. package/src/walletconnect/Provider.tsx +4 -5
@@ -0,0 +1,26 @@
1
+ import { connectLogsToSentry, startSpan } from "./performance";
2
+
3
+ test("connectLogsToSentry", () => {
4
+ const finish = jest.fn();
5
+ const startChild = jest.fn((arg) => ({ arg, finish }));
6
+ const getSpan = jest.fn(() => ({ startChild }));
7
+ const Sentry = {
8
+ getCurrentHub: () => ({
9
+ getScope: () => ({ getSpan }),
10
+ }),
11
+ };
12
+ connectLogsToSentry(Sentry);
13
+ const span = startSpan("op", "desc", { tags: { foo: 42 } });
14
+ expect(startChild.mock.calls.length).toBe(1);
15
+ expect(startChild.mock.calls[0][0]).toMatchObject({
16
+ op: "op",
17
+ description: "desc",
18
+ tags: { foo: 42 },
19
+ });
20
+ expect(finish.mock.calls.length).toBe(0);
21
+ span.finish();
22
+ startSpan("ignored");
23
+ expect(finish.mock.calls.length).toBe(1);
24
+ span.finish();
25
+ expect(finish.mock.calls.length).toBe(1);
26
+ });
@@ -0,0 +1,61 @@
1
+ // Provide helpers to track performance spans through our internal logs
2
+ import { log, listen } from "@ledgerhq/logs";
3
+
4
+ type Unsubscribe = () => void;
5
+
6
+ export function connectLogsToSentry(Sentry: any): Unsubscribe {
7
+ let apduSpan;
8
+ const spans = {};
9
+ return listen((l) => {
10
+ if (!l) return;
11
+ if (l.type === "apdu") {
12
+ if (l.message?.startsWith("=>")) {
13
+ const t = Sentry.getCurrentHub().getScope().getSpan();
14
+ apduSpan = t?.startChild({
15
+ op: "apdu",
16
+ description: l.message.slice(0, 11),
17
+ });
18
+ } else if (l.message?.startsWith("<=")) {
19
+ apduSpan?.finish();
20
+ }
21
+ } else if (l.type === "perf-span") {
22
+ const { data } = l;
23
+ if (!data) return;
24
+ const { id, starts, span } = data;
25
+ if (starts) {
26
+ const t = Sentry.getCurrentHub().getScope().getSpan();
27
+ spans[id] = t?.startChild({ ...span, description: l.message || "" });
28
+ } else {
29
+ const span = spans[id];
30
+ span?.finish();
31
+ }
32
+ }
33
+ });
34
+ }
35
+
36
+ let idCounter = 0;
37
+ export function startSpan(
38
+ op: string,
39
+ description?: string,
40
+ rest?: {
41
+ tags?: any;
42
+ data?: any;
43
+ }
44
+ ): {
45
+ finish: () => void;
46
+ } {
47
+ let id = ++idCounter;
48
+ const span: any = { op, ...rest };
49
+ log("perf-span", description || "", {
50
+ id,
51
+ starts: true,
52
+ span,
53
+ });
54
+ return {
55
+ finish: () => {
56
+ if (!id) return;
57
+ log("perf-span", description || "", { id });
58
+ id = 0;
59
+ },
60
+ };
61
+ }
@@ -34,6 +34,12 @@ const api = {
34
34
  provider: string
35
35
  ): Promise<LiveAppManifest[]> => {
36
36
  if (getEnv("MOCK")) {
37
+ if (getEnv("MOCK_REMOTE_LIVE_MANIFEST")) {
38
+ return [
39
+ ...mockData,
40
+ ...JSON.parse(getEnv("MOCK_REMOTE_LIVE_MANIFEST")),
41
+ ] as LiveAppManifest[];
42
+ }
37
43
  return mockData as LiveAppManifest[];
38
44
  }
39
45
 
@@ -920,36 +920,5 @@
920
920
  "domains": [
921
921
  "https://*"
922
922
  ]
923
- },
924
- {
925
- "id": "dummy-live-app",
926
- "name": "Dummy Live App",
927
- "url": "http://localhost:3001",
928
- "homepageUrl": "https://developers.ledger.com/",
929
- "icon": "",
930
- "platform": "all",
931
- "apiVersion": "0.0.1",
932
- "manifestVersion": "1",
933
- "branch": "stable",
934
- "categories": [
935
- "tools"
936
- ],
937
- "currencies": "*",
938
- "content": {
939
- "shortDescription": {
940
- "en": "Dummy app for testing the Platform apps and Live SDK in E2E (Playwright) tests"
941
- },
942
- "description": {
943
- "en": "Dummy app for testing the Platform apps and Live SDK in E2E (Playwright) tests"
944
- }
945
- },
946
- "permissions": [
947
- {
948
- "method": "*"
949
- }
950
- ],
951
- "domains": [
952
- "https://*"
953
- ]
954
923
  }
955
- ]
924
+ ]
@@ -6,7 +6,7 @@ import type {
6
6
  FiatCurrency,
7
7
  Currency,
8
8
  CryptoCurrencyIds,
9
- } from "@ledgerhq/cryptoassets/lib/types";
9
+ } from "@ledgerhq/cryptoassets";
10
10
  export type {
11
11
  Unit,
12
12
  ExplorerView,
@@ -133,16 +133,14 @@ const ProviderCommon = ({
133
133
  status: STATUS.CONNECTED,
134
134
  });
135
135
  });
136
- connector.on("disconnect", () => {
137
- disconnect();
138
- });
139
- connector.on("error", (error) => {
136
+ connector.on("disconnect", () => disconnect());
137
+ connector.on("error", (error: Error) => {
140
138
  dispatch({
141
139
  status: STATUS.ERROR,
142
140
  error,
143
141
  });
144
142
  });
145
- connector.on("call_request", (error, payload) => {
143
+ connector.on("call_request", (error: Error, payload: unknown | null) => {
146
144
  if (error) {
147
145
  dispatch({
148
146
  status: STATUS.ERROR,
@@ -153,6 +151,7 @@ const ProviderCommon = ({
153
151
 
154
152
  handleCallRequest(payload);
155
153
  });
154
+
156
155
  dispatch({
157
156
  error: null,
158
157
  connector,