@t2000/cli 0.25.7 → 0.25.8

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.
@@ -65369,13 +65369,14 @@ async function trySelfFunded(client, signer, tx) {
65369
65369
  const result = await client.executeTransactionBlock({
65370
65370
  transactionBlock: toBase642(builtBytes),
65371
65371
  signature: [signature],
65372
- options: { showEffects: true }
65372
+ options: { showEffects: true, showBalanceChanges: true }
65373
65373
  });
65374
65374
  await client.waitForTransaction({ digest: result.digest });
65375
65375
  await assertTxSuccess(result.effects, result.digest);
65376
65376
  return {
65377
65377
  digest: result.digest,
65378
65378
  effects: result.effects,
65379
+ balanceChanges: result.balanceChanges,
65379
65380
  gasMethod: "self-funded",
65380
65381
  gasCostSui: extractGasCost(result.effects),
65381
65382
  preTxSuiMist: suiBalance
@@ -65394,13 +65395,14 @@ async function tryAutoTopUpThenSelfFund(client, signer, buildTx) {
65394
65395
  const result = await client.executeTransactionBlock({
65395
65396
  transactionBlock: toBase642(builtBytes),
65396
65397
  signature: [signature],
65397
- options: { showEffects: true }
65398
+ options: { showEffects: true, showBalanceChanges: true }
65398
65399
  });
65399
65400
  await client.waitForTransaction({ digest: result.digest });
65400
65401
  await assertTxSuccess(result.effects, result.digest);
65401
65402
  return {
65402
65403
  digest: result.digest,
65403
65404
  effects: result.effects,
65405
+ balanceChanges: result.balanceChanges,
65404
65406
  gasMethod: "auto-topup",
65405
65407
  gasCostSui: extractGasCost(result.effects),
65406
65408
  preTxSuiMist: suiAfterTopUp
@@ -65424,7 +65426,7 @@ async function trySponsored(client, signer, tx) {
65424
65426
  const result = await client.executeTransactionBlock({
65425
65427
  transactionBlock: sponsoredResult.txBytes,
65426
65428
  signature: [agentSig, sponsoredResult.sponsorSignature],
65427
- options: { showEffects: true }
65429
+ options: { showEffects: true, showBalanceChanges: true }
65428
65430
  });
65429
65431
  await client.waitForTransaction({ digest: result.digest });
65430
65432
  await assertTxSuccess(result.effects, result.digest);
@@ -65433,6 +65435,7 @@ async function trySponsored(client, signer, tx) {
65433
65435
  return {
65434
65436
  digest: result.digest,
65435
65437
  effects: result.effects,
65438
+ balanceChanges: result.balanceChanges,
65436
65439
  gasMethod: "sponsored",
65437
65440
  gasCostSui: gasCost,
65438
65441
  preTxSuiMist: suiBalance
@@ -66031,28 +66034,22 @@ var T2000 = class _T2000 extends import_index.default {
66031
66034
  const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
66032
66035
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
66033
66036
  let toAmount = Number(route.amountOut) / 10 ** toDecimals;
66034
- try {
66035
- const txBlock = await this.client.getTransactionBlock({
66036
- digest: gasResult.digest,
66037
- options: { showBalanceChanges: true }
66038
- });
66039
- const changes = txBlock.balanceChanges ?? [];
66040
- const received = changes.find(
66041
- (c) => c.coinType === toType && BigInt(c.amount) > 0n && c.owner.AddressOwner === this._address
66042
- );
66043
- if (received) {
66044
- const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
66045
- if (actual > 0) toAmount = actual;
66046
- }
66047
- } catch (e) {
66048
- console.warn("[swap] Could not parse on-chain balance changes, using route estimate:", e);
66037
+ const changes = gasResult.balanceChanges ?? [];
66038
+ const received = changes.find(
66039
+ (c) => c.coinType === toType && BigInt(c.amount) > 0n && c.owner.AddressOwner === this._address
66040
+ );
66041
+ if (received) {
66042
+ const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
66043
+ if (actual > 0) toAmount = actual;
66049
66044
  }
66045
+ const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
66046
+ const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
66050
66047
  const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
66051
66048
  return {
66052
66049
  success: true,
66053
66050
  tx: gasResult.digest,
66054
- fromToken: params.from,
66055
- toToken: params.to,
66051
+ fromToken: fromName,
66052
+ toToken: toName,
66056
66053
  fromAmount,
66057
66054
  toAmount,
66058
66055
  priceImpact: route.priceImpact,
@@ -66457,6 +66454,12 @@ var T2000 = class _T2000 extends import_index.default {
66457
66454
  }
66458
66455
  return all3;
66459
66456
  }
66457
+ _resolveTokenName(coinType, fallback) {
66458
+ const entry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === coinType);
66459
+ if (entry) return entry[0];
66460
+ const suffix = coinType.split("::").pop();
66461
+ return suffix && suffix !== coinType ? suffix : fallback;
66462
+ }
66460
66463
  _mergeCoinsInTx(tx, coins) {
66461
66464
  if (coins.length === 0) throw new T2000Error("INSUFFICIENT_BALANCE", "No coins to merge");
66462
66465
  const primary = tx.object(coins[0].coinObjectId);
@@ -67062,4 +67065,4 @@ axios/dist/node/axios.cjs:
67062
67065
  @scure/bip39/index.js:
67063
67066
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
67064
67067
  */
67065
- //# sourceMappingURL=chunk-YZ6UELLB.js.map
67068
+ //# sourceMappingURL=chunk-MHJ6L6JJ.js.map