UNPKG

@helios-lang/compiler

Version:

Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to bu

199 lines 7.34 kB
/** * @import { ErrorCollector, Site, Source } from "@helios-lang/compiler-utils" * @typedef {import("@helios-lang/ir").OptimizeOptions} OptimizeOptions * @typedef {import("@helios-lang/ir").ParseOptions} ParseOptions * @typedef {import("@helios-lang/ir").SourceMappedStringI} SourceMappedStringI * @typedef {import("@helios-lang/uplc").UplcData} UplcData * @typedef {import("@helios-lang/uplc").UplcValue} UplcValue * @typedef {import("@helios-lang/uplc").UplcProgramV2} UplcProgramV2 * @typedef {import("../codegen/index.js").Definitions} Definitions * @typedef {import("../typecheck/index.js").DataType} DataType * @typedef {import("../typecheck/index.js").ScriptTypes} ScriptTypes * @typedef {import("../typecheck/index.js").Type} Type * @typedef {import("./EntryPoint.js").EntryPoint} EntryPoint * @typedef {import("./UserTypes.js").UserTypes} UserTypes */ /** * `throwCompilerErrors` defaults to true * @typedef {{ * isTestnet?: boolean * moduleSources?: (string | Source)[] * validatorTypes?: ScriptTypes * throwCompilerErrors?: boolean * }} ProgramProps */ /** * @typedef {{ * optimize?: boolean | OptimizeOptions * dependsOnOwnHash?: boolean * hashDependencies?: Record<string, string> * validatorIndices?: Record<string, number> * onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void * excludeUserFuncs?: Set<string> * withAlt?: boolean * }} CompileOptions */ /** * @type {ProgramProps} */ export const DEFAULT_PROGRAM_PROPS: ProgramProps; /** * Helios root object */ export class Program { /** * @param {string | Source} mainSource * @param {ProgramProps} props */ constructor(mainSource: string | Source, props?: ProgramProps); /** * @readonly * @type {ProgramProps} */ readonly props: ProgramProps; /** * @readonly * @type {EntryPoint} */ readonly entryPoint: EntryPoint; /** * @readonly * @type {ErrorCollector} */ readonly errors: ErrorCollector; /** * @type {boolean} */ get isForTestnet(): boolean; /** * @type {string} */ get name(): string; /** * @type {string} */ get purpose(): string; /** * @type {number | undefined} */ get currentScriptIndex(): number | undefined; /** * @type {Record<string, Record<string, UserFunc>>} */ get userFunctions(): Record<string, Record<string, UserFunc>>; /** * @type {Record<string, Record<string, DataType>>} */ get userTypes(): Record<string, Record<string, import("../typecheck/common.js").DataType>>; /** * @type {Record<string, DataType>} */ get paramTypes(): Record<string, import("../typecheck/common.js").DataType>; /** * @type {Set<string>} */ get requiredParams(): Set<string>; /** * Change the literal value of a const statements * @param {string} name * @param {UplcData} data * @returns {boolean} */ changeParam(name: string, data: UplcData): boolean; /** * Compiles the program to UPLC form * @remarks * By default (with no optimize setting provided) it compiles an optimized * version, while also attaching an alternative (unoptimized, with logging) * version to the UplcProgram. When available, the logging version * of the script is used to provide diagnostic details for developer or * application-layer use. * * if 'optimize' is enabled explicitly via boolean or `{optimize:boolean}` or * `{optimize: {...options}}`, then the logging version is only included if * `options.withAlt=true`. Additional `options.optimize:{... optimizeOptions}` * can provide fine-grained tuning of the optimization process. * * Specifying `options.withAlt=true` + `options.optimize=true` is equivalent to * the default behavior. `withAlt` is ignored if `optimize` is explicitly disabled. * * If only the optimized version of the script is used, any execution errors * will not have access to logged details from the program; in that case, a * warning message will be emitted, indicating the lack of loggable details. * * @param {boolean | CompileOptions} optimizeOrOptions * @returns {UplcProgramV2} */ compile(optimizeOrOptions?: boolean | CompileOptions): UplcProgramV2; /** * @param {(name: string, uplc: UplcProgramV2) => void} onCompile * @param {{ * excludeUserFuncs: Set<string> * hashDependencies: Record<string, string> * validatorIndices?: Record<string, number> * }} options */ compileUserFuncs(onCompile: (name: string, uplc: UplcProgramV2) => void, options: { excludeUserFuncs: Set<string>; hashDependencies: Record<string, string>; validatorIndices?: Record<string, number>; }): void; /** * Generate additional IR definitions * * dependency on own hash through methods defined on the ScriptContext * * dependency on hashes of other validators or dependency on own precalculated hash (eg. unoptimized program should use hash of optimized program) * @param {{ * dependsOnOwnHash: boolean * hashDependencies: Record<string, string> * optimize: boolean * makeParamSubstitutable?: boolean * validatorIndices?: Record<string, number> * }} options * @returns {SourceMappedStringI} */ toIR(options: { dependsOnOwnHash: boolean; hashDependencies: Record<string, string>; optimize: boolean; makeParamSubstitutable?: boolean; validatorIndices?: Record<string, number>; }): SourceMappedStringI; /** * @returns {string} */ toString(): string; } export type OptimizeOptions = import("@helios-lang/ir").OptimizeOptions; export type ParseOptions = import("@helios-lang/ir").ParseOptions; export type SourceMappedStringI = import("@helios-lang/ir").SourceMappedStringI; export type UplcData = import("@helios-lang/uplc").UplcData; export type UplcValue = import("@helios-lang/uplc").UplcValue; export type UplcProgramV2 = import("@helios-lang/uplc").UplcProgramV2; export type Definitions = import("../codegen/index.js").Definitions; export type DataType = import("../typecheck/index.js").DataType; export type ScriptTypes = import("../typecheck/index.js").ScriptTypes; export type Type = import("../typecheck/index.js").Type; export type EntryPoint = import("./EntryPoint.js").EntryPoint; export type UserTypes = import("./UserTypes.js").UserTypes; /** * `throwCompilerErrors` defaults to true */ export type ProgramProps = { isTestnet?: boolean; moduleSources?: (string | Source)[]; validatorTypes?: ScriptTypes; throwCompilerErrors?: boolean; }; export type CompileOptions = { optimize?: boolean | OptimizeOptions; dependsOnOwnHash?: boolean; hashDependencies?: Record<string, string>; validatorIndices?: Record<string, number>; onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void; excludeUserFuncs?: Set<string>; withAlt?: boolean; }; import type { ErrorCollector } from "@helios-lang/compiler-utils"; import { UserFunc } from "./UserFunc.js"; import type { Source } from "@helios-lang/compiler-utils"; //# sourceMappingURL=Program.d.ts.map