Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 9 additions & 5 deletions src/features/godbolt/lib/func/compilation.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -10,7 +12,7 @@ export interface FuncCompilationResult {
readonly code: string
readonly assembly: string
readonly sourceMap?: trace.FuncMapping
readonly mapping: Map<number, trace.InstructionInfo[]>
readonly mapping: Map<number, InstructionInfo[]>
}

export class FuncCompilationError extends Error {
Expand Down Expand Up @@ -51,12 +53,14 @@ export const compileFuncCode = async (code: string): Promise<FuncCompilationResu
return cell?.instructions ?? []
})

const debugSectionToInstructions = new Map<number, trace.InstructionInfo[]>()
const debugSectionToInstructions = new Map<number, InstructionInfo[]>()

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 {
Expand Down
11 changes: 7 additions & 4 deletions src/features/godbolt/lib/tolk/compilation.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -27,12 +28,14 @@ export const compileTolkCode = async (code: string): Promise<TolkCompilationResu
return cell?.instructions ?? []
})

const debugSectionToInstructions = new Map<number, trace.InstructionInfo[]>()
const debugSectionToInstructions = new Map<number, InstructionInfo[]>()

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 {
Expand Down
5 changes: 3 additions & 2 deletions src/features/godbolt/lib/tolk/types.ts
Original file line number Diff line number Diff line change
@@ -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<number, trace.InstructionInfo[]>
readonly mapping: Map<number, InstructionInfo[]>
}

export class TolkCompilationError extends Error {
Expand Down
6 changes: 4 additions & 2 deletions src/features/tasm/lib/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion src/features/txTrace/hooks/useFuncLineStepper.ts
Original file line number Diff line number Diff line change
@@ -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<number, trace.InstructionInfo[]>
readonly mapping?: Map<number, InstructionInfo[]>
readonly assembly?: string
readonly funcSourceMap?: trace.FuncMapping
}
Expand Down
10 changes: 4 additions & 6 deletions src/features/txTrace/lib/traceTx.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/pages/GodboltPage/hooks/useSourceMapHighlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -78,7 +80,7 @@ const COLORS = [

export function useSourceMapHighlight(
sourceMap: trace.FuncMapping | undefined,
debugSectionToInstructions?: Map<number, trace.InstructionInfo[]>,
debugSectionToInstructions?: Map<number, InstructionInfo[]>,
funcEditorRef?: React.RefObject<monaco.editor.IStandaloneCodeEditor | null>,
asmEditorRef?: React.RefObject<monaco.editor.IStandaloneCodeEditor | null>,
originalAsmCode?: string,
Expand Down
74 changes: 29 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down