@ledgerhq/live-cli 24.26.1-nightly.0 → 24.26.1-nightly.1

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 (2) hide show
  1. package/lib/cli.js +118 -41
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -515377,7 +515377,7 @@ var require_package7 = __commonJS({
515377
515377
  module2.exports = {
515378
515378
  name: "@ledgerhq/live-common",
515379
515379
  description: "Common ground for the Ledger Live apps",
515380
- version: "34.52.0-nightly.0",
515380
+ version: "34.52.0-nightly.1",
515381
515381
  repository: {
515382
515382
  type: "git",
515383
515383
  url: "https://github.com/LedgerHQ/ledger-live.git"
@@ -515711,7 +515711,7 @@ var require_package8 = __commonJS({
515711
515711
  "package.json"(exports2, module2) {
515712
515712
  module2.exports = {
515713
515713
  name: "@ledgerhq/live-cli",
515714
- version: "24.26.1-nightly.0",
515714
+ version: "24.26.1-nightly.1",
515715
515715
  description: "ledger-live CLI version",
515716
515716
  repository: {
515717
515717
  type: "git",
@@ -575111,6 +575111,10 @@ var OP_EQUALVERIFY = 136;
575111
575111
  var OP_CHECKSIG = 172;
575112
575112
  var ZCASH_ACTIVATION_HEIGHTS = {
575113
575113
  // https://zcash.readthedocs.io/en/latest/rtd_pages/nu_dev_guide.html
575114
+ //
575115
+ // https://zips.z.cash/zip-0255
575116
+ // https://github.com/zcash/zcash/releases/tag/v6.10.0
575117
+ NU6_1: 3146400,
575114
575118
  // https://zips.z.cash/zip-0253
575115
575119
  NU6: 2726400,
575116
575120
  // https://zips.z.cash/zip-0252
@@ -576880,7 +576884,9 @@ var defaultsSignTransaction = {
576880
576884
  };
576881
576885
  var getZcashBranchId = (blockHeight) => {
576882
576886
  const branchId = Buffer.alloc(4);
576883
- if (!blockHeight || blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU6) {
576887
+ if (!blockHeight || blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU6_1) {
576888
+ branchId.writeUInt32LE(1307332080, 0);
576889
+ } else if (blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU6) {
576884
576890
  branchId.writeUInt32LE(3370586197, 0);
576885
576891
  } else if (blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU5) {
576886
576892
  branchId.writeUInt32LE(3268858036, 0);
@@ -621482,11 +621488,13 @@ function extractType(asset, op) {
621482
621488
  return asset.parents[op.hash].type;
621483
621489
  return "NONE";
621484
621490
  }
621485
- function computeValue(asset, op, type4) {
621486
- if (type4 === "FEES")
621487
- return BigInt(op.fee.toFixed(0));
621488
- if (asset.type === "native" && op.type === "OUT")
621491
+ function computeValue(asset, op) {
621492
+ if (asset.type === "native" && ["OUT", "FEES"].includes(op.type)) {
621489
621493
  return BigInt(op.value.toFixed(0)) - BigInt(op.fee.toFixed(0));
621494
+ }
621495
+ if (asset.type === "token" && op.hash in asset.parents) {
621496
+ return BigInt(asset.parents[op.hash].value.toFixed(0));
621497
+ }
621490
621498
  return BigInt(op.value.toFixed(0));
621491
621499
  }
621492
621500
  function toOperation(asset, op) {
@@ -621497,7 +621505,7 @@ function toOperation(asset, op) {
621497
621505
  assetInfo.type = extractStandard(op);
621498
621506
  }
621499
621507
  const type4 = extractType(asset, op);
621500
- const value2 = computeValue(asset, op, type4);
621508
+ const value2 = computeValue(asset, op);
621501
621509
  return {
621502
621510
  id: op.id,
621503
621511
  type: type4,
@@ -621515,8 +621523,16 @@ function toOperation(asset, op) {
621515
621523
  date: op.date
621516
621524
  },
621517
621525
  details: {
621518
- ledgerOpType: op.type,
621519
- ...asset.type === "token" ? { assetAmount: op.value.toFixed(0) } : {}
621526
+ sequence: op.transactionSequenceNumber,
621527
+ status: op.hasFailed ? "failed" : "success",
621528
+ ...asset.type === "token" ? {
621529
+ ledgerOpType: op.type,
621530
+ assetAmount: op.value.toFixed(0),
621531
+ assetSenders: op.senders,
621532
+ assetRecipients: op.recipients,
621533
+ parentSenders: asset.parents[op.hash]?.senders ?? [],
621534
+ parentRecipients: asset.parents[op.hash]?.recipients ?? []
621535
+ } : {}
621520
621536
  }
621521
621537
  };
621522
621538
  }
@@ -621524,16 +621540,22 @@ async function listOperations2(currency24, address3, minHeight) {
621524
621540
  const explorerApi2 = getExplorerApi(currency24);
621525
621541
  const { lastCoinOperations, lastTokenOperations, lastNftOperations } = await explorerApi2.getLastOperations(currency24, address3, `js:2:${currency24.id}:${address3}:`, minHeight);
621526
621542
  const isNativeOperation = (coinOperation) => ![...lastTokenOperations, ...lastNftOperations].map((op) => op.hash).includes(coinOperation.hash);
621527
- const isTokenOperation = (coinOperation) => lastTokenOperations.map((op) => op.hash).includes(coinOperation.hash);
621543
+ const isTokenOperation = (coinOperation) => [...lastTokenOperations, ...lastNftOperations].map((op) => op.hash).includes(coinOperation.hash);
621528
621544
  const parents = Object.fromEntries(lastCoinOperations.filter(isTokenOperation).map((op) => [op.hash, op]));
621529
621545
  const nativeOperations = lastCoinOperations.filter(isNativeOperation).map((op) => toOperation({ type: "native" }, op));
621530
- const tokenOperations = lastTokenOperations.map((op) => toOperation({ type: "token", owner: address3, parents }, op));
621531
- const hasValidType = (operation) => ["NONE", "FEES", "IN", "OUT", "DELEGATE", "UNDELEGATE", "REDELEGATE"].includes(operation.type);
621532
- const isAlone = (operation) => ["NONE", "FEES"].includes(operation.type) && !("assetAmount" in (operation.details ?? {}));
621533
- return [
621534
- nativeOperations.concat(tokenOperations).filter((op) => hasValidType(op) && !isAlone(op)),
621535
- ""
621536
- ];
621546
+ const tokenOperations = [...lastTokenOperations, ...lastNftOperations].map((op) => toOperation({ type: "token", owner: address3, parents }, op));
621547
+ const hasValidType = (operation) => [
621548
+ "NONE",
621549
+ "FEES",
621550
+ "IN",
621551
+ "OUT",
621552
+ "DELEGATE",
621553
+ "UNDELEGATE",
621554
+ "REDELEGATE",
621555
+ "NFT_IN",
621556
+ "NFT_OUT"
621557
+ ].includes(operation.type);
621558
+ return [nativeOperations.concat(tokenOperations).filter(hasValidType), ""];
621537
621559
  }
621538
621560
 
621539
621561
  // ../../libs/coin-modules/coin-evm/lib-es/logic/craftTransaction.js
@@ -850138,6 +850160,25 @@ function extractBalance(balances, type4) {
850138
850160
  value: 0n
850139
850161
  };
850140
850162
  }
850163
+ function isStringArray(value2) {
850164
+ return Array.isArray(value2) && value2.every((item) => typeof item === "string");
850165
+ }
850166
+ function cleanedOperation(operation) {
850167
+ if (!operation.extra)
850168
+ return operation;
850169
+ const extraToClean = /* @__PURE__ */ new Set([
850170
+ "assetReference",
850171
+ "assetAmount",
850172
+ "assetOwner",
850173
+ "assetSenders",
850174
+ "assetRecipients",
850175
+ "parentSenders",
850176
+ "parentRecipients",
850177
+ "ledgerOpType"
850178
+ ]);
850179
+ const cleanedExtra = Object.fromEntries(Object.entries(operation.extra).filter(([key2]) => !extraToClean.has(key2)));
850180
+ return { ...operation, extra: cleanedExtra };
850181
+ }
850141
850182
  function adaptCoreOperationToLiveOperation(accountId2, op) {
850142
850183
  const opType = op.type;
850143
850184
  const extra = {};
@@ -850147,6 +850188,18 @@ function adaptCoreOperationToLiveOperation(accountId2, op) {
850147
850188
  if (op.details?.assetAmount !== void 0) {
850148
850189
  extra.assetAmount = op.details.assetAmount;
850149
850190
  }
850191
+ if (isStringArray(op.details?.assetSenders)) {
850192
+ extra.assetSenders = op.details?.assetSenders;
850193
+ }
850194
+ if (isStringArray(op.details?.assetRecipients)) {
850195
+ extra.assetRecipients = op.details?.assetRecipients;
850196
+ }
850197
+ if (isStringArray(op.details?.parentSenders)) {
850198
+ extra.parentSenders = op.details?.parentSenders;
850199
+ }
850200
+ if (isStringArray(op.details?.parentRecipients)) {
850201
+ extra.parentRecipients = op.details?.parentRecipients;
850202
+ }
850150
850203
  if (op.asset?.type !== "native") {
850151
850204
  extra.assetReference = "assetReference" in (op.asset ?? {}) ? op.asset.assetReference : "";
850152
850205
  extra.assetOwner = "assetOwner" in (op.asset ?? {}) ? op.asset.assetOwner : "";
@@ -850164,8 +850217,8 @@ function adaptCoreOperationToLiveOperation(accountId2, op) {
850164
850217
  fee: bnFees,
850165
850218
  blockHash: op.tx.block.hash,
850166
850219
  blockHeight: op.tx.block.height,
850167
- senders: op.senders,
850168
- recipients: op.recipients,
850220
+ senders: extra.parentSenders ?? op.senders,
850221
+ recipients: extra.parentRecipients ?? op.recipients,
850169
850222
  date: op.tx.date,
850170
850223
  transactionSequenceNumber: op.details?.sequence,
850171
850224
  hasFailed: op.details?.status === "failed",
@@ -850315,12 +850368,15 @@ function buildTokenAccount({ parentAccountId, assetBalance, token, operations: o
850315
850368
  const id7 = encodeTokenAccountId(parentAccountId, token);
850316
850369
  const balance2 = new import_bignumber356.default(assetBalance.value.toString() || "0");
850317
850370
  const spendableBalance = new import_bignumber356.default(assetBalance.value.toString()).minus(new import_bignumber356.default(assetBalance.locked?.toString() || "0"));
850318
- const tokenOperations = operations4.map((op) => ({
850371
+ const tokenOperations = operations4.map((op) => cleanedOperation({
850319
850372
  ...op,
850320
850373
  id: encodeOperationId(id7, op.hash, op.extra?.ledgerOpType),
850321
850374
  accountId: id7,
850322
850375
  type: op.extra?.ledgerOpType,
850323
- value: op.extra?.assetAmount ? new import_bignumber356.default(op.extra?.assetAmount) : op.value
850376
+ contract: token.contractAddress,
850377
+ value: op.extra?.assetAmount ? new import_bignumber356.default(op.extra?.assetAmount) : op.value,
850378
+ senders: op.extra?.assetSenders ?? op.senders,
850379
+ recipients: op.extra?.assetRecipients ?? op.recipients
850324
850380
  }));
850325
850381
  return {
850326
850382
  type: "TokenAccount",
@@ -850338,15 +850394,14 @@ function buildTokenAccount({ parentAccountId, assetBalance, token, operations: o
850338
850394
  // calculated in the jsHelpers
850339
850395
  };
850340
850396
  }
850341
- async function buildSubAccounts4({ currency: currency24, accountId: accountId2, allTokenAssetsBalances, syncConfig, operations: operations4, getTokenFromAsset: getTokenFromAsset3 }) {
850397
+ async function buildSubAccounts4({ accountId: accountId2, allTokenAssetsBalances, syncConfig, operations: operations4, getTokenFromAsset: getTokenFromAsset3 }) {
850342
850398
  const { blacklistedTokenIds = [] } = syncConfig;
850343
- const allTokens = listTokensForCryptoCurrency(currency24);
850344
850399
  const tokenAccounts = [];
850345
- if (allTokens.length === 0 || allTokenAssetsBalances.length === 0) {
850400
+ if (allTokenAssetsBalances.length === 0 || !getTokenFromAsset3) {
850346
850401
  return tokenAccounts;
850347
850402
  }
850348
850403
  for (const balance2 of allTokenAssetsBalances) {
850349
- const token = getTokenFromAsset3 && await getTokenFromAsset3(balance2.asset);
850404
+ const token = await getTokenFromAsset3(balance2.asset);
850350
850405
  if (token && !blacklistedTokenIds.includes(token.id)) {
850351
850406
  tokenAccounts.push(buildTokenAccount({
850352
850407
  parentAccountId: accountId2,
@@ -850358,8 +850413,35 @@ async function buildSubAccounts4({ currency: currency24, accountId: accountId2,
850358
850413
  }
850359
850414
  return tokenAccounts;
850360
850415
  }
850416
+ function mergeSubAccounts5(oldSubAccounts, newSubAccounts) {
850417
+ if (!oldSubAccounts.length) {
850418
+ return newSubAccounts;
850419
+ }
850420
+ const oldSubAccountsById = Object.fromEntries(oldSubAccounts.map((account3) => [account3.id, account3]));
850421
+ const newSubAccountsToAdd = [];
850422
+ for (const newSubAccount of newSubAccounts) {
850423
+ const existingSubAccount = oldSubAccountsById[newSubAccount.id];
850424
+ if (!existingSubAccount) {
850425
+ newSubAccountsToAdd.push(newSubAccount);
850426
+ continue;
850427
+ }
850428
+ const operations4 = mergeOps(existingSubAccount.operations, newSubAccount.operations);
850429
+ oldSubAccountsById[newSubAccount.id] = {
850430
+ ...existingSubAccount,
850431
+ balance: newSubAccount.balance,
850432
+ spendableBalance: newSubAccount.spendableBalance,
850433
+ operations: operations4,
850434
+ operationsCount: operations4.length
850435
+ };
850436
+ }
850437
+ const updatedOldSubAccounts = Object.values(oldSubAccountsById);
850438
+ return [...updatedOldSubAccounts, ...newSubAccountsToAdd];
850439
+ }
850361
850440
 
850362
850441
  // ../../libs/ledger-live-common/lib-es/bridge/generic-alpaca/getAccountShape.js
850442
+ function isNftCoreOp(operation) {
850443
+ return typeof operation.details?.ledgerOpType === "string" && ["NFT_IN", "NFT_OUT"].includes(operation.details?.ledgerOpType);
850444
+ }
850363
850445
  function genericGetAccountShape(network, kind) {
850364
850446
  return async (info6, syncConfig) => {
850365
850447
  const { address: address3, initialAccount, currency: currency24, derivationMode } = info6;
@@ -850394,29 +850476,24 @@ function genericGetAccountShape(network, kind) {
850394
850476
  paginationParams.lastPagingToken = lastPagingToken;
850395
850477
  }
850396
850478
  const [newCoreOps] = await alpacaApi.listOperations(address3, paginationParams);
850397
- const newOps = newCoreOps.map((op) => adaptCoreOperationToLiveOperation(accountId2, op));
850398
- const mergedOps = mergeOps(oldOps, newOps);
850399
- const assetOperations = [];
850400
- mergedOps.forEach((operation) => {
850401
- if (operation?.extra?.assetReference && operation?.extra?.assetOwner && !["OPT_IN", "OPT_OUT"].includes(operation.type)) {
850402
- assetOperations.push(operation);
850403
- }
850404
- });
850405
- const subAccounts = await buildSubAccounts4({
850406
- currency: currency24,
850479
+ const newOps = newCoreOps.filter((op) => !isNftCoreOp(op)).map((op) => adaptCoreOperationToLiveOperation(accountId2, op));
850480
+ const newAssetOperations = newOps.filter((operation) => operation?.extra?.assetReference && operation?.extra?.assetOwner && !["OPT_IN", "OPT_OUT"].includes(operation.type));
850481
+ const newSubAccounts = await buildSubAccounts4({
850407
850482
  accountId: accountId2,
850408
850483
  allTokenAssetsBalances,
850409
850484
  syncConfig,
850410
- operations: assetOperations,
850485
+ operations: newAssetOperations,
850411
850486
  getTokenFromAsset: alpacaApi.getTokenFromAsset
850412
850487
  });
850413
- const operations4 = mergedOps.map((op) => {
850414
- const subOperations = inferSubOperations(op.hash, subAccounts);
850415
- return {
850488
+ const subAccounts = mergeSubAccounts5(initialAccount?.subAccounts ?? [], newSubAccounts);
850489
+ const newOpsWithSubs = newOps.map((op) => {
850490
+ const subOperations = inferSubOperations(op.hash, newSubAccounts);
850491
+ return cleanedOperation({
850416
850492
  ...op,
850417
850493
  subOperations
850418
- };
850494
+ });
850419
850495
  });
850496
+ const operations4 = mergeOps(oldOps, newOpsWithSubs);
850420
850497
  const res = {
850421
850498
  id: accountId2,
850422
850499
  xpub: address3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/live-cli",
3
- "version": "24.26.1-nightly.0",
3
+ "version": "24.26.1-nightly.1",
4
4
  "description": "ledger-live CLI version",
5
5
  "repository": {
6
6
  "type": "git",