@t2000/engine 0.6.4 → 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 +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
|
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;
|
|
@@ -1667,9 +1670,26 @@ var explainTxTool = buildTool({
|
|
|
1667
1670
|
const amount = Number(bc.amount);
|
|
1668
1671
|
const isNegative = amount < 0;
|
|
1669
1672
|
const decimals = guessDecimals(bc.coinType);
|
|
1673
|
+
const absHuman = Math.abs(amount / 10 ** decimals);
|
|
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
|
+
}
|
|
1688
|
+
continue;
|
|
1689
|
+
}
|
|
1670
1690
|
txEffects.push({
|
|
1671
1691
|
type: isNegative ? "send" : "receive",
|
|
1672
|
-
description: `${ownerAddr.slice(0, 8)}...${ownerAddr.slice(-4)} ${isNegative ? "sent" : "received"} ${
|
|
1692
|
+
description: `${ownerAddr.slice(0, 8)}...${ownerAddr.slice(-4)} ${isNegative ? "sent" : "received"} ${absHuman.toFixed(decimals > 6 ? 4 : 2)} ${symbol}`
|
|
1673
1693
|
});
|
|
1674
1694
|
}
|
|
1675
1695
|
}
|