@algorandfoundation/puya-ts 1.0.0-alpha.10

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.
Files changed (242) hide show
  1. package/README.md +11 -0
  2. package/awst/index.d.ts +4 -0
  3. package/awst/intrinsic-factory.d.ts +35 -0
  4. package/awst/json-serialize-awst.d.ts +17 -0
  5. package/awst/models.d.ts +85 -0
  6. package/awst/node-factory.d.ts +90 -0
  7. package/awst/nodes.d.ts +841 -0
  8. package/awst/source-location.d.ts +21 -0
  9. package/awst/to-code-visitor.d.ts +87 -0
  10. package/awst/txn-fields.d.ts +84 -0
  11. package/awst/util.d.ts +2 -0
  12. package/awst/wtypes.d.ts +136 -0
  13. package/awst_build/base-visitor.d.ts +87 -0
  14. package/awst_build/constructor-visitor.d.ts +18 -0
  15. package/awst_build/context/awst-build-context.d.ts +72 -0
  16. package/awst_build/context/evaluation-context.d.ts +11 -0
  17. package/awst_build/context/switch-loop-context.d.ts +31 -0
  18. package/awst_build/context/unique-name-resolver.d.ts +14 -0
  19. package/awst_build/contract-data.d.ts +24 -0
  20. package/awst_build/contract-method-visitor.d.ts +20 -0
  21. package/awst_build/contract-visitor.d.ts +33 -0
  22. package/awst_build/decorator-visitor.d.ts +34 -0
  23. package/awst_build/eb/arc4/arrays.d.ts +31 -0
  24. package/awst_build/eb/arc4/uint-n-constructor-builder.d.ts +14 -0
  25. package/awst_build/eb/arc4-bare-method-decorator-builder.d.ts +19 -0
  26. package/awst_build/eb/assert-function-builder.d.ts +10 -0
  27. package/awst_build/eb/assert-match-function-builder.d.ts +8 -0
  28. package/awst_build/eb/biguint-expression-builder.d.ts +21 -0
  29. package/awst_build/eb/boolean-expression-builder.d.ts +15 -0
  30. package/awst_build/eb/bytes-expression-builder.d.ts +44 -0
  31. package/awst_build/eb/contract-builder.d.ts +19 -0
  32. package/awst_build/eb/ensure-budget.d.ts +8 -0
  33. package/awst_build/eb/folding.d.ts +5 -0
  34. package/awst_build/eb/free-subroutine-expression-builder.d.ts +22 -0
  35. package/awst_build/eb/index.d.ts +90 -0
  36. package/awst_build/eb/intrinsic-enum-builder.d.ts +9 -0
  37. package/awst_build/eb/iterable-iterator-expression-builder.d.ts +10 -0
  38. package/awst_build/eb/literal/array-literal-expression-builder.d.ts +18 -0
  39. package/awst_build/eb/literal/big-int-literal-expression-builder.d.ts +17 -0
  40. package/awst_build/eb/literal/conditional-expression-builder.d.ts +22 -0
  41. package/awst_build/eb/literal/object-expression-builder.d.ts +13 -0
  42. package/awst_build/eb/literal/object-literal-expression-builder.d.ts +28 -0
  43. package/awst_build/eb/literal-expression-builder.d.ts +27 -0
  44. package/awst_build/eb/log-function-builder.d.ts +7 -0
  45. package/awst_build/eb/namespace-builder.d.ts +9 -0
  46. package/awst_build/eb/native-array-expression-builder.d.ts +8 -0
  47. package/awst_build/eb/omitted-expression-builder.d.ts +9 -0
  48. package/awst_build/eb/op-module-builder.d.ts +25 -0
  49. package/awst_build/eb/reference/account.d.ts +15 -0
  50. package/awst_build/eb/reference/application.d.ts +12 -0
  51. package/awst_build/eb/reference/asset.d.ts +13 -0
  52. package/awst_build/eb/reference/base.d.ts +37 -0
  53. package/awst_build/eb/storage/box.d.ts +50 -0
  54. package/awst_build/eb/storage/global-state.d.ts +29 -0
  55. package/awst_build/eb/storage/local-state.d.ts +32 -0
  56. package/awst_build/eb/storage/util.d.ts +5 -0
  57. package/awst_build/eb/storage/value-proxy.d.ts +22 -0
  58. package/awst_build/eb/string-expression-builder.d.ts +27 -0
  59. package/awst_build/eb/transactions/group-transactions.d.ts +15 -0
  60. package/awst_build/eb/transactions/inner-transaction-params.d.ts +19 -0
  61. package/awst_build/eb/transactions/inner-transactions.d.ts +10 -0
  62. package/awst_build/eb/transactions/txn-fields.d.ts +1317 -0
  63. package/awst_build/eb/transactions/util.d.ts +5 -0
  64. package/awst_build/eb/tuple-expression-builder.d.ts +12 -0
  65. package/awst_build/eb/uint64-enum-type-builder.d.ts +13 -0
  66. package/awst_build/eb/uint64-expression-builder.d.ts +21 -0
  67. package/awst_build/eb/urange-function.d.ts +7 -0
  68. package/awst_build/eb/util/arg-parsing.d.ts +106 -0
  69. package/awst_build/eb/util/compare-bytes.d.ts +5 -0
  70. package/awst_build/eb/util/compare-uint64.d.ts +5 -0
  71. package/awst_build/eb/util/index.d.ts +19 -0
  72. package/awst_build/eb/util/require-constant-value.d.ts +4 -0
  73. package/awst_build/eb/void-expression-builder.d.ts +7 -0
  74. package/awst_build/function-visitor.d.ts +45 -0
  75. package/awst_build/index.d.ts +5 -0
  76. package/awst_build/lib/index.d.ts +2 -0
  77. package/awst_build/op-metadata.d.ts +27 -0
  78. package/awst_build/ptypes/arc4-types.d.ts +56 -0
  79. package/awst_build/ptypes/base.d.ts +31 -0
  80. package/awst_build/ptypes/index.d.ts +464 -0
  81. package/awst_build/ptypes/intrinsic-enum-type.d.ts +14 -0
  82. package/awst_build/ptypes/op-ptypes.d.ts +6 -0
  83. package/awst_build/ptypes/register.d.ts +2 -0
  84. package/awst_build/ptypes/transient-type-errors.d.ts +14 -0
  85. package/awst_build/source-file-visitor.d.ts +21 -0
  86. package/awst_build/subroutine-visitor.d.ts +10 -0
  87. package/awst_build/symbol-name.d.ts +10 -0
  88. package/awst_build/text-visitor.d.ts +20 -0
  89. package/awst_build/type-registry.d.ts +61 -0
  90. package/awst_build/type-resolver.d.ts +18 -0
  91. package/bin/run-cli.d.ts +2 -0
  92. package/bin/run-cli.mjs +21 -0
  93. package/bin/run-cli.mjs.map +1 -0
  94. package/cli.d.ts +1 -0
  95. package/cli.mjs +161 -0
  96. package/cli.mjs.map +1 -0
  97. package/compile-options.d.ts +23 -0
  98. package/constants.d.ts +20 -0
  99. package/errors.d.ts +46 -0
  100. package/index-GbFBpbmB.js +16444 -0
  101. package/index-GbFBpbmB.js.map +1 -0
  102. package/index.d.ts +31 -0
  103. package/index.mjs +16 -0
  104. package/index.mjs.map +1 -0
  105. package/logger.d.ts +39 -0
  106. package/node_modules/typescript/LICENSE.txt +55 -0
  107. package/node_modules/typescript/README.md +50 -0
  108. package/node_modules/typescript/SECURITY.md +41 -0
  109. package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  110. package/node_modules/typescript/bin/tsc +2 -0
  111. package/node_modules/typescript/bin/tsserver +2 -0
  112. package/node_modules/typescript/lib/cancellationToken.js +90 -0
  113. package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2087 -0
  114. package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2087 -0
  115. package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2087 -0
  116. package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2087 -0
  117. package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2087 -0
  118. package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2087 -0
  119. package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2087 -0
  120. package/node_modules/typescript/lib/lib.d.ts +22 -0
  121. package/node_modules/typescript/lib/lib.decorators.d.ts +386 -0
  122. package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  123. package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  124. package/node_modules/typescript/lib/lib.dom.d.ts +28087 -0
  125. package/node_modules/typescript/lib/lib.dom.iterable.d.ts +491 -0
  126. package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  127. package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  128. package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  129. package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  130. package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +527 -0
  131. package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  132. package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  133. package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  134. package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  135. package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  136. package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  137. package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  138. package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  139. package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  140. package/node_modules/typescript/lib/lib.es2017.d.ts +25 -0
  141. package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  142. package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  143. package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  144. package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  145. package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  146. package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  147. package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  148. package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  149. package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  150. package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  151. package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  152. package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  153. package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  154. package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  155. package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  156. package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  157. package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  158. package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  159. package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  160. package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  161. package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  162. package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +727 -0
  163. package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  164. package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  165. package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  166. package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  167. package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  168. package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  169. package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
  170. package/node_modules/typescript/lib/lib.es2020.string.d.ts +42 -0
  171. package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  172. package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  173. package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  174. package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  175. package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  176. package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  177. package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +76 -0
  178. package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  179. package/node_modules/typescript/lib/lib.es2022.d.ts +26 -0
  180. package/node_modules/typescript/lib/lib.es2022.error.d.ts +73 -0
  181. package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  182. package/node_modules/typescript/lib/lib.es2022.intl.d.ts +121 -0
  183. package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  184. package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  185. package/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts +39 -0
  186. package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  187. package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  188. package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  189. package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  190. package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  191. package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  192. package/node_modules/typescript/lib/lib.es5.d.ts +4585 -0
  193. package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  194. package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  195. package/node_modules/typescript/lib/lib.esnext.collection.d.ts +106 -0
  196. package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  197. package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  198. package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  199. package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  200. package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  201. package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  202. package/node_modules/typescript/lib/lib.esnext.object.d.ts +29 -0
  203. package/node_modules/typescript/lib/lib.esnext.promise.d.ts +35 -0
  204. package/node_modules/typescript/lib/lib.esnext.regexp.d.ts +25 -0
  205. package/node_modules/typescript/lib/lib.esnext.string.d.ts +29 -0
  206. package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  207. package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  208. package/node_modules/typescript/lib/lib.webworker.d.ts +9410 -0
  209. package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  210. package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +288 -0
  211. package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2087 -0
  212. package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2087 -0
  213. package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2087 -0
  214. package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2087 -0
  215. package/node_modules/typescript/lib/tsc.js +130769 -0
  216. package/node_modules/typescript/lib/tsserver.js +623 -0
  217. package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  218. package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  219. package/node_modules/typescript/lib/typesMap.json +497 -0
  220. package/node_modules/typescript/lib/typescript.d.ts +11329 -0
  221. package/node_modules/typescript/lib/typescript.js +196072 -0
  222. package/node_modules/typescript/lib/typingsInstaller.js +236 -0
  223. package/node_modules/typescript/lib/watchGuard.js +53 -0
  224. package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2087 -0
  225. package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2087 -0
  226. package/node_modules/typescript/package.json +121 -0
  227. package/package.json +43 -0
  228. package/parser/index.d.ts +13 -0
  229. package/parser/json-serialize-source-files.d.ts +2 -0
  230. package/parser/resolve-module-name-literals.d.ts +2 -0
  231. package/puya/build-compilation-set-mapping.d.ts +9 -0
  232. package/puya/index.d.ts +13 -0
  233. package/puya/options.d.ts +29 -0
  234. package/puya/run-child-proc.d.ts +5 -0
  235. package/util/base-32.d.ts +2 -0
  236. package/util/base-85.d.ts +10 -0
  237. package/util/default-map.d.ts +1 -0
  238. package/util/generate-temp-file.d.ts +9 -0
  239. package/util/index.d.ts +47 -0
  240. package/visitor/syntax-names.d.ts +441 -0
  241. package/visitor/visitor.d.ts +26 -0
  242. package/write-artifact.d.ts +12 -0
