@ledgerhq/live-common 21.36.2 → 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.
Files changed (35) hide show
  1. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  2. package/lib/bridge/jsHelpers.js +238 -245
  3. package/lib/bridge/jsHelpers.js.map +1 -1
  4. package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
  5. package/lib/families/bitcoin/js-signOperation.js +130 -139
  6. package/lib/families/bitcoin/js-signOperation.js.map +1 -1
  7. package/lib/families/crypto_org/js-signOperation.d.ts.map +1 -1
  8. package/lib/families/crypto_org/js-signOperation.js +55 -62
  9. package/lib/families/crypto_org/js-signOperation.js.map +1 -1
  10. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  11. package/lib/families/elrond/js-signOperation.js +43 -50
  12. package/lib/families/elrond/js-signOperation.js.map +1 -1
  13. package/lib/families/polkadot/js-signOperation.d.ts.map +1 -1
  14. package/lib/families/polkadot/js-signOperation.js +54 -61
  15. package/lib/families/polkadot/js-signOperation.js.map +1 -1
  16. package/lib/families/ripple/bridge/js.d.ts.map +1 -1
  17. package/lib/families/ripple/bridge/js.js +299 -313
  18. package/lib/families/ripple/bridge/js.js.map +1 -1
  19. package/lib/families/stellar/js-signOperation.d.ts.map +1 -1
  20. package/lib/families/stellar/js-signOperation.js +44 -51
  21. package/lib/families/stellar/js-signOperation.js.map +1 -1
  22. package/lib/families/tron/bridge/js.d.ts.map +1 -1
  23. package/lib/families/tron/bridge/js.js +159 -167
  24. package/lib/families/tron/bridge/js.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/.DS_Store +0 -0
  27. package/src/bridge/jsHelpers.ts +213 -213
  28. package/src/data/flags/.DS_Store +0 -0
  29. package/src/families/bitcoin/js-signOperation.ts +14 -17
  30. package/src/families/crypto_org/js-signOperation.ts +12 -16
  31. package/src/families/elrond/js-signOperation.ts +10 -14
  32. package/src/families/polkadot/js-signOperation.ts +61 -61
  33. package/src/families/ripple/bridge/js.ts +257 -260
  34. package/src/families/stellar/js-signOperation.ts +10 -14
  35. package/src/families/tron/bridge/js.ts +57 -58
@@ -89,7 +89,7 @@ var operation_1 = require("../../../operation");
89
89
  var account_1 = require("../../../account");
90
90
  var account_2 = require("../../../account");
91
91
  var getAddress_1 = __importDefault(require("../../../hw/getAddress"));
92
- var hw_1 = require("../../../hw");
92
+ var deviceAccess_1 = require("../../../hw/deviceAccess");
93
93
  var Ripple_1 = require("../../../api/Ripple");
94
94
  var signTransaction_1 = __importDefault(require("../../../hw/signTransaction"));
95
95
  var jsHelpers_1 = require("../../../bridge/jsHelpers");
@@ -125,109 +125,101 @@ var validateTag = function (tag) {
125
125
  };
