@t2000/engine 0.6.5 → 0.6.6

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.
package/dist/index.js CHANGED
@@ -1653,7 +1653,10 @@ var explainTxTool = buildTool({
1653
1653
  const effects = tx.effects;
1654
1654
  const balanceChanges = tx.balanceChanges;
1655
1655
  const events = tx.events;
1656
- const sender = txInput?.data?.sender ?? "unknown";
1656
+ const txData = txInput?.data;
1657
+ const sender = txData?.sender ?? "unknown";
1658
+ const gasData = txData?.gasData;
1659
+ const gasPayer = gasData?.owner ?? sender;
1657
1660
  const status = effects?.status?.status ?? "unknown";
1658
1661
  const gasUsed = effects?.gasUsed;
1659
1662
  const gasCost = gasUsed ? (Number(gasUsed.computationCost ?? 0) + Number(gasUsed.storageCost ?? 0) - Number(gasUsed.storageRebate ?? 0)) / 1e9 : 0;
@@ -1668,14 +1671,20 @@ var explainTxTool = buildTool({
1668
1671
  const isNegative = amount < 0;
1669
1672
  const decimals = guessDecimals(bc.coinType);
1670
1673
  const absHuman = Math.abs(amount / 10 ** decimals);
1671
- const isSenderSui = ownerAddr === sender && bc.coinType.endsWith("::sui::SUI") && isNegative;
1672
- if (isSenderSui) {
1673
- const netTransfer = absHuman - gasCost;
1674
- if (netTransfer < 1e-4) continue;
1675
- txEffects.push({
1676
- type: "send",
1677
- description: `${ownerAddr.slice(0, 8)}...${ownerAddr.slice(-4)} sent ${netTransfer.toFixed(4)} ${symbol}`
1678
- });
1674
+ if (bc.coinType.endsWith("::sui::SUI") && isNegative) {
1675
+ if (ownerAddr === gasPayer) {
1676
+ const netTransfer = absHuman - gasCost;
1677
+ if (netTransfer < 1e-4) continue;
1678
+ txEffects.push({
1679
+ type: "send",
1680
+ description: `${ownerAddr.slice(0, 8)}...${ownerAddr.slice(-4)} sent ${netTransfer.toFixed(4)} ${symbol}`
1681
+ });
1682
+ } else {
1683
+ txEffects.push({
1684
+ type: "send",
1685
+ description: `${ownerAddr.slice(0, 8)}...${ownerAddr.slice(-4)} sent ${absHuman.toFixed(4)} ${symbol}`
1686
+ });
1687
+ }
1679
1688
  continue;
1680
1689
  }
1681
1690
  txEffects.push({