@ledgerhq/live-common 21.10.0 → 21.13.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 (155) hide show
  1. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
  2. package/lib/api/explorerConfig/index.d.ts.map +1 -1
  3. package/lib/api/explorerConfig/index.js +7 -8
  4. package/lib/api/explorerConfig/index.js.map +1 -1
  5. package/lib/apps/support.d.ts.map +1 -1
  6. package/lib/apps/support.js +2 -1
  7. package/lib/apps/support.js.map +1 -1
  8. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  9. package/lib/bridge/jsHelpers.js +8 -3
  10. package/lib/bridge/jsHelpers.js.map +1 -1
  11. package/lib/bridge/react/BridgeSync.js +8 -0
  12. package/lib/bridge/react/BridgeSync.js.map +1 -1
  13. package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +1 -1
  14. package/lib/families/bitcoin/js-prepareTransaction.js +0 -3
  15. package/lib/families/bitcoin/js-prepareTransaction.js.map +1 -1
  16. package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
  17. package/lib/families/bitcoin/js-signOperation.js +3 -1
  18. package/lib/families/bitcoin/js-signOperation.js.map +1 -1
  19. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  20. package/lib/families/bitcoin/js-synchronisation.js +2 -0
  21. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  22. package/lib/families/bitcoin/specs.js +2 -1
  23. package/lib/families/bitcoin/specs.js.map +1 -1
  24. package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
  25. package/lib/families/bitcoin/speculos-deviceActions.js +4 -0
  26. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  27. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +1 -1
  28. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
  29. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts +2 -2
  30. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
  31. package/lib/families/bitcoin/wallet-btc/explorer/index.js +1 -3
  32. package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
  33. package/lib/families/bitcoin/wallet-btc/index.d.ts.map +1 -1
  34. package/lib/families/bitcoin/wallet-btc/index.js +3 -0
  35. package/lib/families/bitcoin/wallet-btc/index.js.map +1 -1
  36. package/lib/families/bitcoin/wallet-btc/storage/index.js +10 -10
  37. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  38. package/lib/families/bitcoin/wallet-btc/wallet.d.ts +1 -0
  39. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  40. package/lib/families/bitcoin/wallet-btc/wallet.js +18 -8
  41. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  42. package/lib/families/cosmos/test-dataset.d.ts.map +1 -1
  43. package/lib/families/cosmos/test-dataset.js +8 -14
  44. package/lib/families/cosmos/test-dataset.js.map +1 -1
  45. package/lib/families/crypto_org/api/sdk.d.ts.map +1 -1
  46. package/lib/families/crypto_org/api/sdk.js +6 -4
  47. package/lib/families/crypto_org/api/sdk.js.map +1 -1
  48. package/lib/families/crypto_org/cli-transaction.d.ts.map +1 -1
  49. package/lib/families/crypto_org/cli-transaction.js +6 -1
  50. package/lib/families/crypto_org/cli-transaction.js.map +1 -1
  51. package/lib/families/crypto_org/js-buildTransaction.d.ts.map +1 -1
  52. package/lib/families/crypto_org/js-buildTransaction.js +4 -1
  53. package/lib/families/crypto_org/js-buildTransaction.js.map +1 -1
  54. package/lib/families/crypto_org/js-transaction.d.ts +1 -0
  55. package/lib/families/crypto_org/js-transaction.d.ts.map +1 -1
  56. package/lib/families/crypto_org/js-transaction.js +9 -4
  57. package/lib/families/crypto_org/js-transaction.js.map +1 -1
  58. package/lib/families/crypto_org/transaction.d.ts +2 -2
  59. package/lib/families/crypto_org/transaction.d.ts.map +1 -1
  60. package/lib/families/crypto_org/transaction.js +4 -4
  61. package/lib/families/crypto_org/transaction.js.map +1 -1
  62. package/lib/families/crypto_org/types.d.ts +2 -0
  63. package/lib/families/crypto_org/types.d.ts.map +1 -1
  64. package/lib/families/crypto_org/types.js.map +1 -1
  65. package/lib/families/elrond/api/apiCalls.d.ts +1 -2
  66. package/lib/families/elrond/api/apiCalls.d.ts.map +1 -1
  67. package/lib/families/elrond/api/apiCalls.js +3 -4
  68. package/lib/families/elrond/api/apiCalls.js.map +1 -1
  69. package/lib/families/elrond/api/sdk.d.ts +1 -3
  70. package/lib/families/elrond/api/sdk.d.ts.map +1 -1
  71. package/lib/families/elrond/api/sdk.js +1 -3
  72. package/lib/families/elrond/api/sdk.js.map +1 -1
  73. package/lib/families/elrond/constants.d.ts +0 -4
  74. package/lib/families/elrond/constants.d.ts.map +1 -1
  75. package/lib/families/elrond/constants.js +1 -5
  76. package/lib/families/elrond/constants.js.map +1 -1
  77. package/lib/families/elrond/js-broadcast.d.ts.map +1 -1
  78. package/lib/families/elrond/js-broadcast.js +6 -9
  79. package/lib/families/elrond/js-broadcast.js.map +1 -1
  80. package/lib/families/elrond/js-buildTransaction.d.ts +1 -1
  81. package/lib/families/elrond/js-buildTransaction.d.ts.map +1 -1
  82. package/lib/families/elrond/js-buildTransaction.js +17 -21
  83. package/lib/families/elrond/js-buildTransaction.js.map +1 -1
  84. package/lib/families/elrond/js-estimateMaxSpendable.d.ts.map +1 -1
  85. package/lib/families/elrond/js-estimateMaxSpendable.js +1 -2
  86. package/lib/families/elrond/js-estimateMaxSpendable.js.map +1 -1
  87. package/lib/families/elrond/js-getFeesForTransaction.d.ts +1 -2
  88. package/lib/families/elrond/js-getFeesForTransaction.d.ts.map +1 -1
  89. package/lib/families/elrond/js-getFeesForTransaction.js +6 -6
  90. package/lib/families/elrond/js-getFeesForTransaction.js.map +1 -1
  91. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  92. package/lib/families/elrond/js-signOperation.js +11 -17
  93. package/lib/families/elrond/js-signOperation.js.map +1 -1
  94. package/lib/families/elrond/js-synchronisation.d.ts.map +1 -1
  95. package/lib/families/elrond/js-synchronisation.js.map +1 -1
  96. package/lib/families/elrond/js-transaction.d.ts.map +1 -1
  97. package/lib/families/elrond/js-transaction.js +1 -2
  98. package/lib/families/elrond/js-transaction.js.map +1 -1
  99. package/lib/families/elrond/logic.d.ts +0 -1
  100. package/lib/families/elrond/logic.d.ts.map +1 -1
  101. package/lib/families/elrond/logic.js +1 -20
  102. package/lib/families/elrond/logic.js.map +1 -1
  103. package/lib/families/elrond/test-dataset.js +2 -2
  104. package/lib/families/elrond/test-dataset.js.map +1 -1
  105. package/lib/families/polkadot/api/sidecar.d.ts +9 -1
  106. package/lib/families/polkadot/api/sidecar.d.ts.map +1 -1
  107. package/lib/families/polkadot/api/sidecar.js +14 -2
  108. package/lib/families/polkadot/api/sidecar.js.map +1 -1
  109. package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
  110. package/lib/families/tezos/bakers.whitelist-default.js +1 -1
  111. package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
  112. package/lib/generated/transaction.d.ts +1 -1
  113. package/lib/reconciliation.d.ts.map +1 -1
  114. package/lib/reconciliation.js +3 -1
  115. package/lib/reconciliation.js.map +1 -1
  116. package/package.json +25 -25
  117. package/src/__tests__/__snapshots__/all.libcore.ts.snap +180523 -1210
  118. package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
  119. package/src/api/explorerConfig/index.ts +7 -8
  120. package/src/apps/support.ts +2 -1
  121. package/src/bridge/jsHelpers.ts +9 -1
  122. package/src/bridge/react/BridgeSync.tsx +10 -0
  123. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +229 -2
  124. package/src/families/bitcoin/js-prepareTransaction.ts +0 -2
  125. package/src/families/bitcoin/js-signOperation.ts +3 -0
  126. package/src/families/bitcoin/js-synchronisation.ts +2 -0
  127. package/src/families/bitcoin/specs.ts +1 -1
  128. package/src/families/bitcoin/speculos-deviceActions.ts +4 -0
  129. package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +1 -1
  130. package/src/families/bitcoin/wallet-btc/explorer/index.ts +1 -5
  131. package/src/families/bitcoin/wallet-btc/index.ts +2 -0
  132. package/src/families/bitcoin/wallet-btc/storage/index.ts +12 -12
  133. package/src/families/bitcoin/wallet-btc/wallet.ts +24 -7
  134. package/src/families/cosmos/test-dataset.ts +11 -16
  135. package/src/families/crypto_org/api/sdk.ts +7 -3
  136. package/src/families/crypto_org/cli-transaction.ts +11 -1
  137. package/src/families/crypto_org/js-buildTransaction.ts +5 -0
  138. package/src/families/crypto_org/js-transaction.ts +9 -2
  139. package/src/families/crypto_org/transaction.ts +4 -2
  140. package/src/families/crypto_org/types.ts +2 -0
  141. package/src/families/elrond/api/apiCalls.ts +2 -4
  142. package/src/families/elrond/api/sdk.ts +1 -3
  143. package/src/families/elrond/constants.ts +0 -4
  144. package/src/families/elrond/js-broadcast.ts +2 -5
  145. package/src/families/elrond/js-buildTransaction.ts +4 -8
  146. package/src/families/elrond/js-estimateMaxSpendable.ts +0 -1
  147. package/src/families/elrond/js-getFeesForTransaction.ts +1 -3
  148. package/src/families/elrond/js-signOperation.ts +11 -16
  149. package/src/families/elrond/js-synchronisation.ts +1 -0
  150. package/src/families/elrond/js-transaction.ts +0 -1
  151. package/src/families/elrond/logic.ts +0 -24
  152. package/src/families/elrond/test-dataset.ts +1 -1
  153. package/src/families/polkadot/api/sidecar.ts +20 -1
  154. package/src/families/tezos/bakers.whitelist-default.ts +0 -2
  155. package/src/reconciliation.ts +2 -1
