@ledgerhq/live-common 21.32.1 → 21.32.5

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 (166) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +1 -0
  2. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js.map +1 -1
  3. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.d.ts +2 -0
  4. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.d.ts.map +1 -0
  5. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js +126 -0
  6. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.js.map +1 -0
  7. package/lib/apps/hw.d.ts.map +1 -1
  8. package/lib/apps/hw.js +4 -3
  9. package/lib/apps/hw.js.map +1 -1
  10. package/lib/apps/logic.d.ts.map +1 -1
  11. package/lib/apps/logic.js +7 -5
  12. package/lib/apps/logic.js.map +1 -1
  13. package/lib/bot/engine.d.ts.map +1 -1
  14. package/lib/bot/engine.js +3 -0
  15. package/lib/bot/engine.js.map +1 -1
  16. package/lib/env.d.ts +10 -5
  17. package/lib/env.d.ts.map +1 -1
  18. package/lib/env.js +5 -0
  19. package/lib/env.js.map +1 -1
  20. package/lib/env.react.d.ts +1 -1
  21. package/lib/env.react.d.ts.map +1 -1
  22. package/lib/errors.d.ts +3 -0
  23. package/lib/errors.d.ts.map +1 -1
  24. package/lib/errors.js +3 -2
  25. package/lib/errors.js.map +1 -1
  26. package/lib/exchange/platform/transfer/index.d.ts.map +1 -1
  27. package/lib/exchange/platform/transfer/index.js +15 -1
  28. package/lib/exchange/platform/transfer/index.js.map +1 -1
  29. package/lib/families/algorand/buildTransaction.d.ts +2 -2
  30. package/lib/families/algorand/buildTransaction.d.ts.map +1 -1
  31. package/lib/families/algorand/buildTransaction.js +13 -19
  32. package/lib/families/algorand/buildTransaction.js.map +1 -1
  33. package/lib/families/algorand/js-getFeesForTransaction.js +4 -6
  34. package/lib/families/algorand/js-getFeesForTransaction.js.map +1 -1
  35. package/lib/families/algorand/js-signOperation.js +3 -7
  36. package/lib/families/algorand/js-signOperation.js.map +1 -1
  37. package/lib/families/algorand/js-synchronization.d.ts.map +1 -1
  38. package/lib/families/algorand/js-synchronization.js +1 -0
  39. package/lib/families/algorand/js-synchronization.js.map +1 -1
  40. package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
  41. package/lib/families/bitcoin/js-signOperation.js +3 -5
  42. package/lib/families/bitcoin/js-signOperation.js.map +1 -1
  43. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +4 -3
  44. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  45. package/lib/families/bitcoin/wallet-btc/crypto/base.js +8 -7
  46. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  47. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +2 -2
  48. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -1
  49. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts +1 -1
  50. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
  51. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +3 -7
  52. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
  53. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +3 -4
  54. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
  55. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +27 -53
  56. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  57. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts +1 -1
  58. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  59. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +2 -7
  60. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  61. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts +1 -6
  62. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts.map +1 -1
  63. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js +0 -51
  64. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js.map +1 -1
  65. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +1 -0
  66. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
  67. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +5 -6
  68. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
  69. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +63 -33
  70. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  71. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +3 -5
  72. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
  73. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +77 -46
  74. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  75. package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
  76. package/lib/families/celo/speculos-deviceActions.js +1 -2
  77. package/lib/families/celo/speculos-deviceActions.js.map +1 -1
  78. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  79. package/lib/families/ethereum/signOperation.js +26 -15
  80. package/lib/families/ethereum/signOperation.js.map +1 -1
  81. package/lib/families/ethereum/specs.d.ts.map +1 -1
  82. package/lib/families/ethereum/specs.js +2 -4
  83. package/lib/families/ethereum/specs.js.map +1 -1
  84. package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
  85. package/lib/families/ethereum/speculos-deviceActions.js +4 -0
  86. package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
  87. package/lib/families/ethereum/transaction.d.ts +4 -1
  88. package/lib/families/ethereum/transaction.d.ts.map +1 -1
  89. package/lib/families/ethereum/transaction.js +15 -27
  90. package/lib/families/ethereum/transaction.js.map +1 -1
  91. package/lib/families/solana/api/chain/instruction/token/types.d.ts +1 -1
  92. package/lib/families/solana/test-dataset.d.ts.map +1 -1
  93. package/lib/families/solana/test-dataset.js +1 -2
  94. package/lib/families/solana/test-dataset.js.map +1 -1
  95. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  96. package/lib/families/tezos/bridge/js.js +2 -1
  97. package/lib/families/tezos/bridge/js.js.map +1 -1
  98. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  99. package/lib/families/tezos/synchronisation.js +2 -0
  100. package/lib/families/tezos/synchronisation.js.map +1 -1
  101. package/lib/families/tron/synchronisation.test.js +1 -0
  102. package/lib/families/tron/synchronisation.test.js.map +1 -1
  103. package/lib/featureFlags/FeatureToggle.js +2 -2
  104. package/lib/featureFlags/FeatureToggle.js.map +1 -1
  105. package/lib/featureFlags/defaultFeatures.js +1 -1
  106. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  107. package/lib/featureFlags/types.d.ts +1 -1
  108. package/lib/featureFlags/types.d.ts.map +1 -1
  109. package/lib/load/speculos.d.ts +7 -0
  110. package/lib/load/speculos.d.ts.map +1 -1
  111. package/lib/load/speculos.js +27 -11
  112. package/lib/load/speculos.js.map +1 -1
  113. package/lib/platform/PlatformAppProvider/helpers.d.ts +1 -0
  114. package/lib/platform/PlatformAppProvider/helpers.d.ts.map +1 -1
  115. package/lib/platform/PlatformAppProvider/helpers.js +23 -1
  116. package/lib/platform/PlatformAppProvider/helpers.js.map +1 -1
  117. package/lib/platform/PlatformAppProvider/index.d.ts.map +1 -1
  118. package/lib/platform/PlatformAppProvider/index.js +2 -1
  119. package/lib/platform/PlatformAppProvider/index.js.map +1 -1
  120. package/lib/types/manager.d.ts +4 -3
  121. package/lib/types/manager.d.ts.map +1 -1
  122. package/lib/types/manager.js +4 -3
  123. package/lib/types/manager.js.map +1 -1
  124. package/package.json +21 -21
  125. package/src/.DS_Store +0 -0
  126. package/src/__tests__/__snapshots__/all.libcore.ts.snap +109 -23
  127. package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -0
  128. package/src/__tests__/families/bitcoin/wallet-btc/xpub.getAddress.ts +78 -0
  129. package/src/apps/hw.ts +4 -3
  130. package/src/apps/logic.ts +6 -3
  131. package/src/bot/engine.ts +3 -0
  132. package/src/{__tests__ → data/flags}/.DS_Store +0 -0
  133. package/src/env.ts +5 -0
  134. package/src/errors.ts +3 -0
  135. package/src/exchange/platform/transfer/index.ts +21 -1
  136. package/src/families/algorand/buildTransaction.ts +4 -8
  137. package/src/families/algorand/js-getFeesForTransaction.ts +1 -1
  138. package/src/families/algorand/js-signOperation.ts +2 -2
  139. package/src/families/algorand/js-synchronization.ts +1 -0
  140. package/src/families/bitcoin/js-signOperation.ts +3 -5
  141. package/src/families/bitcoin/wallet-btc/crypto/base.ts +31 -18
  142. package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +2 -2
  143. package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +3 -17
  144. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +5 -39
  145. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +2 -15
  146. package/src/families/bitcoin/wallet-btc/crypto/litecoin.ts +1 -71
  147. package/src/families/bitcoin/wallet-btc/crypto/types.ts +7 -0
  148. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +23 -41
  149. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +30 -49
  150. package/src/families/celo/speculos-deviceActions.ts +0 -1
  151. package/src/families/ethereum/signOperation.ts +21 -20
  152. package/src/families/ethereum/specs.ts +0 -2
  153. package/src/families/ethereum/speculos-deviceActions.ts +4 -0
  154. package/src/families/ethereum/transaction.ts +10 -24
  155. package/src/families/solana/test-dataset.ts +3 -4
  156. package/src/families/tezos/bridge/js.ts +6 -1
  157. package/src/families/tezos/synchronisation.ts +2 -0
  158. package/src/families/tron/synchronisation.test.ts +2 -0
  159. package/src/featureFlags/FeatureToggle.tsx +2 -2
  160. package/src/featureFlags/defaultFeatures.ts +1 -1
  161. package/src/featureFlags/types.ts +1 -1
  162. package/src/load/speculos.ts +23 -10
  163. package/src/platform/PlatformAppProvider/helpers.ts +29 -0
  164. package/src/platform/PlatformAppProvider/index.tsx +3 -2
  165. package/src/types/manager.ts +4 -3
  166. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +0 -6195
