@ledgerhq/live-common 21.36.0 → 21.36.3
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/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +238 -245
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js +17 -14
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-signOperation.js +130 -139
- package/lib/families/bitcoin/js-signOperation.js.map +1 -1
- package/lib/families/crypto_org/js-signOperation.d.ts.map +1 -1
- package/lib/families/crypto_org/js-signOperation.js +55 -62
- package/lib/families/crypto_org/js-signOperation.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +43 -50
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/families/polkadot/js-signOperation.d.ts.map +1 -1
- package/lib/families/polkadot/js-signOperation.js +54 -61
- package/lib/families/polkadot/js-signOperation.js.map +1 -1
- package/lib/families/ripple/bridge/js.d.ts.map +1 -1
- package/lib/families/ripple/bridge/js.js +299 -313
- package/lib/families/ripple/bridge/js.js.map +1 -1
- package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
- package/lib/families/stellar/js-signOperation.js +44 -51
- package/lib/families/stellar/js-signOperation.js.map +1 -1
- package/lib/families/tron/bridge/js.d.ts.map +1 -1
- package/lib/families/tron/bridge/js.js +159 -167
- package/lib/families/tron/bridge/js.js.map +1 -1
- package/lib/notifications/AnnouncementProvider/machine.d.ts +21 -4
- package/lib/notifications/AnnouncementProvider/machine.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/machine.d.ts +21 -4
- package/lib/notifications/ServiceStatusProvider/machine.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/.DS_Store +0 -0
- package/src/bridge/jsHelpers.ts +213 -213
- package/src/data/flags/.DS_Store +0 -0
- package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
- package/src/families/bitcoin/js-signOperation.ts +14 -17
- package/src/families/crypto_org/js-signOperation.ts +12 -16
- package/src/families/elrond/js-signOperation.ts +10 -14
- package/src/families/polkadot/js-signOperation.ts +61 -61
- package/src/families/ripple/bridge/js.ts +257 -260
- package/src/families/stellar/js-signOperation.ts +10 -14
- package/src/families/tron/bridge/js.ts +57 -58
package/src/bridge/jsHelpers.ts
CHANGED
|
@@ -39,7 +39,6 @@ import type {
|
|
|
39
39
|
import type { CurrencyBridge, AccountBridge } from "../types/bridge";
|
|
40
40
|
import getAddress from "../hw/getAddress";
|
|
41
41
|
import type { Result, GetAddressOptions } from "../hw/getAddress/types";
|
|
42
|
-
import { open, close } from "../hw";
|
|
43
42
|
import { withDevice } from "../hw/deviceAccess";
|
|
44
43
|
|
|
45
44
|
// Customize the way to iterate on the keychain derivation
|
|
@@ -276,257 +275,258 @@ export const makeScanAccounts =
|
|
|
276
275
|
) => (opts: GetAddressOptions) => Promise<Result>;
|
|
277
276
|
}): CurrencyBridge["scanAccounts"] =>
|
|
278
277
|
({ currency, deviceId, syncConfig }): Observable<ScanAccountEvent> =>
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
withDevice(deviceId)((transport) =>
|
|
279
|
+
Observable.create((o) => {
|
|
280
|
+
let finished = false;
|
|
281
281
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
const unsubscribe = () => {
|
|
283
|
+
finished = true;
|
|
284
|
+
};
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
const derivationsCache = {};
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
async function stepAccount(
|
|
289
|
+
index,
|
|
290
|
+
res: Result,
|
|
291
|
+
derivationMode,
|
|
292
|
+
seedIdentifier,
|
|
293
|
+
transport
|
|
294
|
+
): Promise<Account | null | undefined> {
|
|
295
|
+
if (finished) return;
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
const { address, path: freshAddressPath, ...rest } = res;
|
|
298
298
|
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
transport,
|
|
302
|
-
currency,
|
|
303
|
-
index,
|
|
304
|
-
address,
|
|
305
|
-
derivationPath: freshAddressPath,
|
|
306
|
-
derivationMode,
|
|
307
|
-
rest,
|
|
308
|
-
},
|
|
309
|
-
syncConfig
|
|
310
|
-
);
|
|
311
|
-
if (finished) return;
|
|
312
|
-
|
|
313
|
-
const freshAddress = address;
|
|
314
|
-
const operations = accountShape.operations || [];
|
|
315
|
-
const operationsCount =
|
|
316
|
-
accountShape.operationsCount || operations.length;
|
|
317
|
-
const creationDate =
|
|
318
|
-
operations.length > 0
|
|
319
|
-
? operations[operations.length - 1].date
|
|
320
|
-
: new Date();
|
|
321
|
-
const balance = accountShape.balance || new BigNumber(0);
|
|
322
|
-
const spendableBalance =
|
|
323
|
-
accountShape.spendableBalance || new BigNumber(0);
|
|
324
|
-
if (!accountShape.id) throw new Error("account ID must be provided");
|
|
325
|
-
if (balance.isNaN()) throw new Error("invalid balance NaN");
|
|
326
|
-
const initialAccount: Account = {
|
|
327
|
-
type: "Account",
|
|
328
|
-
id: accountShape.id,
|
|
329
|
-
seedIdentifier,
|
|
330
|
-
freshAddress,
|
|
331
|
-
freshAddressPath,
|
|
332
|
-
freshAddresses: [
|
|
299
|
+
const accountShape: Partial<Account> = await getAccountShape(
|
|
333
300
|
{
|
|
334
|
-
|
|
301
|
+
transport,
|
|
302
|
+
currency,
|
|
303
|
+
index,
|
|
304
|
+
address,
|
|
335
305
|
derivationPath: freshAddressPath,
|
|
306
|
+
derivationMode,
|
|
307
|
+
rest,
|
|
336
308
|
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
309
|
+
syncConfig
|
|
310
|
+
);
|
|
311
|
+
if (finished) return;
|
|
312
|
+
|
|
313
|
+
const freshAddress = address;
|
|
314
|
+
const operations = accountShape.operations || [];
|
|
315
|
+
const operationsCount =
|
|
316
|
+
accountShape.operationsCount || operations.length;
|
|
317
|
+
const creationDate =
|
|
318
|
+
operations.length > 0
|
|
319
|
+
? operations[operations.length - 1].date
|
|
320
|
+
: new Date();
|
|
321
|
+
const balance = accountShape.balance || new BigNumber(0);
|
|
322
|
+
const spendableBalance =
|
|
323
|
+
accountShape.spendableBalance || new BigNumber(0);
|
|
324
|
+
if (!accountShape.id) throw new Error("account ID must be provided");
|
|
325
|
+
if (balance.isNaN()) throw new Error("invalid balance NaN");
|
|
326
|
+
const initialAccount: Account = {
|
|
327
|
+
type: "Account",
|
|
328
|
+
id: accountShape.id,
|
|
329
|
+
seedIdentifier,
|
|
330
|
+
freshAddress,
|
|
331
|
+
freshAddressPath,
|
|
332
|
+
freshAddresses: [
|
|
333
|
+
{
|
|
334
|
+
address: freshAddress,
|
|
335
|
+
derivationPath: freshAddressPath,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
derivationMode,
|
|
339
|
+
name: "",
|
|
340
|
+
starred: false,
|
|
341
|
+
used: false,
|
|
342
|
+
index,
|
|
343
|
+
currency,
|
|
344
|
+
operationsCount,
|
|
345
|
+
operations: [],
|
|
346
|
+
swapHistory: [],
|
|
347
|
+
pendingOperations: [],
|
|
348
|
+
unit: currency.units[0],
|
|
349
|
+
lastSyncDate: new Date(),
|
|
350
|
+
creationDate,
|
|
351
|
+
// overrides
|
|
352
|
+
balance,
|
|
353
|
+
spendableBalance,
|
|
354
|
+
blockHeight: 0,
|
|
355
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
356
|
+
};
|
|
357
|
+
const account = { ...initialAccount, ...accountShape };
|
|
358
|
+
|
|
359
|
+
if (account.balanceHistoryCache === emptyHistoryCache) {
|
|
360
|
+
account.balanceHistoryCache =
|
|
361
|
+
generateHistoryFromOperations(account);
|
|
362
|
+
}
|
|
366
363
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
res.address = account.freshAddress;
|
|
371
|
-
derivationsCache[account.freshAddressPath] = res;
|
|
372
|
-
}
|
|
364
|
+
if (!account.used) {
|
|
365
|
+
account.used = !isAccountEmpty(account);
|
|
366
|
+
}
|
|
373
367
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
} resulted of ${
|
|
381
|
-
account
|
|
382
|
-
? `Account with ${account.operations.length} txs`
|
|
383
|
-
: "no account"
|
|
384
|
-
}`
|
|
385
|
-
);
|
|
386
|
-
if (!account) return;
|
|
387
|
-
account.name = !account.used
|
|
388
|
-
? getNewAccountPlaceholderName({
|
|
389
|
-
currency,
|
|
390
|
-
index,
|
|
391
|
-
derivationMode,
|
|
392
|
-
})
|
|
393
|
-
: getAccountPlaceholderName({
|
|
394
|
-
currency,
|
|
395
|
-
index,
|
|
396
|
-
derivationMode,
|
|
397
|
-
});
|
|
368
|
+
// Bitcoin needs to compute the freshAddressPath itself,
|
|
369
|
+
// so we update it afterwards
|
|
370
|
+
if (account?.freshAddressPath) {
|
|
371
|
+
res.address = account.freshAddress;
|
|
372
|
+
derivationsCache[account.freshAddressPath] = res;
|
|
373
|
+
}
|
|
398
374
|
|
|
399
|
-
|
|
375
|
+
log("scanAccounts", "derivationsCache", res);
|
|
400
376
|
|
|
401
|
-
if (account.used || showNewAccount) {
|
|
402
377
|
log(
|
|
403
|
-
"
|
|
404
|
-
`
|
|
378
|
+
"scanAccounts",
|
|
379
|
+
`scanning ${currency.id} at ${freshAddressPath}: ${
|
|
380
|
+
res.address
|
|
381
|
+
} resulted of ${
|
|
382
|
+
account
|
|
383
|
+
? `Account with ${account.operations.length} txs`
|
|
384
|
+
: "no account"
|
|
385
|
+
}`
|
|
405
386
|
);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
387
|
+
if (!account) return;
|
|
388
|
+
account.name = !account.used
|
|
389
|
+
? getNewAccountPlaceholderName({
|
|
390
|
+
currency,
|
|
391
|
+
index,
|
|
392
|
+
derivationMode,
|
|
393
|
+
})
|
|
394
|
+
: getAccountPlaceholderName({
|
|
395
|
+
currency,
|
|
396
|
+
index,
|
|
397
|
+
derivationMode,
|
|
398
|
+
});
|
|
414
399
|
|
|
415
|
-
|
|
416
|
-
// TODO switch to withDevice
|
|
417
|
-
let transport;
|
|
400
|
+
const showNewAccount = shouldShowNewAccount(currency, derivationMode);
|
|
418
401
|
|
|
419
|
-
|
|
420
|
-
transport = await open(deviceId);
|
|
421
|
-
const getAddr = getAddressFn
|
|
422
|
-
? getAddressFn(transport)
|
|
423
|
-
: (opts) => getAddress(transport, opts);
|
|
424
|
-
const derivationModes = getDerivationModesForCurrency(currency);
|
|
425
|
-
|
|
426
|
-
for (const derivationMode of derivationModes) {
|
|
427
|
-
if (finished) break;
|
|
428
|
-
const path = getSeedIdentifierDerivation(currency, derivationMode);
|
|
402
|
+
if (account.used || showNewAccount) {
|
|
429
403
|
log(
|
|
430
|
-
"
|
|
431
|
-
`
|
|
404
|
+
"debug",
|
|
405
|
+
`Emit 'discovered' event for a new account found. AccountUsed: ${account.used} - showNewAccount: ${showNewAccount}`
|
|
432
406
|
);
|
|
433
|
-
|
|
407
|
+
o.next({
|
|
408
|
+
type: "discovered",
|
|
409
|
+
account,
|
|
410
|
+
});
|
|
411
|
+
}
|
|
434
412
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
result = await getAddr({
|
|
438
|
-
currency,
|
|
439
|
-
path,
|
|
440
|
-
derivationMode,
|
|
441
|
-
});
|
|
413
|
+
return account;
|
|
414
|
+
}
|
|
442
415
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
416
|
+
async function main() {
|
|
417
|
+
try {
|
|
418
|
+
const getAddr = getAddressFn
|
|
419
|
+
? getAddressFn(transport)
|
|
420
|
+
: (opts) => getAddress(transport, opts);
|
|
421
|
+
const derivationModes = getDerivationModesForCurrency(currency);
|
|
422
|
+
|
|
423
|
+
for (const derivationMode of derivationModes) {
|
|
424
|
+
if (finished) break;
|
|
425
|
+
const path = getSeedIdentifierDerivation(
|
|
426
|
+
currency,
|
|
427
|
+
derivationMode
|
|
428
|
+
);
|
|
429
|
+
log(
|
|
430
|
+
"scanAccounts",
|
|
431
|
+
`scanning ${currency.id} on derivationMode=${derivationMode}`
|
|
432
|
+
);
|
|
433
|
+
let result: Result = derivationsCache[path];
|
|
434
|
+
|
|
435
|
+
if (!result) {
|
|
436
|
+
try {
|
|
437
|
+
result = await getAddr({
|
|
438
|
+
currency,
|
|
439
|
+
path,
|
|
440
|
+
derivationMode,
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
derivationsCache[path] = result;
|
|
444
|
+
} catch (e) {
|
|
445
|
+
if (e instanceof UnsupportedDerivation) {
|
|
446
|
+
log(
|
|
447
|
+
"scanAccounts",
|
|
448
|
+
"ignore derivationMode=" + derivationMode
|
|
449
|
+
);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
throw e;
|
|
451
453
|
}
|
|
452
|
-
throw e;
|
|
453
454
|
}
|
|
454
|
-
}
|
|
455
455
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
456
|
+
if (!result) continue;
|
|
457
|
+
const seedIdentifier = result.publicKey;
|
|
458
|
+
let emptyCount = 0;
|
|
459
|
+
const mandatoryEmptyAccountSkip =
|
|
460
|
+
getMandatoryEmptyAccountSkip(derivationMode);
|
|
461
|
+
const derivationScheme = getDerivationScheme({
|
|
462
|
+
derivationMode,
|
|
463
|
+
currency,
|
|
464
|
+
});
|
|
465
465
|
|
|
466
|
-
|
|
467
|
-
|
|
466
|
+
const stopAt = isIterableDerivationMode(derivationMode) ? 255 : 1;
|
|
467
|
+
const startsAt = getDerivationModeStartsAt(derivationMode);
|
|
468
468
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
469
|
+
log(
|
|
470
|
+
"debug",
|
|
471
|
+
`start scanning account process. MandatoryEmptyAccountSkip ${mandatoryEmptyAccountSkip} / StartsAt: ${startsAt} - StopAt: ${stopAt}`
|
|
472
|
+
);
|
|
473
473
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
474
|
+
const iterateResult = await buildIterateResult({
|
|
475
|
+
result,
|
|
476
|
+
derivationMode,
|
|
477
|
+
derivationScheme,
|
|
478
|
+
});
|
|
479
479
|
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
for (let index = startsAt; index < stopAt; index++) {
|
|
481
|
+
log("debug", `start to scan a new account. Index: ${index}`);
|
|
482
482
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
483
|
+
if (finished) {
|
|
484
|
+
log(
|
|
485
|
+
"debug",
|
|
486
|
+
`new account scanning process has been finished`
|
|
487
|
+
);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
487
490
|
|
|
488
|
-
|
|
491
|
+
if (!derivationModeSupportsIndex(derivationMode, index))
|
|
492
|
+
continue;
|
|
489
493
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
494
|
+
const res = await iterateResult({
|
|
495
|
+
transport,
|
|
496
|
+
index,
|
|
497
|
+
derivationsCache,
|
|
498
|
+
derivationMode,
|
|
499
|
+
derivationScheme,
|
|
500
|
+
currency,
|
|
501
|
+
});
|
|
498
502
|
|
|
499
|
-
|
|
503
|
+
if (!res) break;
|
|
500
504
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
505
|
+
const account = await stepAccount(
|
|
506
|
+
index,
|
|
507
|
+
res,
|
|
508
|
+
derivationMode,
|
|
509
|
+
seedIdentifier,
|
|
510
|
+
transport
|
|
511
|
+
);
|
|
508
512
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
513
|
+
if (account && !account.used) {
|
|
514
|
+
if (emptyCount >= mandatoryEmptyAccountSkip) break;
|
|
515
|
+
emptyCount++;
|
|
516
|
+
}
|
|
512
517
|
}
|
|
513
518
|
}
|
|
514
|
-
}
|
|
515
|
-
// }
|
|
516
519
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
} finally {
|
|
521
|
-
if (transport) {
|
|
522
|
-
close(transport, deviceId);
|
|
520
|
+
o.complete();
|
|
521
|
+
} catch (e) {
|
|
522
|
+
o.error(e);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
}
|
|
526
525
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
main();
|
|
527
|
+
return unsubscribe;
|
|
528
|
+
})
|
|
529
|
+
);
|
|
530
530
|
export function makeAccountBridgeReceive({
|
|
531
531
|
injectGetAddressParams,
|
|
532
532
|
}: {
|
|
Binary file
|
|
@@ -5,7 +5,7 @@ import { log } from "@ledgerhq/logs";
|
|
|
5
5
|
import type { Account, Operation, SignOperationEvent } from "./../../types";
|
|
6
6
|
import { isSegwitDerivationMode } from "./../../derivation";
|
|
7
7
|
import { encodeOperationId } from "./../../operation";
|
|
8
|
-
import {
|
|
8
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
9
9
|
import type { Transaction } from "./types";
|
|
10
10
|
import { getNetworkParameters } from "./networks";
|
|
11
11
|
import { buildTransaction } from "./js-buildTransaction";
|
|
@@ -22,14 +22,13 @@ const signOperation = ({
|
|
|
22
22
|
deviceId: any;
|
|
23
23
|
transaction: Transaction;
|
|
24
24
|
}): Observable<SignOperationEvent> =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
try {
|
|
25
|
+
withDevice(deviceId)((transport) =>
|
|
26
|
+
Observable.create((o) => {
|
|
27
|
+
async function main() {
|
|
28
|
+
const { currency } = account;
|
|
29
|
+
const hwApp = new Btc(transport);
|
|
30
|
+
const walletAccount = getWalletAccount(account);
|
|
31
|
+
|
|
33
32
|
log("hw", `signTransaction ${currency.id} for account ${account.id}`);
|
|
34
33
|
const txInfo = await buildTransaction(account, transaction);
|
|
35
34
|
let senders = new Set<string>();
|
|
@@ -152,15 +151,13 @@ const signOperation = ({
|
|
|
152
151
|
expirationDate: null,
|
|
153
152
|
},
|
|
154
153
|
});
|
|
155
|
-
} finally {
|
|
156
|
-
close(transport, deviceId);
|
|
157
154
|
}
|
|
158
|
-
}
|
|
159
155
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
main().then(
|
|
157
|
+
() => o.complete(),
|
|
158
|
+
(e) => o.error(e)
|
|
159
|
+
);
|
|
160
|
+
})
|
|
161
|
+
);
|
|
165
162
|
|
|
166
163
|
export default signOperation;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
+
import { utils } from "@crypto-com/chain-jslib";
|
|
3
4
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
5
|
+
import CryptoOrgApp from "@ledgerhq/hw-app-cosmos";
|
|
4
6
|
import {
|
|
5
7
|
CryptoOrgWrongSignatureHeader,
|
|
6
8
|
CryptoOrgSignatureSize,
|
|
7
9
|
} from "./errors";
|
|
8
10
|
import type { Transaction } from "./types";
|
|
9
11
|
import type { Account, Operation, SignOperationEvent } from "../../types";
|
|
10
|
-
import { open, close } from "../../hw";
|
|
11
12
|
import { encodeOperationId } from "../../operation";
|
|
12
|
-
import
|
|
13
|
-
import { utils } from "@crypto-com/chain-jslib";
|
|
13
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
14
14
|
import { buildTransaction } from "./js-buildTransaction";
|
|
15
15
|
import { isTestNet } from "./logic";
|
|
16
16
|
|
|
@@ -104,11 +104,9 @@ const signOperation = ({
|
|
|
104
104
|
deviceId: any;
|
|
105
105
|
transaction: Transaction;
|
|
106
106
|
}): Observable<SignOperationEvent> =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
try {
|
|
107
|
+
withDevice(deviceId)((transport) =>
|
|
108
|
+
Observable.create((o) => {
|
|
109
|
+
async function main() {
|
|
112
110
|
o.next({
|
|
113
111
|
type: "device-signature-requested",
|
|
114
112
|
});
|
|
@@ -165,15 +163,13 @@ const signOperation = ({
|
|
|
165
163
|
},
|
|
166
164
|
});
|
|
167
165
|
}
|
|
168
|
-
} finally {
|
|
169
|
-
close(transport, deviceId);
|
|
170
166
|
}
|
|
171
|
-
}
|
|
172
167
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
main().then(
|
|
169
|
+
() => o.complete(),
|
|
170
|
+
(e) => o.error(e)
|
|
171
|
+
);
|
|
172
|
+
})
|
|
173
|
+
);
|
|
178
174
|
|
|
179
175
|
export default signOperation;
|
|
@@ -3,7 +3,7 @@ import { Observable } from "rxjs";
|
|
|
3
3
|
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
4
4
|
import type { Transaction } from "./types";
|
|
5
5
|
import type { Account, Operation, SignOperationEvent } from "../../types";
|
|
6
|
-
import {
|
|
6
|
+
import { withDevice } from "../../hw/deviceAccess";
|
|
7
7
|
import { encodeOperationId } from "../../operation";
|
|
8
8
|
import Elrond from "./hw-app-elrond";
|
|
9
9
|
import { buildTransaction } from "./js-buildTransaction";
|
|
@@ -48,11 +48,9 @@ const signOperation = ({
|
|
|
48
48
|
deviceId: any;
|
|
49
49
|
transaction: Transaction;
|
|
50
50
|
}): Observable<SignOperationEvent> =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
try {
|
|
51
|
+
withDevice(deviceId)((transport) =>
|
|
52
|
+
Observable.create((o) => {
|
|
53
|
+
async function main() {
|
|
56
54
|
if (!transaction.fees) {
|
|
57
55
|
throw new FeeNotLoaded();
|
|
58
56
|
}
|
|
@@ -89,15 +87,13 @@ const signOperation = ({
|
|
|
89
87
|
expirationDate: null,
|
|
90
88
|
},
|
|
91
89
|
});
|
|
92
|
-
} finally {
|
|
93
|
-
close(transport, deviceId);
|
|
94
90
|
}
|
|
95
|
-
}
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
main().then(
|
|
93
|
+
() => o.complete(),
|
|
94
|
+
(e) => o.error(e)
|
|
95
|
+
);
|
|
96
|
+
})
|
|
97
|
+
);
|
|
102
98
|
|
|
103
99
|
export default signOperation;
|