@ledgerhq/live-cli 24.25.0-nightly.3 → 24.25.0-nightly.5

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 +67 -45
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -513744,7 +513744,7 @@ var require_package7 = __commonJS({
513744
513744
  module2.exports = {
513745
513745
  name: "@ledgerhq/live-common",
513746
513746
  description: "Common ground for the Ledger Live apps",
513747
- version: "34.50.0-nightly.3",
513747
+ version: "34.50.0-nightly.5",
513748
513748
  repository: {
513749
513749
  type: "git",
513750
513750
  url: "https://github.com/LedgerHQ/ledger-live.git"
@@ -514081,7 +514081,7 @@ var require_package8 = __commonJS({
514081
514081
  "package.json"(exports2, module2) {
514082
514082
  module2.exports = {
514083
514083
  name: "@ledgerhq/live-cli",
514084
- version: "24.25.0-nightly.3",
514084
+ version: "24.25.0-nightly.5",
514085
514085
  description: "ledger-live CLI version",
514086
514086
  repository: {
514087
514087
  type: "git",
@@ -585350,7 +585350,6 @@ var CELO_STAKE_TOKENS_PAIR = {
585350
585350
  };
585351
585351
  var CELO_STABLE_TOKENS = Object.keys(CELO_STAKE_TOKENS_PAIR);
585352
585352
  var getStableTokenEnum = (tokenTicker) => CELO_STAKE_TOKENS_PAIR[tokenTicker];
585353
- var MAX_PRIORITY_FEE_PER_GAS = 1000000000n;
585354
585353
  var MAX_FEES_THRESHOLD_MULTIPLIER = 4;
585355
585354
 
585356
585355
  // ../../libs/coin-modules/coin-celo/lib-es/bridge/buildTransaction.js
@@ -585445,8 +585444,9 @@ var buildTransaction4 = async (account3, transaction) => {
585445
585444
  } else if (isTokenTransaction) {
585446
585445
  value5 = transaction.useAllAmount ? tokenAccount.balance : transaction.amount;
585447
585446
  const block2 = await kit4.connection.web3.eth.getBlock("latest");
585448
- const baseFee = BigInt(block2.baseFeePerGas || MAX_PRIORITY_FEE_PER_GAS);
585449
- const maxFeePerGas = baseFee + MAX_PRIORITY_FEE_PER_GAS;
585447
+ const maxPriorityFeePerGas = await kit4.connection.getMaxPriorityFeePerGas();
585448
+ const baseFee = BigInt(block2.baseFeePerGas || maxPriorityFeePerGas);
585449
+ const maxFeePerGas = baseFee + BigInt(maxPriorityFeePerGas);
585450
585450
  let token;
585451
585451
  if (CELO_STABLE_TOKENS.includes(tokenAccount.token.id)) {
585452
585452
  token = await kit4.contracts.getStableToken(getStableTokenEnum(tokenAccount.token.id));
@@ -585457,8 +585457,6 @@ var buildTransaction4 = async (account3, transaction) => {
585457
585457
  from: account3.freshAddress,
585458
585458
  to: transaction.recipient,
585459
585459
  data: token.transfer(transaction.recipient, value5.toFixed()).txo.encodeABI(),
585460
- maxFeePerGas: maxFeePerGas.toString(),
585461
- maxPriorityFeePerGas: await kit4.connection.getMaxPriorityFeePerGas(),
585462
585460
  value: value5.toFixed()
585463
585461
  };
585464
585462
  } else {
@@ -585508,6 +585506,7 @@ var getFeesForTransaction2 = async ({ account: account3, transaction }) => {
585508
585506
  const totalSpendableBalance = account3.spendableBalance.minus(pendingOperationAmounts.lock);
585509
585507
  const tokenAccount = findSubAccountById(account3, transaction.subAccountId || "");
585510
585508
  const isTokenTransaction = tokenAccount?.type === "TokenAccount";
585509
+ const maxPriorityFeePerGas = await kit4.connection.getMaxPriorityFeePerGas();
585511
585510
  if ((transaction.mode === "unlock" || transaction.mode === "vote") && account3.celoResources) {
585512
585511
  value5 = transaction.useAllAmount ? totalNonVotingLockedBalance : import_bignumber129.BigNumber.minimum(amount, totalNonVotingLockedBalance);
585513
585512
  } else if (transaction.mode === "revoke" && account3.celoResources) {
@@ -585557,8 +585556,8 @@ var getFeesForTransaction2 = async ({ account: account3, transaction }) => {
585557
585556
  } else if (isTokenTransaction) {
585558
585557
  value5 = transaction.useAllAmount ? tokenAccount.balance : transaction.amount;
585559
585558
  const block2 = await kit4.connection.web3.eth.getBlock("latest");
585560
- const baseFee = BigInt(block2.baseFeePerGas || MAX_PRIORITY_FEE_PER_GAS);
585561
- const maxFeePerGas = baseFee + MAX_PRIORITY_FEE_PER_GAS;
585559
+ const baseFee = BigInt(block2.baseFeePerGas || maxPriorityFeePerGas);
585560
+ const maxFeePerGas2 = baseFee + BigInt(maxPriorityFeePerGas);
585562
585561
  let token;
585563
585562
  if (CELO_STABLE_TOKENS.includes(tokenAccount.token.id)) {
585564
585563
  token = await kit4.contracts.getStableToken(getStableTokenEnum(tokenAccount.token.id));
@@ -585569,8 +585568,8 @@ var getFeesForTransaction2 = async ({ account: account3, transaction }) => {
585569
585568
  from: account3.freshAddress,
585570
585569
  to: transaction.recipient,
585571
585570
  data: token.transfer(transaction.recipient, value5.toFixed()).txo.encodeABI(),
585572
- maxFeePerGas: maxFeePerGas.toString(),
585573
- maxPriorityFeePerGas: await kit4.connection.getMaxPriorityFeePerGas(),
585571
+ maxFeePerGas: maxFeePerGas2.toString(),
585572
+ maxPriorityFeePerGas,
585574
585573
  value: value5.toFixed()
585575
585574
  };
585576
585575
  gas = Number((await kit4.connection.estimateGasWithInflationFactor(celoTransaction) * MAX_FEES_THRESHOLD_MULTIPLIER).toFixed());
@@ -585578,8 +585577,10 @@ var getFeesForTransaction2 = async ({ account: account3, transaction }) => {
585578
585577
  const tx = await buildTransaction_default2(account3, transaction);
585579
585578
  gas = tx.gas ? Number(tx.gas) : 0;
585580
585579
  }
585581
- const gasPrice = new import_bignumber129.BigNumber(await kit4.connection.gasPrice());
585582
- return gasPrice.times(gas);
585580
+ const gasPrice = await kit4.connection.gasPrice();
585581
+ const maxFeePerGas = (BigInt(gasPrice) - BigInt(maxPriorityFeePerGas)) * BigInt(120) / BigInt(100) + BigInt(maxPriorityFeePerGas);
585582
+ const maxFeePerGasNumber = new import_bignumber129.BigNumber(maxFeePerGas.toString());
585583
+ return maxFeePerGasNumber.times(gas);
585583
585584
  };
585584
585585
  var getFeesForTransaction_default2 = getFeesForTransaction2;
585585
585586
 
@@ -585606,15 +585607,10 @@ var prepareTransaction8 = async (account3, transaction) => {
585606
585607
  } else {
585607
585608
  token = await kit4.contracts.getGoldToken();
585608
585609
  }
585609
- const block2 = await kit4.connection.web3.eth.getBlock("latest");
585610
- const baseFee = BigInt(block2.baseFeePerGas || MAX_PRIORITY_FEE_PER_GAS);
585611
- const maxFeePerGas = baseFee + MAX_PRIORITY_FEE_PER_GAS;
585612
585610
  return {
585613
585611
  ...transaction,
585614
585612
  amount,
585615
585613
  fees: fees2,
585616
- maxFeePerGas: maxFeePerGas.toString(),
585617
- maxPriorityFeePerGas: await kit4.connection.getMaxPriorityFeePerGas(),
585618
585614
  ...isTokenTransaction ? {
585619
585615
  data: Buffer.from(token.transfer(transaction.recipient, amount.toFixed()).txo.encodeABI())
585620
585616
  } : {}
@@ -612975,6 +612971,9 @@ var buildSignOperation7 = (signerContext4) => ({ account: account3, transaction,
612975
612971
  to: isTokenTransaction ? subAccount.token.contractAddress : to,
612976
612972
  value: isTokenTransaction ? 0 : unsignedTransaction.value
612977
612973
  };
612974
+ const { address: address3 } = await signerContext4(deviceId, (signer2) => {
612975
+ return signer2.getAddress(account3.freshAddressPath);
612976
+ });
612978
612977
  await determineFees(finalTransaction);
612979
612978
  const rlpEncodedTransaction = await signerContext4(deviceId, (signer2) => {
612980
612979
  return signer2.rlpEncodedTxForLedger(finalTransaction);
@@ -612983,9 +612982,6 @@ var buildSignOperation7 = (signerContext4) => ({ account: account3, transaction,
612983
612982
  const response = await signerContext4(deviceId, (signer2) => {
612984
612983
  return signer2.signTransaction(account3.freshAddressPath, trimLeading0x(rlpEncodedTransaction.rlpEncode));
612985
612984
  });
612986
- const { address: address3 } = await signerContext4(deviceId, (signer2) => {
612987
- return signer2.getAddress(account3.freshAddressPath);
612988
- });
612989
612985
  const convertedResponse = { ...response, v: response.v.toString() };
612990
612986
  if (cancelled)
612991
612987
  return;
@@ -707225,7 +707221,7 @@ var getStakingFees = (t46, gasPrice) => {
707225
707221
  // ../../libs/coin-modules/coin-near/lib-es/api/node.js
707226
707222
  var fetchAccountDetails2 = async (address3) => {
707227
707223
  const currencyConfig = getCoinConfig5();
707228
- const { data: data12 } = await network_default({
707224
+ const { data: data12 } = await lib_es_default({
707229
707225
  method: "POST",
707230
707226
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707231
707227
  data: {
@@ -707275,7 +707271,7 @@ var getAccount7 = async (address3) => {
707275
707271
  };
707276
707272
  var getProtocolConfig = async () => {
707277
707273
  const currencyConfig = getCoinConfig5();
707278
- const { data: data12 } = await network_default({
707274
+ const { data: data12 } = await lib_es_default({
707279
707275
  method: "POST",
707280
707276
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707281
707277
  data: {
@@ -707291,7 +707287,7 @@ var getProtocolConfig = async () => {
707291
707287
  };
707292
707288
  var getGasPrice = async () => {
707293
707289
  const currencyConfig = getCoinConfig5();
707294
- const { data: data12 } = await network_default({
707290
+ const { data: data12 } = await lib_es_default({
707295
707291
  method: "POST",
707296
707292
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707297
707293
  data: {
@@ -707305,7 +707301,7 @@ var getGasPrice = async () => {
707305
707301
  };
707306
707302
  var getAccessKey = async ({ address: address3, publicKey: publicKey3 }) => {
707307
707303
  const currencyConfig = getCoinConfig5();
707308
- const { data: data12 } = await network_default({
707304
+ const { data: data12 } = await lib_es_default({
707309
707305
  method: "POST",
707310
707306
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707311
707307
  data: {
@@ -707324,7 +707320,7 @@ var getAccessKey = async ({ address: address3, publicKey: publicKey3 }) => {
707324
707320
  };
707325
707321
  var broadcastTransaction7 = async (transaction, retries = 6) => {
707326
707322
  const currencyConfig = getCoinConfig5();
707327
- const { data: data12 } = await network_default({
707323
+ const { data: data12 } = await lib_es_default({
707328
707324
  method: "POST",
707329
707325
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707330
707326
  data: {
@@ -707431,7 +707427,7 @@ var getStakingPositions = async (address3) => {
707431
707427
  };
707432
707428
  var getValidators3 = makeLRUCache(async () => {
707433
707429
  const currencyConfig = getCoinConfig5();
707434
- const { data: data12 } = await network_default({
707430
+ const { data: data12 } = await lib_es_default({
707435
707431
  method: "POST",
707436
707432
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707437
707433
  data: {
@@ -707445,7 +707441,7 @@ var getValidators3 = makeLRUCache(async () => {
707445
707441
  }, () => "", { ttl: 30 * 60 * 1e3 });
707446
707442
  var getCommission = makeLRUCache(async (validatorAddress) => {
707447
707443
  const currencyConfig = getCoinConfig5();
707448
- const { data: data12 } = await network_default({
707444
+ const { data: data12 } = await lib_es_default({
707449
707445
  method: "POST",
707450
707446
  url: currencyConfig.infra.API_NEAR_PRIVATE_NODE,
707451
707447
  data: {
@@ -707555,8 +707551,13 @@ var preload5 = async () => {
707555
707551
  getValidators3(),
707556
707552
  getGasPrice()
707557
707553
  ]);
707554
+ const defautCommission = 10;
707558
707555
  const validators7 = await Promise.all(rawValidators.map(async ({ account_id: validatorAddress, stake }) => {
707559
- const commission = await getCommission(validatorAddress);
707556
+ let commission = defautCommission;
707557
+ try {
707558
+ commission = await getCommission(validatorAddress) || defautCommission;
707559
+ } catch (error) {
707560
+ }
707560
707561
  return {
707561
707562
  validatorAddress,
707562
707563
  tokens: stake,
@@ -815711,23 +815712,19 @@ async function withApi2(execute2) {
815711
815712
  var getAllBalancesCached = makeLRUCache(async (owner) => withApi2(async (api7) => await api7.getAllBalances({
815712
815713
  owner
815713
815714
  })), (owner) => owner, minutes(1));
815714
- function isStaking(block2) {
815715
- if (!block2)
815716
- return false;
815717
- if (block2.kind === "ProgrammableTransaction") {
815715
+ function isMoveCallWithFunction(functionName, block2) {
815716
+ if (block2?.kind === "ProgrammableTransaction") {
815718
815717
  const move = block2.transactions.find((item) => "MoveCall" in item);
815719
- return move?.MoveCall.function === "request_add_stake";
815718
+ return move?.MoveCall.function === functionName;
815719
+ } else {
815720
+ return false;
815720
815721
  }
815721
- return false;
815722
+ }
815723
+ function isStaking(block2) {
815724
+ return isMoveCallWithFunction("request_add_stake", block2);
815722
815725
  }
815723
815726
  function isUnstaking(block2) {
815724
- if (!block2)
815725
- return false;
815726
- if (block2.kind === "ProgrammableTransaction") {
815727
- const move = block2.transactions.find((item) => "MoveCall" in item && item["MoveCall"].function === "request_withdraw_stake");
815728
- return Boolean(move);
815729
- }
815730
- return false;
815727
+ return isMoveCallWithFunction("request_withdraw_stake", block2);
815731
815728
  }
815732
815729
  var getAccountBalances = async (addr) => {
815733
815730
  const balances = await getAllBalancesCached(addr);
@@ -847226,7 +847223,16 @@ async function listOperations9(address3, { token, limit, sort, minHeight }) {
847226
847223
  const limitedOperations = limit ? operations4.slice(0, limit) : operations4;
847227
847224
  const lastOperation = limitedOperations.at(-1);
847228
847225
  const nextToken = lastOperation ? JSON.stringify(lastOperation?.id) : "";
847229
- const filteredOperations = limitedOperations.filter((op) => isAPITransactionType(op) || isAPIDelegationType(op) || isAPIRevealType(op)).reduce((acc, op) => acc.concat(convertOperation(address3, op)), []);
847226
+ const filteredOperations = limitedOperations.filter((op) => isAPITransactionType(op) || isAPIDelegationType(op) || isAPIRevealType(op)).filter((op) => {
847227
+ const hasFailed = op.status !== "applied";
847228
+ if (hasFailed && isAPITransactionType(op)) {
847229
+ const isIn = op.target?.address === address3;
847230
+ if (isIn) {
847231
+ return false;
847232
+ }
847233
+ }
847234
+ return true;
847235
+ }).map((op) => convertOperation(address3, op)).flat();
847230
847236
  const sortedOperations = filteredOperations.sort((a65, b20) => b20.tx.date.getTime() - a65.tx.date.getTime());
847231
847237
  return [sortedOperations, nextToken];
847232
847238
  }
@@ -847904,8 +847910,24 @@ function transactionToIntent(account3, transaction, computeIntentType2) {
847904
847910
  return res;
847905
847911
  }
847906
847912
  var buildOptimisticOperation20 = (account3, transaction, sequenceNumber) => {
847907
- const type4 = transaction["mode"] === "changeTrust" ? "OPT_IN" : "OUT";
847908
- const fees2 = BigInt(transaction["fees"]?.toString() || "0");
847913
+ let type4;
847914
+ switch (transaction.mode) {
847915
+ case "changeTrust":
847916
+ type4 = "OPT_IN";
847917
+ break;
847918
+ case "delegate":
847919
+ case "stake":
847920
+ type4 = "DELEGATE";
847921
+ break;
847922
+ case "undelegate":
847923
+ case "unstake":
847924
+ type4 = "UNDELEGATE";
847925
+ break;
847926
+ default:
847927
+ type4 = "OUT";
847928
+ break;
847929
+ }
847930
+ const fees2 = BigInt(transaction.fees?.toString() || "0");
847909
847931
  const { subAccountId } = transaction;
847910
847932
  const { subAccounts } = account3;
847911
847933
  const operation = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/live-cli",
3
- "version": "24.25.0-nightly.3",
3
+ "version": "24.25.0-nightly.5",
4
4
  "description": "ledger-live CLI version",
5
5
  "repository": {
6
6
  "type": "git",