@@ -6,8 +6,8 @@ import type {
6
6
  TransactionRaw,
7
7
  EthereumGasLimitRequest,
8
8
  } from "./types";
9
- import Common from "ethereumjs-common";
10
- import { Transaction as EthereumTx } from "ethereumjs-tx";
9
+ import Common from "@ethereumjs/common";
10
+ import { Transaction as EthereumTx } from "@ethereumjs/tx";
11
11
  import eip55 from "eip55";
12
12
  import {
13
13
  InvalidAddress,
@@ -196,23 +196,18 @@ function getEthereumjsTxCommon(currency) {
196
196
  `currency ${currency.id} did not set ethereumLikeInfo`
197
197
  );
198
198
  if (ethereumLikeInfo.chainId === 1) {
199
- return new Common(
200
- // $FlowFixMe
201
- ethereumLikeInfo.baseChain || "mainnet",
202
- // $FlowFixMe
203
- ethereumLikeInfo.hardfork || "petersburg"
204
- );
199
+ return new Common({
200
+ chain: ethereumLikeInfo.baseChain || "mainnet",
201
+ hardfork: ethereumLikeInfo.hardfork || "petersburg",
202
+ });
205
203
  }
206
204
  return Common.forCustomChain(
207
- // $FlowFixMe
208
205
  ethereumLikeInfo.baseChain || "mainnet",
209
206
  {
210
207
  name: currency.ticker,
211
208
  chainId: ethereumLikeInfo.chainId,
212
- // $FlowFixMe
213
209
  networkId: ethereumLikeInfo.networkId || ethereumLikeInfo.chainId,
214
210
  },
215
- // $FlowFixMe
216
211
  ethereumLikeInfo.hardfork || "petersburg"
217
212
  );
218
213
  }
