@ledgerhq/live-cli 24.21.1-nightly.0 → 24.21.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 +61 -55
  2. package/package.json +1 -1
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.0",
516707
+ version: "34.45.0-nightly.1",
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.0",
523510
+ version: "24.21.1-nightly.1",
523511
523511
  description: "ledger-live CLI version",
523512
523512
  repository: {
523513
523513
  type: "git",
@@ -807845,57 +807845,46 @@ var getTotalGasUsed = (effects) => {
807845
807845
  return BigInt(0);
807846
807846
  return BigInt(gasSummary.computationCost) + BigInt(gasSummary.storageCost) - BigInt(gasSummary.storageRebate);
807847
807847
  };
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({
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({
807882
807855
  owner: address4,
807883
- coinType: transaction.coinType
807856
+ coinType,
807857
+ cursor
807884
807858
  });
807885
- return tokenInfo.data.map((coin) => coin.coinObjectId);
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;
807886
807871
  }
807887
- return coinObjectId;
807888
- });
807872
+ return coins;
807873
+ };
807889
807874
  var createTransaction25 = async (address4, transaction) => withApi2(async (api7) => {
807890
807875
  const tx = new Transaction6();
807891
807876
  tx.setSender(ensureAddressFormat(address4));
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));
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}`);
807897
807882
  }
807898
- const [coin] = tx.splitCoins(coins[0], [transaction.amount.toNumber()]);
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()]);
807899
807888
  tx.transferObjects([coin], transaction.recipient);
807900
807889
  } else {
807901
807890
  const [coin] = tx.splitCoins(tx.gas, [transaction.amount.toNumber()]);
@@ -807903,6 +807892,16 @@ var createTransaction25 = async (address4, transaction) => withApi2(async (api7)
807903
807892
  }
807904
807893
  return tx.build({ client: api7 });
807905
807894
  });
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
+ });
807906
807905
  var executeTransactionBlock = async (params) => withApi2(async (api7) => {
807907
807906
  return api7.executeTransactionBlock(params);
807908
807907
  });
@@ -808017,9 +808016,9 @@ async function craftTransaction5({ amount, asset, recipient, sender, type: type4
808017
808016
  }
808018
808017
  const unsigned2 = await network_default3.createTransaction(sender, {
808019
808018
  amount: (0, import_bignumber317.default)(amount.toString()),
808020
- recipient,
808021
808019
  coinType,
808022
- mode: type4
808020
+ mode: type4,
808021
+ recipient
808023
808022
  });
808024
808023
  return { unsigned: unsigned2 };
808025
808024
  }
@@ -808167,7 +808166,7 @@ async function getEstimatedFees12({ account: account3, transaction }) {
808167
808166
  // Remove fees if present since we are fetching fees
808168
808167
  };
808169
808168
  const subAccount = findSubAccountById(account3, transaction.subAccountId ?? "");
808170
- const asset = subAccount ? { type: "token", coinType: subAccount?.token.contractAddress } : { type: "native" };
808169
+ const asset = toSuiAsset(subAccount?.token.contractAddress ?? DEFAULT_COIN_TYPE);
808171
808170
  const fees2 = await estimateFees6({
808172
808171
  recipient: getAbandonSeedAddress(account3.currency.id),
808173
808172
  sender: account3.freshAddress,
@@ -808948,13 +808947,16 @@ function optimisticOpcommons2(commandDescriptor) {
808948
808947
  }
808949
808948
 
808950
808949
  // ../../libs/coin-modules/coin-sui/lib-es/bridge/buildTransaction.js
808951
- var buildTransaction10 = async (account3, { recipient, mode, amount, coinType }) => {
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);
808952
808954
  return craftTransaction5({
808953
- sender: account3.freshAddress,
808954
- recipient,
808955
- type: mode,
808956
808955
  amount: BigInt(amount.toString()),
808957
- asset: toSuiAsset(coinType)
808956
+ asset,
808957
+ recipient,
808958
+ sender: freshAddress,
808959
+ type: mode
808958
808960
  });
808959
808961
  };
808960
808962
 
@@ -836818,7 +836820,11 @@ var DeviceModelId2;
836818
836820
  DeviceModelId3["europa"] = "europa";
836819
836821
  DeviceModelId3["apex"] = "apex";
836820
836822
  })(DeviceModelId2 || (DeviceModelId2 = {}));
836821
- var DevicesWithTouchScreen = [DeviceModelId2.stax, DeviceModelId2.europa];
836823
+ var DevicesWithTouchScreen = [
836824
+ DeviceModelId2.stax,
836825
+ DeviceModelId2.europa,
836826
+ DeviceModelId2.apex
836827
+ ];
836822
836828
  var ChargingModes;
836823
836829
  (function(ChargingModes2) {
836824
836830
  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.0",
3
+ "version": "24.21.1-nightly.1",
4
4
  "description": "ledger-live CLI version",
5
5
  "repository": {
6
6
  "type": "git",