@ledgerhq/live-common 21.10.0 → 21.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
  2. package/lib/apps/support.d.ts.map +1 -1
  3. package/lib/apps/support.js +2 -1
  4. package/lib/apps/support.js.map +1 -1
  5. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  6. package/lib/bridge/jsHelpers.js +8 -3
  7. package/lib/bridge/jsHelpers.js.map +1 -1
  8. package/lib/bridge/react/BridgeSync.js +8 -0
  9. package/lib/bridge/react/BridgeSync.js.map +1 -1
  10. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  11. package/lib/families/bitcoin/js-synchronisation.js +2 -0
  12. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  13. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
  14. package/lib/families/bitcoin/wallet-btc/explorer/index.js +1 -3
  15. package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
  16. package/lib/families/bitcoin/wallet-btc/wallet.js +1 -1
  17. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  18. package/lib/families/cosmos/test-dataset.d.ts.map +1 -1
  19. package/lib/families/cosmos/test-dataset.js +8 -14
  20. package/lib/families/cosmos/test-dataset.js.map +1 -1
  21. package/lib/families/elrond/api/apiCalls.d.ts +1 -2
  22. package/lib/families/elrond/api/apiCalls.d.ts.map +1 -1
  23. package/lib/families/elrond/api/apiCalls.js +3 -4
  24. package/lib/families/elrond/api/apiCalls.js.map +1 -1
  25. package/lib/families/elrond/api/sdk.d.ts +1 -3
  26. package/lib/families/elrond/api/sdk.d.ts.map +1 -1
  27. package/lib/families/elrond/api/sdk.js +1 -3
  28. package/lib/families/elrond/api/sdk.js.map +1 -1
  29. package/lib/families/elrond/constants.d.ts +0 -4
  30. package/lib/families/elrond/constants.d.ts.map +1 -1
  31. package/lib/families/elrond/constants.js +1 -5
  32. package/lib/families/elrond/constants.js.map +1 -1
  33. package/lib/families/elrond/js-broadcast.d.ts.map +1 -1
  34. package/lib/families/elrond/js-broadcast.js +6 -9
  35. package/lib/families/elrond/js-broadcast.js.map +1 -1
  36. package/lib/families/elrond/js-buildTransaction.d.ts +1 -1
  37. package/lib/families/elrond/js-buildTransaction.d.ts.map +1 -1
  38. package/lib/families/elrond/js-buildTransaction.js +17 -21
  39. package/lib/families/elrond/js-buildTransaction.js.map +1 -1
  40. package/lib/families/elrond/js-estimateMaxSpendable.d.ts.map +1 -1
  41. package/lib/families/elrond/js-estimateMaxSpendable.js +1 -2
  42. package/lib/families/elrond/js-estimateMaxSpendable.js.map +1 -1
  43. package/lib/families/elrond/js-getFeesForTransaction.d.ts +1 -2
  44. package/lib/families/elrond/js-getFeesForTransaction.d.ts.map +1 -1
  45. package/lib/families/elrond/js-getFeesForTransaction.js +6 -6
  46. package/lib/families/elrond/js-getFeesForTransaction.js.map +1 -1
  47. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  48. package/lib/families/elrond/js-signOperation.js +11 -17
  49. package/lib/families/elrond/js-signOperation.js.map +1 -1
  50. package/lib/families/elrond/js-synchronisation.d.ts.map +1 -1
  51. package/lib/families/elrond/js-synchronisation.js.map +1 -1
  52. package/lib/families/elrond/js-transaction.d.ts.map +1 -1
  53. package/lib/families/elrond/js-transaction.js +1 -2
  54. package/lib/families/elrond/js-transaction.js.map +1 -1
  55. package/lib/families/elrond/logic.d.ts +0 -1
  56. package/lib/families/elrond/logic.d.ts.map +1 -1
  57. package/lib/families/elrond/logic.js +1 -20
  58. package/lib/families/elrond/logic.js.map +1 -1
  59. package/lib/families/polkadot/api/sidecar.d.ts +9 -1
  60. package/lib/families/polkadot/api/sidecar.d.ts.map +1 -1
  61. package/lib/families/polkadot/api/sidecar.js +14 -2
  62. package/lib/families/polkadot/api/sidecar.js.map +1 -1
  63. package/package.json +8 -8
  64. package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
  65. package/src/apps/support.ts +2 -1
  66. package/src/bridge/jsHelpers.ts +9 -1
  67. package/src/bridge/react/BridgeSync.tsx +10 -0
  68. package/src/families/bitcoin/js-synchronisation.ts +2 -0
  69. package/src/families/bitcoin/wallet-btc/explorer/index.ts +1 -5
  70. package/src/families/bitcoin/wallet-btc/wallet.ts +1 -1
  71. package/src/families/cosmos/test-dataset.ts +11 -16
  72. package/src/families/elrond/api/apiCalls.ts +2 -4
  73. package/src/families/elrond/api/sdk.ts +1 -3
  74. package/src/families/elrond/constants.ts +0 -4
  75. package/src/families/elrond/js-broadcast.ts +2 -5
  76. package/src/families/elrond/js-buildTransaction.ts +4 -8
  77. package/src/families/elrond/js-estimateMaxSpendable.ts +0 -1
  78. package/src/families/elrond/js-getFeesForTransaction.ts +1 -3
  79. package/src/families/elrond/js-signOperation.ts +11 -16
  80. package/src/families/elrond/js-synchronisation.ts +1 -0
  81. package/src/families/elrond/js-transaction.ts +0 -1
  82. package/src/families/elrond/logic.ts +0 -24
  83. package/src/families/polkadot/api/sidecar.ts +20 -1
  84. package/src/.DS_Store +0 -0
  85. package/src/__tests__/.DS_Store +0 -0
  86. package/src/__tests__/__snapshots__/all.libcore.ts.snap +0 -2148
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/LedgerHQ/ledger-live-common"
10
10
  },