@@ -239,8 +234,6 @@ export function buildEthereumTx(
239
234
  "only token accounts expected"
240
235
  );
241
236
  const common = getEthereumjsTxCommon(currency);
242
- invariant(common, `common not found for currency ${currency.name}`);
243
- // FIXME: make sure it doesn't break
244
237
  if (!common) {
245
238
  throw new Error(`common not found for currency ${currency.name}`);
246
239
  }
@@ -258,18 +251,11 @@ export function buildEthereumTx(
258
251
  ethTxObject
259
252
  );
260
253
  log("ethereum", "buildEthereumTx", ethTxObject);
261
- const tx = new EthereumTx(ethTxObject, {
262
- common,
263
- });
264
- // these will be filled by device signature
265
- tx.raw[6] = Buffer.from([common.chainId()]); // v
266
-
267
- tx.raw[7] = Buffer.from([]); // r
268
-
269
- tx.raw[8] = Buffer.from([]); // s
270
-
254
+ const tx = new EthereumTx(ethTxObject, { common });
271
255
  return {
272
256
  tx,
257
+ common,
258
+ ethTxObject,
273
259
  fillTransactionDataResult,
274
260
  };
275
261
  }
@@ -294,7 +280,7 @@ export function inferEthereumGasLimitRequest(
294
280
  }
295
281
 
296
282
  if (to) {
297
- r.to = "0x" + to.toString("hex");
283
+ r.to = to.toString();
298
284
  }
299
285
 
