@t2000/cli 0.25.8 → 0.25.10

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.
@@ -66034,13 +66034,21 @@ var T2000 = class _T2000 extends import_index.default {
66034
66034
  const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
66035
66035
  const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
66036
66036
  let toAmount = Number(route.amountOut) / 10 ** toDecimals;
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;
66037
+ try {
66038
+ const txBlock = await this.client.getTransactionBlock({
66039
+ digest: gasResult.digest,
66040
+ options: { showBalanceChanges: true }
66041
+ });
66042
+ const changes = txBlock.balanceChanges ?? [];
66043
+ const received = changes.find(
66044
+ (c) => c.coinType === toType && BigInt(c.amount) > 0n && c.owner.AddressOwner === this._address
66045
+ );
66046
+ if (received) {
66047
+ const actual = Number(BigInt(received.amount)) / 10 ** toDecimals;
66048
+ if (actual > 0) toAmount = actual;
66049
+ }
66050
+ } catch {
66051
+ console.warn("[swap] Could not read balance changes, using route estimate");
66044
66052
  }
66045
66053
  const fromName = fromEntry ? fromEntry[0] : this._resolveTokenName(fromType, params.from);
66046
66054
  const toName = toEntry ? toEntry[0] : this._resolveTokenName(toType, params.to);
@@ -67065,4 +67073,4 @@ axios/dist/node/axios.cjs:
67065
67073
  @scure/bip39/index.js:
67066
67074
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
67067
67075
  */
67068
- //# sourceMappingURL=chunk-MHJ6L6JJ.js.map
67076
+ //# sourceMappingURL=chunk-CEYH4WJI.js.map