11
- "version": "21.10.0",
11
+ "version": "21.11.0",
12
12
  "main": "lib/index.js",
13
13
  "types": "lib/index.d.ts",
14
14
  "license": "Apache-2.0",
@@ -48,7 +48,7 @@
48
48
  "@ledgerhq/devices": "6.11.0",
49
49
  "@ledgerhq/errors": "6.10.0",
50
50
  "@ledgerhq/hw-app-algorand": "6.11.0",
51
- "@ledgerhq/hw-app-btc": "6.11.0",
51
+ "@ledgerhq/hw-app-btc": "6.11.1",
52
52
  "@ledgerhq/hw-app-cosmos": "6.11.0",
53
53
  "@ledgerhq/hw-app-eth": "6.11.0",
54
54
  "@ledgerhq/hw-app-polkadot": "6.11.0",
@@ -62,8 +62,8 @@
62
62
  "@ledgerhq/json-bignumber": "^1.1.0",
63
63
  "@ledgerhq/live-app-sdk": "^0.2.0",
64
64
  "@ledgerhq/logs": "6.10.0",
65
- "@polkadot/types": "6.4.2",
66
- "@polkadot/types-known": "6.4.2",
65
+ "@polkadot/types": "6.5.2",
66
+ "@polkadot/types-known": "6.5.2",
67
67
  "@taquito/ledger-signer": "^10.2.1",
68
68
  "@taquito/taquito": "10.2.1",
69
69
  "@types/bchaddrjs": "^0.4.0",
@@ -108,7 +108,7 @@
108
108
  "performance-now": "^2.1.0",
109
109
  "prando": "^6.0.1",
110
110
  "redux": "^4.1.1",
111
- "reselect": "^4.0.0",
111
+ "reselect": "^4.1.0",
112
112
  "ripemd160": "^2.0.2",
113
113
  "ripple-binary-codec": "^1.1.3",
114
114
  "ripple-bs58check": "^2.0.2",
@@ -131,7 +131,7 @@
131
131
  "@types/cbor": "^6.0.0",
