/
ton-org
/
blueprint
Обзор
Документация
Войти
/
ton-org
/
blueprint
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
develop
src/compile/CompilerConfig.ts
56 строк
2 KB
Trinketer22
feat: compile into library (#298)
04 авг 2025, 14:58
Не верифицирован
04 авг 2025, 14:58
d5fa75a
Код
Авторство
О чём код?
import { Cell } from '@ton/core'; import { TolkCompilerConfig } from './tolk/config'; import { FuncCompilerConfig } from './func/config'; import { TactCompilerConfig, TactLegacyCompilerConfig } from './tact/config'; export type HookParams = { userData?: any; }; export type CommonCompilerConfig = { /** * A hook that runs **before** the contract is compiled. * * @param {HookParams} params - Hook parameters including user-defined data. * * @example * const config: CompilerConfig = { * preCompileHook: async (params) => { * console.log("Preparing to compile, user params:", params); * } * }; */ preCompileHook?: (params: HookParams) => Promise<void>; /** * A hook that runs **after** the contract is compiled. * * @param {Cell} code - The compiled contract code as a TON `Cell`. * @param {HookParams} params - Hook parameters including user-defined data. * * @example * const config: CompilerConfig = { * postCompileHook: async (code) => { * console.log("Compiled BOC size:", code.toBoc().length); * } * }; */ postCompileHook?: (code: Cell, params: HookParams) => Promise<void>; /** * Allows to build artifact into library cell instead of regular * code cell * https://docs.ton.org/v3/documentation/data-formats/tlb/library-cells#introduction */ buildLibrary?: boolean; }; export type CompilableConfig = (TactLegacyCompilerConfig | FuncCompilerConfig | TolkCompilerConfig) & CommonCompilerConfig; export type CompilerConfig = TactCompilerConfig | CompilableConfig; export function isCompilableConfig(config: CompilerConfig): config is CompilableConfig { return 'lang' in config; }