@@ -116,18 +116,18 @@ class BitcoinLikeStorage implements IStorage {
116
116
 
117
117
  async removeTxs(txsFilter: { account: number; index: number }) {
118
118
  const newTxs: TX[] = [];
119
+ this.primaryIndex = {};
119
120
 
120
121
  this.txs.forEach((tx: TX) => {
121
- if (tx.account !== txsFilter.account || tx.index !== txsFilter.index) {
122
- newTxs.push(tx);
123
- return;
124
- }
125
-
126
122
  // clean
127
123
  const indexAddress = tx.address;
128
124
  const index = `${indexAddress}-${tx.hash}`;
129
125
 
130
- delete this.primaryIndex[index];
126
+ if (tx.account !== txsFilter.account || tx.index !== txsFilter.index) {
127
+ this.primaryIndex[index] = newTxs.push(tx) - 1;
128
+ return;
129
+ }
130
+
131
131
  delete this.unspentUtxos[indexAddress];
132
132
  delete this.spentUtxos[indexAddress];
133
133
  });
@@ -140,10 +140,15 @@ class BitcoinLikeStorage implements IStorage {
140
140
  async removePendingTxs(txsFilter: { account: number; index: number }) {
141
141
  const newTxs: TX[] = [];
142
142
  const txsToReAdd: TX[] = [];
143
+ this.primaryIndex = {};
143
144
 
144
145
  this.txs.forEach((tx: TX) => {
146
+ // clean
147
+ const indexAddress = tx.address;
148
+ const index = `${indexAddress}-${tx.hash}`;
149
+
145
150
  if (tx.account !== txsFilter.account || tx.index !== txsFilter.index) {
146
- newTxs.push(tx);
151
+ this.primaryIndex[index] = newTxs.push(tx) - 1;
147
152
  return;
148
153
  }
149
154
 
@@ -151,11 +156,6 @@ class BitcoinLikeStorage implements IStorage {
151
156
  txsToReAdd.push(tx);
152
157
  }
153
158
 
154
- // clean
155
- const indexAddress = tx.address;
156
- const index = `${indexAddress}-${tx.hash}`;
157
-
158
- delete this.primaryIndex[index];
159
159
  delete this.unspentUtxos[indexAddress];
160
160
  delete this.spentUtxos[indexAddress];
161
161
  });
@@ -209,6 +209,7 @@ class BitcoinLikeWallet {
209
209
  segwit?: boolean;
210
210
  additionals?: Array<string>;
211
211
  expiryHeight?: Buffer;
212
+ hasExtraData?: boolean;
212
213
  onDeviceSignatureRequested?: () => void;
213
214
  onDeviceSignatureGranted?: () => void;
214
215
  onDeviceStreaming?: (arg0: {
@@ -221,7 +222,9 @@ class BitcoinLikeWallet {
221
222
  btc,
222
223
  fromAccount,
223
224
  txInfo,
225
+ segwit,
224
226
  additionals,
227
+ hasExtraData,
225
228
  onDeviceSignatureRequested,
226
229
  onDeviceSignatureGranted,
227
230
  onDeviceStreaming,
@@ -239,7 +242,6 @@ class BitcoinLikeWallet {
239
242
  bufferWriter.writeVarSlice(txOut.script);
240
243
  });
241
244
  const outputScriptHex = buffer.toString("hex");
242
-
243
245
  const associatedKeysets = txInfo.associatedDerivations.map(
244
246
  ([account, index]) =>
245
247
  `${fromAccount.params.path}/${fromAccount.params.index}'/${account}/${index}`
@@ -250,12 +252,27 @@ class BitcoinLikeWallet {
250
252
  string | null | undefined,
251
253
  number | null | undefined
252
254
  ][];
253
- const inputs: Inputs = txInfo.inputs.map((i) => [
254
- btc.splitTransaction(i.txHex, true),
255
- i.output_index,
256
- null,
257
- null,
258
- ]);
255
+ const inputs: Inputs = txInfo.inputs.map((i) => {
256
+ log("hw", `splitTransaction`, {
257
+ transactionHex: i.txHex,
258
+ isSegwitSupported: segwit,
259
+ hasTimestamp: false,
260
+ hasExtraData,
261
+ additionals,
262
+ });
263
+ return [
264
+ btc.splitTransaction(
265
+ i.txHex,
266
+ segwit,
267
+ false, // FIXME hasTimestamp needed for LL-7539
268
+ hasExtraData,
269
+ additionals
270
+ ),
271
+ i.output_index,
272
+ null,
273
+ i.sequence,
274
+ ];
275
+ });
259
276
 
260
277
  const lastOutputIndex = txInfo.outputs.length - 1;
261
278
 
@@ -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;
@@ -148,7 +148,8 @@ function convertSendTransactionToOperation(
148
148
  addr: string,
149
149
  messageSendContent: CryptoOrgMsgSendContent,
150
150
  transaction: CryptoOrgAccountTransaction,
151
- currencyId: string
151
+ currencyId: string,
152
+ memo: string
152
153
  ): Operation {
153
154
  const type = getOperationType(messageSendContent, addr);
154
155
  return {
@@ -164,7 +165,7 @@ function convertSendTransactionToOperation(
164
165
  senders: [messageSendContent.fromAddress],
165
166
  recipients: [messageSendContent.toAddress],
166
167
  hasFailed: !transaction.success,
167
- extra: {},
168
+ extra: { memo },
168
169
  };
169
170
  }
170
171
 
@@ -191,6 +192,8 @@ export const getOperations = async (
191
192
 
192
193
  for (let i = 0; i < accountTransactions.length; i++) {
193
194
  const msgs = accountTransactions[i].messages;
195
+ const memo = accountTransactions[i].memo;
196
+ const memoTransaction = memo || "";
194
197
 
195
198
  for (let j = 0; j < msgs.length; j++) {
196
199
  switch (msgs[j].type) {
@@ -202,7 +205,8 @@ export const getOperations = async (
202
205
  addr,
203
206
  msgSend,
204
207
  accountTransactions[i],
205
- currencyId
208
+ currencyId,
209
+ memoTransaction
206
210
  )
207
211
  );
208
212
  break;
@@ -7,6 +7,11 @@ const options = [
7
7
  type: String,
8
8
  desc: "mode of transaction: send",
9
9
  },
10
+ {
11
+ name: "memo",
12
+ type: String,
13
+ desc: "add a memo to a transaction",
14
+ },
10
15
  ];
11
16
 
12
17
  function inferTransactions(
@@ -27,7 +32,12 @@ function inferTransactions(
27
32
  if (!account.cryptoOrgResources) throw new Error("unactivated account");
28
33
  }
29
34
 
30
- return { ...transaction, family: "crypto_org", mode: opts.mode || "send" };
35
+ return {
36
+ ...transaction,
37
+ family: "crypto_org",
38
+ mode: opts.mode || "send",
39
+ memo: opts.memo,
40
+ };
31
41
  });
32
42
  }
33
43
 
@@ -45,6 +45,11 @@ export const buildTransaction = async (
45
45
  toAddress: t.recipient,
46
46
  amount: getTransactionAmount(a, t),
47
47
  });
48
+
49
+ const { memo } = t;
50
+ const memoTransaction = memo || "";
51
+ rawTx.setMemo(memoTransaction);
52
+
48
53
  const signableTx = rawTx
49
54
  .appendMessage(msgSend)
50
55
  .addSigner({
@@ -17,6 +17,7 @@ export const createTransaction = (): Transaction => ({
17
17
  recipient: "",
18
18
  useAllAmount: false,
19
19
  fees: new BigNumber(0),
20
+ memo: null,
20
21
  });
21
22
 
22
23
  /**
@@ -38,10 +39,16 @@ export const updateTransaction = (
38
39
  */
39
40
  export const prepareTransaction = async (a: Account, t: Transaction) => {
40
41
  let fees = t.fees;
42
+ let memo = t.memo;
43
+
41
44
  fees = await getEstimatedFees();
42
45
 
43
- if (!sameFees(t.fees, fees)) {
44
- return { ...t, fees };
46
+ if (t.mode !== "send" && !memo) {
47
+ memo = "Ledger Live";
48
+ }
49
+
50
+ if (t.memo !== memo || !sameFees(t.fees, fees)) {
51
+ return { ...t, memo, fees };
45
52
  }
46
53
 
47
54
  return t;
@@ -8,7 +8,7 @@ import type { Account } from "../../types";
8
8
  import { getAccountUnit } from "../../account";
9
9
  import { formatCurrencyUnit } from "../../currencies";
10
10
  export const formatTransaction = (
11
- { mode, amount, recipient, useAllAmount }: Transaction,
11
+ { mode, amount, recipient, useAllAmount, memo }: Transaction,
12
12
  account: Account
13
13
  ): string => `
14
14
  ${mode.toUpperCase()} ${
@@ -21,7 +21,7 @@ ${mode.toUpperCase()} ${
21
21
  showCode: true,
22
22
  disableRounding: true,
23
23
  })
24
- }${recipient ? `\nTO ${recipient}` : ""}`;
24
+ }${recipient ? `\nTO ${recipient}` : ""}${!memo ? "" : `\n with memo=${memo}`}`;
25
25
  export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
26
26
  const common = fromTransactionCommonRaw(tr);
27
27
  return {
@@ -29,6 +29,7 @@ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
29
29
  family: tr.family,
30
30
  mode: tr.mode,
31
31
  fees: tr.fees ? new BigNumber(tr.fees) : new BigNumber(0),
32
+ memo: tr.memo,
32
33
  };
33
34
  };
34
35
  export const toTransactionRaw = (t: Transaction): TransactionRaw => {
@@ -38,6 +39,7 @@ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
38
39
  family: t.family,
39
40
  mode: t.mode,
40
41
  fees: t.fees?.toString() || "",
42
+ memo: t.memo,
41
43
  };
42
44
  };
43
45
  export default {
@@ -23,11 +23,13 @@ export type Transaction = TransactionCommon & {
23
23
  mode: string;
24
24
  family: "crypto_org";
25
25
  fees?: BigNumber; // add here all transaction-specific fields if you implement other modes than "send"
26
+ memo: string | null | undefined;
26
27
  };
27
28
  export type TransactionRaw = TransactionCommonRaw & {
28
29
  family: "crypto_org";
29
30
  mode: string;
30
31
  fees?: string; // also the transaction fields as raw JSON data
32
+ memo: string | null | undefined;
31
33
  };
32
34
  export type CryptoOrgPreloadData = Record<any, any>;
33
35
  export type NetworkInfo = {
@@ -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
 
@@ -103,7 +103,7 @@ const dataset: DatasetTest<Transaction> = {
103
103
  implementations: ["js"],
104
104
  currencies: {
105
105
  // FIXME: temporarily disabled until a solution is found for an inconstency between two sync
106
- elrond,
106
+ // elrond, // infra issue
107
107
  },
108
108
  };
109
109
 
@@ -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
+ );
@@ -14,7 +14,6 @@ tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6
14
14
  tz1Ldzz6k1BHdhuKvAtMRX7h5kJSMHESMHLC
15
15
  tz1Kf25fX1VdmYGSEzwFy1wNmkbSEZ2V83sY
16
16
  tz1RCFbB9GpALpsZtu6J58sb74dm8qe6XBzv
17
- tz1LLNkQK4UQV6QcFShiXJ2vT2ELw449MzAA
18
17
  tz1dbfppLAAxXZNtf2SDps7rch3qfUznKSoK
19
18
  tz1Q8QkSBS63ZQnH3fBTiAMPes9R666Rn6Sc
20
19
  tz2FCNBrERXtaTtNX6iimR1UJ5JSDxvdHM93
@@ -24,7 +23,6 @@ tz1SohptP53wDPZhzTWzDUFAUcWF6DMBpaJV
24
23
  tz1P2Po7YM526ughEsRbY4oR9zaUPDZjxFrb
25
24
  tz1KzSC1J9aBxKp7u8TUnpN8L7S65PBRkgdF
26
25
  tz1STeamwbp68THcny9zk3LsbG3H36DMvbRK
27
- tz1bLwpPfr3xqy1gWBF4sGvv8bLJyPHR11kx
28
26
  tz1fJHFn6sWEd3NnBPngACuw2dggTv6nQZ7g
29
27
  tz1NEKxGEHsFufk87CVZcrqWu8o22qh46GK6
30
28
  tz1V3yg82mcrPJbegqVCPn6bC8w1CSTRp3f8
@@ -168,7 +168,8 @@ function shouldRefreshBitcoinResources(
168
168
  const { bitcoinResources: raw } = updatedRaw;
169
169
  // FIXME Need more typing in wallet-btc to have a meaningful comparison
170
170
  //if (!isEqual(raw.walletAccount?.xpub?.data, existing.walletAccount?.xpub?.data)) return true;
171
- return raw.utxos.length !== existing.utxos.length;
171
+ if (raw.utxos.length !== existing.utxos.length) return true;
172
+ return !isEqual(raw.utxos, existing.utxos);
172
173
  }
173
174
 
174
175
  export function patchAccount(