package/cli.mjs ADDED
@@ -0,0 +1,161 @@
1
+ import { Command, Option } from 'commander';
2
+ import { z } from 'zod';
3
+ import { globSync } from 'glob';
4
+ import * as fs from 'node:fs';
5
+ import upath from 'upath';
6
+ import { n as normalisePath, l as logger, P as PuyaError, L as LogLevel, a as LocalsCoalescingStrategy, d as defaultPuyaOptions, c as compile } from './index-GbFBpbmB.js';
7
+ import 'change-case';
8
+ import 'node:path';
9
+ import 'node:buffer';
10
+ import 'node:util';
11
+ import 'chalk';
12
+ import 'polytype';
13
+ import 'typescript';
14
+ import 'tslib';
15
+ import 'crypto';
16
+ import 'fs';
17
+ import 'os';
18
+ import 'cross-spawn';
19
+
20
+ const buildCompileOptions = ({ paths, workingDirectory = process.cwd(), outDir, ...rest }) => {
21
+ const filePaths = [];
22
+ for (const p of paths) {
23
+ if (p.endsWith('.algo.ts')) {
24
+ if (fs.existsSync(p)) {
25
+ const actualPath = normalisePath(p, workingDirectory);
26
+ filePaths.push({
27
+ matchedInput: p,
28
+ sourceFile: actualPath,
29
+ outDir: upath.isAbsolute(outDir) ? upath.normalize(outDir) : upath.join(upath.dirname(actualPath), outDir),
30
+ });
31
+ }
32
+ else {
33
+ logger.warn(undefined, `File ${p} could not be found`);
34
+ }
35
+ }
36
+ else if (p.endsWith('.ts')) {
37
+ logger.warn(undefined, `Ignoring path ${p} as it does use the .algo.ts extension`);
38
+ }
39
+ else {
40
+ const matches = globSync(upath.join(p, '**/*.algo.ts'));
41
+ if (matches.length) {
42
+ for (const match of matches) {
43
+ filePaths.push({
44
+ matchedInput: p,
45
+ sourceFile: normalisePath(match, workingDirectory),
46
+ outDir: upath.join(upath.isAbsolute(outDir) ? outDir : upath.join(p, outDir), upath.relative(p, upath.dirname(match))),
47
+ });
48
+ }
49
+ }
50
+ else {
51
+ logger.warn(undefined, `Path '${p}' did not match any .algo.ts files`);
52
+ }
53
+ }
54
+ }
55
+ if (filePaths.length === 0) {
56
+ throw new PuyaError('Input paths did not match any .algo.ts files');
57
+ }
58
+ return {
59
+ filePaths,
60
+ ...rest,
61
+ getFileFromSource(sourceFile) {
62
+ return filePaths.find((p) => p.sourceFile === sourceFile);
63
+ },
64
+ };
65
+ };
66
+
67
+ const cliOptionsSchema = z.object({
68
+ outputAwst: z.boolean(),
69
+ outputAwstJson: z.boolean(),
70
+ outDir: z.string(),
71
+ dryRun: z.boolean(),
72
+ logLevel: z.nativeEnum(LogLevel),
73
+ // Puya options
74
+ outputTeal: z.boolean(),
75
+ outputArc32: z.boolean(),
76
+ outputSsaIr: z.boolean(),
77
+ outputOptimizationIr: z.boolean(),
78
+ outputDestructuredIr: z.boolean(),
79
+ outputMemoryIr: z.boolean(),
80
+ outputBytecode: z.boolean(),
81
+ matchAlgodBytecode: z.boolean(),
82
+ debugLevel: z.number().int(),
83
+ optimizationLevel: z.number().int(),
84
+ targetAvmVersion: z.number().int(),
85
+ cliTemplateDefinitions: z.preprocess((x) => x ?? [], z.array(z.string())),
86
+ templateVarsPrefix: z.string(),
87
+ localsCoalescingStrategy: z.nativeEnum(LocalsCoalescingStrategy),
88
+ });
89
+ const cliArgumentsSchema = z.array(z.string());
90
+ function cli() {
91
+ const commander = new Command().name('puya-ts').description('Algo-TS to Algorand smart contract compiler');
92
+ commander.helpCommand(true);
93
+ commander
94
+ .command('build')
95
+ .argument('<paths...>', 'The path, or paths to search for compatible .algo.ts files')
96
+ .addOption(new Option('--log-level [level]', 'The minimum log level to output')
97
+ .choices([LogLevel.Debug, LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Critical])
98
+ .default(LogLevel.Info))
99
+ .addOption(new Option('--output-awst', 'Output debugging awst file per parsed file').default(false))
100
+ .addOption(new Option('--output-awst-json', 'Output debugging awst json file per parsed file').default(false))
101
+ .addOption(new Option('--out-dir [outDir]').default('out'))
102
+ .addOption(new Option('--dry-run').default(false))
103
+ .addOption(new Option('--no-output-teal', 'Do not output TEAL code').default(defaultPuyaOptions.outputTeal))
104
+ .addOption(new Option('--no-output-arc32', 'Do not output {contract}.arc32.json ARC-32 app spec file. Only applicable to ARC4 contracts').default(defaultPuyaOptions.outputArc32))
105
+ .addOption(new Option('--output-ssa-ir', 'Output IR (in SSA form) before optimisations').default(defaultPuyaOptions.outputSsaIr))
106
+ .addOption(new Option('--output-optimization-ir', 'Output IR after each optimization').default(defaultPuyaOptions.outputOptimizationIr))
107
+ .addOption(new Option('--output-destructured-ir', 'Output IR after SSA destructuring and before MIR').default(defaultPuyaOptions.outputDestructuredIr))
108
+ .addOption(new Option('--output-memory-ir', 'Output MIR before lowering to TealOps').default(defaultPuyaOptions.outputMemoryIr))
109
+ .addOption(new Option('--output-bytecode', 'Output AVM bytecode').default(defaultPuyaOptions.outputBytecode))
110
+ .addOption(new Option('--match-algod-bytecode', 'When outputting bytecode, ensure bytecode matches algod output').default(defaultPuyaOptions.matchAlgodBytecode))
111
+ .addOption(new Option('--debug-level [level]', 'Output debug information level, 0 = none, 1 = debug, 2 = reserved for future use')
112
+ .choices(['0', '1', '2'])
113
+ .default(defaultPuyaOptions.debugLevel))
114
+ .addOption(new Option('--optimization-level [level]', 'Set optimization level of output TEAL / AVM bytecode')
115
+ .choices(['0', '1', '2'])
116
+ .default(defaultPuyaOptions.optimizationLevel))
117
+ .addOption(new Option('--target-avm-version [version]', '').choices(['10']).default(10))
118
+ .addOption(new Option('--cli-template-definitions <...definitions>', 'Define template vars for use when assembling via --output-bytecode, should be specified without the prefix (see --template-vars-prefix)'))
119
+ .addOption(new Option('--template-vars-prefix [prefix]', 'Define the prefix to use with --template-var').default(defaultPuyaOptions.templateVarsPrefix))
120
+ .addOption(new Option('--locals-coalescing-strategy', '')
121
+ .default(defaultPuyaOptions.localsCoalescingStrategy)
122
+ .choices([
123
+ LocalsCoalescingStrategy.root_operand,
124
+ LocalsCoalescingStrategy.root_operand_excluding_args,
125
+ LocalsCoalescingStrategy.aggressive,
126
+ ]))
127
+ .action((a, o) => {
128
+ try {
129
+ const paths = cliArgumentsSchema.parse(a);
130
+ const cliOptions = cliOptionsSchema.parse(o);
131
+ logger.configure({
132
+ minLogLevel: cliOptions.logLevel,
133
+ });
134
+ const compileOptions = buildCompileOptions({
135
+ paths,
136
+ ...cliOptions,
137
+ });
138
+ const passThroughOptions = cliOptions;
139
+ const result = compile(compileOptions, passThroughOptions);
140
+ if (result.logs.some((l) => l.level === LogLevel.Error || l.level === LogLevel.Critical)) {
141
+ process.exit(-1);
142
+ }
143
+ }
144
+ catch (e) {
145
+ if (e instanceof Error) {
146
+ logger.error(e);
147
+ }
148
+ else {
149
+ throw e;
150
+ }
151
+ }
152
+ });
153
+ if (process.argv.length < 3) {
154
+ commander.help();
155
+ }
156
+ else {
157
+ commander.parse(process.argv);
158
+ }
159
+ }
160
+ cli();
161
+ //# sourceMappingURL=cli.mjs.map
package/cli.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","sources":["../src/compile-options.ts","../src/cli.ts"],"sourcesContent":["import { globSync } from 'glob'\nimport * as fs from 'node:fs'\nimport upath from 'upath'\nimport { PuyaError } from './errors'\nimport type { LogLevel } from './logger'\nimport { logger } from './logger'\nimport { normalisePath } from './util'\n\nexport interface AlgoFile {\n matchedInput: string\n sourceFile: string\n outDir: string\n}\n\nexport interface CompileOptions {\n filePaths: AlgoFile[]\n logLevel: LogLevel\n outputAwst: boolean\n outputAwstJson: boolean\n /*\n Don't generate artifacts for puya, or invoke puya\n */\n dryRun: boolean\n\n getFileFromSource(sourceFile: string): AlgoFile | undefined\n}\n\nexport const buildCompileOptions = ({\n paths,\n workingDirectory = process.cwd(),\n outDir,\n ...rest\n}: {\n paths: string[]\n outputAwst: boolean\n outDir: string\n outputAwstJson: boolean\n workingDirectory?: string\n dryRun: boolean\n logLevel: LogLevel\n}): CompileOptions => {\n const filePaths: AlgoFile[] = []\n\n for (const p of paths) {\n if (p.endsWith('.algo.ts')) {\n if (fs.existsSync(p)) {\n const actualPath = normalisePath(p, workingDirectory)\n filePaths.push({\n matchedInput: p,\n sourceFile: actualPath,\n outDir: upath.isAbsolute(outDir) ? upath.normalize(outDir) : upath.join(upath.dirname(actualPath), outDir),\n })\n } else {\n logger.warn(undefined, `File ${p} could not be found`)\n }\n } else if (p.endsWith('.ts')) {\n logger.warn(undefined, `Ignoring path ${p} as it does use the .algo.ts extension`)\n } else {\n const matches = globSync(upath.join(p, '**/*.algo.ts'))\n if (matches.length) {\n for (const match of matches) {\n filePaths.push({\n matchedInput: p,\n sourceFile: normalisePath(match, workingDirectory),\n outDir: upath.join(upath.isAbsolute(outDir) ? outDir : upath.join(p, outDir), upath.relative(p, upath.dirname(match))),\n })\n }\n } else {\n logger.warn(undefined, `Path '${p}' did not match any .algo.ts files`)\n }\n }\n }\n if (filePaths.length === 0) {\n throw new PuyaError('Input paths did not match any .algo.ts files')\n }\n\n return {\n filePaths,\n ...rest,\n getFileFromSource(sourceFile: string): AlgoFile | undefined {\n return filePaths.find((p) => p.sourceFile === sourceFile)\n },\n }\n}\n","import { Command, Option } from 'commander'\nimport { z } from 'zod'\nimport { buildCompileOptions } from './compile-options'\nimport { compile } from './index'\nimport { logger, LogLevel } from './logger'\nimport type { PuyaPassThroughOptions } from './puya/options'\nimport { defaultPuyaOptions, LocalsCoalescingStrategy } from './puya/options'\n\nconst cliOptionsSchema = z.object({\n outputAwst: z.boolean(),\n outputAwstJson: z.boolean(),\n outDir: z.string(),\n dryRun: z.boolean(),\n logLevel: z.nativeEnum(LogLevel),\n\n // Puya options\n outputTeal: z.boolean(),\n outputArc32: z.boolean(),\n outputSsaIr: z.boolean(),\n outputOptimizationIr: z.boolean(),\n outputDestructuredIr: z.boolean(),\n outputMemoryIr: z.boolean(),\n outputBytecode: z.boolean(),\n matchAlgodBytecode: z.boolean(),\n debugLevel: z.number().int(),\n optimizationLevel: z.number().int(),\n targetAvmVersion: z.number().int(),\n cliTemplateDefinitions: z.preprocess((x) => x ?? [], z.array(z.string())),\n templateVarsPrefix: z.string(),\n localsCoalescingStrategy: z.nativeEnum(LocalsCoalescingStrategy),\n})\n\nconst cliArgumentsSchema = z.array(z.string())\n\nfunction cli() {\n const commander = new Command().name('puya-ts').description('Algo-TS to Algorand smart contract compiler')\n\n commander.helpCommand(true)\n\n commander\n .command('build')\n .argument('<paths...>', 'The path, or paths to search for compatible .algo.ts files')\n .addOption(\n new Option('--log-level [level]', 'The minimum log level to output')\n .choices([LogLevel.Debug, LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Critical])\n .default(LogLevel.Info),\n )\n .addOption(new Option('--output-awst', 'Output debugging awst file per parsed file').default(false))\n .addOption(new Option('--output-awst-json', 'Output debugging awst json file per parsed file').default(false))\n .addOption(new Option('--out-dir [outDir]').default('out'))\n .addOption(new Option('--dry-run').default(false))\n\n .addOption(new Option('--no-output-teal', 'Do not output TEAL code').default(defaultPuyaOptions.outputTeal))\n .addOption(\n new Option(\n '--no-output-arc32',\n 'Do not output {contract}.arc32.json ARC-32 app spec file. Only applicable to ARC4 contracts',\n ).default(defaultPuyaOptions.outputArc32),\n )\n .addOption(new Option('--output-ssa-ir', 'Output IR (in SSA form) before optimisations').default(defaultPuyaOptions.outputSsaIr))\n .addOption(new Option('--output-optimization-ir', 'Output IR after each optimization').default(defaultPuyaOptions.outputOptimizationIr))\n .addOption(\n new Option('--output-destructured-ir', 'Output IR after SSA destructuring and before MIR').default(\n defaultPuyaOptions.outputDestructuredIr,\n ),\n )\n .addOption(new Option('--output-memory-ir', 'Output MIR before lowering to TealOps').default(defaultPuyaOptions.outputMemoryIr))\n .addOption(new Option('--output-bytecode', 'Output AVM bytecode').default(defaultPuyaOptions.outputBytecode))\n .addOption(\n new Option('--match-algod-bytecode', 'When outputting bytecode, ensure bytecode matches algod output').default(\n defaultPuyaOptions.matchAlgodBytecode,\n ),\n )\n .addOption(\n new Option('--debug-level [level]', 'Output debug information level, 0 = none, 1 = debug, 2 = reserved for future use')\n .choices(['0', '1', '2'])\n .default(defaultPuyaOptions.debugLevel),\n )\n .addOption(\n new Option('--optimization-level [level]', 'Set optimization level of output TEAL / AVM bytecode')\n .choices(['0', '1', '2'])\n .default(defaultPuyaOptions.optimizationLevel),\n )\n .addOption(new Option('--target-avm-version [version]', '').choices(['10']).default(10))\n .addOption(\n new Option(\n '--cli-template-definitions <...definitions>',\n 'Define template vars for use when assembling via --output-bytecode, should be specified without the prefix (see --template-vars-prefix)',\n ),\n )\n .addOption(\n new Option('--template-vars-prefix [prefix]', 'Define the prefix to use with --template-var').default(\n defaultPuyaOptions.templateVarsPrefix,\n ),\n )\n .addOption(\n new Option('--locals-coalescing-strategy', '')\n .default(defaultPuyaOptions.localsCoalescingStrategy)\n .choices([\n LocalsCoalescingStrategy.root_operand,\n LocalsCoalescingStrategy.root_operand_excluding_args,\n LocalsCoalescingStrategy.aggressive,\n ]),\n )\n\n .action((a, o) => {\n try {\n const paths = cliArgumentsSchema.parse(a)\n const cliOptions = cliOptionsSchema.parse(o)\n logger.configure({\n minLogLevel: cliOptions.logLevel,\n })\n\n const compileOptions = buildCompileOptions({\n paths,\n ...cliOptions,\n })\n const passThroughOptions: PuyaPassThroughOptions = cliOptions\n const result = compile(compileOptions, passThroughOptions)\n if (result.logs.some((l) => l.level === LogLevel.Error || l.level === LogLevel.Critical)) {\n process.exit(-1)\n }\n } catch (e) {\n if (e instanceof Error) {\n logger.error(e)\n } else {\n throw e\n }\n }\n })\n\n if (process.argv.length < 3) {\n commander.help()\n } else {\n commander.parse(process.argv)\n }\n}\ncli()\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA2BO,MAAM,mBAAmB,GAAG,CAAC,EAClC,KAAK,EACL,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,EAChC,MAAM,EACN,GAAG,IAAI,EASR,KAAoB;IACnB,MAAM,SAAS,GAAe,EAAE,CAAA;AAEhC,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AAC1B,YAAA,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;gBACpB,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAA;gBACrD,SAAS,CAAC,IAAI,CAAC;AACb,oBAAA,YAAY,EAAE,CAAC;AACf,oBAAA,UAAU,EAAE,UAAU;AACtB,oBAAA,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;AAC3G,iBAAA,CAAC,CAAA;aACH;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAQ,KAAA,EAAA,CA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AE;AACxF,gBAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;QAAC,OAAO,CAAC,EAAE;AACV,YAAA,IAAI,CAAC,YAAY,KAAK,EAAE;AACtB,gBAAA,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aAChB;iBAAM;AACL,gBAAA,MAAM,CAAC,CAAA;aACR;SACF;AACH,KAAC,CAAC,CAAA;IAEJ,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,SAAS,CAAC,IAAI,EAAE,CAAA;KACjB;SAAM;AACL,QAAA,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;KAC9B;AACH,CAAC;AACD,GAAG,EAAE"}
@@ -0,0 +1,23 @@
1
+ import type { LogLevel } from './logger';
2
+ export interface AlgoFile {
3
+ matchedInput: string;
4
+ sourceFile: string;
5
+ outDir: string;
6
+ }
7
+ export interface CompileOptions {
8
+ filePaths: AlgoFile[];
9
+ logLevel: LogLevel;
10
+ outputAwst: boolean;
11
+ outputAwstJson: boolean;
12
+ dryRun: boolean;
13
+ getFileFromSource(sourceFile: string): AlgoFile | undefined;
14
+ }
15
+ export declare const buildCompileOptions: ({ paths, workingDirectory, outDir, ...rest }: {
16
+ paths: string[];
17
+ outputAwst: boolean;
18
+ outDir: string;
19
+ outputAwstJson: boolean;
20
+ workingDirectory?: string;
21
+ dryRun: boolean;
22
+ logLevel: LogLevel;
23
+ }) => CompileOptions;
package/constants.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export declare const Constants: {
2
+ readonly approvalProgramMethodName: "approvalProgram";
3
+ readonly clearStateProgramMethodName: "clearStateProgram";
4
+ readonly algoTsPackage: "@algorandfoundation/algorand-typescript";
5
+ readonly arc4ModuleName: "@algorandfoundation/algorand-typescript/arc4/index.d.ts";
6
+ readonly opModuleName: "@algorandfoundation/algorand-typescript/op.d.ts";
7
+ readonly baseContractModuleName: "@algorandfoundation/algorand-typescript/base-contract.d.ts";
8
+ readonly utilModuleName: "@algorandfoundation/algorand-typescript/util.d.ts";
9
+ readonly referenceModuleName: "@algorandfoundation/algorand-typescript/reference.d.ts";
10
+ readonly stateModuleName: "@algorandfoundation/algorand-typescript/state.d.ts";
11
+ readonly boxModuleName: "@algorandfoundation/algorand-typescript/box.d.ts";
12
+ readonly transactionsModuleName: "@algorandfoundation/algorand-typescript/transactions.d.ts";
13
+ readonly gtxnModuleName: "@algorandfoundation/algorand-typescript/gtxn.d.ts";
14
+ readonly itxnModuleName: "@algorandfoundation/algorand-typescript/itxn.d.ts";
15
+ readonly primitivesModuleName: "@algorandfoundation/algorand-typescript/primitives.d.ts";
16
+ readonly arc4EncodedTypesModuleName: "@algorandfoundation/algorand-typescript/arc4/encoded-types.d.ts";
17
+ readonly arc4BareDecoratorName: "arc4.baremethod";
18
+ readonly arc4AbiDecoratorName: "arc4.abimethod";
19
+ readonly constructorMethodName: "constructor";
20
+ };
package/errors.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import type { SourceLocation } from './awst/source-location';
2
+ import type { PType, PTypeOrClass } from './awst_build/ptypes';
3
+ type PuyaErrorOptions = {
4
+ cause?: Error;
5
+ sourceLocation?: SourceLocation;
6
+ };
7
+ /**
8
+ * Thrown when the awst visitor cannot return a meaningful value
9
+ */
10
+ export declare class AwstBuildFailureError extends Error {
11
+ constructor();
12
+ }
13
+ export declare class PuyaError extends Error {
14
+ readonly sourceLocation: SourceLocation | undefined;
15
+ constructor(message?: string, options?: PuyaErrorOptions);
16
+ }
17
+ export declare class CodeError extends PuyaError {
18
+ static unexpectedUnhandledArgs({ sourceLocation }: {
19
+ sourceLocation: SourceLocation;
20
+ }): CodeError;
21
+ static unexpectedTypeArgs({ sourceLocation }: {
22
+ sourceLocation: SourceLocation;
23
+ }): CodeError;
24
+ static expectedCompileTimeConstant({ sourceLocation }: {
25
+ sourceLocation: SourceLocation;
26
+ }): CodeError;
27
+ static invalidAssignmentTarget({ sourceLocation, name }: {
28
+ sourceLocation: SourceLocation;
29
+ name: string;
30
+ }): CodeError;
31
+ static cannotResolveToType({ sourceType, targetType, sourceLocation, }: {
32
+ sourceLocation: SourceLocation;
33
+ sourceType: PType;
34
+ targetType: PTypeOrClass;
35
+ }): CodeError;
36
+ }
37
+ export declare class TodoError extends PuyaError {
38
+ }
39
+ export declare class InternalError extends PuyaError {
40
+ }
41
+ export declare class NotSupported extends CodeError {
42
+ constructor(featureName: string, options?: PuyaErrorOptions);
43
+ }
44
+ export declare const throwError: (error: Error) => never;
45
+ export declare const wrapInCodeError: <T>(func: () => T, sourceLocation: SourceLocation) => T;
46
+ export {};