diff --git a/package.json b/package.json index 658bcee2..db442799 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@ton-community/func-js": "^0.9.1", "@ton/core": "^0.61.0", "@ton/crypto": "^3.3.0", - "@ton/sandbox": "^0.36.0", + "@ton/sandbox": "^0.41.0", "@ton/test-utils": "^0.7.0", "@ton/tolk-js": "^1.1.0", "@truecarry/tlb-abi": "^0.2.0", @@ -46,8 +46,9 @@ "react-helmet-async": "^2.0.5", "react-icons": "^5.5.0", "react-markdown": "^10.1.0", - "ton-assembly": "0.2.4", - "txtracer-core": "^0.3.1" + "ton-assembly": "0.6.1", + "ton-source-map": "^0.2.2", + "txtracer-core": "^0.5.0" }, "devDependencies": { "@astrojs/check": "^0.9.4", diff --git a/src/features/godbolt/lib/func/compilation.ts b/src/features/godbolt/lib/func/compilation.ts index 3d457975..a4e5d44d 100644 --- a/src/features/godbolt/lib/func/compilation.ts +++ b/src/features/godbolt/lib/func/compilation.ts @@ -1,6 +1,8 @@ import {Cell} from "@ton/core" import {runtime as i, text, trace} from "ton-assembly" +import type {InstructionInfo} from "ton-source-map" + import {FUNC_STDLIB} from "@features/godbolt/lib/func/stdlib.ts" import {funcCompile} from "@features/godbolt/lib/func/func-wasm/func-compile.ts" @@ -10,7 +12,7 @@ export interface FuncCompilationResult { readonly code: string readonly assembly: string readonly sourceMap?: trace.FuncMapping - readonly mapping: Map + readonly mapping: Map } export class FuncCompilationError extends Error { @@ -51,12 +53,14 @@ export const compileFuncCode = async (code: string): Promise() + const debugSectionToInstructions = new Map() for (const instr of allInstructions) { - const arr = debugSectionToInstructions.get(instr.debugSection) ?? [] - arr.push(instr) - debugSectionToInstructions.set(instr.debugSection, arr) + for (const debugSection of instr.debugSections) { + const arr = debugSectionToInstructions.get(debugSection) ?? [] + arr.push(instr) + debugSectionToInstructions.set(debugSection, arr) + } } return { diff --git a/src/features/godbolt/lib/tolk/compilation.ts b/src/features/godbolt/lib/tolk/compilation.ts index 52d8e8a5..aef6b122 100644 --- a/src/features/godbolt/lib/tolk/compilation.ts +++ b/src/features/godbolt/lib/tolk/compilation.ts @@ -1,6 +1,7 @@ import {Cell} from "@ton/core" import {runtime as i, text, trace} from "ton-assembly" +import type {InstructionInfo} from "ton-source-map" import {runTolkCompiler} from "@ton/tolk-js" import {TolkCompilationError, type TolkCompilationResult} from "@features/godbolt/lib/tolk/types.ts" @@ -27,12 +28,14 @@ export const compileTolkCode = async (code: string): Promise() + const debugSectionToInstructions = new Map() for (const instr of allInstructions) { - const arr = debugSectionToInstructions.get(instr.debugSection) ?? [] - arr.push(instr) - debugSectionToInstructions.set(instr.debugSection, arr) + for (const debugSection of instr.debugSections) { + const arr = debugSectionToInstructions.get(debugSection) ?? [] + arr.push(instr) + debugSectionToInstructions.set(debugSection, arr) + } } return { diff --git a/src/features/godbolt/lib/tolk/types.ts b/src/features/godbolt/lib/tolk/types.ts index 8029b442..96702b92 100644 --- a/src/features/godbolt/lib/tolk/types.ts +++ b/src/features/godbolt/lib/tolk/types.ts @@ -1,11 +1,12 @@ -import {runtime as i, trace} from "ton-assembly" +import {runtime as i} from "ton-assembly" +import type {InstructionInfo} from "ton-source-map" export interface TolkCompilationResult { readonly lang: "tolk" readonly instructions: i.Instr[] readonly code: string readonly assembly: string - readonly mapping: Map + readonly mapping: Map } export class TolkCompilationError extends Error { diff --git a/src/features/tasm/lib/executor.ts b/src/features/tasm/lib/executor.ts index d3c578ff..443ac7ba 100644 --- a/src/features/tasm/lib/executor.ts +++ b/src/features/tasm/lib/executor.ts @@ -3,9 +3,11 @@ import type {Address, Contract, ContractProvider, Sender, StateInit, TupleReader import {Cell, contractAddress, toNano, TupleBuilder} from "@ton/core" import {GetMethodError, type SandboxContract, type TreasuryContract} from "@ton/sandbox" import {Blockchain} from "@ton/sandbox" -import {createMappingInfo, type MappingInfo} from "ton-assembly/dist/trace/mapping" +import {createMappingInfo} from "ton-assembly/dist/trace/mapping" import type {StackElement} from "ton-assembly/dist/trace" +import type {AssemblyMapping} from "ton-source-map" + import {type ExitCode, findExitCode} from "@features/txTrace/lib/traceTx.ts" function stackElementsToTupleBuilder(stackElements: StackElement[]): TupleBuilder { @@ -112,7 +114,7 @@ export interface AssemblyExecutionResult { readonly vmLogs: string readonly instructions: i.Instr[] readonly code: string - readonly mappingInfo: MappingInfo | null + readonly mappingInfo: AssemblyMapping | null readonly exitCode: ExitCode | undefined readonly traceInfo: trace.TraceInfo | undefined } diff --git a/src/features/txTrace/hooks/useFuncLineStepper.ts b/src/features/txTrace/hooks/useFuncLineStepper.ts index 76b94cf2..1d4b7f59 100644 --- a/src/features/txTrace/hooks/useFuncLineStepper.ts +++ b/src/features/txTrace/hooks/useFuncLineStepper.ts @@ -1,10 +1,12 @@ import {useCallback, useEffect, useMemo, useState} from "react" import {trace} from "ton-assembly" +import type {InstructionInfo} from "ton-source-map" + import type {UseTraceStepperReturn} from "./useTraceStepper" export interface CompilationResult { - readonly mapping?: Map + readonly mapping?: Map readonly assembly?: string readonly funcSourceMap?: trace.FuncMapping } diff --git a/src/features/txTrace/lib/traceTx.ts b/src/features/txTrace/lib/traceTx.ts index 500f065b..7babcd21 100644 --- a/src/features/txTrace/lib/traceTx.ts +++ b/src/features/txTrace/lib/traceTx.ts @@ -1,17 +1,15 @@ import {retrace, retraceBaseTx} from "txtracer-core" import type {TraceResult} from "txtracer-core/dist/types" import {compileCellWithMapping, decompileCell} from "ton-assembly/dist/runtime/instr" -import { - createMappingInfo, - type InstructionInfo, - type MappingInfo, -} from "ton-assembly/dist/trace/mapping" +import {createMappingInfo} from "ton-assembly/dist/trace/mapping" import {type Step, type TraceInfo} from "ton-assembly/dist/trace" import {createTraceInfoPerTransaction, findInstructionInfo} from "ton-assembly/dist/trace/trace" import {parse, print} from "ton-assembly/dist/text" import * as l from "ton-assembly/dist/logs" import {Cell} from "@ton/core" +import type {AssemblyMapping, InstructionInfo} from "ton-source-map" + import type {NetworkType, RetraceResultAndCode} from "@features/txTrace/ui" import type {TransactionInfo} from "@features/sandbox/lib/transaction" import type {ContractData} from "@features/sandbox/lib/contract" @@ -135,7 +133,7 @@ export function findException(reversedEntries: l.VmLine[]) { return mapped.find(it => it !== undefined) } -export function findExitCode(vmLogs: string, mappingInfo: MappingInfo) { +export function findExitCode(vmLogs: string, mappingInfo: AssemblyMapping) { const res = l.parse(vmLogs) const reversedEntries = [...res].reverse() const description = findException(reversedEntries) diff --git a/src/pages/GodboltPage/hooks/useSourceMapHighlight.ts b/src/pages/GodboltPage/hooks/useSourceMapHighlight.ts index 001724f6..62a0096f 100644 --- a/src/pages/GodboltPage/hooks/useSourceMapHighlight.ts +++ b/src/pages/GodboltPage/hooks/useSourceMapHighlight.ts @@ -3,6 +3,8 @@ import type * as monaco from "monaco-editor" import {trace} from "ton-assembly" +import type {InstructionInfo} from "ton-source-map" + import type {HighlightGroup, HighlightRange} from "@shared/ui/CodeEditor" export interface UseSourceMapHighlightReturn { @@ -78,7 +80,7 @@ const COLORS = [ export function useSourceMapHighlight( sourceMap: trace.FuncMapping | undefined, - debugSectionToInstructions?: Map, + debugSectionToInstructions?: Map, funcEditorRef?: React.RefObject, asmEditorRef?: React.RefObject, originalAsmCode?: string, diff --git a/yarn.lock b/yarn.lock index d38ac4e7..09e9dcb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2443,17 +2443,6 @@ __metadata: languageName: node linkType: hard -"@ton/core@npm:^0.60.1": - version: 0.60.1 - resolution: "@ton/core@npm:0.60.1" - dependencies: - symbol.inspect: "npm:1.0.1" - peerDependencies: - "@ton/crypto": ">=3.2.0" - checksum: 10c0/aa2181cb1b7db85ce651f5d31b552858e2e6b98bb69803fc384a7e62b6a9cb4685f6e9f6f00a29bddfa872486ba7c2eb9e51fc84a8599b253c1649b2802876be - languageName: node - linkType: hard - "@ton/core@npm:^0.61.0": version: 0.61.0 resolution: "@ton/core@npm:0.61.0" @@ -2485,27 +2474,27 @@ __metadata: languageName: node linkType: hard -"@ton/sandbox@npm:^0.36.0": - version: 0.36.0 - resolution: "@ton/sandbox@npm:0.36.0" +"@ton/sandbox@npm:^0.41.0": + version: 0.41.0 + resolution: "@ton/sandbox@npm:0.41.0" dependencies: "@vscode/debugadapter": "npm:^1.68.0" chalk: "npm:^4.1.2" fflate: "npm:^0.8.2" table: "npm:^6.9.0" - ton-assembly: "npm:0.1.0" + ton-assembly: "npm:0.6.1" peerDependencies: "@ton-community/func-js": ">=0.10.0" "@ton/core": ">=0.61.0" "@ton/crypto": ">=3.3.0" "@ton/test-utils": ">=0.7.0" - jest: ^29.5.0 + jest: ^29.5.0 || ^30.0.5 peerDependenciesMeta: "@ton/test-utils": optional: true jest: optional: true - checksum: 10c0/66270e89188a390d82dbbcf4cc4b493945476cc44c39bb15abf31d66f81f7a2084e8fb2ec14447f6ed3c62871d0f60efecafe3c53f37b1d89b6810e424cc0e0a + checksum: 10c0/15471f4dfa35d17182f9577941a85ea4c2e88ed0bf2ece8bacd1f7302bd42195d82eaf205fb5940e334a7930c302546a2c3fbedf0065318de6531191a9820238 languageName: node linkType: hard @@ -11729,36 +11718,30 @@ __metadata: languageName: node linkType: hard -"ton-assembly@npm:0.1.0": - version: 0.1.0 - resolution: "ton-assembly@npm:0.1.0" +"ton-assembly@npm:0.6.1": + version: 0.6.1 + resolution: "ton-assembly@npm:0.6.1" dependencies: - "@ton/core": "npm:^0.60.1" "@tonstudio/parser-runtime": "npm:^0.0.1" cac: "npm:^6.7.14" + ton-source-map: "npm:^0.2.2" peerDependencies: - "@ton/core": ">=0.60.1" + "@ton/core": ">=0.61.0" + peerDependenciesMeta: + "@ton/core": + optional: false bin: tasm: dist/cli/assembler.js tdisasm: dist/cli/disassembler.js - checksum: 10c0/5880376d14f45394e959446f7f50352f1796b80a390b4c6ecd502251a2495ce2565fcc0a7522764eb626821f1ba568065a27cf5179629cf52b485319df3acad1 + tfift: dist/cli/fift-compiler.js + checksum: 10c0/0248810f2b3e7a31d3617996d0f0b0ea973e0b288af0985fdc8e1c9784638dbc4d9876dd82f381ed838753f2d8c0c5273fcae93d422c4f9da6c09f88f0f37b38 languageName: node linkType: hard -"ton-assembly@npm:0.2.4": - version: 0.2.4 - resolution: "ton-assembly@npm:0.2.4" - dependencies: - "@ton/core": "npm:^0.60.1" - "@tonstudio/parser-runtime": "npm:^0.0.1" - cac: "npm:^6.7.14" - peerDependencies: - "@ton/core": ">=0.60.1" - bin: - tasm: dist/cli/assembler.js - tdisasm: dist/cli/disassembler.js - tfift: dist/cli/fift-compiler.js - checksum: 10c0/453042e3776ba9cf72dd1186643f5c79ce6c4dc88daadd56ee7eceeb68e0d20c1e70e7e2bab529288398eea2d2ddc41408e59e07d1bffe8699aaed09eab8badd +"ton-source-map@npm:^0.2.2": + version: 0.2.2 + resolution: "ton-source-map@npm:0.2.2" + checksum: 10c0/c1e0413983f589a1dfcbb53aa35d04f42244e88d75899eb4c04a3733ac37d2a915063dc91a726409b0239e4a039059d860e1069efb9c8faa6580d06c8b88f3a0 languageName: node linkType: hard @@ -11903,16 +11886,16 @@ __metadata: languageName: node linkType: hard -"txtracer-core@npm:^0.3.1": - version: 0.3.1 - resolution: "txtracer-core@npm:0.3.1" +"txtracer-core@npm:^0.5.0": + version: 0.5.0 + resolution: "txtracer-core@npm:0.5.0" dependencies: "@ton-community/func-js": "npm:^0.10.0" "@ton/core": "npm:^0.61.0" - "@ton/sandbox": "npm:^0.36.0" + "@ton/sandbox": "npm:^0.41.0" "@ton/ton": "npm:^15.3.1" axios: "npm:^1.6.7" - checksum: 10c0/507906a3cf3740895a45593169a75884d06d34e8dec7832604ff9bd49f19c39406873e2659a0e82584f79d1c7f445956f23d0456841d2bb79a45c6d4c036e886 + checksum: 10c0/fca832c727cd4455c650b966782cd9543a609d86381a2b2ca4b1ea0856b00160c0396e7614ddf60ef630ee517708bfb00a3709ae0ab1173b7a08ce58991629c5 languageName: node linkType: hard @@ -11931,7 +11914,7 @@ __metadata: "@ton-community/func-js": "npm:^0.9.1" "@ton/core": "npm:^0.61.0" "@ton/crypto": "npm:^3.3.0" - "@ton/sandbox": "npm:^0.36.0" + "@ton/sandbox": "npm:^0.41.0" "@ton/test-utils": "npm:^0.7.0" "@ton/tolk-js": "npm:^1.1.0" "@truecarry/tlb-abi": "npm:^0.2.0" @@ -11981,9 +11964,10 @@ __metadata: stylelint: "npm:^16.24.0" stylelint-config-css-modules: "npm:^4.5.1" stylelint-config-standard: "npm:^39.0.0" - ton-assembly: "npm:0.2.4" + ton-assembly: "npm:0.6.1" + ton-source-map: "npm:^0.2.2" ts-node: "npm:^10.9.1" - txtracer-core: "npm:^0.3.1" + txtracer-core: "npm:^0.5.0" typescript: "npm:~5.8.3" typescript-eslint: "npm:^8.30.1" vite: "npm:^6.4.0"