@helios-lang/contract-utils 0.1.20 → 0.1.24

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 (104) hide show
  1. package/examples/multi-validator/README.md +13 -0
  2. package/examples/multi-validator/contract.js +28 -0
  3. package/examples/{spending → multi-validator}/index.d.ts +3 -3
  4. package/examples/multi-validator/index.js +27 -0
  5. package/examples/multi-validator/minting.hl +5 -0
  6. package/examples/{spending → multi-validator}/package-lock.json +6 -15
  7. package/examples/{spending → multi-validator}/package.json +0 -1
  8. package/examples/multi-validator/spending.hl +18 -0
  9. package/examples/multi-validator/utils.hl +9 -0
  10. package/package.json +7 -6
  11. package/src/{runtime → cast}/Cast.js +31 -8
  12. package/src/cast/index.js +12 -0
  13. package/src/codegen/LoadedModule.js +9 -0
  14. package/src/codegen/{TypescriptWriter.js → LoadedScriptsWriter.js} +149 -108
  15. package/src/codegen/LoadedValidator.js +23 -0
  16. package/src/codegen/{Module.js → TypeCheckedModule.js} +3 -3
  17. package/src/codegen/{Validator.js → TypeCheckedValidator.js} +5 -8
  18. package/src/codegen/TypeSchema.js +6 -2
  19. package/src/codegen/index.js +5 -4
  20. package/src/compiler/CompilerLib.js +51 -0
  21. package/src/{lib/Libg_v0_16.js → compiler/CompilerLib_v0_16.js} +244 -255
  22. package/src/compiler/index.js +6 -0
  23. package/src/compiler/ops.js +137 -0
  24. package/src/context/ContractContext.js +78 -0
  25. package/src/context/ContractContextBuilder.js +69 -0
  26. package/src/context/DagCompiler.js +229 -0
  27. package/src/context/index.js +1 -0
  28. package/src/hl2ts.js +116 -104
  29. package/src/index.js +12 -1
  30. package/types/cast/Cast.d.ts +32 -0
  31. package/types/cast/Cast.d.ts.map +1 -0
  32. package/types/cast/PermissiveType.d.ts +3 -0
  33. package/types/cast/PermissiveType.d.ts.map +1 -0
  34. package/types/cast/StrictType.d.ts +3 -0
  35. package/types/cast/StrictType.d.ts.map +1 -0
  36. package/types/cast/index.d.ts +5 -0
  37. package/types/cast/index.d.ts.map +1 -0
  38. package/types/codegen/LoadedModule.d.ts +6 -0
  39. package/types/codegen/LoadedModule.d.ts.map +1 -0
  40. package/types/codegen/LoadedScriptsWriter.d.ts +57 -0
  41. package/types/codegen/LoadedScriptsWriter.d.ts.map +1 -0
  42. package/types/codegen/LoadedValidator.d.ts +16 -0
  43. package/types/codegen/LoadedValidator.d.ts.map +1 -0
  44. package/types/codegen/TypeCheckedModule.d.ts +11 -0
  45. package/types/codegen/TypeCheckedModule.d.ts.map +1 -0
  46. package/types/codegen/TypeCheckedValidator.d.ts +8 -0
  47. package/types/codegen/TypeCheckedValidator.d.ts.map +1 -0
  48. package/types/codegen/TypeSchema.d.ts +10 -0
  49. package/types/codegen/TypeSchema.d.ts.map +1 -1
  50. package/types/codegen/TypescriptWriter.d.ts +4 -4
  51. package/types/codegen/Validator.d.ts +1 -1
  52. package/types/codegen/index.d.ts +5 -4
  53. package/types/codegen/index.d.ts.map +1 -1
  54. package/types/compiler/CompilerLib.d.ts +45 -0
  55. package/types/compiler/CompilerLib.d.ts.map +1 -0
  56. package/types/compiler/CompilerLib_v0_16.d.ts +271 -0
  57. package/types/compiler/CompilerLib_v0_16.d.ts.map +1 -0
  58. package/types/compiler/index.d.ts +4 -0
  59. package/types/compiler/index.d.ts.map +1 -0
  60. package/types/compiler/ops.d.ts +24 -0
  61. package/types/compiler/ops.d.ts.map +1 -0
  62. package/types/context/ContractContext.d.ts +23 -0
  63. package/types/context/ContractContext.d.ts.map +1 -0
  64. package/types/context/ContractContextBuilder.d.ts +53 -0
  65. package/types/context/ContractContextBuilder.d.ts.map +1 -0
  66. package/types/context/DagCompiler.d.ts +64 -0
  67. package/types/context/DagCompiler.d.ts.map +1 -0
  68. package/types/context/index.d.ts +2 -0
  69. package/types/context/index.d.ts.map +1 -0
  70. package/types/hl2ts.d.ts +9 -4
  71. package/types/hl2ts.d.ts.map +1 -1
  72. package/types/index.d.ts +4 -1
  73. package/types/index.d.ts.map +1 -1
  74. package/types/lib/Lib.d.ts +13 -71
  75. package/types/lib/Lib.d.ts.map +1 -1
  76. package/types/lib/Libg_v0_16.d.ts +53 -52
  77. package/types/lib/Libg_v0_16.d.ts.map +1 -1
  78. package/types/lib/index.d.ts +0 -1
  79. package/types/lib/index.d.ts.map +1 -1
  80. package/types/lib/load.d.ts +1 -7
  81. package/types/lib/load.d.ts.map +1 -1
  82. package/types/runtime/ContractContext.d.ts +22 -43
  83. package/types/runtime/ContractContext.d.ts.map +1 -1
  84. package/types/runtime/ContractContextBuilder.d.ts +15 -123
  85. package/types/runtime/ContractContextBuilder.d.ts.map +1 -1
  86. package/types/runtime/DagCompiler.d.ts +64 -0
  87. package/types/runtime/DagCompiler.d.ts.map +1 -0
  88. package/types/runtime/PermissiveType.d.ts +1 -1
  89. package/types/runtime/StrictType.d.ts +1 -1
  90. package/types/runtime/index.d.ts +0 -2
  91. package/examples/spending/contract.js +0 -16
  92. package/examples/spending/index.js +0 -27
  93. package/examples/spending/minting.hl +0 -5
  94. package/examples/spending/spending.hl +0 -17
  95. package/examples/spending/utils.hl +0 -5
  96. package/src/codegen/Writer.js +0 -37
  97. package/src/lib/Lib.js +0 -56
  98. package/src/lib/index.js +0 -6
  99. package/src/lib/load.js +0 -26
  100. package/src/runtime/ContractContext.js +0 -35
  101. package/src/runtime/ContractContextBuilder.js +0 -340
  102. package/src/runtime/index.js +0 -3
  103. /package/src/{runtime → cast}/PermissiveType.js +0 -0
  104. /package/src/{runtime → cast}/StrictType.js +0 -0
