@ledgerhq/live-cli 24.21.1-nightly.1 → 24.21.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 +55 -61
  2. package/package.json +2 -2
package/lib/cli.js CHANGED
@@ -516704,7 +516704,7 @@ var require_package8 = __commonJS({
516704
516704
  module2.exports = {
516705
516705
  name: "@ledgerhq/live-common",
516706
516706
  description: "Common ground for the Ledger Live apps",
516707
- version: "34.45.0-nightly.1",
516707
+ version: "34.45.0",
516708
516708
  repository: {
516709
516709
  type: "git",
516710
516710
  url: "https://github.com/LedgerHQ/ledger-live.git"
@@ -523507,7 +523507,7 @@ var require_package9 = __commonJS({
523507
523507
  "package.json"(exports2, module2) {
523508
523508
  module2.exports = {
523509
523509
  name: "@ledgerhq/live-cli",
523510
- version: "24.21.1-nightly.1",
523510
+ version: "24.21.1",
523511
523511
  description: "ledger-live CLI version",
523512
523512
  repository: {
523513
523513
  type: "git",
@@ -807845,46 +807845,57 @@ var getTotalGasUsed = (effects) => {
807845
807845
  return BigInt(0);
807846
807846
  return BigInt(gasSummary.computationCost) + BigInt(gasSummary.storageCost) - BigInt(gasSummary.storageRebate);
807847
807847
  };
807848
- var getCoinsForAmount = async (api7, address4, coinType, requiredAmount) => {
807849
- const coins = [];
807850
- let cursor = null;
807851
- let hasNextPage = true;
807852
- let totalBalance = 0;
807853
- while (hasNextPage && totalBalance < requiredAmount) {
807854
- const response = await api7.getCoins({
807848
+ var FALLBACK_GAS_BUDGET = {
807849
+ SUI_TRANSFER: "3976000",
807850
+ TOKEN_TRANSFER: "4461792"
807851
+ };
807852
+ var paymentInfo3 = async (sender, fakeTransaction) => withApi2(async (api7) => {
807853
+ const tx = new Transaction6();
807854
+ tx.setSender(ensureAddressFormat(sender));
807855
+ const coinObjects = await getCoinObjectIds(sender, fakeTransaction);
807856
+ const [coin] = tx.splitCoins(Array.isArray(coinObjects) ? coinObjects[0] : tx.gas, [
807857
+ fakeTransaction.amount.toNumber()
807858
+ ]);
807859
+ tx.transferObjects([coin], fakeTransaction.recipient);
807860
+ try {
807861
+ const txb = await tx.build({ client: api7 });
807862
+ const dryRunTxResponse = await api7.dryRunTransactionBlock({ transactionBlock: txb });
807863
+ const fees2 = getTotalGasUsed(dryRunTxResponse.effects);
807864
+ return {
807865
+ gasBudget: dryRunTxResponse.input.gasData.budget,
807866
+ totalGasUsed: fees2,
807867
+ fees: fees2
807868
+ };
807869
+ } catch (error) {
807870
+ console.warn("Fee estimation failed:", error);
807871
+ return {
807872
+ gasBudget: Array.isArray(coinObjects) ? FALLBACK_GAS_BUDGET.TOKEN_TRANSFER : FALLBACK_GAS_BUDGET.SUI_TRANSFER,
807873
+ totalGasUsed: BigInt(1e6),
807874
+ fees: BigInt(1e6)
807875
+ };
807876
+ }
807877
+ });
807878
+ var getCoinObjectIds = async (address4, transaction) => withApi2(async (api7) => {
807879
+ const coinObjectId = null;
807880
+ if (transaction.coinType !== DEFAULT_COIN_TYPE) {
807881
+ const tokenInfo = await api7.getCoins({
807855
807882
  owner: address4,
807856
- coinType,
807857
- cursor
807883
+ coinType: transaction.coinType
807858
807884
  });
807859
- const validCoins = response.data.filter((coin) => parseInt(coin.balance) > 0).sort((a63, b17) => parseInt(b17.balance) - parseInt(a63.balance));
807860
- let currentBalance = totalBalance;
807861
- let i56 = 0;
807862
- while (i56 < validCoins.length && currentBalance < requiredAmount) {
807863
- const coin = validCoins[i56];
807864
- coins.push(coin);
807865
- currentBalance += parseInt(coin.balance);
807866
- i56++;
807867
- }
807868
- totalBalance = currentBalance;
807869
- cursor = response.nextCursor;
807870
- hasNextPage = response.hasNextPage && totalBalance < requiredAmount;
807885
+ return tokenInfo.data.map((coin) => coin.coinObjectId);
807871
807886
  }
807872
- return coins;
807873
- };
807887
+ return coinObjectId;
807888
+ });
807874
807889
  var createTransaction25 = async (address4, transaction) => withApi2(async (api7) => {
807875
807890
  const tx = new Transaction6();
807876
807891
  tx.setSender(ensureAddressFormat(address4));
807877
- if (transaction.coinType !== DEFAULT_COIN_TYPE) {
807878
- const requiredAmount = transaction.amount.toNumber();
807879
- const coins = await getCoinsForAmount(api7, address4, transaction.coinType, requiredAmount);
807880
- if (coins.length === 0) {
807881
- throw new Error(`No coins found for type ${transaction.coinType}`);
807892
+ const coinObjects = await getCoinObjectIds(address4, transaction);
807893
+ if (Array.isArray(coinObjects) && transaction.coinType !== DEFAULT_COIN_TYPE) {
807894
+ const coins = coinObjects.map((coinId) => tx.object(coinId));
807895
+ if (coins.length > 1) {
807896
+ tx.mergeCoins(coins[0], coins.slice(1));
807882
807897
  }
807883
- const coinObjects = coins.map((coin2) => tx.object(coin2.coinObjectId));
807884
- if (coinObjects.length > 1) {
807885
- tx.mergeCoins(coinObjects[0], coinObjects.slice(1));
807886
- }
807887
- const [coin] = tx.splitCoins(coinObjects[0], [transaction.amount.toNumber()]);
807898
+ const [coin] = tx.splitCoins(coins[0], [transaction.amount.toNumber()]);
807888
807899
  tx.transferObjects([coin], transaction.recipient);
807889
807900
  } else {
807890
807901
  const [coin] = tx.splitCoins(tx.gas, [transaction.amount.toNumber()]);
@@ -807892,16 +807903,6 @@ var createTransaction25 = async (address4, transaction) => withApi2(async (api7)
807892
807903
  }
807893
807904
  return tx.build({ client: api7 });
807894
807905
  });
807895
- var paymentInfo3 = async (sender, fakeTransaction) => withApi2(async (api7) => {
807896
- const txb = await createTransaction25(sender, fakeTransaction);
807897
- const dryRunTxResponse = await api7.dryRunTransactionBlock({ transactionBlock: txb });
807898
- const fees2 = getTotalGasUsed(dryRunTxResponse.effects);
807899
- return {
807900
- gasBudget: dryRunTxResponse.input.gasData.budget,
807901
- totalGasUsed: fees2,
807902
- fees: fees2
807903
- };
807904
- });
807905
807906
  var executeTransactionBlock = async (params) => withApi2(async (api7) => {
807906
807907
  return api7.executeTransactionBlock(params);
807907
807908
  });
@@ -808016,9 +808017,9 @@ async function craftTransaction5({ amount, asset, recipient, sender, type: type4
808016
808017
  }
808017
808018
  const unsigned2 = await network_default3.createTransaction(sender, {
808018
808019
  amount: (0, import_bignumber317.default)(amount.toString()),
808020
+ recipient,
808019
808021
  coinType,
808020
- mode: type4,
808021
- recipient
808022
+ mode: type4
808022
808023
  });
808023
808024
  return { unsigned: unsigned2 };
808024
808025
  }
@@ -808166,7 +808167,7 @@ async function getEstimatedFees12({ account: account3, transaction }) {
808166
808167
  // Remove fees if present since we are fetching fees
808167
808168
  };
808168
808169
  const subAccount = findSubAccountById(account3, transaction.subAccountId ?? "");
808169
- const asset = toSuiAsset(subAccount?.token.contractAddress ?? DEFAULT_COIN_TYPE);
808170
+ const asset = subAccount ? { type: "token", coinType: subAccount?.token.contractAddress } : { type: "native" };
808170
808171
  const fees2 = await estimateFees6({
808171
808172
  recipient: getAbandonSeedAddress(account3.currency.id),
808172
808173
  sender: account3.freshAddress,
@@ -808947,16 +808948,13 @@ function optimisticOpcommons2(commandDescriptor) {
808947
808948
  }
808948
808949
 
808949
808950
  // ../../libs/coin-modules/coin-sui/lib-es/bridge/buildTransaction.js
808950
- var buildTransaction10 = async (account3, { amount, mode, recipient, subAccountId }) => {
808951
- const { freshAddress } = account3;
808952
- const subAccount = findSubAccountById(account3, subAccountId ?? "");
808953
- const asset = toSuiAsset(subAccount?.token.contractAddress ?? DEFAULT_COIN_TYPE);
808951
+ var buildTransaction10 = async (account3, { recipient, mode, amount, coinType }) => {
808954
808952
  return craftTransaction5({
808955
- amount: BigInt(amount.toString()),
808956
- asset,
808953
+ sender: account3.freshAddress,
808957
808954
  recipient,
808958
- sender: freshAddress,
808959
- type: mode
808955
+ type: mode,
808956
+ amount: BigInt(amount.toString()),
808957
+ asset: toSuiAsset(coinType)
808960
808958
  });
808961
808959
  };
808962
808960
 
@@ -836820,11 +836818,7 @@ var DeviceModelId2;
836820
836818
  DeviceModelId3["europa"] = "europa";
836821
836819
  DeviceModelId3["apex"] = "apex";
836822
836820
  })(DeviceModelId2 || (DeviceModelId2 = {}));
836823
- var DevicesWithTouchScreen = [
836824
- DeviceModelId2.stax,
836825
- DeviceModelId2.europa,
836826
- DeviceModelId2.apex
836827
- ];
836821
+ var DevicesWithTouchScreen = [DeviceModelId2.stax, DeviceModelId2.europa];
836828
836822
  var ChargingModes;
836829
836823
  (function(ChargingModes2) {
836830
836824
  ChargingModes2[ChargingModes2["NONE"] = 0] = "NONE";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/live-cli",
3
- "version": "24.21.1-nightly.1",
3
+ "version": "24.21.1",
4
4
  "description": "ledger-live CLI version",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,7 +58,7 @@
58
58
  "ts-node": "10.9.2",
59
59
  "tsup": "7.3.0",
60
60
  "@ledgerhq/types-cryptoassets": "^7.25.0",
61
- "@ledgerhq/types-live": "^6.80.0"
61
+ "@ledgerhq/types-live": "^6.81.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "directory": "dist"