300
286
  if (data) {
@@ -1,5 +1,5 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { DatasetTest, encodeAccountId } from "../../types";
2
+ import { CurrenciesData, DatasetTest, encodeAccountId } from "../../types";
3
3
 
4
4
  import { Transaction, TransactionModel } from "./types";
5
5
 
@@ -75,8 +75,7 @@ const fees = (signatureCount: number) =>
75
75
 
76
76
  const zero = new BigNumber(0);
77
77
 
78
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
- const solana = {
78
+ const solana: CurrenciesData<Transaction> = {
80
79
  scanAccounts: [scanAccounts1],
81
80
  accounts: [
82
81
  {
@@ -438,7 +437,7 @@ const solana = {
438
437
  const dataset: DatasetTest<Transaction> = {
439
438
  implementations: [getEnv("MOCK") ? "mock" : "js"], // FIXME we should actually put both mock and js like other dataset do
440
439
  currencies: {
441
- // solana, // TODO re enable when it's ready
440
+ solana,
442
441
  },
443
442
  };
444
443
 
@@ -1,6 +1,10 @@
1
1
  // @flow
2
2
  import { BigNumber } from "bignumber.js";
3
- import { TezosToolkit, DEFAULT_FEE } from "@taquito/taquito";
3
+ import {
4
+ TezosToolkit,
5
+ DEFAULT_FEE,
6
+ DEFAULT_STORAGE_LIMIT,
7
+ } from "@taquito/taquito";
4
8
  import {
5
9
  AmountRequired,
6
10
  NotEnoughBalance,
@@ -201,6 +205,7 @@ const prepareTransaction = async (
201
205
  mutez: true,
202
206
  to: transaction.recipient,
203
207
  amount: amount.toNumber(),
208
+ storageLimit: DEFAULT_STORAGE_LIMIT.ORIGINATION, // https://github.com/TezTech/eztz/blob/master/PROTO_003_FEES.md for originating an account
204
209
  });
205
210
  break;
206
211
  case "delegate":
@@ -74,6 +74,7 @@ export const getAccountShape: GetAccountShape = async (infoInput) => {
74
74
  if (apiAccount.type === "empty") {
75
75
  return {
76
76
  id: accountId,
77
+ xpub: address,
77
78
  blockHeight,
78
79
  lastSyncDate: new Date(),
79
80
  tezosResources: {
@@ -110,6 +111,7 @@ export const getAccountShape: GetAccountShape = async (infoInput) => {
110
111
 
111
112
  const accountShape = {
112
113
  id: accountId,
114
+ xpub: address,
113
115
  operations,
114
116
  balance,
115
117
  subAccounts,
@@ -6,6 +6,8 @@ import { defaultTronResources } from "./utils";
6
6
  import bridge from "./bridge/js";
7
7
  import { Account } from "../../types";
8
8
 
9
+ jest.setTimeout(30000);
10
+
9
11
  const tron = getCryptoCurrencyById("tron");
10
12
  const defaultSyncConfig = {
11
13
  paginationConfig: {},
@@ -17,8 +17,8 @@ export const FeatureToggle = ({
17
17
  const feature = useFeature(featureId);
18
18
 
19
19
  if (!feature || !feature.enabled) {
20
- return fallback;
20
+ return fallback ?? null;
21
21
  }
22
22
 
23
- return children;
23
+ return children ?? null;
24
24
  };
@@ -1,7 +1,7 @@
1
1
  import { DefaultFeatures } from "./types";
2
2
 
3
3
  export const defaultFeatures: DefaultFeatures = {
4
- market: {
4
+ learn: {
5
5
  enabled: false,
6
6
  },
7
7
  };
@@ -1,4 +1,4 @@
1
- export type FeatureId = "market"; // Add others with union
1
+ export type FeatureId = "learn"; // Add others with union (e.g. "learn" | "market" | "foo")
2
2
 
3
3
  // We use objects instead of direct booleans for potential future improvements
4
4
  // like feature versioning etc
@@ -412,7 +412,13 @@ function parseAppSearch(query: string):
412
412
  };
413
413
  }
414
414
 
415
- async function openImplicitSpeculos(query: string) {
415
+ export async function createImplicitSpeculos(query: string): Promise<{
416
+ device: {
417
+ transport: SpeculosTransport;
418
+ id: string;
419
+ };
420
+ appCandidate: AppCandidate;
421
+ } | null> {
416
422
  const coinapps = getEnv("COINAPPS");
417
423
  invariant(coinapps, "COINAPPS folder is missing!");
418
424
  const seed = getEnv("SEED");
@@ -438,16 +444,23 @@ async function openImplicitSpeculos(query: string) {
438
444
  "speculos",
439
445
  "using app " + formatAppCandidate(appCandidate as AppCandidate)
440
446
  );
441
- const device = appCandidate
442
- ? await createSpeculosDevice({
443
- ...appCandidate,
444
- coinapps,
445
- appName,
446
- dependency,
447
- seed,
448
- })
447
+ return appCandidate
448
+ ? {
449
+ device: await createSpeculosDevice({
450
+ ...appCandidate,
451
+ coinapps,
452
+ appName,
453
+ dependency,
454
+ seed,
455
+ }),
456
+ appCandidate,
457
+ }
449
458
  : null;
450
- return device?.transport;
459
+ }
460
+
461
+ async function openImplicitSpeculos(query: string) {
462
+ const r = await createImplicitSpeculos(query);
463
+ return r?.device.transport;
451
464
  }
452
465
 
453
466
  registerTransportModule({
@@ -6,6 +6,7 @@ export type FilterParams = {
6
6
  private?: boolean;
7
7
  version?: string;
8
8
  };
9
+ import { getEnv } from "../../env";
9
10
 
10
11
  function matchVersion(filterParams: FilterParams, manifest: AppManifest) {
11
12
  return (
@@ -52,3 +53,31 @@ export function mergeManifestLists(
52
53
  const newIds = new Set(list2.map((elem) => elem.id));
53
54
  return [...list1.filter((elem) => !newIds.has(elem.id)), ...list2];
54
55
  }
56
+
57
+ export const initializeLocalManifest = (): Map<string, AppManifest> => {
58
+ const localManifestJsonRaw: string | null | undefined = getEnv(
59
+ "PLATFORM_LOCAL_MANIFEST_JSON"
60
+ );
61
+
62
+ if (!localManifestJsonRaw) {
63
+ return new Map();
64
+ }
65
+
66
+ try {
67
+ const manifest: AppManifest | [AppManifest] =
68
+ JSON.parse(localManifestJsonRaw);
69
+
70
+ const manifestArray = Array.isArray(manifest) ? manifest : [manifest];
71
+
72
+ const map = new Map(manifestArray.map((m) => [m.id, m]));
73
+
74
+ return map;
75
+ } catch (error) {
76
+ /**
77
+ * Probable error during `JSON.parse` call, log error and return empty map
78
+ * as if env variable was not defined
79
+ */
80
+ console.error(error);
81
+ return new Map();
82
+ }
83
+ };
@@ -9,11 +9,12 @@ import React, {
9
9
  import type { PlatformAppContextType, Props, State } from "./types";
10
10
  import api from "./api";
11
11
  import type { AppManifest } from "../types";
12
+ import { initializeLocalManifest } from "./helpers";
12
13
 
13
14
  // @ts-expect-error empty object creates an error
14
15
  const PlatformAppContext = createContext<PlatformAppContextType>({});
15
16
  const initialState: State = {
16
- localManifests: new Map(),
17
+ localManifests: initializeLocalManifest(),
17
18
  remoteManifests: new Map(),
18
19
  isLoading: false,
19
20
  lastUpdateTime: undefined,
@@ -28,7 +29,7 @@ export function PlatformAppProvider({
28
29
  autoUpdateDelay,
29
30
  platformAppsServerURL,
30
31
  children,
31
- }: Props) {
32
+ }: Props): JSX.Element {
32
33
  const [state, setState] = useState<State>(initialState);
33
34
 
34
35
  const addLocalManifest = useCallback((manifest: AppManifest) => {
@@ -155,9 +155,10 @@ export type Application = {
155
155
  compatibleWalletsJSON: string | null | undefined;
156
156
  };
157
157
  export enum AppType {
158
- APP = "app",
159
- PLUGIN = "plugin",
160
- TOOL = "tool", // Nb not used for now
158
+ app = "app",
159
+ plugin = "plugin",
160
+ tool = "tool",
161
+ swap = "swap",
161
162
  }
162
163
  // App is higher level on top of Application and ApplicationVersion
163
164
  // with all fields Live needs and in normalized form (but still serializable)