@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.
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
- package/lib/api/explorerConfig/index.d.ts.map +1 -1
- package/lib/api/explorerConfig/index.js +7 -8
- package/lib/api/explorerConfig/index.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +2 -1
- package/lib/apps/support.js.map +1 -1
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +8 -3
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/bridge/react/BridgeSync.js +8 -0
- package/lib/bridge/react/BridgeSync.js.map +1 -1
- package/lib/families/bitcoin/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/bitcoin/js-prepareTransaction.js +0 -3
- package/lib/families/bitcoin/js-prepareTransaction.js.map +1 -1
- package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-signOperation.js +3 -1
- package/lib/families/bitcoin/js-signOperation.js.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.js +2 -0
- package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
- package/lib/families/bitcoin/specs.js +2 -1
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +4 -0
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/explorer/index.js +1 -3
- package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/index.js +3 -0
- package/lib/families/bitcoin/wallet-btc/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/storage/index.js +10 -10
- package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +18 -8
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/cosmos/test-dataset.d.ts.map +1 -1
- package/lib/families/cosmos/test-dataset.js +8 -14
- package/lib/families/cosmos/test-dataset.js.map +1 -1
- package/lib/families/crypto_org/api/sdk.d.ts.map +1 -1
- package/lib/families/crypto_org/api/sdk.js +6 -4
- package/lib/families/crypto_org/api/sdk.js.map +1 -1
- package/lib/families/crypto_org/cli-transaction.d.ts.map +1 -1
- package/lib/families/crypto_org/cli-transaction.js +6 -1
- package/lib/families/crypto_org/cli-transaction.js.map +1 -1
- package/lib/families/crypto_org/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/crypto_org/js-buildTransaction.js +4 -1
- package/lib/families/crypto_org/js-buildTransaction.js.map +1 -1
- package/lib/families/crypto_org/js-transaction.d.ts +1 -0
- package/lib/families/crypto_org/js-transaction.d.ts.map +1 -1
- package/lib/families/crypto_org/js-transaction.js +9 -4
- package/lib/families/crypto_org/js-transaction.js.map +1 -1
- package/lib/families/crypto_org/transaction.d.ts +2 -2
- package/lib/families/crypto_org/transaction.d.ts.map +1 -1
- package/lib/families/crypto_org/transaction.js +4 -4
- package/lib/families/crypto_org/transaction.js.map +1 -1
- package/lib/families/crypto_org/types.d.ts +2 -0
- package/lib/families/crypto_org/types.d.ts.map +1 -1
- package/lib/families/crypto_org/types.js.map +1 -1
- package/lib/families/elrond/api/apiCalls.d.ts +1 -2
- package/lib/families/elrond/api/apiCalls.d.ts.map +1 -1
- package/lib/families/elrond/api/apiCalls.js +3 -4
- package/lib/families/elrond/api/apiCalls.js.map +1 -1
- package/lib/families/elrond/api/sdk.d.ts +1 -3
- package/lib/families/elrond/api/sdk.d.ts.map +1 -1
- package/lib/families/elrond/api/sdk.js +1 -3
- package/lib/families/elrond/api/sdk.js.map +1 -1
- package/lib/families/elrond/constants.d.ts +0 -4
- package/lib/families/elrond/constants.d.ts.map +1 -1
- package/lib/families/elrond/constants.js +1 -5
- package/lib/families/elrond/constants.js.map +1 -1
- package/lib/families/elrond/js-broadcast.d.ts.map +1 -1
- package/lib/families/elrond/js-broadcast.js +6 -9
- package/lib/families/elrond/js-broadcast.js.map +1 -1
- package/lib/families/elrond/js-buildTransaction.d.ts +1 -1
- package/lib/families/elrond/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/elrond/js-buildTransaction.js +17 -21
- package/lib/families/elrond/js-buildTransaction.js.map +1 -1
- package/lib/families/elrond/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/elrond/js-estimateMaxSpendable.js +1 -2
- package/lib/families/elrond/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/elrond/js-getFeesForTransaction.d.ts +1 -2
- package/lib/families/elrond/js-getFeesForTransaction.d.ts.map +1 -1
- package/lib/families/elrond/js-getFeesForTransaction.js +6 -6
- package/lib/families/elrond/js-getFeesForTransaction.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +11 -17
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/families/elrond/js-synchronisation.d.ts.map +1 -1
- package/lib/families/elrond/js-synchronisation.js.map +1 -1
- package/lib/families/elrond/js-transaction.d.ts.map +1 -1
- package/lib/families/elrond/js-transaction.js +1 -2
- package/lib/families/elrond/js-transaction.js.map +1 -1
- package/lib/families/elrond/logic.d.ts +0 -1
- package/lib/families/elrond/logic.d.ts.map +1 -1
- package/lib/families/elrond/logic.js +1 -20
- package/lib/families/elrond/logic.js.map +1 -1
- package/lib/families/elrond/test-dataset.js +2 -2
- package/lib/families/elrond/test-dataset.js.map +1 -1
- package/lib/families/polkadot/api/sidecar.d.ts +9 -1
- package/lib/families/polkadot/api/sidecar.d.ts.map +1 -1
- package/lib/families/polkadot/api/sidecar.js +14 -2
- package/lib/families/polkadot/api/sidecar.js.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
- package/lib/generated/transaction.d.ts +1 -1
- package/lib/reconciliation.d.ts.map +1 -1
- package/lib/reconciliation.js +3 -1
- package/lib/reconciliation.js.map +1 -1
- package/package.json +25 -25
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +180523 -1210
- package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
- package/src/api/explorerConfig/index.ts +7 -8
- package/src/apps/support.ts +2 -1
- package/src/bridge/jsHelpers.ts +9 -1
- package/src/bridge/react/BridgeSync.tsx +10 -0
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +229 -2
- package/src/families/bitcoin/js-prepareTransaction.ts +0 -2
- package/src/families/bitcoin/js-signOperation.ts +3 -0
- package/src/families/bitcoin/js-synchronisation.ts +2 -0
- package/src/families/bitcoin/specs.ts +1 -1
- package/src/families/bitcoin/speculos-deviceActions.ts +4 -0
- package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +1 -1
- package/src/families/bitcoin/wallet-btc/explorer/index.ts +1 -5
- package/src/families/bitcoin/wallet-btc/index.ts +2 -0
- package/src/families/bitcoin/wallet-btc/storage/index.ts +12 -12
- package/src/families/bitcoin/wallet-btc/wallet.ts +24 -7
- package/src/families/cosmos/test-dataset.ts +11 -16
- package/src/families/crypto_org/api/sdk.ts +7 -3
- package/src/families/crypto_org/cli-transaction.ts +11 -1
- package/src/families/crypto_org/js-buildTransaction.ts +5 -0
- package/src/families/crypto_org/js-transaction.ts +9 -2
- package/src/families/crypto_org/transaction.ts +4 -2
- package/src/families/crypto_org/types.ts +2 -0
- package/src/families/elrond/api/apiCalls.ts +2 -4
- package/src/families/elrond/api/sdk.ts +1 -3
- package/src/families/elrond/constants.ts +0 -4
- package/src/families/elrond/js-broadcast.ts +2 -5
- package/src/families/elrond/js-buildTransaction.ts +4 -8
- package/src/families/elrond/js-estimateMaxSpendable.ts +0 -1
- package/src/families/elrond/js-getFeesForTransaction.ts +1 -3
- package/src/families/elrond/js-signOperation.ts +11 -16
- package/src/families/elrond/js-synchronisation.ts +1 -0
- package/src/families/elrond/js-transaction.ts +0 -1
- package/src/families/elrond/logic.ts +0 -24
- package/src/families/elrond/test-dataset.ts +1 -1
- package/src/families/polkadot/api/sidecar.ts +20 -1
- package/src/families/tezos/bakers.whitelist-default.ts +0 -2
- 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
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
466
|
-
|
|
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 {
|
|
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 (
|
|
44
|
-
|
|
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
|
|
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
|
-
...
|
|
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
|
};
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
...
|
|
28
|
+
...HASH_TRANSACTION,
|
|
33
29
|
};
|
|
34
30
|
// Will likely be a call to Elrond SDK
|
|
35
31
|
return JSON.stringify(unsigned);
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
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
|
-
|
|
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",
|
|
@@ -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
|
-
|
|
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
|
package/src/reconciliation.ts
CHANGED
|
@@ -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
|
-
|
|
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(
|