Skip to content

Commit 55d080e

Browse files
authored
feat: support tracing transaction with base info triple (#6)
1 parent 0db5789 commit 55d080e

File tree

6 files changed

+95
-3
lines changed

6 files changed

+95
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.1.0] - 2025-05-16
6+
7+
Add `retraceBaseTx` function to retrace transactions by their triple (`lt`, `hash`, `address`).
8+
9+
## [0.0.1] - 2025-05-10
10+
11+
Initial release

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ import {retrace} from "@tonstudio/txtracer-core"
4040
* @param txHash - hex transaction hash
4141
* @returns Detailed execution report (TraceResult)
4242
*/
43-
const result = await retrace(testnet, txHash)
43+
const result1 = await retrace(testnet, txHash)
44+
45+
/**
46+
* Retrace transaction described as triple
47+
*/
48+
const result2 = await retraceBaseTx(testnet, {
49+
lt: 56166043000001n,
50+
hash: Buffer.from("T6Y6ZoW71mrznFA0RyU/xV5ILpz9WUPJ9i9/4xPq1Is=", "base64"),
51+
address: Address.parse("EQCqKZrrce8Ss6SZaLI-OkH2w8-xtPP9_ZvyyIZLhy9Hmpf8"),
52+
})
4453
```
4554

4655
### Helper Methods

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tonstudio/txtracer-core",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Core TxTracer library for collecting transaction information",
55
"main": "dist/index.js",
66
"scripts": {

src/runner.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {TraceResult} from "./types"
22
import {
3+
BaseTxInfo,
34
collectUsedLibraries,
45
computeFinalData,
56
computeMinLt,
@@ -54,6 +55,17 @@ export const retrace = async (testnet: boolean, txLink: string): Promise<TraceRe
5455
if (baseTx === undefined) {
5556
throw new Error("Cannot find transaction info")
5657
}
58+
return retraceBaseTx(testnet, baseTx)
59+
}
60+
61+
/**
62+
* Fully reproduce (re‑trace) a TON transaction inside a local TON Sandbox
63+
* and return a structured report with VM logs, money flow, generated
64+
* actions and other data.
65+
*
66+
* See {@link retrace} for the full description of the workflow.
67+
*/
68+
export const retraceBaseTx = async (testnet: boolean, baseTx: BaseTxInfo): Promise<TraceResult> => {
5769
const [tx] = await findRawTxByHash(testnet, baseTx)
5870
// eslint bug
5971
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

src/test/__snapshots__/test.spec.ts.snap

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`transactions should return correct information for base transaction 1`] = `"b5ee9c7241021401000281000114ff00f4a413f4bcf2c80b01020120020d020148030402dcd020d749c120915b8f6320d70b1f2082106578746ebd21821073696e74bdb0925f03e082106578746eba8eb48020d72101d074d721fa4030fa44f828fa443058bd915be0ed44d0810141d721f4058307f40e6fa1319130e18040d721707fdb3ce03120d749810280b99130e070e2100f020120050c020120060902016e07080019adce76a2684020eb90eb85ffc00019af1df6a2684010eb90eb858fc00201480a0b0017b325fb51341c75c875c2c7e00011b262fb513435c280200019be5f0f6a2684080a0eb90fa02c0102f20e011e20d70b1f82107369676ebaf2e08a7f0f01e68ef0eda2edfb218308d722028308d723208020d721d31fd31fd31fed44d0d200d31f20d31fd3ffd70a000af90140ccf9109a28945f0adb31e1f2c087df02b35007b0f2d0845125baf2e0855036baf2e086f823bbf2d0882292f800de01a47fc8ca00cb1f01cf16c9ed542092f80fde70db3cd81003f6eda2edfb02f404216e926c218e4c0221d73930709421c700b38e2d01d72820761e436c20d749c008f2e09320d74ac002f2e09320d71d06c712c2005230b0f2d089d74cd7393001a4e86c128407bbf2e093d74ac000f2e093ed55e2d20001c000915be0ebd72c08142091709601d72c081c12e25210b1e30f20d74a111213009601fa4001fa44f828fa443058baf2e091ed44d0810141d718f405049d7fc8ca0040048307f453f2e08b8e14038307f45bf2e08c22d70a00216e01b3b0f2d090e2c85003cf1612f400c9ed54007230d72c08248e2d21f2e092d200ed44d0d2005113baf2d08f54503091319c01810140d721d70a00f2e08ee2c8ca0058cf16c9ed5493f2c08de20010935bdb31e1d74cd0b4d6c35e"`;
4+
5+
exports[`transactions should return correct information for base transaction 2`] = `"b5ee9c7241021401000281000114ff00f4a413f4bcf2c80b01020120020d020148030402dcd020d749c120915b8f6320d70b1f2082106578746ebd21821073696e74bdb0925f03e082106578746eba8eb48020d72101d074d721fa4030fa44f828fa443058bd915be0ed44d0810141d721f4058307f40e6fa1319130e18040d721707fdb3ce03120d749810280b99130e070e2100f020120050c020120060902016e07080019adce76a2684020eb90eb85ffc00019af1df6a2684010eb90eb858fc00201480a0b0017b325fb51341c75c875c2c7e00011b262fb513435c280200019be5f0f6a2684080a0eb90fa02c0102f20e011e20d70b1f82107369676ebaf2e08a7f0f01e68ef0eda2edfb218308d722028308d723208020d721d31fd31fd31fed44d0d200d31f20d31fd3ffd70a000af90140ccf9109a28945f0adb31e1f2c087df02b35007b0f2d0845125baf2e0855036baf2e086f823bbf2d0882292f800de01a47fc8ca00cb1f01cf16c9ed542092f80fde70db3cd81003f6eda2edfb02f404216e926c218e4c0221d73930709421c700b38e2d01d72820761e436c20d749c008f2e09320d74ac002f2e09320d71d06c712c2005230b0f2d089d74cd7393001a4e86c128407bbf2e093d74ac000f2e093ed55e2d20001c000915be0ebd72c08142091709601d72c081c12e25210b1e30f20d74a111213009601fa4001fa44f828fa443058baf2e091ed44d0810141d718f405049d7fc8ca0040048307f453f2e08b8e14038307f45bf2e08c22d70a00216e01b3b0f2d090e2c85003cf1612f400c9ed54007230d72c08248e2d21f2e092d200ed44d0d2005113baf2d08f54503091319c01810140d721d70a00f2e08ee2c8ca0058cf16c9ed5493f2c08de20010935bdb31e1d74cd0b4d6c35e"`;
6+
7+
exports[`transactions should return correct information for base transaction 3`] = `undefined`;
8+
9+
exports[`transactions should return correct information for base transaction 4`] = `"EQCqKZrrce8Ss6SZaLI-OkH2w8-xtPP9_ZvyyIZLhy9Hmpf8"`;
10+
11+
exports[`transactions should return correct information for base transaction 5`] = `undefined`;
12+
13+
exports[`transactions should return correct information for base transaction 6`] = `56166043000001n`;
14+
15+
exports[`transactions should return correct information for base transaction 7`] = `1744898820`;
16+
17+
exports[`transactions should return correct information for base transaction 8`] = `
18+
{
19+
"exitCode": 0,
20+
"gasFees": 1975600n,
21+
"gasUsed": 4939n,
22+
"success": true,
23+
"vmSteps": 143,
24+
}
25+
`;
26+
27+
exports[`transactions should return correct information for base transaction 9`] = `
28+
"x{0EC3C86D03}
29+
x{}
30+
x{62004729ACCB84DBCE80E1C7063E54BC94896318DF88EEC4080C5BDB47E0E2F716DC2017D7840000000000000000000000000001}
31+
x{0F8A7EA5546DE4EF7EB185CE3989680800891E15DA14405903E5C99092ACC3BB1DC7F00C6C3B707868EE97885F944FB77F002A8A66BADC7BC4ACE9265A2C8F8E907DB0F3EC6D3CFF7F66FCB22192E1CBD1E68203}
32+
x{0000000057656C636F6D65204368616C6C656E6765205072697A652E20436F6E67726174756C6174696F6E7320F09F8E89}"
33+
`;
34+
35+
exports[`transactions should return correct information for base transaction 10`] = `
36+
{
37+
"balanceAfter": 328324326n,
38+
"balanceBefore": 382413532n,
39+
"sentTotal": 50000000n,
40+
"totalFees": 3485468n,
41+
}
42+
`;
43+
344
exports[`transactions should return correct information for simple transaction with exit code 0 1`] = `"b5ee9c724101010100710000deff0020dd2082014c97ba218201339cbab19f71b0ed44d0d31fd31f31d70bffe304e0a4f2608308d71820d31fd31fd31ff82313bbf263ed44d0d31fd31fd3ffd15132baf2a15144baf2a204f901541055f910f2a3f8009320d74a96d307d402fb00e8d101a4c8cb1fcb1fcbffc9ed5410bd6dad"`;
445

546
exports[`transactions should return correct information for simple transaction with exit code 0 2`] = `"b5ee9c724101010100710000deff0020dd2082014c97ba218201339cbab19f71b0ed44d0d31fd31f31d70bffe304e0a4f2608308d71820d31fd31fd31ff82313bbf263ed44d0d31fd31fd3ffd15132baf2a15144baf2a204f901541055f910f2a3f8009320d74a96d307d402fb00e8d101a4c8cb1fcb1fcbffc9ed5410bd6dad"`;

src/test/test.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import {retrace} from "../runner"
1+
import {retrace, retraceBaseTx} from "../runner"
22
import {TraceResult} from "../types"
3+
import {Buffer} from "buffer"
4+
import {Address} from "@ton/core"
35

46
const DEFAULT_TIMEOUT = 100_000
57
const DELAY_FOR_RATE_LIMIT = process.env["CI"] === undefined ? 5000 : 10_000
@@ -116,6 +118,23 @@ describe("transactions", () => {
116118
DEFAULT_TIMEOUT,
117119
)
118120

121+
it(
122+
"should return correct information for base transaction",
123+
async () => {
124+
await wait()
125+
126+
const testnet = false
127+
128+
const res = await retraceBaseTx(testnet, {
129+
lt: 56_166_043_000_001n,
130+
hash: Buffer.from("T6Y6ZoW71mrznFA0RyU/xV5ILpz9WUPJ9i9/4xPq1Is=", "base64"),
131+
address: Address.parse("EQCqKZrrce8Ss6SZaLI-OkH2w8-xtPP9_ZvyyIZLhy9Hmpf8"),
132+
})
133+
checkResult(res)
134+
},
135+
DEFAULT_TIMEOUT,
136+
)
137+
119138
function checkResult(res: TraceResult, expectedOk: boolean = true): void {
120139
expect(res.stateUpdateHashOk).toEqual(expectedOk)
121140
expect(res.codeCell?.toBoc().toString("hex")).toMatchSnapshot()

0 commit comments

Comments
 (0)