126
126
  var signOperation = function (_a) {
127
127
  var account = _a.account, transaction = _a.transaction, deviceId = _a.deviceId;
128
- return new rxjs_1.Observable(function (o) {
129
- delete cacheRecipientsNew[transaction.recipient];
130
- var fee = transaction.fee;
131
- if (!fee)
132
- throw new errors_1.FeeNotLoaded();
133
- function main() {
134
- return __awaiter(this, void 0, void 0, function () {
135
- var amount, tag, payment, instruction, prepared, signature, transport, hash, operation, e_1;
136
- var _a;
137
- return __generator(this, function (_b) {
138
- switch (_b.label) {
139
- case 0:
140
- _b.trys.push([0, 8, , 9]);
141
- amount = (0, Ripple_1.formatAPICurrencyXRP)(transaction.amount);
142
- tag = transaction.tag ? transaction.tag : undefined;
143
- payment = {
144
- source: {
145
- address: account.freshAddress,
146
- amount: amount
147
- },
148
- destination: {
149
- address: transaction.recipient,
150
- minAmount: amount,
151
- tag: tag
128
+ return (0, deviceAccess_1.withDevice)(deviceId)(function (transport) {
129
+ return new rxjs_1.Observable(function (o) {
130
+ delete cacheRecipientsNew[transaction.recipient];
131
+ var fee = transaction.fee;
132
+ if (!fee)
133
+ throw new errors_1.FeeNotLoaded();
134
+ function main() {
135
+ return __awaiter(this, void 0, void 0, function () {
136
+ var amount, tag, payment, instruction, prepared, signature, hash, operation, e_1;
137
+ var _a;
138
+ return __generator(this, function (_b) {
139
+ switch (_b.label) {
140
+ case 0:
141
+ amount = (0, Ripple_1.formatAPICurrencyXRP)(transaction.amount);
142
+ tag = transaction.tag ? transaction.tag : undefined;
143
+ payment = {
144
+ source: {
145
+ address: account.freshAddress,
146
+ amount: amount
147
+ },
148
+ destination: {
149
+ address: transaction.recipient,
150
+ minAmount: amount,
151
+ tag: tag
152
+ }
153
+ };
154
+ instruction = {
155
+ fee: (0, Ripple_1.formatAPICurrencyXRP)(fee).value,
156
+ maxLedgerVersionOffset: 12
157
+ };
158
+ if (tag)
159
+ (0, invariant_1["default"])(validateTag(new bignumber_js_1.BigNumber(tag)), "tag is set but is not in a valid format, should be between [0 - ".concat(uint32maxPlus1
160
+ .minus(1)
161
+ .toString(), "]"));
162
+ return [4 /*yield*/, (0, Ripple_2.preparePayment)(account.freshAddress, payment, instruction)];
163
+ case 1:
164
+ prepared = _b.sent();
165
+ _b.label = 2;
166
+ case 2:
167
+ _b.trys.push([2, 5, , 6]);
168
+ o.next({
169
+ type: "device-signature-requested"
170
+ });
171
+ return [4 /*yield*/, (0, signTransaction_1["default"])(account.currency, transport, account.freshAddressPath, JSON.parse(prepared.txJSON))];
172
+ case 3:
173
+ signature = _b.sent();
174
+ o.next({
175
+ type: "device-signature-granted"
176
+ });
177
+ hash = "";
178
+ _a = {
179
+ id: "".concat(account.id, "-").concat(hash, "-OUT"),
180
+ hash: hash,
181
+ accountId: account.id,
182
+ type: "OUT",
183
+ value: transaction.amount,
184
+ fee: fee,
185
+ blockHash: null,
186
+ blockHeight: null,
187
+ senders: [account.freshAddress],
188
+ recipients: [transaction.recipient],
189
+ date: new Date()
190
+ };
191
+ return [4 /*yield*/, getSequenceNumber(account)];
192
+ case 4:
193
+ operation = (
194
+ // we probably can't get it so it's a predictive value
195
+ _a.transactionSequenceNumber = _b.sent(),
196
+ _a.extra = {},
197
+ _a);
198
+ if (transaction.tag) {
199
+ operation.extra.tag = transaction.tag;
152
200
  }
153
- };
154
- instruction = {
155
- fee: (0, Ripple_1.formatAPICurrencyXRP)(fee).value,
156
- maxLedgerVersionOffset: 12
157
- };
158
- if (tag)
159
- (0, invariant_1["default"])(validateTag(new bignumber_js_1.BigNumber(tag)), "tag is set but is not in a valid format, should be between [0 - ".concat(uint32maxPlus1
160
- .minus(1)
161
- .toString(), "]"));
162
- return [4 /*yield*/, (0, Ripple_2.preparePayment)(account.freshAddress, payment, instruction)];
163
- case 1:
164
- prepared = _b.sent();
165
- signature = void 0;
166
- return [4 /*yield*/, (0, hw_1.open)(deviceId)];
167
- case 2:
168
- transport = _b.sent();
169
- _b.label = 3;
170
- case 3:
171
- _b.trys.push([3, , 5, 6]);
172
- o.next({
173
- type: "device-signature-requested"
174
- });
175
- return [4 /*yield*/, (0, signTransaction_1["default"])(account.currency, transport, account.freshAddressPath, JSON.parse(prepared.txJSON))];
176
- case 4:
177
- signature = _b.sent();
178
- o.next({
179
- type: "device-signature-granted"
180
- });
181
- return [3 /*break*/, 6];
182
- case 5:
183
- (0, hw_1.close)(transport, deviceId);
184
- return [7 /*endfinally*/];
185
- case 6:
186
- hash = "";
187
- _a = {
188
- id: "".concat(account.id, "-").concat(hash, "-OUT"),
189
- hash: hash,
190
- accountId: account.id,
191
- type: "OUT",
192
- value: transaction.amount,
193
- fee: fee,
194
- blockHash: null,
195
- blockHeight: null,
196
- senders: [account.freshAddress],
197
- recipients: [transaction.recipient],
198
- date: new Date()
199
- };
200
- return [4 /*yield*/, getSequenceNumber(account)];
201
- case 7:
202
- operation = (
203
- // we probably can't get it so it's a predictive value
204
- _a.transactionSequenceNumber = _b.sent(),
205
- _a.extra = {},
206
- _a);
207
- if (transaction.tag) {
208
- operation.extra.tag = transaction.tag;
209
- }
210
- o.next({
211
- type: "signed",
212
- signedOperation: {
213
- operation: operation,
214
- signature: signature,
215
- expirationDate: null
201
+ o.next({
202
+ type: "signed",
203
+ signedOperation: {
204
+ operation: operation,
205
+ signature: signature,
206
+ expirationDate: null
207
+ }
208
+ });
209
+ return [3 /*break*/, 6];
210
+ case 5:
211
+ e_1 = _b.sent();
212
+ if (e_1 && e_1.name === "RippledError" && e_1.data.resultMessage) {
213
+ throw new Error(e_1.data.resultMessage);
216
214
  }
217
- });
218
- return [3 /*break*/, 9];
219
- case 8:
220
- e_1 = _b.sent();
221
- if (e_1 && e_1.name === "RippledError" && e_1.data.resultMessage) {
222
- throw new Error(e_1.data.resultMessage);
223
- }
224
- throw e_1;
225
- case 9: return [2 /*return*/];
226
- }
215
+ throw e_1;
216
+ case 6: return [2 /*return*/];
217
+ }
218
+ });
227
219
  });
228
- });
229
- }
230
- main().then(function () { return o.complete(); }, function (e) { return o.error(e); });
220
+ }
221
+ main().then(function () { return o.complete(); }, function (e) { return o.error(e); });
222
+ });
231
223
  });
232
224
  };
233
225
  var broadcast = function (_a) {
@@ -337,222 +329,216 @@ var currencyBridge = {
337
329
  hydrate: function () { },
338
330
  scanAccounts: function (_a) {
339
331
  var currency = _a.currency, deviceId = _a.deviceId;
340
- return new rxjs_1.Observable(function (o) {
341
- var finished = false;
342
- var unsubscribe = function () {
343
- finished = true;
344
- };
345
- function main() {
346
- return __awaiter(this, void 0, void 0, function () {
347
- var transport, serverInfo, ledgers, minLedgerVersion, maxLedgerVersion, derivationModes, derivationModes_1, derivationModes_1_1, derivationMode, derivationScheme, stopAt, index, freshAddressPath, address, accountId, info, e_3, freshAddress, balance, transactions, account, e_4_1, e_5;
348
- var e_4, _a;
349
- return __generator(this, function (_b) {
350
- switch (_b.label) {
351
- case 0:
352
- _b.trys.push([0, 18, 19, 22]);
353
- return [4 /*yield*/, (0, hw_1.open)(deviceId)];
354
- case 1:
355
- transport = _b.sent();
356
- return [4 /*yield*/, (0, Ripple_2.getServerInfo)()];
357
- case 2:
358
- serverInfo = _b.sent();
359
- ledgers = serverInfo.completeLedgers.split("-");
360
- minLedgerVersion = Number(ledgers[0]);
361
- maxLedgerVersion = Number(ledgers[1]);
362
- derivationModes = (0, derivation_1.getDerivationModesForCurrency)(currency);
363
- _b.label = 3;
364
- case 3:
365
- _b.trys.push([3, 15, 16, 17]);
366
- derivationModes_1 = __values(derivationModes), derivationModes_1_1 = derivationModes_1.next();
367
- _b.label = 4;
368
- case 4:
369
- if (!!derivationModes_1_1.done) return [3 /*break*/, 14];
370
- derivationMode = derivationModes_1_1.value;
371
- derivationScheme = (0, derivation_1.getDerivationScheme)({
372
- derivationMode: derivationMode,
373
- currency: currency
374
- });
375
- stopAt = (0, derivation_1.isIterableDerivationMode)(derivationMode) ? 255 : 1;
376
- index = 0;
377
- _b.label = 5;
378
- case 5:
379
- if (!(index < stopAt)) return [3 /*break*/, 13];
380
- if (!(0, derivation_1.derivationModeSupportsIndex)(derivationMode, index))
381
- return [3 /*break*/, 12];
382
- freshAddressPath = (0, derivation_1.runDerivationScheme)(derivationScheme, currency, {
383
- account: index
384
- });
385
- return [4 /*yield*/, (0, getAddress_1["default"])(transport, {
386
- currency: currency,
387
- path: freshAddressPath,
388
- derivationMode: derivationMode
389
- })];
390
- case 6:
391
- address = (_b.sent()).address;
392
- if (finished)
393
- return [2 /*return*/];
394
- accountId = "ripplejs:2:".concat(currency.id, ":").concat(address, ":").concat(derivationMode);
395
- info = void 0;
396
- _b.label = 7;
397
- case 7:
398
- _b.trys.push([7, 9, , 10]);
399
- return [4 /*yield*/, (0, Ripple_2.getAccountInfo)(address)];
400
- case 8:
401
- info = _b.sent();
402
- return [3 /*break*/, 10];
403
- case 9:
404
- e_3 = _b.sent();
405
- if (checkAccountNotFound(e_3)) {
406
- throw e_3;
407
- }
408
- return [3 /*break*/, 10];
409
- case 10:
410
- freshAddress = address;
411
- if (!info) {
412
- // account does not exist in Ripple server
413
- // we are generating a new account locally
414
- if (derivationMode === "") {
415
- o.next({
416
- type: "discovered",
417
- account: {
418
- type: "Account",
419
- id: accountId,
420
- seedIdentifier: freshAddress,
421
- derivationMode: derivationMode,
422
- name: (0, account_2.getNewAccountPlaceholderName)({
423
- currency: currency,
332
+ return (0, deviceAccess_1.withDevice)(deviceId)(function (transport) {
333
+ return new rxjs_1.Observable(function (o) {
334
+ var finished = false;
335
+ var unsubscribe = function () {
336
+ finished = true;
337
+ };
338
+ function main() {
339
+ return __awaiter(this, void 0, void 0, function () {
340
+ var serverInfo, ledgers, minLedgerVersion, maxLedgerVersion, derivationModes, derivationModes_1, derivationModes_1_1, derivationMode, derivationScheme, stopAt, index, freshAddressPath, address, accountId, info, e_3, freshAddress, balance, transactions, account, e_4_1, e_5;
341
+ var e_4, _a;
342
+ return __generator(this, function (_b) {
343
+ switch (_b.label) {
344
+ case 0:
345
+ _b.trys.push([0, 17, , 18]);
346
+ return [4 /*yield*/, (0, Ripple_2.getServerInfo)()];
347
+ case 1:
348
+ serverInfo = _b.sent();
349
+ ledgers = serverInfo.completeLedgers.split("-");
350
+ minLedgerVersion = Number(ledgers[0]);
351
+ maxLedgerVersion = Number(ledgers[1]);
352
+ derivationModes = (0, derivation_1.getDerivationModesForCurrency)(currency);
353
+ _b.label = 2;
354
+ case 2:
355
+ _b.trys.push([2, 14, 15, 16]);
356
+ derivationModes_1 = __values(derivationModes), derivationModes_1_1 = derivationModes_1.next();
357
+ _b.label = 3;
358
+ case 3:
359
+ if (!!derivationModes_1_1.done) return [3 /*break*/, 13];
360
+ derivationMode = derivationModes_1_1.value;
361
+ derivationScheme = (0, derivation_1.getDerivationScheme)({
362
+ derivationMode: derivationMode,
363
+ currency: currency
364
+ });
365
+ stopAt = (0, derivation_1.isIterableDerivationMode)(derivationMode)
366
+ ? 255
367
+ : 1;
368
+ index = 0;
369
+ _b.label = 4;
370
+ case 4:
371
+ if (!(index < stopAt)) return [3 /*break*/, 12];
372
+ if (!(0, derivation_1.derivationModeSupportsIndex)(derivationMode, index))
373
+ return [3 /*break*/, 11];
374
+ freshAddressPath = (0, derivation_1.runDerivationScheme)(derivationScheme, currency, {
375
+ account: index
376
+ });
377
+ return [4 /*yield*/, (0, getAddress_1["default"])(transport, {
378
+ currency: currency,
379
+ path: freshAddressPath,
380
+ derivationMode: derivationMode
381
+ })];
382
+ case 5:
383
+ address = (_b.sent()).address;
384
+ if (finished)
385
+ return [2 /*return*/];
386
+ accountId = "ripplejs:2:".concat(currency.id, ":").concat(address, ":").concat(derivationMode);
387
+ info = void 0;
388
+ _b.label = 6;
389
+ case 6:
390
+ _b.trys.push([6, 8, , 9]);
391
+ return [4 /*yield*/, (0, Ripple_2.getAccountInfo)(address)];
392
+ case 7:
393
+ info = _b.sent();
394
+ return [3 /*break*/, 9];
395
+ case 8:
396
+ e_3 = _b.sent();
397
+ if (checkAccountNotFound(e_3)) {
398
+ throw e_3;
399
+ }
400
+ return [3 /*break*/, 9];
401
+ case 9:
402
+ freshAddress = address;
403
+ if (!info) {
404
+ // account does not exist in Ripple server
405
+ // we are generating a new account locally
406
+ if (derivationMode === "") {
407
+ o.next({
408
+ type: "discovered",
409
+ account: {
410
+ type: "Account",
411
+ id: accountId,
412
+ seedIdentifier: freshAddress,
413
+ derivationMode: derivationMode,
414
+ name: (0, account_2.getNewAccountPlaceholderName)({
415
+ currency: currency,
416
+ index: index,
417
+ derivationMode: derivationMode
418
+ }),
419
+ starred: false,
420
+ used: false,
421
+ freshAddress: freshAddress,
422
+ freshAddressPath: freshAddressPath,
423
+ freshAddresses: [
424
+ {
425
+ address: freshAddress,
426
+ derivationPath: freshAddressPath
427
+ },
428
+ ],
429
+ balance: new bignumber_js_1.BigNumber(0),
430
+ spendableBalance: new bignumber_js_1.BigNumber(0),
431
+ blockHeight: maxLedgerVersion,
424
432
  index: index,
425
- derivationMode: derivationMode
426
- }),
427
- starred: false,
428
- used: false,
429
- freshAddress: freshAddress,
430
- freshAddressPath: freshAddressPath,
431
- freshAddresses: [
432
- {
433
- address: freshAddress,
434
- derivationPath: freshAddressPath
435
- },
436
- ],
437
- balance: new bignumber_js_1.BigNumber(0),
438
- spendableBalance: new bignumber_js_1.BigNumber(0),
439
- blockHeight: maxLedgerVersion,
440
- index: index,
441
- currency: currency,
442
- operationsCount: 0,
443
- operations: [],
444
- pendingOperations: [],
445
- unit: currency.units[0],
446
- // @ts-expect-error archived does not exists on type Account
447
- archived: false,
448
- lastSyncDate: new Date(),
449
- creationDate: new Date(),
450
- swapHistory: [],
451
- balanceHistoryCache: account_2.emptyHistoryCache
452
- }
453
- });
433
+ currency: currency,
434
+ operationsCount: 0,
435
+ operations: [],
436
+ pendingOperations: [],
437
+ unit: currency.units[0],
438
+ // @ts-expect-error archived does not exists on type Account
439
+ archived: false,
440
+ lastSyncDate: new Date(),
441
+ creationDate: new Date(),
442
+ swapHistory: [],
443
+ balanceHistoryCache: account_2.emptyHistoryCache
444
+ }
445
+ });
446
+ }
447
+ return [3 /*break*/, 12];
454
448
  }
455
- return [3 /*break*/, 13];
456
- }
457
- if (finished)
458
- return [2 /*return*/];
459
- balance = (0, Ripple_1.parseAPIValue)(info.xrpBalance);
460
- (0, invariant_1["default"])(!balance.isNaN() && balance.isFinite(), "Ripple: invalid balance=".concat(balance.toString(), " for address ").concat(address));
461
- return [4 /*yield*/, (0, Ripple_2.getTransactions)(address, {
462
- minLedgerVersion: minLedgerVersion,
463
- maxLedgerVersion: maxLedgerVersion,
464
- types: ["payment"]
465
- })];
466
- case 11:
467
- transactions = _b.sent();
468
- if (finished)
469
- return [2 /*return*/];
470
- account = {
471
- type: "Account",
472
- id: accountId,
473
- seedIdentifier: freshAddress,
474
- derivationMode: derivationMode,
475
- name: (0, account_2.getAccountPlaceholderName)({
476
- currency: currency,
449
+ if (finished)
450
+ return [2 /*return*/];
451
+ balance = (0, Ripple_1.parseAPIValue)(info.xrpBalance);
452
+ (0, invariant_1["default"])(!balance.isNaN() && balance.isFinite(), "Ripple: invalid balance=".concat(balance.toString(), " for address ").concat(address));
453
+ return [4 /*yield*/, (0, Ripple_2.getTransactions)(address, {
454
+ minLedgerVersion: minLedgerVersion,
455
+ maxLedgerVersion: maxLedgerVersion,
456
+ types: ["payment"]
457
+ })];
458
+ case 10:
459
+ transactions = _b.sent();
460
+ if (finished)
461
+ return [2 /*return*/];
462
+ account = {
463
+ type: "Account",
464
+ id: accountId,
465
+ seedIdentifier: freshAddress,
466
+ derivationMode: derivationMode,
467
+ name: (0, account_2.getAccountPlaceholderName)({
468
+ currency: currency,
469
+ index: index,
470
+ derivationMode: derivationMode
471
+ }),
472
+ starred: false,
473
+ used: true,
474
+ freshAddress: freshAddress,
475
+ freshAddressPath: freshAddressPath,
476
+ freshAddresses: [
477
+ {
478
+ address: freshAddress,
479
+ derivationPath: freshAddressPath
480
+ },
481
+ ],
482
+ balance: balance,
483
+ spendableBalance: balance,
484
+ // TODO calc with base reserve
485
+ blockHeight: maxLedgerVersion,
477
486
  index: index,
478
- derivationMode: derivationMode
479
- }),
480
- starred: false,
481
- used: true,
482
- freshAddress: freshAddress,
483
- freshAddressPath: freshAddressPath,
484
- freshAddresses: [
485
- {
486
- address: freshAddress,
487
- derivationPath: freshAddressPath
488
- },
489
- ],
490
- balance: balance,
491
- spendableBalance: balance,
492
- // TODO calc with base reserve
493
- blockHeight: maxLedgerVersion,
494
- index: index,
495
- currency: currency,
496
- operationsCount: 0,
497
- operations: [],
498
- pendingOperations: [],
499
- unit: currency.units[0],
500
- lastSyncDate: new Date(),
501
- creationDate: new Date(),
502
- swapHistory: [],
503
- balanceHistoryCache: account_2.emptyHistoryCache
504
- };
505
- account.operations = transactions
506
- .map(txToOperation(account))
507
- .filter(Boolean);
508
- account.operationsCount = account.operations.length;
509
- if (account.operations.length > 0) {
510
- account.creationDate =
511
- account.operations[account.operations.length - 1].date;
512
- }
513
- o.next({
514
- type: "discovered",
515
- account: account
516
- });
517
- _b.label = 12;
518
- case 12:
519
- index++;
520
- return [3 /*break*/, 5];
521
- case 13:
522
- derivationModes_1_1 = derivationModes_1.next();
523
- return [3 /*break*/, 4];
524
- case 14: return [3 /*break*/, 17];
525
- case 15:
526
- e_4_1 = _b.sent();
527
- e_4 = { error: e_4_1 };
528
- return [3 /*break*/, 17];
529
- case 16:
530
- try {
531
- if (derivationModes_1_1 && !derivationModes_1_1.done && (_a = derivationModes_1["return"])) _a.call(derivationModes_1);
532
- }
533
- finally { if (e_4) throw e_4.error; }
534
- return [7 /*endfinally*/];
535
- case 17:
536
- o.complete();
537
- return [3 /*break*/, 22];
538
- case 18:
539
- e_5 = _b.sent();
540
- o.error(e_5);
541
- return [3 /*break*/, 22];
542
- case 19:
543
- if (!transport) return [3 /*break*/, 21];
544
- return [4 /*yield*/, (0, hw_1.close)(transport, deviceId)];
545
- case 20:
546
- _b.sent();
547
- _b.label = 21;
548
- case 21: return [7 /*endfinally*/];
549
- case 22: return [2 /*return*/];
550
- }
487
+ currency: currency,
488
+ operationsCount: 0,
489
+ operations: [],
490
+ pendingOperations: [],
491
+ unit: currency.units[0],
492
+ lastSyncDate: new Date(),
493
+ creationDate: new Date(),
494
+ swapHistory: [],
495
+ balanceHistoryCache: account_2.emptyHistoryCache
496
+ };
497
+ account.operations = transactions
498
+ .map(txToOperation(account))
499
+ .filter(Boolean);
500
+ account.operationsCount = account.operations.length;
501
+ if (account.operations.length > 0) {
502
+ account.creationDate =
503
+ account.operations[account.operations.length - 1].date;
504
+ }
505
+ o.next({
506
+ type: "discovered",
507
+ account: account
508
+ });
509
+ _b.label = 11;
510
+ case 11:
511
+ index++;
512
+ return [3 /*break*/, 4];
513
+ case 12:
514
+ derivationModes_1_1 = derivationModes_1.next();
515
+ return [3 /*break*/, 3];
516
+ case 13: return [3 /*break*/, 16];
517
+ case 14:
518
+ e_4_1 = _b.sent();
519
+ e_4 = { error: e_4_1 };
520
+ return [3 /*break*/, 16];
521
+ case 15:
522
+ try {
523
+ if (derivationModes_1_1 && !derivationModes_1_1.done && (_a = derivationModes_1["return"])) _a.call(derivationModes_1);
524
+ }
525
+ finally { if (e_4) throw e_4.error; }
526
+ return [7 /*endfinally*/];
527
+ case 16:
528
+ o.complete();
529
+ return [3 /*break*/, 18];
530
+ case 17:
531
+ e_5 = _b.sent();
532
+ o.error(e_5);
533
+ return [3 /*break*/, 18];
534
+ case 18: return [2 /*return*/];
535
+ }
536
+ });
551
537
  });
552
- });
553
- }
554
- main();
555
- return unsubscribe;
538
+ }
539
+ main();
540
+ return unsubscribe;
541
+ });
556
542
  });
557
543
  }
558
544
  };