Skip to content

Commit

Permalink
feat: debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
krigga committed Aug 14, 2024
1 parent 9b1c238 commit ceb4fb7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ton/blueprint",
"version": "0.22.0",
"version": "0.23.0-debugger.0",
"description": "Framework for development of TON smart contracts",
"main": "dist/index.js",
"bin": "./dist/cli/cli.js",
Expand Down Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"@orbs-network/ton-access": "^2.3.3",
"@tact-lang/compiler": "^1.4.0",
"@ton-community/func-js": "^0.7.0",
"@ton-community/func-js": "^0.8.0-debuginfo.0",
"@tonconnect/sdk": "^2.2.0",
"arg": "^5.0.2",
"chalk": "^4.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/compile/CompilerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type TactCompilerConfig = {
export type FuncCompilerConfig = {
lang?: 'func';
optLevel?: number;
debugInfo?: boolean;
} & (
| {
targets: string[];
Expand Down
9 changes: 9 additions & 0 deletions src/compile/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CompilerConfig as FuncCompilerConfig,
compilerVersion,
SourcesArray,
DebugInfoEntry,
} from '@ton-community/func-js';
import { existsSync, readFileSync } from 'fs';
import path from 'path';
Expand Down Expand Up @@ -41,6 +42,7 @@ export type FuncCompileResult = {
targets: string[];
snapshot: SourcesArray;
version: string;
debugInfo?: DebugInfoEntry[];
};

async function doCompileFunc(config: FuncCompilerConfig): Promise<FuncCompileResult> {
Expand All @@ -61,6 +63,7 @@ async function doCompileFunc(config: FuncCompilerConfig): Promise<FuncCompileRes
targets,
snapshot: cr.snapshot,
version: (await compilerVersion()).funcVersion,
debugInfo: cr.debugInfo,
};
}

Expand Down Expand Up @@ -143,12 +146,17 @@ async function doCompileInner(name: string, config: CompilerConfig): Promise<Com
targets: config.targets,
sources: config.sources ?? ((path: string) => readFileSync(path).toString()),
optLevel: config.optLevel,
debugInfo: config.debugInfo,
} as FuncCompilerConfig);
}

export async function doCompile(name: string, opts?: CompileOpts): Promise<CompileResult> {
const config = await getCompilerConfigForContract(name);

if (opts?.debugInfo && config.lang === 'func') {
config.debugInfo = true;
}

if (config.preCompileHook !== undefined) {
await config.preCompileHook({
userData: opts?.hookUserData,
Expand All @@ -168,6 +176,7 @@ export async function doCompile(name: string, opts?: CompileOpts): Promise<Compi

export type CompileOpts = {
hookUserData?: any;
debugInfo?: boolean;
};

export async function compile(name: string, opts?: CompileOpts): Promise<Cell> {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { NetworkProvider } from './network/NetworkProvider';

export { createNetworkProvider } from './network/createNetworkProvider';

export { compile, CompileOpts } from './compile/compile';
export { compile, CompileOpts, CompileResult, FuncCompileResult, TactCompileResult, doCompile } from './compile/compile';

export { CompilerConfig, HookParams } from './compile/CompilerConfig';

Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,22 @@ __metadata:
languageName: node
linkType: hard

"@ton-community/func-js-bin@npm:0.4.4-newops.1":
version: 0.4.4-newops.1
resolution: "@ton-community/func-js-bin@npm:0.4.4-newops.1"
checksum: 10/1bddbd618abfb68fce0777849c88827bdd29bd3bfcf41d54f83f9acf43ea3323fc03ec25873a766eb7a1d4a0ffa08199b24eff3cbeb31fe25dbe69431756b9ea
"@ton-community/func-js-bin@npm:0.4.4-debuginfo.0":
version: 0.4.4-debuginfo.0
resolution: "@ton-community/func-js-bin@npm:0.4.4-debuginfo.0"
checksum: 10/841de2e839b36b0b52702c4ab34cc8e559bbd24029eae66d63f14352ea9d6c25fadb9a1a3fcbde5c0e485a61ef39298d40f02b505a63a671dfb5adc1c3ba0735
languageName: node
linkType: hard

"@ton-community/func-js@npm:^0.7.0":
version: 0.7.0
resolution: "@ton-community/func-js@npm:0.7.0"
"@ton-community/func-js@npm:^0.8.0-debuginfo.0":
version: 0.8.0-debuginfo.0
resolution: "@ton-community/func-js@npm:0.8.0-debuginfo.0"
dependencies:
"@ton-community/func-js-bin": "npm:0.4.4-newops.1"
"@ton-community/func-js-bin": "npm:0.4.4-debuginfo.0"
arg: "npm:^5.0.2"
bin:
func-js: dist/cli.js
checksum: 10/506192acff889a1abcdb8cd1f3a66e495b88a75579ebd390a33d8f302e0ac012e327a1e6a17d7c4fb5aab98d2399e06b621fa9374829450c54f6198769e2637c
checksum: 10/1e6f8a525fc3a5c3bb625e3c76d0fd53078b1bf98cdea21cff8a707b3275651e7ff2d015760916b100f3650c53f4e8a18bb2a7b63a98034581e4c0e4fc4601ce
languageName: node
linkType: hard

Expand All @@ -213,7 +213,7 @@ __metadata:
dependencies:
"@orbs-network/ton-access": "npm:^2.3.3"
"@tact-lang/compiler": "npm:^1.4.0"
"@ton-community/func-js": "npm:^0.7.0"
"@ton-community/func-js": "npm:^0.8.0-debuginfo.0"
"@ton/core": "npm:^0.56.0"
"@ton/crypto": "npm:^3.2.0"
"@ton/ton": "npm:^13.11.0"
Expand Down

0 comments on commit ceb4fb7

Please sign in to comment.