132
132
  "@types/jest": "^27.0.2",
133
133
  "@types/lodash": "^4.14.176",
134
- "@types/node": "16.11.2",
134
+ "@types/node": "16.11.6",
135
135
  "@types/object-hash": "^2.1.0",
136
136
  "@typescript-eslint/eslint-plugin": "^4.33.0",
137
137
  "@typescript-eslint/parser": "^4.33.0",
@@ -157,12 +157,12 @@
157
157
  "prettier": "2.3.2",
158
158
  "react": "17.0.2",
159
159
  "react-dom": "17.0.2",
160
- "react-redux": "7.2.5",
160
+ "react-redux": "7.2.6",
161
161
  "react-test-renderer": "^17.0.2",
162
162
  "rimraf": "^3.0.2",
163
163
  "timemachine": "^0.3.2",
164
164
  "ts-jest": "^27.0.7",
165
- "ts-node": "^10.3.0",
165
+ "ts-node": "^10.4.0",
166
166
  "typescript": "^4.4.4",
167
167
  "typescript-eslint-parser": "^22.0.0"
168
168
  }
@@ -63,7 +63,7 @@ describe("testing wallet", () => {
63
63
  fromAccount: account,
64
64
  txInfo,
65
65
  });
66
- expect(tx).toEqual("a1e3e67bfc06cc1ae259474beebc423b2890a19a");
66
+ expect(tx).toEqual("66ad13fd62ca677ae4d169ec5fe84be2f846562a");
67
67
  });
68
68
 
69
69
  it("should allow to build a transaction splitting outputs", async () => {
@@ -87,7 +87,7 @@ describe("testing wallet", () => {
87
87
  fromAccount: account,
88
88
  txInfo,
89
89
  });
90
- expect(tx).toEqual("637a8cb808fa1cd8b81a97e27b6bab94d87b899f");
90
+ expect(tx).toEqual("23ab414d38fe836e22619d6ee84fdebafa6b5168");
91
91
  });
92
92
 
