@ledgerhq/live-cli 24.18.4-nightly.0 → 24.18.4-nightly.2

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 +143 -61
  2. package/package.json +3 -3
package/lib/cli.js CHANGED
@@ -530283,7 +530283,7 @@ var require_package8 = __commonJS({
530283
530283
  module2.exports = {
530284
530284
  name: "@ledgerhq/live-common",
530285
530285
  description: "Common ground for the Ledger Live apps",
530286
- version: "34.35.0-nightly.0",
530286
+ version: "34.35.0-nightly.2",
530287
530287
  repository: {
530288
530288
  type: "git",
530289
530289
  url: "https://github.com/LedgerHQ/ledger-live.git"
@@ -537082,7 +537082,7 @@ var require_package9 = __commonJS({
537082
537082
  "package.json"(exports2, module2) {
537083
537083
  module2.exports = {
537084
537084
  name: "@ledgerhq/live-cli",
537085
- version: "24.18.4-nightly.0",
537085
+ version: "24.18.4-nightly.2",
537086
537086
  description: "ledger-live CLI version",
537087
537087
  repository: {
537088
537088
  type: "git",
@@ -581498,8 +581498,6 @@ var import_bignumber53 = __toESM(require("bignumber.js"));
581498
581498
 
581499
581499
  // ../../libs/coin-modules/coin-aptos/lib-es/constants.js
581500
581500
  var import_bignumber52 = __toESM(require("bignumber.js"));
581501
- var DEFAULT_GAS = new import_bignumber52.default(200);
581502
- var DEFAULT_GAS_PRICE = new import_bignumber52.default(100);
581503
581501
  var ESTIMATE_GAS_MUL = new import_bignumber52.default(1);
581504
581502
  var TX_STATUS;
581505
581503
  (function(TX_STATUS2) {
@@ -581532,6 +581530,8 @@ var DIRECTION;
581532
581530
  DIRECTION2["UNKNOWN"] = "UNKNOWN";
581533
581531
  })(DIRECTION || (DIRECTION = {}));
581534
581532
  var SUPPORTED_TOKEN_TYPES = ["coin", "fungible_asset"];
581533
+ var DEFAULT_GAS = new import_bignumber52.default(200);
581534
+ var DEFAULT_GAS_PRICE = new import_bignumber52.default(100);
581535
581535
 
581536
581536
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/logic.js
581537
581537
  var CLEAN_HEX_REGEXP = /^0x0*|^0+/;
@@ -581544,13 +581544,6 @@ var getMaxSendBalance = (gas, gasPrice, account3, transaction) => {
581544
581544
  const totalGas = gas.multipliedBy(gasPrice);
581545
581545
  return fromTokenAccount ? tokenAccount.spendableBalance : account3.spendableBalance.gt(totalGas) ? account3.spendableBalance.minus(totalGas) : new import_bignumber53.default(0);
581546
581546
  };
581547
- function normalizeTransactionOptions(options22) {
581548
- const check3 = (v37) => (v37 ?? "").toString().trim() ? v37 : void 0;
581549
- return {
581550
- maxGasAmount: check3(options22.maxGasAmount),
581551
- gasUnitPrice: check3(options22.gasUnitPrice)
581552
- };
581553
- }
581554
581547
  var getBlankOperation = (tx, id5) => ({
581555
581548
  id: "",
581556
581549
  hash: tx.hash,
@@ -581794,6 +581787,15 @@ var getTransactionStatus_default = getTransactionStatus2;
581794
581787
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/estimateMaxSpendable.js
581795
581788
  var import_bignumber57 = require("bignumber.js");
581796
581789
 
581790
+ // ../../libs/coin-modules/coin-aptos/lib-es/logic/combine.js
581791
+ function combineSignedTransaction(txRaw, signature3, pubkey) {
581792
+ const authenticator = new u12(pubkey, signature3);
581793
+ return wn({
581794
+ transaction: { rawTransaction: txRaw },
581795
+ senderAuthenticator: authenticator
581796
+ });
581797
+ }
581798
+
581797
581799
  // ../../node_modules/.pnpm/@apollo+client@3.12.6_graphql@16.10.0_react@18.3.1/node_modules/@apollo/client/core/ApolloClient.js
581798
581800
  init_tslib_es6();
581799
581801
 
@@ -594541,24 +594543,22 @@ var AptosAPI = class {
594541
594543
  options: options22
594542
594544
  });
594543
594545
  }
594544
- async broadcast(signature3) {
594545
- const txBytes = Uint8Array.from(Buffer.from(signature3, "hex"));
594546
- const pendingTx = await o5({
594547
- contentType: g7.BCS_SIGNED_TRANSACTION,
594546
+ async broadcast(tx) {
594547
+ const txBytes = a.fromHexString(tx).toUint8Array();
594548
+ const pendingTx = await q2({
594548
594549
  aptosConfig: this.aptosClient.config,
594549
594550
  body: txBytes,
594550
594551
  path: "transactions",
594551
- type: t17.FULLNODE,
594552
- originMethod: ""
594552
+ originMethod: "",
594553
+ contentType: g7.BCS_SIGNED_TRANSACTION
594553
594554
  });
594554
594555
  return pendingTx.data.hash;
594555
594556
  }
594556
594557
  async getBalance(address4, token) {
594557
594558
  if (token.tokenType === "coin") {
594558
594559
  return await this.getCoinBalance(address4, token.contractAddress);
594559
- } else {
594560
- return await this.getFABalance(address4, token.contractAddress);
594561
594560
  }
594561
+ return await this.getFABalance(address4, token.contractAddress);
594562
594562
  }
594563
594563
  async getLastBlock() {
594564
594564
  const { block_height } = await this.aptosClient.getLedgerInfo();
@@ -594683,6 +594683,23 @@ var AptosAPI = class {
594683
594683
  hash: block2.block_hash
594684
594684
  };
594685
594685
  }
594686
+ async getBalances(address4) {
594687
+ const response = await this.aptosClient.getCurrentFungibleAssetBalances({
594688
+ options: {
594689
+ offset: 0,
594690
+ limit: 1e3,
594691
+ where: {
594692
+ asset_type: { _eq: APTOS_ASSET_ID },
594693
+ // to return all asset balances (native / token) we should remove this filter
594694
+ owner_address: { _eq: address4 }
594695
+ }
594696
+ }
594697
+ });
594698
+ return response.map((x23) => ({
594699
+ asset_type: x23.asset_type ?? "-",
594700
+ amount: (0, import_bignumber55.default)(x23.amount)
594701
+ }));
594702
+ }
594686
594703
  };
594687
594704
 
594688
594705
  // ../../libs/coin-modules/coin-aptos/lib-es/network/index.js
@@ -594699,20 +594716,25 @@ async function signTransaction2(signerContext3, account3, deviceId, rawTxn) {
594699
594716
  rawTransaction: rawTxn
594700
594717
  });
594701
594718
  const response = await signerContext3(deviceId, async (signer) => await signer.signTransaction(derivationPath, Buffer.from(signingMessage)));
594702
- const sigHexStr = a.fromHexString(response.signature.toString("hex"));
594703
- const signature3 = new h9(sigHexStr.toUint8Array());
594704
- const authenticator = new u12(new f6(publicKey3.toString("hex")), signature3);
594705
- return wn({
594706
- transaction: { rawTransaction: rawTxn },
594707
- senderAuthenticator: authenticator
594708
- });
594719
+ const signature3 = new h9(response.signature.toString("hex"));
594720
+ const pubkey = new f6(publicKey3.toString("hex"));
594721
+ return combineSignedTransaction(rawTxn, signature3, pubkey);
594709
594722
  }
594710
594723
 
594711
594724
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/getFeesForTransaction.js
594712
594725
  init_lib_es2();
594713
594726
  var import_bignumber56 = __toESM(require("bignumber.js"));
594714
594727
 
594715
- // ../../libs/coin-modules/coin-aptos/lib-es/bridge/buildTransaction.js
594728
+ // ../../libs/coin-modules/coin-aptos/lib-es/logic/normalizeTransactionOptions.js
594729
+ function normalizeTransactionOptions(options22) {
594730
+ const check3 = (v37) => (v37 ?? "").toString().trim() ? v37 : void 0;
594731
+ return {
594732
+ maxGasAmount: check3(options22.maxGasAmount),
594733
+ gasUnitPrice: check3(options22.gasUnitPrice)
594734
+ };
594735
+ }
594736
+
594737
+ // ../../libs/coin-modules/coin-aptos/lib-es/logic/buildTransaction.js
594716
594738
  var buildTransaction = async (account3, transaction, aptosClient2) => {
594717
594739
  const subAccount = findSubAccountById(account3, transaction.subAccountId ?? "");
594718
594740
  const txPayload = getPayload(subAccount, transaction);
@@ -594845,21 +594867,6 @@ var prepareTransaction2 = async (account3, transaction) => {
594845
594867
  };
594846
594868
  var prepareTransaction_default = prepareTransaction2;
594847
594869
 
594848
- // ../../libs/coin-modules/coin-aptos/lib-es/bridge/createTransaction.js
594849
- var import_bignumber59 = __toESM(require("bignumber.js"));
594850
- var createTransaction2 = () => ({
594851
- family: "aptos",
594852
- mode: "send",
594853
- amount: (0, import_bignumber59.default)(0),
594854
- recipient: "",
594855
- useAllAmount: false,
594856
- options: {
594857
- maxGasAmount: DEFAULT_GAS.toString(),
594858
- gasUnitPrice: DEFAULT_GAS_PRICE.toString()
594859
- }
594860
- });
594861
- var createTransaction_default2 = createTransaction2;
594862
-
594863
594870
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/synchronisation.js
594864
594871
  var updatableSubAccountProperties = [
594865
594872
  { name: "balance", isOps: false },
@@ -594981,7 +594988,7 @@ var getAccountShape2 = async (info6) => {
594981
594988
 
594982
594989
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/signOperation.js
594983
594990
  var import_rxjs10 = require("rxjs");
594984
- var import_bignumber60 = __toESM(require("bignumber.js"));
594991
+ var import_bignumber59 = __toESM(require("bignumber.js"));
594985
594992
  var buildSignOperation2 = (signerContext3) => ({ account: account3, transaction, deviceId }) => new import_rxjs10.Observable((o47) => {
594986
594993
  async function main2() {
594987
594994
  o47.next({ type: "device-signature-requested" });
@@ -594993,7 +595000,7 @@ var buildSignOperation2 = (signerContext3) => ({ account: account3, transaction,
594993
595000
  const accountId2 = account3.id;
594994
595001
  const hash12 = "";
594995
595002
  const type4 = "OUT";
594996
- const fee = transaction.fees || new import_bignumber60.default(0);
595003
+ const fee = transaction.fees || new import_bignumber59.default(0);
594997
595004
  const extra = {};
594998
595005
  const senders = [];
594999
595006
  const recipients = [];
@@ -595050,6 +595057,21 @@ var broadcast3 = async ({ signedOperation, account: account3 }) => {
595050
595057
  };
595051
595058
  var broadcast_default = broadcast3;
595052
595059
 
595060
+ // ../../libs/coin-modules/coin-aptos/lib-es/logic/createTransaction.js
595061
+ var import_bignumber60 = __toESM(require("bignumber.js"));
595062
+ var createTransaction2 = () => ({
595063
+ family: "aptos",
595064
+ mode: "send",
595065
+ amount: (0, import_bignumber60.default)(0),
595066
+ recipient: "",
595067
+ useAllAmount: false,
595068
+ options: {
595069
+ maxGasAmount: DEFAULT_GAS.toString(),
595070
+ gasUnitPrice: DEFAULT_GAS_PRICE.toString()
595071
+ }
595072
+ });
595073
+ var createTransaction_default2 = createTransaction2;
595074
+
595053
595075
  // ../../libs/coin-modules/coin-aptos/lib-es/bridge/index.js
595054
595076
  function buildCurrencyBridge2(signerContext3) {
595055
595077
  const getAddress12 = signer_default(signerContext3);
@@ -699518,6 +699540,14 @@ async function calculateAmount2({ account: account3, transaction }) {
699518
699540
  function base64ToUrlSafeBase64(data6) {
699519
699541
  return data6.replace(/\//g, "_").replace(/\+/g, "-");
699520
699542
  }
699543
+ function patchOperationWithExtra(operation, extra) {
699544
+ return {
699545
+ ...operation,
699546
+ extra,
699547
+ subOperations: (operation.subOperations ?? []).map((op) => ({ ...op, extra })),
699548
+ nftOperations: (operation.nftOperations ?? []).map((op) => ({ ...op, extra }))
699549
+ };
699550
+ }
699521
699551
 
699522
699552
  // ../../libs/coin-modules/coin-hedera/lib-es/bridge/getTransactionStatus.js
699523
699553
  var getTransactionStatus8 = async (account3, transaction) => {
@@ -699644,17 +699674,32 @@ async function getAccountsForPublicKey(publicKey3) {
699644
699674
  }
699645
699675
  return accounts2;
699646
699676
  }
699677
+ async function getAccountTransactions2(address4, since) {
699678
+ const transactions3 = [];
699679
+ const params = new URLSearchParams({
699680
+ "account.id": address4,
699681
+ order: "desc",
699682
+ limit: "100"
699683
+ });
699684
+ if (since) {
699685
+ params.append("timestamp", `gt:${since}`);
699686
+ }
699687
+ let nextUrl = `/api/v1/transactions?${params.toString()}`;
699688
+ while (nextUrl) {
699689
+ const res = await fetch5(nextUrl);
699690
+ const newTransactions = res.data.transactions;
699691
+ if (newTransactions.length === 0)
699692
+ break;
699693
+ transactions3.push(...newTransactions);
699694
+ nextUrl = res.data.links.next;
699695
+ }
699696
+ return transactions3;
699697
+ }
699647
699698
  async function getOperationsForAccount(ledgerAccountId, address4, latestOperationTimestamp) {
699699
+ const rawOperations = await getAccountTransactions2(address4, latestOperationTimestamp);
699648
699700
  const operations = [];
699649
- let r38 = await fetch5(`/api/v1/transactions?account.id=${address4}&timestamp=gt:${latestOperationTimestamp}`);
699650
- const rawOperations = r38.data.transactions;
699651
- while (r38.data.links.next) {
699652
- r38 = await fetch5(r38.data.links.next);
699653
- const newOperations = r38.data.transactions;
699654
- rawOperations.push(...newOperations);
699655
- }
699656
699701
  for (const raw of rawOperations) {
699657
- const { consensus_timestamp } = raw;
699702
+ const { consensus_timestamp, transaction_id } = raw;
699658
699703
  const timestamp = new Date(parseInt(consensus_timestamp.split(".")[0], 10) * 1e3);
699659
699704
  const senders = [];
699660
699705
  const recipients = [];
@@ -699701,7 +699746,10 @@ async function getOperationsForAccount(ledgerAccountId, address4, latestOperatio
699701
699746
  // Set a value just so that it's considered confirmed according to isConfirmedOperation
699702
699747
  blockHeight: 5,
699703
699748
  blockHash: null,
699704
- extra: { consensusTimestamp: consensus_timestamp },
699749
+ extra: {
699750
+ consensusTimestamp: consensus_timestamp,
699751
+ transactionId: transaction_id
699752
+ },
699705
699753
  fee,
699706
699754
  hash: hash12,
699707
699755
  recipients,
@@ -699727,8 +699775,8 @@ var getAccountShape7 = async (info6) => {
699727
699775
  });
699728
699776
  const accountBalance = await getAccountBalance(address4);
699729
699777
  const oldOperations = initialAccount?.operations ?? [];
699730
- const latestOperationTimestamp = oldOperations[0] ? Math.floor(oldOperations[0].date.getTime() / 1e3) : 0;
699731
- const newOperations = await getOperationsForAccount(liveAccountId, address4, new import_bignumber166.BigNumber(latestOperationTimestamp).toString());
699778
+ const latestOperationTimestamp = oldOperations[0] ? new import_bignumber166.BigNumber(Math.floor(oldOperations[0].date.getTime() / 1e3)) : null;
699779
+ const newOperations = await getOperationsForAccount(liveAccountId, address4, latestOperationTimestamp ? latestOperationTimestamp.toString() : null);
699732
699780
  const operations = mergeOps(oldOperations, newOperations);
699733
699781
  return {
699734
699782
  id: liveAccountId,
@@ -699829,7 +699877,13 @@ var broadcast9 = async ({ signedOperation }) => {
699829
699877
  const response = await broadcastTransaction4(hederaTransaction);
699830
699878
  const base64Hash = Buffer.from(response.transactionHash).toString("base64");
699831
699879
  const base64HashUrlSafe = base64ToUrlSafeBase64(base64Hash);
699832
- return patchOperationWithHash(operation, base64HashUrlSafe);
699880
+ const extra = {
699881
+ transactionId: response.transactionId.toString()
699882
+ };
699883
+ let patchedOperation = operation;
699884
+ patchedOperation = patchOperationWithHash(patchedOperation, base64HashUrlSafe);
699885
+ patchedOperation = patchOperationWithExtra(patchedOperation, extra);
699886
+ return patchedOperation;
699833
699887
  };
699834
699888
 
699835
699889
  // ../../libs/coin-modules/coin-hedera/lib-es/bridge/receive.js
@@ -777351,6 +777405,15 @@ var SWAP_DATA_CDN = {
777351
777405
  mainUrl: "https://changelly.com/",
777352
777406
  needsKYC: false
777353
777407
  },
777408
+ changelly_v2: {
777409
+ type: "CEX",
777410
+ useInExchangeApp: true,
777411
+ displayName: "Changelly",
777412
+ termsOfUseUrl: "https://changelly.com/terms-of-use",
777413
+ supportUrl: "https://support.changelly.com/en/support/home",
777414
+ mainUrl: "https://changelly.com/",
777415
+ needsKYC: false
777416
+ },
777354
777417
  cic: {
777355
777418
  needsKYC: false,
777356
777419
  displayName: "CIC",
@@ -804282,6 +804345,10 @@ async function estimateFee(address4, body, initCode, initData) {
804282
804345
  async function broadcastTx4(bocBase64) {
804283
804346
  return (await send2("/message", { boc: bocBase64 })).message_hash;
804284
804347
  }
804348
+ async function fetchAdjacentTransactions(txHash, dir = "in") {
804349
+ const url4 = `/adjacentTransactions?hash=${encodeURIComponent(txHash)}&direction=${dir}`;
804350
+ return await fetch13(url4);
804351
+ }
804285
804352
 
804286
804353
  // ../../libs/coin-modules/coin-ton/lib-es/broadcast.js
804287
804354
  var broadcast22 = async ({ signedOperation: { signature: signature3, operation } }) => {
@@ -804911,7 +804978,6 @@ function mapTxToOps5(accountId2, addr, addressBook) {
804911
804978
  ops.push({
804912
804979
  id: encodeOperationId(accountId2, hash12, "OUT"),
804913
804980
  hash: tx.out_msgs[0].hash,
804914
- // this hash matches with in_msg.hash of IN transaction
804915
804981
  type: "OUT",
804916
804982
  value: (0, import_bignumber272.default)(tx.out_msgs[0].value ?? 0),
804917
804983
  fee: (0, import_bignumber272.default)(tx.total_fees),
@@ -804935,7 +805001,7 @@ function mapTxToOps5(accountId2, addr, addressBook) {
804935
805001
  return ops;
804936
805002
  };
804937
805003
  }
804938
- function mapJettonTxToOps(accountId2, addr, addressBook) {
805004
+ function mapJettonTxToOps(accountId2, addr, addressBook, jettonTxMessageHashesMap2) {
804939
805005
  return (tx) => {
804940
805006
  const accountAddr = import_core19.Address.parse(addr).toString({ urlSafe: true, bounceable: false });
804941
805007
  if (accountAddr !== addr)
@@ -804981,8 +805047,9 @@ function mapJettonTxToOps(accountId2, addr, addressBook) {
804981
805047
  });
804982
805048
  }
804983
805049
  if (isSending) {
805050
+ const hash_message = jettonTxMessageHashesMap2 ? jettonTxMessageHashesMap2.get(hash12) ?? hash12 : hash12;
804984
805051
  ops.push({
804985
- id: encodeOperationId(tokenAccountId, hash12, "OUT"),
805052
+ id: encodeOperationId(tokenAccountId, hash_message, "OUT"),
804986
805053
  hash: hash12,
804987
805054
  type: "OUT",
804988
805055
  value: (0, import_bignumber272.default)(tx.amount),
@@ -805064,6 +805131,7 @@ function getSyncHash2(currency24, blacklistedList) {
805064
805131
  }
805065
805132
 
805066
805133
  // ../../libs/coin-modules/coin-ton/lib-es/synchronisation.js
805134
+ var jettonTxMessageHashesMap = /* @__PURE__ */ new Map();
805067
805135
  var getAccountShape17 = async (info6, { blacklistedTokenIds }) => {
805068
805136
  const { address: address4, rest, currency: currency24, derivationMode, initialAccount } = info6;
805069
805137
  const publicKey3 = reconciliatePubkey(rest?.publicKey, initialAccount);
@@ -805103,8 +805171,22 @@ var getAccountShape17 = async (info6, { blacklistedTokenIds }) => {
805103
805171
  }
805104
805172
  }
805105
805173
  }
805174
+ for (const tx of newJettonTxs) {
805175
+ const hash12 = tx.transaction_hash;
805176
+ try {
805177
+ if (!jettonTxMessageHashesMap.has(hash12)) {
805178
+ const res = await fetchAdjacentTransactions(hash12);
805179
+ const hash_message = res.transactions.at(0)?.in_msg?.hash;
805180
+ if (hash_message) {
805181
+ jettonTxMessageHashesMap.set(hash12, hash_message);
805182
+ }
805183
+ }
805184
+ } catch (error) {
805185
+ console.error(`Error processing ton jetton hash ${hash12}:`, error);
805186
+ }
805187
+ }
805106
805188
  const newOps = (0, import_flatMap19.default)(newTxs.transactions, mapTxToOps5(accountId2, address4, newTxs.address_book));
805107
- const newJettonOps = (0, import_flatMap19.default)(newJettonTxs, mapJettonTxToOps(accountId2, address4, newTxs.address_book));
805189
+ const newJettonOps = (0, import_flatMap19.default)(newJettonTxs, mapJettonTxToOps(accountId2, address4, newTxs.address_book, jettonTxMessageHashesMap));
805108
805190
  const operations = shouldSyncFromScratch ? newOps : mergeOps(oldOps, newOps);
805109
805191
  const subAccounts = await getSubAccounts3(info6, accountId2, newJettonOps, blacklistedTokenIds, shouldSyncFromScratch);
805110
805192
  const toReturn = {
@@ -805145,7 +805227,7 @@ var getSubAccountShape3 = async (info6, parentId, token, ops, shouldSyncFromScra
805145
805227
  creationDate: operations.length > 0 ? operations[operations.length - 1].date : /* @__PURE__ */ new Date(),
805146
805228
  balanceHistoryCache: emptyHistoryCache,
805147
805229
  // calculated in the jsHelpers
805148
- swapHistory: [],
805230
+ swapHistory: maybeExistingSubAccount ? maybeExistingSubAccount.swapHistory : [],
805149
805231
  jettonWallet
805150
805232
  // Address of the jetton wallet contract that holds the token balance and handles transfers
805151
805233
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/live-cli",
3
- "version": "24.18.4-nightly.0",
3
+ "version": "24.18.4-nightly.2",
4
4
  "description": "ledger-live CLI version",
5
5
  "repository": {
6
6
  "type": "git",
@@ -55,8 +55,8 @@
55
55
  "@types/ws": "8.5.10",
56
56
  "ts-node": "10.9.2",
57
57
  "tsup": "7.3.0",
58
- "@ledgerhq/types-cryptoassets": "^7.23.0",
59
- "@ledgerhq/types-live": "^6.71.0-nightly.1"
58
+ "@ledgerhq/types-live": "^6.71.0-nightly.1",
59
+ "@ledgerhq/types-cryptoassets": "^7.23.0"
60
60
  },
61
61
  "publishConfig": {
62
62
  "directory": "dist"