@algorandfoundation/puya-ts 1.2.0-beta.4 → 1.2.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/{analyser-service-_vXhzOY0.js → analyser-service-D0IsFlp4.js} +409 -372
- package/analyser-service-D0IsFlp4.js.map +1 -0
- package/analyserService.mjs +7 -6
- package/analyserService.mjs.map +1 -1
- package/arc4-clientgen-BMCeFyNd.js +324 -0
- package/arc4-clientgen-BMCeFyNd.js.map +1 -0
- package/arc4-clientgen.d.ts +6 -0
- package/awst/intrinsic-factory.d.ts +4 -2
- package/awst/json-serialize-awst.d.ts +0 -1
- package/awst/node-factory.d.ts +1 -0
- package/awst/nodes.d.ts +26 -15
- package/awst/source-location.d.ts +0 -1
- package/awst/to-code-visitor.d.ts +3 -2
- package/awst/validation/arc4-approval-calls-router.d.ts +1 -1
- package/awst/validation/{awst-traverser.d.ts → function-traverser.d.ts} +4 -10
- package/awst/wtypes.d.ts +47 -45
- package/awst_build/arc4-util.d.ts +1 -38
- package/awst_build/ast-visitors/base-visitor.d.ts +0 -1
- package/awst_build/ast-visitors/class-definition-visitor.d.ts +721 -1
- package/awst_build/ast-visitors/contract-method-visitor.d.ts +3 -5
- package/awst_build/ast-visitors/function-visitor.d.ts +721 -1
- package/awst_build/ast-visitors/text-visitor.d.ts +721 -1
- package/awst_build/context/awst-build-context.d.ts +1 -1
- package/awst_build/eb/arc28/arc-28-emit-function-builder.d.ts +1 -2
- package/awst_build/eb/arc4/arrays.d.ts +2 -1
- package/awst_build/eb/arc4/c2c.d.ts +0 -17
- package/awst_build/eb/arc4/uintn.d.ts +1 -1
- package/awst_build/eb/arc4/util.d.ts +1 -0
- package/awst_build/eb/array-like/arrays.d.ts +3 -2
- package/awst_build/eb/array-like/util.d.ts +0 -1
- package/awst_build/eb/bytes-expression-builder.d.ts +0 -28
- package/awst_build/eb/contract-builder.d.ts +0 -11
- package/awst_build/eb/index.d.ts +0 -2
- package/awst_build/eb/literal/object-literal-expression-builder.d.ts +8 -4
- package/awst_build/eb/logged-error-builder.d.ts +11 -0
- package/awst_build/eb/objects/util.d.ts +0 -2
- package/awst_build/eb/op-module-builder.d.ts +0 -3
- package/awst_build/eb/storage/box/box.d.ts +1 -21
- package/awst_build/eb/storage/global-map.d.ts +21 -0
- package/awst_build/eb/storage/local-map.d.ts +21 -0
- package/awst_build/eb/string-expression-builder.d.ts +0 -6
- package/awst_build/eb/util/resolve-compat-builder.d.ts +0 -8
- package/awst_build/models/decorator-data.d.ts +1 -0
- package/awst_build/op-metadata.d.ts +4 -3
- package/awst_build/ptypes/arc4-types.d.ts +11 -7
- package/awst_build/ptypes/base.d.ts +5 -0
- package/awst_build/ptypes/for-export.d.ts +0 -1
- package/awst_build/ptypes/index.d.ts +103 -100
- package/awst_build/ptypes/util.d.ts +2 -2
- package/awst_build/ptypes/visitor.d.ts +3 -1
- package/awst_build/ptypes/visitors/default-visitor.d.ts +3 -1
- package/awst_build/ptypes/visitors/index-type-visitor.d.ts +0 -31
- package/awst_build/type-resolver.d.ts +1 -1
- package/bin/puyats-clientgen.d.ts +2 -0
- package/bin/puyats-clientgen.mjs +101 -0
- package/bin/puyats-clientgen.mjs.map +1 -0
- package/bin/puyats-ls.mjs +24 -49
- package/bin/puyats-ls.mjs.map +1 -1
- package/bin/run-cli.mjs +19 -13
- package/bin/run-cli.mjs.map +1 -1
- package/{check-node-version-CNvxI8_l.js → check-node-version-BP_a9Mv8.js} +3 -3
- package/{check-node-version-CNvxI8_l.js.map → check-node-version-BP_a9Mv8.js.map} +1 -1
- package/cli/build-command.d.ts +2 -0
- package/cli-ls.d.ts +1 -1
- package/cli.d.ts +1 -1
- package/cli.mjs +39 -79
- package/cli.mjs.map +1 -1
- package/clientgen.d.ts +1 -0
- package/code-fix/{invalid-non-null-assertion.d.ts → no-op-non-null-assertion.d.ts} +1 -1
- package/{compile-Bz8LVwK2.js → compile-BaYaEC1Y.js} +11 -4
- package/compile-BaYaEC1Y.js.map +1 -0
- package/compile.d.ts +1 -1
- package/constants.d.ts +7 -2
- package/contract-class-model-pgJctz5F.js +5456 -0
- package/contract-class-model-pgJctz5F.js.map +1 -0
- package/errors.d.ts +1 -6
- package/index.d.ts +1 -2
- package/index.mjs +36 -26
- package/index.mjs.map +1 -1
- package/language-server/analyser-service.d.ts +0 -1
- package/language-server/compile-trigger-queue.d.ts +2 -2
- package/language-server/puya-language-server.d.ts +0 -38
- package/logger/index.d.ts +0 -7
- package/{options-COFRHTFQ.js → options-8bOJR8qx.js} +2776 -8517
- package/options-8bOJR8qx.js.map +1 -0
- package/options.d.ts +8 -3
- package/package.json +20 -12
- package/puya/check-puya-version.d.ts +0 -13
- package/puya/index.d.ts +1 -1
- package/puya/log-deserializer.d.ts +0 -2
- package/puya/puya-service.d.ts +5 -1
- package/{resolve-puya-path-DtTAMi0Y.js → resolve-puya-path-EZBzWIlE.js} +9 -45
- package/resolve-puya-path-EZBzWIlE.js.map +1 -0
- package/semver-DpFo0aCr.js +45 -0
- package/semver-DpFo0aCr.js.map +1 -0
- package/util/base-85.d.ts +1 -4
- package/util/generate-temp-file.d.ts +0 -8
- package/util/index.d.ts +1 -3
- package/util/typed-message-port.d.ts +2 -2
- package/util-JPoBh0Op.js +63 -0
- package/util-JPoBh0Op.js.map +1 -0
- package/visitor/syntax-names.d.ts +194 -194
- package/visitor/visitor.d.ts +4 -4
- package/analyser-service-_vXhzOY0.js.map +0 -1
- package/compile-Bz8LVwK2.js.map +0 -1
- package/language-server/ls-logger.d.ts +0 -11
- package/options-COFRHTFQ.js.map +0 -1
- package/resolve-puya-path-DtTAMi0Y.js.map +0 -1
- package/util/arc4-signature-parser.d.ts +0 -14
- package/util/polyfills.d.ts +0 -1
package/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sources":["../src/logger/sinks/console-log-sink.ts","../src/cli/util.ts","../src/cli/build-command.ts","../src/cli/parse.ts","../src/cli.ts"],"sourcesContent":["import chalk from 'chalk'\nimport type { SourceLocation } from '../../awst/source-location'\nimport type { LogEvent } from '../index'\nimport { isMinLevel, LoggingContext, LogLevel } from '../index'\nimport type { LogSink } from './index'\nimport type { AbsolutePath } from '../../util/absolute-path'\n\ntype ColorFn = (text: string) => string\nconst levelConfig: Record<LogEvent['level'], { colorFn: ColorFn; writeFn: (...args: unknown[]) => void }> = {\n /* eslint-disable no-console */\n debug: { colorFn: chalk.green, writeFn: console.debug },\n info: { colorFn: chalk.green, writeFn: console.info },\n warning: { colorFn: chalk.yellow, writeFn: console.warn },\n error: { colorFn: chalk.red, writeFn: console.error },\n critical: { colorFn: chalk.red, writeFn: console.error },\n /* eslint-enable no-console */\n}\n\nexport class ConsoleLogSink implements LogSink {\n constructor(\n public readonly minLogLevel: LogLevel,\n private readonly pathsRelativeTo?: AbsolutePath,\n ) {}\n\n add(logEvent: LogEvent): void {\n const config = levelConfig[logEvent.level]\n\n let logText = `${config.colorFn(logEvent.level)}: ${logEvent.message}`\n if (logEvent.sourceLocation) {\n const sourceLocationText = logEvent.sourceLocation.toString({ pathsRelativeTo: this.pathsRelativeTo })\n const indentSize = sourceLocationText.length + logEvent.level.length + 4\n\n const sourceSummary = isMinLevel(logEvent.level, LogLevel.Warning) ? this.getSourceSummary(logEvent.sourceLocation, indentSize) : ''\n logText = `${sourceLocationText} ${logText}${sourceSummary}`\n }\n if (isMinLevel(LogLevel.Debug, this.minLogLevel) && logEvent.stack) {\n logText += `\\n ${logEvent.stack}`\n }\n config.writeFn(logText)\n }\n\n getSourceSummary(sourceLocation: SourceLocation, indent: number): string {\n const sourceFile = sourceLocation.file && LoggingContext.current.sourcesByPath[sourceLocation.file.toString()]\n if (!sourceFile || sourceLocation.scope === 'file') return ''\n\n const line = sourceFile[sourceLocation.line - 1]\n const trimmedLine = line.trimStart()\n const marker = `${''.padStart(sourceLocation.column - (line.length - trimmedLine.length))}^${''.padStart(Math.max(sourceLocation.endColumn - sourceLocation.column - 1, 0), '~')}`\n const indentChars = ''.padStart(indent, ' ')\n return `\\n${indentChars}${trimmedLine}\\n${indentChars}${marker}`\n }\n}\n","import type { ArgumentParser } from 'argparse'\nimport { enumFromValue } from '../util'\n\nexport function addEnumArg<T>(\n parser: ArgumentParser,\n { name, enumType, default: defaultValue, help }: { name: string; enumType: Record<string, string>; default?: T; help: string },\n) {\n parser.add_argument(name, {\n type: (v: string) => enumFromValue(v, enumType),\n choices: Array.from(Object.values(enumType)),\n default: defaultValue,\n help,\n })\n}\n\nexport function convertInt(val: string) {\n const res = Number(val)\n if (isNaN(res) || Math.round(res) !== res) {\n throw new Error(`'${val}' could not be converted to a number`)\n }\n return res\n}\n","import type { ArgumentParser } from 'argparse'\nimport { BooleanOptionalAction } from 'argparse'\nimport { compile } from '../compile'\nimport { processInputPaths } from '../input-paths/process-input-paths'\nimport { logger, LoggingContext, LogLevel } from '../logger'\nimport { ConsoleLogSink } from '../logger/sinks/console-log-sink'\nimport { CompileOptions, defaultPuyaOptions, LocalsCoalescingStrategy } from '../options'\n\nimport { AbsolutePath } from '../util/absolute-path'\nimport { parseCliTemplateVar } from '../util/template-var-cli-parser'\nimport { addEnumArg, convertInt } from './util'\n\nexport interface BuildCommandArgs {\n command: 'build'\n log_level: LogLevel\n output_awst: boolean\n output_awst_json: boolean\n dry_run: boolean\n skip_version_check: boolean\n output_teal: boolean\n output_source_map: boolean\n output_arc32: boolean\n output_arc56: boolean\n output_ssa_ir: boolean\n output_optimization_ir: boolean\n output_destructured_ir: boolean\n output_memory_ir: boolean\n output_bytecode: boolean\n out_dir: string\n debug_level: string\n optimization_level: string\n treat_warnings_as_errors: boolean\n target_avm_version: string\n cli_template_definitions: string[]\n validate_abi_args: boolean\n validate_abi_return: boolean\n template_vars_prefix: string\n locals_coalescing_strategy: LocalsCoalescingStrategy\n paths: string[]\n puya_path: string\n}\n\nexport function addBuildCommand(parser: ArgumentParser) {\n addEnumArg(parser, {\n name: '--log-level',\n default: LogLevel.Info,\n enumType: LogLevel,\n help: 'The minimum log level to output',\n })\n\n parser.add_argument('--output-awst', {\n help: 'Output debugging awst file per parsed file',\n default: false,\n action: BooleanOptionalAction,\n })\n\n parser.add_argument('--output-awst-json', {\n action: BooleanOptionalAction,\n default: false,\n help: 'Output debugging awst json file per parsed file',\n })\n\n parser.add_argument('--dry-run', {\n action: BooleanOptionalAction,\n default: false,\n help: \"Just parse typescript files, don't invoke puya compiler\",\n })\n parser.add_argument('--skip-version-check', {\n action: BooleanOptionalAction,\n default: false,\n help: \"Don't verify installed puya compiler version matches targeted version\",\n })\n parser.add_argument('--output-teal', {\n action: BooleanOptionalAction,\n help: 'Output TEAL code',\n default: defaultPuyaOptions.outputTeal,\n })\n parser.add_argument('--output-source-map', {\n action: BooleanOptionalAction,\n help: 'Output debug source maps ',\n default: defaultPuyaOptions.outputSourceMap,\n })\n parser.add_argument('--output-arc32', {\n action: BooleanOptionalAction,\n help: 'Output {contract}.arc32.json ARC-32 app spec file. Only applicable to ARC4 contracts ',\n default: defaultPuyaOptions.outputArc32,\n })\n parser.add_argument('--output-arc56', {\n action: BooleanOptionalAction,\n help: 'Output {contract}.arc56.json ARC-56 app spec file. Only applicable to ARC4 contracts ',\n default: defaultPuyaOptions.outputArc56,\n })\n parser.add_argument('--output-ssa-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR (in SSA form) before optimisations',\n default: defaultPuyaOptions.outputSsaIr,\n })\n parser.add_argument('--output-optimization-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR after each optimization',\n default: defaultPuyaOptions.outputOptimizationIr,\n })\n parser.add_argument('--output-destructured-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR after SSA destructuring and before MIR',\n default: defaultPuyaOptions.outputDestructuredIr,\n })\n parser.add_argument('--output-memory-ir', {\n action: BooleanOptionalAction,\n help: 'Output MIR before lowering to TealOps',\n default: defaultPuyaOptions.outputMemoryIr,\n })\n parser.add_argument('--output-bytecode', {\n action: BooleanOptionalAction,\n help: 'Output AVM bytecode',\n default: defaultPuyaOptions.outputBytecode,\n })\n\n parser.add_argument('--out-dir', {\n action: 'store',\n help: 'Where to output builder artifacts. Can use [name] placeholder to include contract name in path',\n default: 'out',\n })\n\n parser.add_argument('--debug-level', {\n default: defaultPuyaOptions.debugLevel.toString(),\n choices: ['0', '1', '2'],\n help: 'Output debug information level, 0 = none, 1 = debug, 2 = reserved for future use',\n })\n parser.add_argument('--optimization-level', {\n default: defaultPuyaOptions.optimizationLevel.toString(),\n choices: ['0', '1', '2'],\n help: 'Set optimization level of output TEAL / AVM bytecode, 0 = none, 1 = normal, 2 = intensive',\n })\n parser.add_argument('--treat-warnings-as-errors', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.treatWarningsAsErrors,\n help: 'Report and treat all warnings emitted by the compiler as errors',\n })\n parser.add_argument('--target-avm-version', {\n default: defaultPuyaOptions.targetAvmVersion.toString(),\n choices: ['10', '11', '12', '13'],\n help: 'Select the targeted AVM version for compilation output',\n })\n\n parser.add_argument('--cli-template-definitions', {\n metavar: 'VAR=VALUE',\n nargs: '+',\n help: 'Define template vars for use when assembling via --output-bytecode, should be specified without the prefix (see --template-vars-prefix)',\n })\n\n parser.add_argument('--validate-abi-args', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.validateAbiArgs,\n help: 'Validates ABI transaction arguments by ensuring they are encoded correctly',\n })\n\n parser.add_argument('--validate-abi-return', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.validateAbiReturn,\n help: \"Validates encoding of ABI return values when using convertBytes with 'log' `prefix` option, arc4.abiCall, and strongly typed contract to contract calls\",\n })\n\n parser.add_argument('--template-vars-prefix', {\n help: 'Define the prefix to use with --template-var',\n default: defaultPuyaOptions.templateVarsPrefix,\n })\n\n addEnumArg(parser, {\n name: '--locals-coalescing-strategy',\n enumType: LocalsCoalescingStrategy,\n help: 'Strategy choice for out-of-ssa local variable coalescing. The best choice for your app is best determined through experimentation',\n default: defaultPuyaOptions.localsCoalescingStrategy,\n })\n\n parser.add_argument('paths', {\n metavar: 'PATHS',\n nargs: '*',\n help: 'The path, or paths to search for compatible .algo.ts files',\n default: ['.'],\n })\n\n parser.add_argument('--puya-path', {\n help: 'The path to Puya. If not provided, puya-ts will automatically download the appropriate binary for your system',\n })\n}\n\nexport async function buildCommand(args: BuildCommandArgs) {\n const logCtx = LoggingContext.create()\n return logCtx.run(async () => {\n logger.configure([new ConsoleLogSink(args.log_level, AbsolutePath.resolve({ path: '' }))])\n try {\n const filePaths = processInputPaths({ paths: args.paths, outDir: args.out_dir })\n\n await compile(\n new CompileOptions({\n filePaths,\n outputAwst: args.output_awst,\n outputAwstJson: args.output_awst_json,\n\n skipVersionCheck: args.skip_version_check,\n dryRun: args.dry_run,\n logLevel: args.log_level,\n\n outputTeal: args.output_teal,\n outputArc32: args.output_arc32,\n outputArc56: args.output_arc56,\n outputSsaIr: args.output_ssa_ir,\n outputOptimizationIr: args.output_optimization_ir,\n outputDestructuredIr: args.output_destructured_ir,\n outputMemoryIr: args.output_memory_ir,\n outputBytecode: args.output_bytecode,\n outputSourceMap: args.output_source_map,\n debugLevel: convertInt(args.debug_level),\n optimizationLevel: convertInt(args.optimization_level),\n treatWarningsAsErrors: args.treat_warnings_as_errors,\n targetAvmVersion: convertInt(args.target_avm_version),\n cliTemplateDefinitions: Object.fromEntries(args.cli_template_definitions?.map(parseCliTemplateVar) ?? []),\n templateVarsPrefix: args.template_vars_prefix,\n localsCoalescingStrategy: args.locals_coalescing_strategy,\n customPuyaPath: args.puya_path,\n validateAbiArgs: args.validate_abi_args,\n validateAbiReturn: args.validate_abi_return,\n }),\n )\n logCtx.exitIfErrors()\n } catch (e) {\n if (e instanceof Error) {\n logger.error(e)\n } else {\n throw e\n }\n }\n })\n}\n","import { ArgumentParser } from 'argparse'\nimport { appVersion } from './app-version'\nimport type { BuildCommandArgs } from './build-command'\nimport { addBuildCommand, buildCommand } from './build-command'\nimport { checkNodeVersion } from './check-node-version'\n\nexport async function parseCliArguments() {\n checkNodeVersion()\n const parser = new ArgumentParser({\n prog: 'puya-ts',\n })\n\n parser.add_argument('--version', {\n action: 'store_const',\n help: 'Show application version',\n const: 'version',\n dest: 'command',\n })\n parser.set_defaults({\n command: 'build',\n })\n addBuildCommand(parser)\n const result: PuyaTsCommand = parser.parse_args()\n switch (result.command) {\n case 'build':\n await buildCommand(result)\n break\n case 'version':\n /* eslint-disable-next-line no-console */\n console.log(appVersion())\n break\n default:\n parser.print_help()\n break\n }\n}\n\ntype PuyaTsCommand = NoCommandArgs | BuildCommandArgs | VersionCommand\ninterface NoCommandArgs {\n command: 'none'\n}\ninterface VersionCommand {\n command: 'version'\n}\n","import './util/polyfills'\nimport { parseCliArguments } from './cli/parse'\n\nvoid parseCliArguments()\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,WAAW,GAA2F;;AAE1G,IAAA,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE;AACvD,IAAA,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE;AACrD,IAAA,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE;AACzD,IAAA,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE;AACrD,IAAA,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE;;CAEzD;MAEY,cAAc,CAAA;AAEP,IAAA,WAAA;AACC,IAAA,eAAA;IAFnB,WAAA,CACkB,WAAqB,EACpB,eAA8B,EAAA;QAD/B,IAAA,CAAA,WAAW,GAAX,WAAW;QACV,IAAA,CAAA,eAAe,GAAf,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|
1
|
+
{"version":3,"file":"cli.mjs","sources":["../src/cli/build-command.ts","../src/cli/parse.ts","../src/cli.ts"],"sourcesContent":["import type { ArgumentParser } from 'argparse'\nimport { BooleanOptionalAction } from 'argparse'\nimport { compile } from '../compile'\nimport { processInputPaths } from '../input-paths/process-input-paths'\nimport { logger, LoggingContext, LogLevel } from '../logger'\nimport { ConsoleLogSink } from '../logger/sinks/console-log-sink'\nimport { CompileOptions, defaultPuyaOptions, LocalsCoalescingStrategy } from '../options'\n\nimport { AbsolutePath } from '../util/absolute-path'\nimport { parseCliTemplateVar } from '../util/template-var-cli-parser'\nimport { addEnumArg, convertInt } from './util'\n\nexport interface BuildCommandArgs {\n command: 'build'\n log_level: LogLevel\n output_awst: boolean\n output_awst_json: boolean\n dry_run: boolean\n skip_version_check: boolean\n output_teal: boolean\n output_source_map: boolean\n output_arc32: boolean\n output_arc56: boolean\n output_client: boolean\n output_ssa_ir: boolean\n output_optimization_ir: boolean\n output_destructured_ir: boolean\n output_memory_ir: boolean\n output_bytecode: boolean\n output_assembly_report: boolean\n out_dir: string\n debug_level: string\n optimization_level: string\n treat_warnings_as_errors: boolean\n target_avm_version: string\n cli_template_definitions: string[]\n validate_abi_args: boolean\n validate_abi_return: boolean\n template_vars_prefix: string\n locals_coalescing_strategy: LocalsCoalescingStrategy\n paths: string[]\n puya_path: string\n}\n\nexport function addBuildCommand(parser: ArgumentParser) {\n addEnumArg(parser, {\n name: '--log-level',\n default: LogLevel.Info,\n enumType: LogLevel,\n help: 'The minimum log level to output',\n })\n\n parser.add_argument('--output-awst', {\n help: 'Output debugging awst file per parsed file',\n default: false,\n action: BooleanOptionalAction,\n })\n\n parser.add_argument('--output-awst-json', {\n action: BooleanOptionalAction,\n default: false,\n help: 'Output debugging awst json file per parsed file',\n })\n\n parser.add_argument('--dry-run', {\n action: BooleanOptionalAction,\n default: false,\n help: \"Just parse typescript files, don't invoke puya compiler\",\n })\n parser.add_argument('--skip-version-check', {\n action: BooleanOptionalAction,\n default: false,\n help: \"Don't verify installed puya compiler version matches targeted version\",\n })\n parser.add_argument('--output-teal', {\n action: BooleanOptionalAction,\n help: 'Output TEAL code',\n default: defaultPuyaOptions.outputTeal,\n })\n parser.add_argument('--output-source-map', {\n action: BooleanOptionalAction,\n help: 'Output debug source maps ',\n default: defaultPuyaOptions.outputSourceMap,\n })\n parser.add_argument('--output-arc32', {\n action: BooleanOptionalAction,\n help: 'Output {contract}.arc32.json ARC-32 app spec file. Only applicable to ARC4 contracts ',\n default: defaultPuyaOptions.outputArc32,\n })\n parser.add_argument('--output-arc56', {\n action: BooleanOptionalAction,\n help: 'Output {contract}.arc56.json ARC-56 app spec file. Only applicable to ARC4 contracts ',\n default: defaultPuyaOptions.outputArc56,\n })\n parser.add_argument('--output-client', {\n action: BooleanOptionalAction,\n help: 'Output {contract}.client.ts Algorand TypeScript contract client for typed ARC-4 ABI calls. Only applicable to ARC4 contracts ',\n default: defaultPuyaOptions.outputClient,\n })\n parser.add_argument('--output-ssa-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR (in SSA form) before optimisations',\n default: defaultPuyaOptions.outputSsaIr,\n })\n parser.add_argument('--output-optimization-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR after each optimization',\n default: defaultPuyaOptions.outputOptimizationIr,\n })\n parser.add_argument('--output-destructured-ir', {\n action: BooleanOptionalAction,\n help: 'Output IR after SSA destructuring and before MIR',\n default: defaultPuyaOptions.outputDestructuredIr,\n })\n parser.add_argument('--output-memory-ir', {\n action: BooleanOptionalAction,\n help: 'Output MIR before lowering to TealOps',\n default: defaultPuyaOptions.outputMemoryIr,\n })\n parser.add_argument('--output-bytecode', {\n action: BooleanOptionalAction,\n help: 'Output AVM bytecode',\n default: defaultPuyaOptions.outputBytecode,\n })\n parser.add_argument('--output-assembly-report', {\n action: BooleanOptionalAction,\n help: 'Output \"human-readable\" source map for advanced debugging purposes.',\n default: defaultPuyaOptions.outputAssemblyReport,\n })\n\n parser.add_argument('--out-dir', {\n action: 'store',\n help: 'Where to output builder artifacts. Can use [name] placeholder to include contract name in path',\n default: 'out',\n })\n\n parser.add_argument('--debug-level', {\n default: defaultPuyaOptions.debugLevel.toString(),\n choices: ['0', '1', '2'],\n help: 'Output debug information level, 0 = none, 1 = debug, 2 = reserved for future use',\n })\n parser.add_argument('--optimization-level', {\n default: defaultPuyaOptions.optimizationLevel.toString(),\n choices: ['0', '1', '2'],\n help: 'Set optimization level of output TEAL / AVM bytecode, 0 = none, 1 = normal, 2 = intensive',\n })\n parser.add_argument('--treat-warnings-as-errors', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.treatWarningsAsErrors,\n help: 'Report and treat all warnings emitted by the compiler as errors',\n })\n parser.add_argument('--target-avm-version', {\n default: defaultPuyaOptions.targetAvmVersion.toString(),\n choices: ['10', '11', '12', '13'],\n help: 'Select the targeted AVM version for compilation output',\n })\n\n parser.add_argument('--cli-template-definitions', {\n metavar: 'VAR=VALUE',\n nargs: '+',\n help: 'Define template vars for use when assembling via --output-bytecode, should be specified without the prefix (see --template-vars-prefix)',\n })\n\n parser.add_argument('--validate-abi-args', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.validateAbiArgs,\n help: 'Validates ABI transaction arguments by ensuring they are encoded correctly',\n })\n\n parser.add_argument('--validate-abi-return', {\n action: BooleanOptionalAction,\n default: defaultPuyaOptions.validateAbiReturn,\n help: \"Validates encoding of ABI return values when using convertBytes with 'log' `prefix` option, arc4.abiCall, and strongly typed contract to contract calls\",\n })\n\n parser.add_argument('--template-vars-prefix', {\n help: 'Define the prefix to use with --template-var',\n default: defaultPuyaOptions.templateVarsPrefix,\n })\n\n addEnumArg(parser, {\n name: '--locals-coalescing-strategy',\n enumType: LocalsCoalescingStrategy,\n help: 'Strategy choice for out-of-ssa local variable coalescing. The best choice for your app is best determined through experimentation',\n default: defaultPuyaOptions.localsCoalescingStrategy,\n })\n\n parser.add_argument('paths', {\n metavar: 'PATHS',\n nargs: '*',\n help: 'The path, or paths to search for compatible .algo.ts files',\n default: ['.'],\n })\n\n parser.add_argument('--puya-path', {\n help: 'The path to Puya. If not provided, puya-ts will automatically download the appropriate binary for your system',\n })\n}\n\nexport async function buildCommand(args: BuildCommandArgs) {\n const logCtx = LoggingContext.create()\n return logCtx.run(async () => {\n logger.configure([new ConsoleLogSink(args.log_level, AbsolutePath.resolve({ path: '' }))])\n try {\n const filePaths = processInputPaths({ paths: args.paths, outDir: args.out_dir })\n\n await compile(\n new CompileOptions({\n filePaths,\n outputAwst: args.output_awst,\n outputAwstJson: args.output_awst_json,\n\n skipVersionCheck: args.skip_version_check,\n dryRun: args.dry_run,\n logLevel: args.log_level,\n\n outputTeal: args.output_teal,\n outputArc32: args.output_arc32,\n outputArc56: args.output_arc56,\n outputClient: args.output_client,\n outputSsaIr: args.output_ssa_ir,\n outputOptimizationIr: args.output_optimization_ir,\n outputDestructuredIr: args.output_destructured_ir,\n outputMemoryIr: args.output_memory_ir,\n outputBytecode: args.output_bytecode,\n outputSourceMap: args.output_source_map,\n outputAssemblyReport: args.output_assembly_report,\n debugLevel: convertInt(args.debug_level),\n optimizationLevel: convertInt(args.optimization_level),\n treatWarningsAsErrors: args.treat_warnings_as_errors,\n targetAvmVersion: convertInt(args.target_avm_version),\n cliTemplateDefinitions: Object.fromEntries(args.cli_template_definitions?.map(parseCliTemplateVar) ?? []),\n templateVarsPrefix: args.template_vars_prefix,\n localsCoalescingStrategy: args.locals_coalescing_strategy,\n customPuyaPath: args.puya_path,\n validateAbiArgs: args.validate_abi_args,\n validateAbiReturn: args.validate_abi_return,\n }),\n )\n logCtx.exitIfErrors()\n } catch (e) {\n if (e instanceof Error) {\n logger.error(e)\n } else {\n throw e\n }\n }\n })\n}\n","import { ArgumentParser } from 'argparse'\nimport { appVersion } from './app-version'\nimport type { BuildCommandArgs } from './build-command'\nimport { addBuildCommand, buildCommand } from './build-command'\nimport { checkNodeVersion } from './check-node-version'\n\nexport async function parseCliArguments() {\n checkNodeVersion()\n const parser = new ArgumentParser({\n prog: 'puya-ts',\n })\n\n parser.add_argument('--version', {\n action: 'store_const',\n help: 'Show application version',\n const: 'version',\n dest: 'command',\n })\n parser.set_defaults({\n command: 'build',\n })\n addBuildCommand(parser)\n const result: PuyaTsCommand = parser.parse_args()\n switch (result.command) {\n case 'build':\n await buildCommand(result)\n break\n case 'version':\n /* eslint-disable-next-line no-console */\n console.log(appVersion())\n break\n default:\n parser.print_help()\n break\n }\n}\n\ntype PuyaTsCommand = NoCommandArgs | BuildCommandArgs | VersionCommand\ninterface NoCommandArgs {\n command: 'none'\n}\ninterface VersionCommand {\n command: 'version'\n}\n","import { parseCliArguments } from './cli/parse'\n\nvoid parseCliArguments()\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CM,SAAU,eAAe,CAAC,MAAsB,EAAA;IACpD,UAAU,CAAC,MAAM,EAAE;AACjB,QAAA,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,QAAQ,CAAC,IAAI;AACtB,QAAA,QAAQ,EAAE,QAAQ;AAClB,QAAA,IAAI,EAAE,iCAAiC;AACxC,KAAA,CAAC;AAEF,IAAA,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE;AACnC,QAAA,IAAI,EAAE,4CAA4C;AAClD,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,MAAM,EAAE,qBAAqB;AAC9B,KAAA,CAAC;AAEF,IAAA,MAAM,CAAC,YAAY,CAAC,oBAAoB,EAAE;AACxC,QAAA,MAAM,EAAE,qBAAqB;AAC7B,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,IAAI,EAAE,iDAAiD;AACxD,KAAA,CAAC;AAEF,IAAA,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;AAC/B,QAAA,MAAM,EAAE,qBAAqB;AAC7B,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,IAAI,EAAE,yDAAyD;AAChE,KAAA,CAAC;AACF,IAAA,MAAM,CAAC,YAAY,CAAC,sBAAsB,E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AClPO,eAAe,iBAAiB,GAAA;AACrC,IAAA,gBAAgB,EAAE;AAClB,IAAA,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC;AAChC,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;AAEF,IAAA,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;AAC/B,QAAA,MAAM,EAAE,aAAa;AACrB,QAAA,IAAI,EAAE,0BAA0B;AAChC,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;IACF,MAAM,CAAC,YAAY,CAAC;AAClB,QAAA,OAAO,EAAE,OAAO;AACjB,KAAA,CAAC;IACF,eAAe,CAAC,MAAM,CAAC;AACvB,IAAA,MAAM,MAAM,GAAkB,MAAM,CAAC,UAAU,EAAE;AACjD,IAAA,QAAQ,MAAM,CAAC,OAAO;AACpB,QAAA,KAAK,OAAO;AACV,YAAA,MAAM,YAAY,CAAC,MAAM,CAAC;YAC1B;AACF,QAAA,KAAK,SAAS;;AAEZ,YAAA,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;YACzB;AACF,QAAA;YACE,MAAM,CAAC,UAAU,EAAE;YACnB;;AAEN;;ACjCA,KAAK,iBAAiB,EAAE"}
|
package/clientgen.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type ts from 'typescript';
|
|
|
2
2
|
import type { SourceLocation } from '../awst/source-location';
|
|
3
3
|
import type { TextEdit } from '../text-edit';
|
|
4
4
|
import { CodeFix } from './code-fix';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class NoOpNonNullAssertion extends CodeFix {
|
|
6
6
|
constructor({ sourceLocation }: {
|
|
7
7
|
sourceLocation: SourceLocation<ts.NonNullExpression>;
|
|
8
8
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as writeARC4Clients } from './arc4-clientgen-BMCeFyNd.js';
|
|
2
|
+
import { a1 as PuyaService, a2 as deserializeAndLog, Y as registerPTypes, a3 as createTsProgram, a4 as buildAwst, a5 as validateAwst, Z as typeRegistry } from './options-8bOJR8qx.js';
|
|
3
|
+
import { a as appVersion } from './semver-DpFo0aCr.js';
|
|
4
|
+
import { ck as mkDirIfNotExists, L as LogLevel, a as LoggingContext, l as logger } from './contract-class-model-pgJctz5F.js';
|
|
3
5
|
import ts from 'typescript';
|
|
6
|
+
import { r as resolvePuyaPath } from './resolve-puya-path-EZBzWIlE.js';
|
|
4
7
|
|
|
5
8
|
function buildCompilationSetMapping({ awst, inputPaths, compilationSet, }) {
|
|
6
9
|
const setIds = new Set(compilationSet.compilationOutputSet.map((s) => s.id));
|
|
@@ -37,6 +40,7 @@ async function puyaCompile({ moduleAwst, programDirectory, sourceFiles, options,
|
|
|
37
40
|
for (const log of response.logs) {
|
|
38
41
|
deserializeAndLog(log);
|
|
39
42
|
}
|
|
43
|
+
return response;
|
|
40
44
|
}
|
|
41
45
|
function getPuyaLogLevel(logLevel) {
|
|
42
46
|
switch (logLevel) {
|
|
@@ -85,7 +89,7 @@ async function compile(options, puyaService) {
|
|
|
85
89
|
};
|
|
86
90
|
}
|
|
87
91
|
if (!options.dryRun) {
|
|
88
|
-
await puyaCompile({
|
|
92
|
+
const compileResult = await puyaCompile({
|
|
89
93
|
options,
|
|
90
94
|
moduleAwst,
|
|
91
95
|
programDirectory: programResult.programDirectory,
|
|
@@ -93,6 +97,9 @@ async function compile(options, puyaService) {
|
|
|
93
97
|
sourceFiles: programResult.sourceFiles,
|
|
94
98
|
puyaService,
|
|
95
99
|
});
|
|
100
|
+
if (options.outputClient) {
|
|
101
|
+
await writeARC4Clients(compilationSet, options.filePaths, compileResult.arc56);
|
|
102
|
+
}
|
|
96
103
|
}
|
|
97
104
|
return {
|
|
98
105
|
programDirectory: programResult.programDirectory,
|
|
@@ -103,4 +110,4 @@ async function compile(options, puyaService) {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
export { compile as c };
|
|
106
|
-
//# sourceMappingURL=compile-
|
|
113
|
+
//# sourceMappingURL=compile-BaYaEC1Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-BaYaEC1Y.js","sources":["../src/puya/build-compilation-set-mapping.ts","../src/puya/index.ts","../src/compile.ts"],"sourcesContent":["import type { AWST } from '../awst/nodes'\nimport type { CompilationSet } from '../awst_build/models/contract-class-model'\nimport type { AlgoFile, CompilationSetMapping } from '../options'\nimport { mkDirIfNotExists } from '../util'\n\nexport function buildCompilationSetMapping({\n awst,\n inputPaths,\n compilationSet,\n}: {\n awst: AWST[]\n inputPaths: AlgoFile[]\n compilationSet: CompilationSet\n}): CompilationSetMapping {\n const setIds = new Set(compilationSet.compilationOutputSet.map((s) => s.id))\n\n return awst.reduce((acc, cur) => {\n if (setIds.has(cur.id.toString())) {\n const matchedPath = inputPaths.find((p) => cur.sourceLocation.file && p.sourceFile.equals(cur.sourceLocation.file))\n if (matchedPath) {\n mkDirIfNotExists(matchedPath.outDir.toString())\n acc[cur.id.toString()] = matchedPath.outDir.toString()\n }\n }\n return acc\n }, {} as CompilationSetMapping)\n}\n","import ts from 'typescript'\nimport type { AWST } from '../awst/nodes'\nimport type { CompilationSet } from '../awst_build/models/contract-class-model'\nimport { LogLevel } from '../logger'\nimport type { CompileOptions } from '../options'\nimport type { SourceFileMapping } from '../parser'\nimport type { AbsolutePath } from '../util/absolute-path'\nimport { buildCompilationSetMapping } from './build-compilation-set-mapping'\nimport { deserializeAndLog } from './log-deserializer'\nimport { PuyaService } from './puya-service'\nimport { resolvePuyaPath } from './resolve-puya-path'\n\nexport async function puyaCompile({\n moduleAwst,\n programDirectory,\n sourceFiles,\n options,\n compilationSet,\n puyaService,\n}: {\n moduleAwst: AWST[]\n programDirectory: AbsolutePath\n sourceFiles: SourceFileMapping\n options: CompileOptions\n compilationSet: CompilationSet\n puyaService?: PuyaService\n}) {\n const puyaPath = await resolvePuyaPath(options)\n const localPuyaService = puyaService ?? new PuyaService({ puyaPath })\n const puyaOptions = options.buildPuyaOptions(\n buildCompilationSetMapping({\n awst: moduleAwst,\n inputPaths: options.filePaths,\n compilationSet,\n }),\n )\n\n const response = await localPuyaService.compile({\n awst: moduleAwst,\n options: puyaOptions,\n base_path: programDirectory.toString(),\n log_level: getPuyaLogLevel(options.logLevel),\n source_annotations: getSourceFileContents(sourceFiles),\n })\n // Shutdown service if we created it locally\n if (puyaService === undefined) await localPuyaService.shutdown()\n for (const log of response.logs) {\n deserializeAndLog(log)\n }\n\n return response\n}\n\nfunction getPuyaLogLevel(logLevel: LogLevel): string {\n switch (logLevel) {\n case LogLevel.Debug:\n return 'debug'\n case LogLevel.Info:\n return 'info'\n case LogLevel.Warning:\n return 'warning'\n case LogLevel.Error:\n return 'error'\n case LogLevel.Critical:\n return 'critical'\n }\n}\nfunction getSourceFileContents(sourceFiles: SourceFileMapping) {\n return Object.fromEntries(\n Object.entries(sourceFiles).map(([key, value]) => {\n const source = ts.isSourceFile(value) ? value.getFullText().replace(/\\r\\n/g, '\\n').split(/\\n/g) : value\n return [key, source] as const\n }),\n )\n}\n","import type ts from 'typescript'\nimport { writeARC4Clients } from './arc4-clientgen'\nimport type { AWST } from './awst/nodes'\nimport { validateAwst } from './awst/validation'\nimport { buildAwst } from './awst_build'\nimport { type CompilationSet } from './awst_build/models/contract-class-model'\nimport { registerPTypes } from './awst_build/ptypes/register'\nimport { typeRegistry } from './awst_build/type-registry'\nimport { appVersion } from './cli/app-version'\nimport { logger, LoggingContext } from './logger'\nimport type { CompileOptions } from './options'\nimport { createTsProgram } from './parser'\nimport { puyaCompile } from './puya'\nimport type { PuyaService } from './puya/puya-service'\nimport type { AbsolutePath } from './util/absolute-path'\n\nexport type CompileResult = {\n programDirectory: AbsolutePath\n awst?: AWST[]\n ast?: Record<string, ts.SourceFile>\n compilationSet?: CompilationSet\n}\n\nexport async function compile(options: CompileOptions, puyaService?: PuyaService): Promise<CompileResult> {\n const loggerCtx = LoggingContext.current\n if (options.treatWarningsAsErrors) loggerCtx.treatWarningsAsErrors = true\n\n registerPTypes(typeRegistry)\n logger.info(undefined, appVersion({ withAVMVersion: false }))\n const programResult = createTsProgram(options)\n if (loggerCtx.hasErrors()) {\n logger.info(undefined, 'Compilation halted due to parse errors')\n return {\n programDirectory: programResult.programDirectory,\n ast: programResult.sourceFiles,\n }\n }\n const { moduleAwst, compilationSet } = buildAwst(programResult, options)\n validateAwst(moduleAwst)\n\n if (loggerCtx.hasErrors()) {\n logger.info(undefined, 'Compilation halted due to errors')\n return {\n programDirectory: programResult.programDirectory,\n awst: moduleAwst,\n ast: programResult.sourceFiles,\n compilationSet,\n }\n }\n if (!options.dryRun) {\n const compileResult = await puyaCompile({\n options,\n moduleAwst,\n programDirectory: programResult.programDirectory,\n compilationSet,\n sourceFiles: programResult.sourceFiles,\n puyaService,\n })\n\n if (options.outputClient) {\n await writeARC4Clients(compilationSet, options.filePaths, compileResult.arc56)\n }\n }\n\n return {\n programDirectory: programResult.programDirectory,\n awst: moduleAwst,\n ast: programResult.sourceFiles,\n compilationSet,\n }\n}\n"],"names":[],"mappings":";;;;;;;AAKM,SAAU,0BAA0B,CAAC,EACzC,IAAI,EACJ,UAAU,EACV,cAAc,GAKf,EAAA;IACC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAE5E,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;AAC9B,QAAA,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE;AACjC,YAAA,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,C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,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,wCAAwC,CAAC;QAChE,OAAO;YACL,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;YAChD,GAAG,EAAE,aAAa,CAAC,WAAW;SAC/B;IACH;AACA,IAAA,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;IACxE,YAAY,CAAC,UAAU,CAAC;AAExB,IAAA,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE;AACzB,QAAA,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,kCAAkC,CAAC;QAC1D,OAAO;YACL,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;AAChD,YAAA,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,aAAa,CAAC,WAAW;YAC9B,cAAc;SACf;IACH;AACA,IAAA,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AACnB,QAAA,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC;YACtC,OAAO;YACP,UAAU;YACV,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;YAChD,cAAc;YACd,WAAW,EAAE,aAAa,CAAC,WAAW;YACtC,WAAW;AACZ,SAAA,CAAC;AAEF,QAAA,IAAI,OAAO,CAAC,YAAY,EAAE;AACxB,YAAA,MAAM,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC;QAChF;IACF;IAEA,OAAO;QACL,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;AAChD,QAAA,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,aAAa,CAAC,WAAW;QAC9B,cAAc;KACf;AACH;;;;"}
|
package/compile.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { AWST } from './awst/nodes';
|
|
3
|
-
import type
|
|
3
|
+
import { type CompilationSet } from './awst_build/models/contract-class-model';
|
|
4
4
|
import type { CompileOptions } from './options';
|
|
5
5
|
import type { PuyaService } from './puya/puya-service';
|
|
6
6
|
import type { AbsolutePath } from './util/absolute-path';
|
package/constants.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export declare const Constants: {
|
|
2
2
|
readonly algoTsPackage: "@algorandfoundation/algorand-typescript";
|
|
3
3
|
readonly moduleNames: {
|
|
4
|
+
readonly tslib: "lib.d.ts";
|
|
4
5
|
readonly typescript: {
|
|
6
|
+
readonly decorators: "typescript/lib/lib.decorators.d.ts";
|
|
5
7
|
readonly es5: "typescript/lib/lib.es5.d.ts";
|
|
8
|
+
readonly generator: "typescript/lib/lib.es2015.generator.d.ts";
|
|
9
|
+
readonly iterable: "typescript/lib/lib.es2015.iterable.d.ts";
|
|
6
10
|
};
|
|
7
11
|
readonly polytype: "polytype/lib/polytype-module.d.ts";
|
|
8
12
|
readonly algoTs: {
|
|
@@ -31,6 +35,7 @@ export declare const Constants: {
|
|
|
31
35
|
readonly util: "@algorandfoundation/algorand-typescript/util.d.ts";
|
|
32
36
|
readonly mutableObject: "@algorandfoundation/algorand-typescript/mutable-object.d.ts";
|
|
33
37
|
};
|
|
38
|
+
readonly puyaTs: "puya-ts";
|
|
34
39
|
};
|
|
35
40
|
readonly symbolNames: {
|
|
36
41
|
readonly approvalProgramMethodName: "approvalProgram";
|
|
@@ -61,9 +66,9 @@ export declare const Constants: {
|
|
|
61
66
|
readonly zeroAddressB32: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ";
|
|
62
67
|
};
|
|
63
68
|
readonly supportedAvmVersions: readonly [10n, 11n, 12n, 13n];
|
|
64
|
-
readonly targetedPuyaVersion: "5.
|
|
69
|
+
readonly targetedPuyaVersion: "5.9.0-rc.1";
|
|
65
70
|
readonly puyaGithubRepo: "algorandfoundation/puya";
|
|
66
|
-
readonly minNodeVersion: "
|
|
71
|
+
readonly minNodeVersion: "22.11.0";
|
|
67
72
|
readonly languageServerSource: "puyats";
|
|
68
73
|
};
|
|
69
74
|
export type SupportedAvmVersion = (typeof Constants.supportedAvmVersions)[number];
|