93
93
  it("should throw during sync if there is an error in explorer", async () => {
@@ -29,7 +29,8 @@ export function shouldUpgrade(
29
29
  const appVersionsRequired = {
30
30
  Cosmos: ">= 2.14",
31
31
  Algorand: ">= 1.2.9",
32
- Polkadot: ">= 7.9050.0",
32
+ Polkadot: ">= 8.9100.0",
33
+ Elrond: ">= 1.0.11",
33
34
  };
34
35
  export function mustUpgrade(
35
36
  deviceModel: DeviceModelId,
@@ -369,7 +369,7 @@ export const makeScanAccounts =
369
369
  });
370
370
  derivationsCache[freshAddressPath] = res;
371
371
  }
372
- log("scanAccounts", "derivationsCache", res);
372
+
373
373
  const account = await stepAccount(
374
374
  index,
375
375
  res,
@@ -377,6 +377,14 @@ export const makeScanAccounts =
377
377
  seedIdentifier,
378
378
  transport
379
379
  );
380
+ // Bitcoin needs to compute the freshAddressPath itself,
381
+ // so we update it afterwards
382
+ if (account?.freshAddressPath) {
383
+ res.address = account.freshAddress;
384
+ derivationsCache[account.freshAddressPath] = res;
385
+ }
386
+ log("scanAccounts", "derivationsCache", res);
387
+
380
388
  log(
381
389
  "scanAccounts",
382
390
  `scanning ${currency.id} at ${freshAddressPath}: ${
@@ -103,6 +103,7 @@ function useHydrate({ accounts, hydrateCurrency }) {
103
103
  }
104
104
 
105
105
  const lastTimeAnalyticsTrackPerAccountId: Record<string, number> = {};
106
+ const lastTimeSuccessSyncPerAccountId: Record<string, number> = {};
106
107
  const nothingState = {
107
108
  pending: false,
108
109
  error: null,
@@ -160,6 +161,15 @@ function useSyncQueue({
160
161
  const account = accounts.find((a) => a.id === accountId);
161
162
  if (!account) return;
162
163
  const subAccounts: SubAccount[] = account.subAccounts || [];
164
+
165
+ if (event === "SyncSuccess") {
166
+ // Nb Only emit SyncSuccess/SyncSuccessToken event once per launch
167
+ if (lastTimeSuccessSyncPerAccountId[accountId]) {
168
+ return;
169
+ }
170
+ lastTimeSuccessSyncPerAccountId[accountId] = startSyncTime;
171
+ }
172
+
163
173
  trackAnalytics(event, {
164
174
  duration: (Date.now() - startSyncTime) / 1000,
165
175
  currencyName: account.currency.name,
@@ -342,6 +342,8 @@ const getAccountShape: GetAccountShape = async (info) => {
342
342
  spendableBalance: balance,
343
343
  operations,
344
344
  operationsCount: operations.length,
345
+ freshAddress: walletAccount.xpub.freshAddress[0],
346
+ freshAddressPath: `${accountPath}/0/${walletAccount.xpub.freshAddressIndex[0]}`,
345
347
  blockHeight,
346
348
  bitcoinResources: {
347
349
  utxos,
@@ -239,17 +239,13 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
239
239
  tx.index = address.index;
240
240
  // eslint-disable-next-line no-param-reassign
241
241
  tx.address = address.address;
242
-
243
242
  tx.outputs.forEach((output) => {
244
243
  // eslint-disable-next-line no-param-reassign
245
244
  output.output_hash = tx.hash;
246
245
  // eslint-disable-next-line no-param-reassign
247
246
  output.block_height = tx.block ? tx.block.height : null;
248
247
  // Definition of replaceable, per the standard: https://github.com/bitcoin/bips/blob/61ccc84930051e5b4a99926510d0db4a8475a4e6/bip-0125.mediawiki#summary
249
- // eslint-disable-next-line no-param-reassign
250
- output.rbf = !!(
251
- tx.inputs[0]?.sequence && tx.inputs[0].sequence < 0xffffffff
252
- );
248
+ output.rbf = tx.inputs[0] ? tx.inputs[0].sequence < 0xffffffff : false;
253
249
  });
254
250
  }
255
251
 
@@ -254,7 +254,7 @@ class BitcoinLikeWallet {
254
254
  btc.splitTransaction(i.txHex, true),
255
255
  i.output_index,
256
256
  null,
257
- null,
257
+ i.sequence,
258
258
  ]);
259
259
 
260
260
  const lastOutputIndex = txInfo.outputs.length - 1;
@@ -1,5 +1,5 @@
1
1
  import { BigNumber } from "bignumber.js";
2
- import type { DatasetTest } from "../../types";
2
+ import type { CurrenciesData, DatasetTest } from "../../types";
3
3
  import {
4
4
  InvalidAddress,
5
5
  InvalidAddressBecauseDestinationIsAlsoSource,
@@ -10,8 +10,9 @@ import { ClaimRewardsFeesWarning } from "../../errors";
10
10
  import invariant from "invariant";
11
11
  import type { Transaction } from "./types";
12
12
  import transactionTransformer from "./transaction";
13
- // eslint-disable-next-line no-unused-vars
14
- const cosmos = {
13
+
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ const cosmos: CurrenciesData<Transaction> = {
15
16
  FIXME_ignoreAccountFields: [
16
17
  "cosmosResources.unbondingBalance", // They move once all unbonding are done
17
18
  "cosmosResources.pendingRewardsBalance", // They are always movings
@@ -60,11 +61,6 @@ const cosmos = {
60
61
  spendableBalance: "2180673",
61
62
  blockHeight: 1615299,
62
63
  currencyId: "cosmos",
63
- unit: {
64
- name: "Muon",
65
- code: "MUON",
66
- magnitude: 6,
67
- },
68
64
  unitMagnitude: 6,
69
65
  operationsCount: 85,
70
66
  operations: [],
@@ -117,7 +113,8 @@ const cosmos = {
117
113
  }),
118
114
  expectedStatus: (account) => {
119
115
  const { cosmosResources } = account;
120
- invariant(cosmosResources, "Should exist because it's cosmos");
116
+ if (!cosmosResources)
117
+ throw new Error("Should exist because it's cosmos");
121
118
  const totalSpent = account.balance.minus(
122
119
  cosmosResources.unbondingBalance.plus(
123
120
  cosmosResources.delegatedBalance
@@ -147,7 +144,8 @@ const cosmos = {
147
144
  }),
148
145
  expectedStatus: (account, t) => {
149
146
  const { cosmosResources } = account;
150
- invariant(cosmosResources, "Should exist because it's cosmos");
147
+ if (!cosmosResources)
148
+ throw new Error("Should exist because it's cosmos");
151
149
  invariant(t.memo === "test", "Should have a memo");
152
150
  const totalSpent = account.balance.minus(
153
151
  cosmosResources.unbondingBalance.plus(
@@ -442,7 +440,6 @@ const cosmos = {
442
440
  lastSyncDate: "2020-06-11T07:44:10.266Z",
443
441
  balance: "1000000",
444
442
  spendableBalance: "0",
445
- balanceHistory: {},
446
443
  xpub: "cosmospub1addwnpepqd3nvwwx39pqqvw88sg409675u6wyt4wtzqyt2t0e9y4629t50cdzftxnvz",
447
444
  cosmosResources: {
448
445
  delegations: [],
@@ -457,12 +454,10 @@ const cosmos = {
457
454
  },
458
455
  ],
459
456
  };
460
- const currencies = {
461
- cosmos,
462
- };
463
457
  const dataset: DatasetTest<Transaction> = {
464
458
  implementations: ["libcore"],
465
- // FIXEM: bad any
466
- currencies: currencies as any,
459
+ currencies: {
460
+ // cosmos, // LL-7872
461
+ },
467
462
  };
468
463
  export default dataset;
@@ -1,7 +1,6 @@
1
1
  import network from "../../../network";
2
2
  import {
3
3
  HASH_TRANSACTION,
4
- RAW_TRANSACTION,
5
4
  METACHAIN_SHARD,
6
5
  TRANSACTIONS_SIZE,
7
6
  } from "../constants";
@@ -69,9 +68,8 @@ export default class ElrondApi {
69
68
  };
70
69
  }
71
70
 
72
- async submit({ operation, signature, signUsingHash }) {
71
+ async submit({ operation, signature }) {
73
72
  const { chainId, gasLimit, gasPrice } = await this.getNetworkConfig();
74
- const transactionType = signUsingHash ? HASH_TRANSACTION : RAW_TRANSACTION;
75
73
  const {
76
74
  senders: [sender],
77
75
  recipients: [receiver],
@@ -94,7 +92,7 @@ export default class ElrondApi {
94
92
  gasLimit,
95
93
  chainID: chainId,
96
94
  signature,
97
- ...transactionType,
95
+ ...HASH_TRANSACTION,
98
96
  },
99
97
  });
100
98
  return {
@@ -122,7 +122,5 @@ export const getFees = async (unsigned): Promise<BigNumber> => {
122
122
  export const broadcastTransaction = async (blob: any) => {
123
123
  const { hash } = await api.submit(blob);
124
124
  // Transaction hash is likely to be returned
125
- return {
126
- hash,
127
- };
125
+ return hash;
128
126
  };
@@ -2,9 +2,5 @@ export const HASH_TRANSACTION = {
2
2
  version: 2,
3
3
  options: 1,
4
4
  };
5
- export const RAW_TRANSACTION = {
6
- version: 1,
7
- options: 0,
8
- };
9
5
  export const METACHAIN_SHARD = 4294967295;
10
6
  export const TRANSACTIONS_SIZE = 10000;
@@ -11,14 +11,11 @@ const broadcast = async ({
11
11
  }: {
12
12
  signedOperation: SignedOperation;
13
13
  }): Promise<Operation> => {
14
- const {
15
- extra: { signUsingHash },
16
- } = operation;
17
- const { hash } = await broadcastTransaction({
14
+ const hash = await broadcastTransaction({
18
15
  operation,
19
16
  signature,
20
- signUsingHash,
21
17
  });
18
+
22
19
  return patchOperationWithHash(operation, hash);
23
20
  };
24
21
 
@@ -2,7 +2,7 @@ import type { Transaction } from "./types";
2
2
  import type { Account } from "../../types";
3
3
  import { getNonce } from "./logic";
4
4
  import { getNetworkConfig } from "./api";
5
- import { HASH_TRANSACTION, RAW_TRANSACTION } from "./constants";
5
+ import { HASH_TRANSACTION } from "./constants";
6
6
  import BigNumber from "bignumber.js";
7
7
 
8
8
  /**
@@ -10,15 +10,11 @@ import BigNumber from "bignumber.js";
10
10
  * @param {Account} a
11
11
  * @param {Transaction} t
12
12
  */
13
- export const buildTransaction = async (
14
- a: Account,
15
- t: Transaction,
16
- signUsingHash = true
17
- ) => {
13
+ export const buildTransaction = async (a: Account, t: Transaction) => {
18
14
  const address = a.freshAddress;
19
15
  const nonce = getNonce(a);
20
16
  const { gasPrice, gasLimit, chainId } = await getNetworkConfig();
21
- const transactionType = signUsingHash ? HASH_TRANSACTION : RAW_TRANSACTION;
17
+
22
18
  const unsigned = {
23
19
  nonce,
24
20
  value: t.useAllAmount
@@ -29,7 +25,7 @@ export const buildTransaction = async (
29
25
  gasPrice,
30
26
  gasLimit,
31
27
  chainID: chainId,
32
- ...transactionType,
28
+ ...HASH_TRANSACTION,
33
29
  };
34
30
  // Will likely be a call to Elrond SDK
35
31
  return JSON.stringify(unsigned);
@@ -28,7 +28,6 @@ const estimateMaxSpendable = async ({
28
28
  const fees = await getEstimatedFees({
29
29
  a,
30
30
  t,
31
- signUsingHash: true,
32
31
  });
33
32
 
34
33
  if (fees.gt(a.spendableBalance)) {
@@ -13,13 +13,11 @@ import { buildTransaction } from "./js-buildTransaction";
13
13
  const getEstimatedFees = async ({
14
14
  a,
15
15
  t,
16
- signUsingHash = true,
17
16
  }: {
18
17
  a: Account;
19
18
  t: Transaction;
20
- signUsingHash: boolean | undefined;
21
19
  }): Promise<BigNumber> => {
22
- const unsigned = await buildTransaction(a, t, signUsingHash);
20
+ const unsigned = await buildTransaction(a, t);
23
21
  return await getFees(JSON.parse(unsigned));
24
22
  };
25
23
 
@@ -7,13 +7,12 @@ import { open, close } from "../../hw";
7
7
  import { encodeOperationId } from "../../operation";
8
8
  import Elrond from "./hw-app-elrond";
9
9
  import { buildTransaction } from "./js-buildTransaction";
10
- import { getNonce, compareVersions } from "./logic";
10
+ import { getNonce } from "./logic";
11
11
 
12
12
  const buildOptimisticOperation = (
13
13
  account: Account,
14
14
  transaction: Transaction,
15
- fee: BigNumber,
16
- signUsingHash: boolean
15
+ fee: BigNumber
17
16
  ): Operation => {
18
17
  const type = "OUT";
19
18
  const value = new BigNumber(transaction.amount);
@@ -30,9 +29,7 @@ const buildOptimisticOperation = (
30
29
  accountId: account.id,
31
30
  transactionSequenceNumber: getNonce(account),
32
31
  date: new Date(),
33
- extra: {
34
- signUsingHash,
35
- },
32
+ extra: {},
36
33
  };
37
34
  return operation;
38
35
  };
@@ -60,29 +57,27 @@ const signOperation = ({
60
57
 
61
58
  const elrond = new Elrond(transport);
62
59
  await elrond.setAddress(account.freshAddressPath);
63
- const { version } = await elrond.getAppConfiguration();
64
- const signUsingHash = compareVersions(version, "1.0.11") >= 0;
65
- const unsigned = await buildTransaction(
66
- account,
67
- transaction,
68
- signUsingHash
69
- );
60
+
61
+ const unsigned = await buildTransaction(account, transaction);
62
+
70
63
  o.next({
71
64
  type: "device-signature-requested",
72
65
  });
66
+
73
67
  const r = await elrond.signTransaction(
74
68
  account.freshAddressPath,
75
69
  unsigned,
76
- signUsingHash
70
+ true
77
71
  );
72
+
78
73
  o.next({
79
74
  type: "device-signature-granted",
80
75
  });
76
+
81
77
  const operation = buildOptimisticOperation(
82
78
  account,
83
79
  transaction,
84
- transaction.fees ?? new BigNumber(0),
85
- signUsingHash
80
+ transaction.fees ?? new BigNumber(0)
86
81
  );
87
82
  o.next({
88
83
  type: "signed",
@@ -32,6 +32,7 @@ const getAccountShape: GetAccountShape = async (info) => {
32
32
  nonce,
33
33
  },
34
34
  };
35
+
35
36
  return { ...shape, operations };
36
37
  };
37
38
 
@@ -46,7 +46,6 @@ export const prepareTransaction = async (a: Account, t: Transaction) => {
46
46
  fees = await getEstimatedFees({
47
47
  a,
48
48
  t,
49
- signUsingHash: true,
50
49
  });
51
50
 
52
51
  if (!sameFees(t.fees, fees)) {
@@ -12,30 +12,6 @@ const HRP = "erd";
12
12
  */
13
13
  const PUBKEY_LENGTH = 32;
14
14
 
15
- export const compareVersions = (versionA: string, versionB: string): number => {
16
- let i, diff;
17
- const regExStrip0 = /(\.0+)+$/;
18
- const segmentsA = versionA.replace(regExStrip0, "").split(".");
19
- const segmentsB = versionB.replace(regExStrip0, "").split(".");
20
- const minVersionLength = Math.min(segmentsA.length, segmentsB.length);
21
-
22
- for (i = 0; i < minVersionLength; i++) {
23
- diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
24
-
25
- if (diff == 0) {
26
- continue;
27
- }
28
-
29
- if (diff < 0) {
30
- return -1;
31
- }
32
-
33
- return 1;
34
- }
35
-
36
- return segmentsA.length - segmentsB.length;
37
- };
38
-
39
15
  function fromBech32(value: string): string {
40
16
  let decoded;
41
17
 
@@ -657,7 +657,7 @@ export const getRegistry = async (): Promise<{
657
657
  extrinsics: Extrinsics;
658
658
  }> => {
659
659
  const [material, spec] = await Promise.all([
660
- fetchTransactionMaterial(true),
660
+ getTransactionMaterialWithMetadata(),
661
661
  fetchChainSpec(),
662
662
  ]);
663
663
  const registry: any = new TypeRegistry();
@@ -710,3 +710,22 @@ export const getConstants: CacheRes<
710
710
  maxAge: 60 * 60 * 1000, // 1 hour
711
711
  }
712
712
  );
713
+
714
+ /**
715
+ * Cache the fetchTransactionMaterial(true) to avoid too many calls
716
+ *
717
+ * @async
718
+ *
719
+ * @returns {Promise<Object>} consts
720
+ */
721
+ export const getTransactionMaterialWithMetadata: CacheRes<
722
+ Array<void>,
723
+ SidecarTransactionMaterial
724
+ > = makeLRUCache(
725
+ async (): Promise<SidecarTransactionMaterial> =>
726
+ fetchTransactionMaterial(true),
727
+ () => "polkadot",
728
+ {
729
+ maxAge: 60 * 60 * 1000, // 1 hour - could be Infinity
730
+ }
731
+ );
package/src/.DS_Store DELETED
Binary file
Binary file