package/src/hl2ts.js CHANGED
@@ -1,60 +1,136 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { promises, readFileSync, writeFileSync } from "node:fs"
3
+ import {
4
+ existsSync,
5
+ fstat,
6
+ promises,
7
+ readFileSync,
8
+ writeFileSync
9
+ } from "node:fs"
4
10
  import { dirname, join, resolve } from "node:path"
5
- import { readHeader, translateImportPaths } from "@helios-lang/compiler-utils"
6
- import { TypescriptWriter } from "./codegen/index.js"
7
- import { loadLibrary } from "./lib/index.js"
11
+ import { Cli, Command, EnumOpt, StringOpt } from "@helios-lang/cli-utils"
12
+ import { LoadedScriptsWriter } from "./codegen/index.js"
13
+ import { loadCompilerLib } from "./compiler/index.js"
14
+ import { typeCheckFiles, typeCheckScripts } from "./compiler/ops.js"
15
+ import { None } from "@helios-lang/type-utils"
8
16
 
9
17
  /**
10
- * @typedef {import("./lib/Lib.js").Lib} Lib
11
- * @typedef {import("./lib/Lib.js").SourceDetails} SourceDetails
12
- * @typedef {import("./lib/Lib.js").ModuleDetails} ModuleDetails
13
- * @typedef {import("./lib/Lib.js").ValidatorDetails} ValidatorDetails
18
+ * @typedef {import("./compiler/CompilerLib.js").CompilerLib} CompilerLib
19
+ * @typedef {import("./compiler/CompilerLib.js").TypeCheckedModule} ModuleDetails
20
+ * @typedef {import("./compiler/CompilerLib.js").TypeCheckedValidator} ValidatorDetails
21
+ */
22
+
23
+ /**
24
+ * @typedef {{
25
+ * name: string
26
+ * purpose: string
27
+ * sourceCode: string
28
+ * }} SourceDetails
29
+ */
30
+
31
+ /**
32
+ * @typedef {"javascript" | "typescript"} FormatKind
14
33
  */
15
34
 
16
35
  async function main() {
17
- console.log("hl2ts")
36
+ const cli = new Cli({
37
+ minArgs: 0,
38
+ maxArgs: 0,
39
+ options: {
40
+ outDir: new StringOpt({
41
+ long: "--out-dir",
42
+ short: "-o",
43
+ default: () => process.cwd()
44
+ }),
45
+ format: new EnumOpt({
46
+ long: "--format",
47
+ short: "-f",
48
+ variants: /** @type {FormatKind[]} */ ([
49
+ "javascript",
50
+ "typescript"
51
+ ]),
52
+ default: () => {
53
+ const path = findPackageJson()
54
+
55
+ if (
56
+ path &&
57
+ existsSync(join(dirname(path), "tsconfig.json"))
58
+ ) {
59
+ return "typescript"
60
+ } else {
61
+ return "javascript"
62
+ }
63
+ }
64
+ })
65
+ },
66
+ action: mainInternal
67
+ })
68
+
69
+ await cli.run()
70
+ }
18
71
 
19
- const { outDir } = parseArgs(process.argv)
72
+ /**
73
+ * @param {string[]} _args
74
+ * @param {{outDir: string, format: FormatKind}} options
75
+ * @returns {Promise<void>}
76
+ */
77
+ async function mainInternal(_args, { outDir, format }) {
78
+ const lib = loadCompilerLib()
20
79
 
21
- const lib = await loadLibrary()
22
80
  const filePaths = await listFiles(process.cwd(), ".hl")
23
81
  const files = readFiles(filePaths)
24
- const sources = preparseFiles(files)
25
- const { modules, validators } = typeCheck(lib, sources)
26
82
 
27
- const w = new TypescriptWriter()
83
+ console.log(`hl2ts using Helios compiler v${lib.version}`)
84
+ console.log(` Transpiling ${Object.keys(files).length} inputs:`)
85
+ filePaths.forEach((p) => console.log(` ${p}`))
28
86
 
29
- w.writeHeaders()
30
- w.writeModules(modules)
31
- w.writeValidators(validators)
87
+ const { modules, validators } = typeCheckFiles(lib, files, (current, rel) =>
88
+ resolve(join(dirname(current), rel))
89
+ )
90
+
91
+ const [js, dts, ts] = LoadedScriptsWriter.new()
92
+ .writeModules(modules)
93
+ .writeValidators(validators)
94
+ .finalize()
95
+
96
+ if (format == "typescript") {
97
+ const tsPath = join(outDir, "index.ts")
32
98
 
33
- const [js, dts] = w.finalize()
99
+ writeFileSync(tsPath, ts)
100
+
101
+ console.log(` Output:`)
102
+ console.log(` ${tsPath}`)
103
+ } else {
104
+ const jsPath = join(outDir, "index.js")
105
+ const dtsPath = join(outDir, "index.d.ts")
34
106
 
35
- const jsPath = join(outDir, "index.js")
36
- const dtsPath = join(outDir, "index.d.ts")
107
+ writeFileSync(jsPath, js)
108
+ writeFileSync(dtsPath, dts)
37
109
 
38
- writeFileSync(jsPath, js)
39
- writeFileSync(dtsPath, dts)
110
+ console.log(` Output:`)
111
+ console.log(` ${jsPath}`)
112
+ console.log(` ${dtsPath}`)
113
+ }
40
114
  }
41
115
 
42
116
  main()
43
117
 
44
118
  /**
45
119
  * @param {string[]} args
46
- * @returns {{outDir: string}}
120
+ * @returns {{outDir: string, isTypescript: boolean}}
47
121
  */
48
122
  function parseArgs(args) {
123
+ const isTypescript = args.indexOf("--ts") != -1
124
+
49
125
  let i = args.indexOf("-o")
50
126
  if (i != -1) {
51
- if (i == args.length - 1) {
127
+ if (i == args.length - 1 || args[i + 1].startsWith("-")) {
52
128
  throw new Error("expected argument after -o")
53
129
  }
54
130
 
55
- return { outDir: resolve(args[i + 1]) }
131
+ return { outDir: resolve(args[i + 1]), isTypescript }
56
132
  } else {
57
- return { outDir: process.cwd() }
133
+ return { outDir: process.cwd(), isTypescript }
58
134
  }
59
135
  }
60
136
 
@@ -98,88 +174,24 @@ function readFiles(filePaths) {
98
174
  }
99
175
 
100
176
  /**
101
- *
102
- * @param {{[path: string]: string}} files
103
- * @returns {{[name: string]: SourceDetails}}
177
+ * @param {string} fileName
178
+ * @returns {Option<string>}
104
179
  */
105
- function preparseFiles(files) {
106
- const partialSources = {}
180
+ function findPackageJson(fileName = "package.json") {
181
+ let dir = process.cwd()
107
182
 
108
- for (let path in files) {
109
- const [purpose, name] = readHeader(files[path])
183
+ let path = join(dir, fileName)
184
+ let found = existsSync(path)
110
185
 
111
- partialSources[path] = {
112
- name: name,
113
- purpose: purpose,
114
- sourceCode: files[path]
115
- }
186
+ while (!found) {
187
+ dir = dirname(dir)
188
+ path = join(dir, fileName)
189
+ found = existsSync(path)
116
190
  }
117
191
 
118
- /**
119
- * @type {{[name: string]: SourceDetails}}
120
- */
121
- const sources = {}
122
-
123
- for (let path in files) {
124
- const sourceCode = translateImportPaths(files[path], (relPath) => {
125
- const absPath = resolve(join(dirname(path), relPath))
126
-
127
- const d = partialSources[absPath] ?? partialSources[absPath + ".hl"]
128
-
129
- if (!d) {
130
- throw new Error(`'${relPath}' not found`)
131
- }
132
-
133
- return d.name
134
- })
135
-
136
- sources[partialSources[path].name] = {
137
- ...partialSources[path],
138
- sourceCode: sourceCode
139
- }
140
- }
141
-
142
- return sources
143
- }
144
-
145
- /**
146
- * @param {{[name: string]: SourceDetails}} sources
147
- * @returns {[{[name: string]: SourceDetails}, {[name: string]: SourceDetails}]}
148
- */
149
- function splitValidatorsAndModules(sources) {
150
- /**
151
- * @type {{[name: string]: SourceDetails}}
152
- */
153
- const validators = {}
154
-
155
- /**
156
- * @type {{[name: string]: SourceDetails}}
157
- */
158
- const modules = {}
159
-
160
- for (let key in sources) {
161
- const v = sources[key]
162
- if (v.purpose == "module") {
163
- modules[key] = v
164
- } else if (
165
- v.purpose == "spending" ||
166
- v.purpose == "minting" ||
167
- v.purpose == "staking"
168
- ) {
169
- validators[key] = v
170
- }
192
+ if (found) {
193
+ return path
194
+ } else {
195
+ return None
171
196
  }
172
-
173
- return [validators, modules]
174
- }
175
-
176
- /**
177
- * @param {Lib} lib
178
- * @param {{[name: string]: SourceDetails}} sources
179
- * @returns {{modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}}
180
- */
181
- function typeCheck(lib, sources) {
182
- const [validators, modules] = splitValidatorsAndModules(sources)
183
-
184
- return lib.typeCheck(validators, modules)
185
197
  }
package/src/index.js CHANGED
@@ -1 +1,12 @@
1
- export { Cast, ContractContextBuilder } from "./runtime/index.js"
1
+ export { Cast } from "./cast/index.js"
2
+ export { ContractContextBuilder } from "./context/index.js"
3
+
4
+ /**
5
+ * @template {import("./cast/index.js").Cast} C
6
+ * @typedef {import("./cast/index.js").StrictType<C>} StrictType
7
+ */
8
+
9
+ /**
10
+ * @template {import("./cast/index.js").Cast} C
11
+ * @typedef {import("./cast/index.js").PermissiveType<C>} PermissiveType
12
+ */
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @typedef {import("@helios-lang/uplc").UplcData} UplcData
3
+ * @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
4
+ */
5
+ /**
6
+ * @template [TStrict=any]
7
+ * @template [TPermissive=any]
8
+ */
9
+ export class Cast<TStrict = any, TPermissive = any> {
10
+ /**
11
+ * @param {TypeSchema} schema
12
+ */
13
+ constructor(schema: TypeSchema);
14
+ /**
15
+ * @readonly
16
+ * @type {TypeSchema}
17
+ */
18
+ readonly schema: TypeSchema;
19
+ /**
20
+ * @param {UplcData} data
21
+ * @returns {TStrict}
22
+ */
23
+ fromUplcData(data: UplcData): TStrict;
24
+ /**
25
+ * @param {TPermissive} x
26
+ * @returns {UplcData}
27
+ */
28
+ toUplcData(x: TPermissive): UplcData;
29
+ }
30
+ export type UplcData = import("@helios-lang/uplc").UplcData;
31
+ export type TypeSchema = import("../codegen/index.js").TypeSchema;
32
+ //# sourceMappingURL=Cast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/cast/Cast.js"],"names":[],"mappings":"AAiCA;;;GAGG;AAEH;;;GAGG;AACH;IAOI;;OAEG;IACH,oBAFW,UAAU,EAIpB;IAXD;;;OAGG;IACH,iBAFU,UAAU,CAEd;IASN;;;OAGG;IACH,mBAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;OAGG;IACH,cAHW,WAAW,GACT,QAAQ,CAIpB;CACJ;uBArCY,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,qBAAqB,EAAE,UAAU"}
@@ -0,0 +1,3 @@
1
+ export type PermissiveType<C extends Cast<any, any>> = C extends Cast<any, infer TPermissive> ? TPermissive : never;
2
+ import { Cast } from "./Cast.js";
3
+ //# sourceMappingURL=PermissiveType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissiveType.d.ts","sourceRoot":"","sources":["../../src/cast/PermissiveType.js"],"names":[],"mappings":";qBAAqB,WAAW"}
@@ -0,0 +1,3 @@
1
+ export type StrictType<C extends Cast<any, any>> = C extends Cast<infer TStrict, any> ? TStrict : never;
2
+ import { Cast } from "./Cast.js";
3
+ //# sourceMappingURL=StrictType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StrictType.d.ts","sourceRoot":"","sources":["../../src/cast/StrictType.js"],"names":[],"mappings":";qBAAqB,WAAW"}
@@ -0,0 +1,5 @@
1
+ export { Cast };
2
+ export type PermissiveType<C extends Cast<any, any>> = import("./PermissiveType.js").PermissiveType<C>;
3
+ export type StrictType<C extends Cast<any, any>> = import("./StrictType.js").StrictType<C>;
4
+ import { Cast } from "./Cast.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cast/index.js"],"names":[],"mappings":";uDAKa,OAAO,qBAAqB,EAAE,cAAc,CAAC,CAAC,CAAC;mDAK/C,OAAO,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;qBAV/B,WAAW"}
@@ -0,0 +1,6 @@
1
+ export type LoadedModule = {
2
+ $name: string;
3
+ $sourceCode: string;
4
+ $dependencies: LoadedModule[];
5
+ };
6
+ //# sourceMappingURL=LoadedModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedModule.js"],"names":[],"mappings":"2BAGa;IACZ,KAAS,EAAE,MAAM,CAAA;IACjB,WAAe,EAAE,MAAM,CAAA;IACvB,aAAiB,EAAE,YAAY,EAAE,CAAA;CAC9B"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @typedef {import("./TypeCheckedModule.js").TypeCheckedModule} TypeCheckedModule
3
+ * @typedef {import("./TypeCheckedValidator.js").TypeCheckedValidator} TypeCheckedValidator
4
+ */
5
+ export class LoadedScriptsWriter {
6
+ /**
7
+ * Constructs a LoadedScriptsWriter instance and initializes it be writing the header
8
+ * @returns {LoadedScriptsWriter}
9
+ */
10
+ static "new"(): LoadedScriptsWriter;
11
+ definition: StringWriter;
12
+ declaration: StringWriter;
13
+ combined: StringWriter;
14
+ /**
15
+ * @param {{[name: string]: TypeCheckedModule}} ms
16
+ * @returns {LoadedScriptsWriter}
17
+ */
18
+ writeModules(ms: {
19
+ [name: string]: import("./TypeCheckedModule.js").TypeCheckedModule;
20
+ }): LoadedScriptsWriter;
21
+ /**
22
+ * @param {{[name: string]: TypeCheckedValidator}} validators
23
+ * @returns {LoadedScriptsWriter}
24
+ */
25
+ writeValidators(validators: {
26
+ [name: string]: import("./TypeCheckedValidator.js").TypeCheckedValidator;
27
+ }): LoadedScriptsWriter;
28
+ /**
29
+ * @returns {[string, string, string]}
30
+ */
31
+ finalize(): [string, string, string];
32
+ /**
33
+ * @private
34
+ * @param {string} def
35
+ * @param {string} decl
36
+ * @returns {LoadedScriptsWriter}
37
+ */
38
+ private write;
39
+ /**
40
+ * @private
41
+ */
42
+ private writeHeaders;
43
+ /**
44
+ * @private
45
+ * @param {TypeCheckedModule} m
46
+ */
47
+ private writeModule;
48
+ /**
49
+ * @private
50
+ * @param {TypeCheckedValidator} v
51
+ */
52
+ private writeValidator;
53
+ }
54
+ export type TypeCheckedModule = import("./TypeCheckedModule.js").TypeCheckedModule;
55
+ export type TypeCheckedValidator = import("./TypeCheckedValidator.js").TypeCheckedValidator;
56
+ import { StringWriter } from "@helios-lang/codec-utils";
57
+ //# sourceMappingURL=LoadedScriptsWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAkC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;OAEG;IACH,qBAWC;IAED;;;OAGG;IACH,oBA8BC;IAED;;;OAGG;IACH,uBA+CC;CACJ;gCApOY,OAAO,wBAAwB,EAAE,iBAAiB;mCAClD,OAAO,2BAA2B,EAAE,oBAAoB;6BALxC,0BAA0B"}
@@ -0,0 +1,16 @@
1
+ export type LoadedModule = import("./LoadedModule.js").LoadedModule;
2
+ export type LoadedValidator = {
3
+ $name: string;
4
+ $sourceCode: string;
5
+ $dependencies: LoadedModule[];
6
+ $hashDependencies: LoadedValidator[];
7
+ $dependsOnOwnHash: boolean;
8
+ $Redeemer: Cast;
9
+ } & ({
10
+ $purpose: "spending";
11
+ $Datum: Cast;
12
+ } | {
13
+ $purpose: "minting" | "certifying" | "rewarding" | "staking";
14
+ });
15
+ import { Cast } from "../cast/Cast.js";
16
+ //# sourceMappingURL=LoadedValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedValidator.js"],"names":[],"mappings":"2BAGa,OAAO,mBAAmB,EAAE,YAAY;8BAIxC;IACZ,KAAS,EAAE,MAAM,CAAA;IACjB,WAAe,EAAE,MAAM,CAAA;IACvB,aAAiB,EAAE,YAAY,EAAE,CAAA;IACjC,iBAAqB,EAAE,eAAe,EAAE,CAAA;IACxC,iBAAqB,EAAE,OAAO,CAAA;IAC9B,SAAa,EAAE,IAAI,CAAA;CAChB,GAAG,CACN;IACA,QAAc,EAAE,UAAU,CAAA;IAC1B,MAAY,EAAE,IAAI,CAAA;CACb,GAAG;IACR,QAAc,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,CAAA;CAC7D,CACF;qBArBiB,iBAAiB"}
@@ -0,0 +1,11 @@
1
+ export type TypeSchema = import("./TypeSchema.js").TypeSchema;
2
+ export type TypeCheckedModule = {
3
+ name: string;
4
+ purpose: string;
5
+ sourceCode: string;
6
+ moduleDepedencies: string[];
7
+ types: {
8
+ [name: string]: import("./TypeSchema.js").TypeSchema;
9
+ };
10
+ };
11
+ //# sourceMappingURL=TypeCheckedModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeCheckedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedModule.js"],"names":[],"mappings":"yBAGa,OAAO,iBAAiB,EAAE,UAAU;;UAKtC,MAAM;aACH,MAAM;gBACH,MAAM;uBACC,MAAM,EAAE"}
@@ -0,0 +1,8 @@
1
+ export type TypeCheckedModule = import("./TypeCheckedModule.js").TypeCheckedModule;
2
+ export type TypeSchema = import("./TypeSchema.js").TypeSchema;
3
+ export type TypeCheckedValidator = TypeCheckedModule & {
4
+ hashDependencies: string[];
5
+ Redeemer: TypeSchema;
6
+ Datum?: TypeSchema;
7
+ };
8
+ //# sourceMappingURL=TypeCheckedValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeCheckedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedValidator.js"],"names":[],"mappings":"gCAGa,OAAO,wBAAwB,EAAE,iBAAiB;yBAClD,OAAO,iBAAiB,EAAE,UAAU;mCAIpC,iBAAiB,GAAG;IAChC,gBAAoB,EAAE,MAAM,EAAE,CAAA;IAC9B,QAAY,EAAE,UAAU,CAAA;IACxB,KAAS,CAAC,EAAE,UAAU,CAAA;CACnB"}
@@ -1,4 +1,8 @@
1
1
  /**
2
+ * TODO: references and ids for recursive types and more descriptive codegen
3
+ * TODO: use `kind: "internal" | "list" | "map" | "struct" | "option" | "enum"` instead of `primitiveType` etc.
4
+ * TODO: additional property for struct: `format: "list" | "map"`
5
+ * TODO: rename primitiveType -> internalType
2
6
  * @typedef {{
3
7
  * primitiveType: string
4
8
  * } | {
@@ -28,6 +32,12 @@
28
32
  * @returns {[string, string]} - the first entry is the canonical type, the second is the permissive type
29
33
  */
30
34
  export function genTypes(schema: TypeSchema): [string, string];
35
+ /**
36
+ * TODO: references and ids for recursive types and more descriptive codegen
37
+ * TODO: use `kind: "internal" | "list" | "map" | "struct" | "option" | "enum"` instead of `primitiveType` etc.
38
+ * TODO: additional property for struct: `format: "list" | "map"`
39
+ * TODO: rename primitiveType -> internalType
40
+ */
31
41
  export type TypeSchema = {
32
42
  primitiveType: string;
33
43
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"TypeSchema.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeSchema.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,iCAHW,UAAU,GACR,CAAC,MAAM,EAAE,MAAM,CAAC,CA0H5B;yBArJY;IACZ,aAAmB,EAAE,MAAM,CAAA;CACxB,GAAG;IACN,YAAkB,EAAE,UAAU,CAAA;CAC3B,GAAG;IACN,UAAgB,EAAE,UAAU,CAAA;IAC5B,YAAkB,EAAE,UAAU,CAAA;CAC3B,GAAG;IACN,cAAoB,EAAE,UAAU,CAAA;CAC7B,GAAG;IACN,gBAAsB,EAAE;QACxB,MAAgB,MAAM,CAAA;QACtB,IAAc,EAAE,UAAU,CAAA;KACnB,EAAE,CAAA;CACN,GAAG;IACN,gBAAsB,EAAE;QACxB,MAAiB,MAAM,CAAC;QACxB,UAAqB,EAAE;YACvB,MAAqB,MAAM,CAAA;YAC3B,IAAmB,EAAE,UAAU,CAAA;SACnB,EAAE,CAAA;KACP,EAAE,CAAA;CACN"}
1
+ {"version":3,"file":"TypeSchema.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeSchema.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;GAGG;AACH,iCAHW,UAAU,GACR,CAAC,MAAM,EAAE,MAAM,CAAC,CA0H5B;;;;;;;yBArJY;IACZ,aAAmB,EAAE,MAAM,CAAA;CACxB,GAAG;IACN,YAAkB,EAAE,UAAU,CAAA;CAC3B,GAAG;IACN,UAAgB,EAAE,UAAU,CAAA;IAC5B,YAAkB,EAAE,UAAU,CAAA;CAC3B,GAAG;IACN,cAAoB,EAAE,UAAU,CAAA;CAC7B,GAAG;IACN,gBAAsB,EAAE;QACxB,MAAgB,MAAM,CAAA;QACtB,IAAc,EAAE,UAAU,CAAA;KACnB,EAAE,CAAA;CACN,GAAG;IACN,gBAAsB,EAAE;QACxB,MAAiB,MAAM,CAAC;QACxB,UAAqB,EAAE;YACvB,MAAqB,MAAM,CAAA;YAC3B,IAAmB,EAAE,UAAU,CAAA;SACnB,EAAE,CAAA;KACP,EAAE,CAAA;CACN"}
@@ -30,21 +30,21 @@ export class TypescriptWriter {
30
30
  * @param {{[name: string]: Module}} ms
31
31
  */
32
32
  writeModules(ms: {
33
- [name: string]: import("./Module.js").Module;
33
+ [name: string]: import("./TypeCheckedModule.js").Module;
34
34
  }): void;
35
35
  /**
36
36
  *
37
37
  * @param {{[name: string]: Validator}} validators
38
38
  */
39
39
  writeValidators(validators: {
40
- [name: string]: import("./Validator.js").Validator;
40
+ [name: string]: import("./TypeCheckedValidator.js").Validator;
41
41
  }): void;
42
42
  /**
43
43
  * @returns {[string, string]}
44
44
  */
45
45
  finalize(): [string, string];
46
46
  }
47
- export type Module = import("./Module.js").Module;
48
- export type Validator = import("./Validator.js").Validator;
47
+ export type Module = import("./TypeCheckedModule.js").Module;
48
+ export type Validator = import("./TypeCheckedValidator.js").Validator;
49
49
  import { Writer } from "./Writer.js";
50
50
  //# sourceMappingURL=TypescriptWriter.d.ts.map
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export const _: {};
15
15
  export type TypeSchema = import("./TypeSchema.js").TypeSchema;
16
- export type Module = import("./Module.js").Module;
16
+ export type Module = import("./TypeCheckedModule.js").Module;
17
17
  export type Validator = Module & {
18
18
  hashDependencies: string[];
19
19
  Redeemer: TypeSchema;
@@ -1,6 +1,7 @@
1
- export { TypescriptWriter } from "./TypescriptWriter.js";
2
- export { Writer } from "./Writer.js";
3
- export type Module = import("./Module.js").Module;
1
+ export { LoadedScriptsWriter } from "./LoadedScriptsWriter.js";
2
+ export type LoadedModule = import("./LoadedModule.js").LoadedModule;
3
+ export type LoadedValidator = import("./LoadedValidator.js").LoadedValidator;
4
+ export type TypeCheckedModule = import("./TypeCheckedModule.js").TypeCheckedModule;
5
+ export type TypeCheckedValidator = import("./TypeCheckedValidator.js").TypeCheckedValidator;
4
6
  export type TypeSchema = import("./TypeSchema.js").TypeSchema;
5
- export type Validator = import("./Validator.js").Validator;
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.js"],"names":[],"mappings":";;qBAIa,OAAO,aAAa,EAAE,MAAM;yBAC5B,OAAO,iBAAiB,EAAE,UAAU;wBACpC,OAAO,gBAAgB,EAAE,SAAS"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.js"],"names":[],"mappings":";2BAGa,OAAO,mBAAmB,EAAE,YAAY;8BACxC,OAAO,sBAAsB,EAAE,eAAe;gCAC9C,OAAO,wBAAwB,EAAE,iBAAiB;mCAClD,OAAO,2BAA2B,EAAE,oBAAoB;yBACxD,OAAO,iBAAiB,EAAE,UAAU"}
@@ -0,0 +1,45 @@
1
+ export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
2
+ export type TypeCheckedModule = import("../codegen/index.js").TypeCheckedModule;
3
+ export type TypeCheckedValidator = import("../codegen/index.js").TypeCheckedValidator;
4
+ export type CompileOptions = {
5
+ allValidatorHashTypes: {
6
+ [name: string]: any;
7
+ };
8
+ hashDependencies: {
9
+ [name: string]: string;
10
+ };
11
+ dependsOnOwnHash?: boolean | undefined;
12
+ ownHash?: string | undefined;
13
+ optimize: boolean;
14
+ };
15
+ export type CompileOutput = {
16
+ cborHex: string;
17
+ prettyIR: string;
18
+ };
19
+ export type TypeCheckOutput = {
20
+ modules: {
21
+ [name: string]: import("../codegen/TypeCheckedModule.js").TypeCheckedModule;
22
+ };
23
+ validators: {
24
+ [name: string]: import("../codegen/TypeCheckedValidator.js").TypeCheckedValidator;
25
+ };
26
+ };
27
+ export type SourceDetails = {
28
+ name: string;
29
+ purpose: string;
30
+ sourceCode: string;
31
+ };
32
+ export type CompilerLib = {
33
+ version: string;
34
+ getScriptHashType: (purpose: string) => any;
35
+ typeCheck: (validators: string[], modules: string[]) => {
36
+ modules: {
37
+ [name: string]: import("../codegen/TypeCheckedModule.js").TypeCheckedModule;
38
+ };
39
+ validators: {
40
+ [name: string]: import("../codegen/TypeCheckedValidator.js").TypeCheckedValidator;
41
+ };
42
+ };
43
+ compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput;
44
+ };
45
+ //# sourceMappingURL=CompilerLib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"kCAGa,OAAO,qBAAqB,EAAE,UAAU;gCACxC,OAAO,qBAAqB,EAAE,iBAAiB;mCAC/C,OAAO,qBAAqB,EAAE,oBAAoB;;;;;;;;;;cAShD,OAAO;;4BAKT;IACZ,OAAW,EAAE,MAAM,CAAA;IACnB,QAAY,EAAE,MAAM,CAAA;CACjB;;;;;;;;;4BAWS;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB;;aAKU,MAAM;iCACc,MAAM,KAAK,GAAG;4BACnB,MAAM,EAAE,WAAW,MAAM,EAAE;;;;;;;;oBAInC,MAAM,WAAW,MAAM,EAAE,WAAW,cAAc,KAAK,aAAa"}