@helios-lang/contract-utils 0.1.2 → 0.1.7
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/examples/spending/index.d.ts +19 -0
- package/examples/spending/index.js +17 -0
- package/package.json +9 -7
- package/src/codegen/TypeSchema.js +3 -1
- package/src/codegen/TypescriptWriter.js +8 -0
- package/src/codegen/index.js +0 -6
- package/src/hl2ts.js +29 -14
- package/src/index.js +1 -0
- package/src/lib/Libg_v0_16.js +11 -3
- package/src/runtime/Cast.js +4 -0
- package/src/runtime/index.js +1 -0
- package/types/codegen/Module.d.ts +24 -0
- package/types/codegen/Module.d.ts.map +1 -0
- package/types/codegen/TypeSchema.d.ts +54 -0
- package/types/codegen/TypeSchema.d.ts.map +1 -0
- package/types/codegen/TypescriptWriter.d.ts +50 -0
- package/types/codegen/TypescriptWriter.d.ts.map +1 -0
- package/types/codegen/Validator.d.ts +22 -0
- package/types/codegen/Validator.d.ts.map +1 -0
- package/types/codegen/Writer.d.ts +23 -0
- package/types/codegen/Writer.d.ts.map +1 -0
- package/types/codegen/index.d.ts +6 -0
- package/types/codegen/index.d.ts.map +1 -0
- package/types/hl2ts.d.ts +6 -0
- package/types/hl2ts.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/lib/Lib.d.ts +50 -0
- package/types/lib/Lib.d.ts.map +1 -0
- package/types/lib/Libg_v0_16.d.ts +233 -0
- package/types/lib/Libg_v0_16.d.ts.map +1 -0
- package/types/lib/index.d.ts +2 -0
- package/types/lib/index.d.ts.map +1 -0
- package/types/lib/load.d.ts +6 -0
- package/types/lib/load.d.ts.map +1 -0
- package/types/runtime/Cast.d.ts +32 -0
- package/types/runtime/Cast.d.ts.map +1 -0
- package/types/runtime/index.d.ts +2 -0
- package/types/runtime/index.d.ts.map +1 -0
- package/examples/spending/app.js +0 -13
- package/examples/spending/output.d.ts +0 -18
- package/examples/spending/output2.d.ts +0 -24
- package/examples/spending/output2.js +0 -34
- package/examples/spending/specialized.js +0 -6
- package/examples/spending/unspecialized.js +0 -18
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type {UplcData} from "@helios-lang/ledger";
|
|
2
|
+
import { Address, AssetClass, Credential, DatumHash, MintingPolicyHash, PubKeyHash, StakingCredential, StakingHash, StakingValidatorHash, TimeRange, TxId, TxOutputDatum, ValidatorHash, Value} from "@helios-lang/ledger";
|
|
3
|
+
import { Cast } from "@helios-lang/contract-utils";
|
|
4
|
+
export const utils: {
|
|
5
|
+
$name: string
|
|
6
|
+
$purpose: string
|
|
7
|
+
$sourceCode: string
|
|
8
|
+
$dependencies: []
|
|
9
|
+
}
|
|
10
|
+
export const match_string: {
|
|
11
|
+
$name: string
|
|
12
|
+
$purpose: string
|
|
13
|
+
$sourceCode: string
|
|
14
|
+
$dependencies: [typeof utils]
|
|
15
|
+
$hashDependencies: []
|
|
16
|
+
$dependsOnOwnHash: boolean
|
|
17
|
+
$Redeemer: Cast<string, string>
|
|
18
|
+
$Datum: Cast<{One: {message: string}} | {Two: {code: bigint}}, {One: {message: string}} | {Two: {code: bigint | number | string}}>
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cast } from "@helios-lang/contract-utils";
|
|
2
|
+
export const utils = {
|
|
3
|
+
$name: "utils",
|
|
4
|
+
$purpose: "module",
|
|
5
|
+
$sourceCode: "module utils\n\nfunc compare(a: String, b: String) -> Bool {\n a == b\n}",
|
|
6
|
+
$dependencies: [],
|
|
7
|
+
}
|
|
8
|
+
export const match_string = {
|
|
9
|
+
$name: "match_string",
|
|
10
|
+
$purpose: "spending",
|
|
11
|
+
$sourceCode: "spending match_string\n\nimport { compare } from utils\n\nenum Datum {\n One {\n message: String\n }\n\n Two {\n code: Int\n }\n}\n\nfunc main(datum: Datum, redeemer: String, _) -> Bool {\n compare(datum.switch{d: One => d.message, d: Two => d.code.show()}, redeemer)\n}",
|
|
12
|
+
$dependencies: [utils],
|
|
13
|
+
$hashDependencies: [],
|
|
14
|
+
$dependsOnOwnHash: false,
|
|
15
|
+
$Redeemer: new Cast({"primitiveType":"String"}),
|
|
16
|
+
$Datum: new Cast({"enumVariantTypes":[{"name":"One","fieldTypes":[{"name":"message","type":{"primitiveType":"String"}}]},{"name":"Two","fieldTypes":[{"name":"code","type":{"primitiveType":"Int"}}]}]})
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"bin": {
|
|
8
9
|
"hl2ts": "src/hl2ts.js"
|
|
9
10
|
},
|
|
10
11
|
"scripts": {
|
|
11
|
-
"build": "
|
|
12
|
+
"build": "npm run build:types",
|
|
13
|
+
"build:types": "npx tsc -p jsconfig.json --noEmit false --emitDeclarationOnly",
|
|
12
14
|
"clean": "find src/ -name *.d.ts* | xargs rm",
|
|
13
15
|
"prettify": "npx prettier . --write",
|
|
14
16
|
"test": "npm run test:pretty && npm run test:types && npm run test:suite",
|
|
@@ -30,10 +32,10 @@
|
|
|
30
32
|
"singleQuote": false
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@helios-lang/codec-utils": "^0.1.
|
|
34
|
-
"@helios-lang/compiler-utils": "^0.1.
|
|
35
|
-
"@helios-lang/ledger": "^0.1.
|
|
36
|
-
"@helios-lang/type-utils": "^0.1.
|
|
37
|
-
"@helios-lang/uplc": "^0.1.
|
|
35
|
+
"@helios-lang/codec-utils": "^0.1.26",
|
|
36
|
+
"@helios-lang/compiler-utils": "^0.1.20",
|
|
37
|
+
"@helios-lang/ledger": "^0.1.10",
|
|
38
|
+
"@helios-lang/type-utils": "^0.1.8",
|
|
39
|
+
"@helios-lang/uplc": "^0.1.21"
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -46,6 +46,8 @@ export function genTypes(schema) {
|
|
|
46
46
|
return ["number[]", "number[]"]
|
|
47
47
|
case "Credential":
|
|
48
48
|
return ["Credential", "Credential | PubKeyHash | ValidatorHash"]
|
|
49
|
+
case "Data":
|
|
50
|
+
return ["UplcData", "UplcData"]
|
|
49
51
|
case "Duration":
|
|
50
52
|
return ["bigint", "bigint | number"]
|
|
51
53
|
case "Int":
|
|
@@ -79,7 +81,7 @@ export function genTypes(schema) {
|
|
|
79
81
|
case "String":
|
|
80
82
|
return ["string", "string"]
|
|
81
83
|
case "Time":
|
|
82
|
-
return ["Date", "
|
|
84
|
+
return ["Date", "Date | bigint | number"]
|
|
83
85
|
case "TimeRange":
|
|
84
86
|
return [
|
|
85
87
|
"TimeRange",
|
|
@@ -98,6 +98,14 @@ export class TypescriptWriter {
|
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
writeHeaders() {
|
|
102
|
+
this.wjs.writeLine("import { Cast } from \"@helios-lang/contract-utils\";")
|
|
103
|
+
|
|
104
|
+
this.wdts.writeLine("import type {UplcData} from \"@helios-lang/ledger\";")
|
|
105
|
+
this.wdts.writeLine("import { Address, AssetClass, Credential, DatumHash, MintingPolicyHash, PubKeyHash, StakingCredential, StakingHash, StakingValidatorHash, TimeRange, TxId, TxOutputDatum, ValidatorHash, Value} from \"@helios-lang/ledger\";")
|
|
106
|
+
this.wdts.writeLine("import { Cast } from \"@helios-lang/contract-utils\";")
|
|
107
|
+
}
|
|
108
|
+
|
|
101
109
|
/**
|
|
102
110
|
* @param {{[name: string]: Module}} ms
|
|
103
111
|
*/
|
package/src/codegen/index.js
CHANGED
package/src/hl2ts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { promises, readFileSync } from "node:fs"
|
|
3
|
+
import { promises, readFileSync, writeFileSync } from "node:fs"
|
|
4
4
|
import { dirname, join, resolve } from "node:path"
|
|
5
5
|
import { readHeader, translateImportPaths } from "@helios-lang/compiler-utils"
|
|
6
6
|
import { TypescriptWriter } from "./codegen/index.js"
|
|
@@ -8,23 +8,16 @@ import { loadLibrary } from "./lib/index.js"
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {import("./lib/Lib.js").Lib} Lib
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
11
|
* @typedef {import("./lib/Lib.js").SourceDetails} SourceDetails
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
12
|
* @typedef {import("./lib/Lib.js").ModuleDetails} ModuleDetails
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
13
|
* @typedef {import("./lib/Lib.js").ValidatorDetails} ValidatorDetails
|
|
23
14
|
*/
|
|
24
15
|
|
|
25
16
|
async function main() {
|
|
26
17
|
console.log("hl2ts")
|
|
27
18
|
|
|
19
|
+
const { outDir } = parseArgs(process.argv)
|
|
20
|
+
|
|
28
21
|
const lib = await loadLibrary()
|
|
29
22
|
const filePaths = await listFiles(process.cwd(), ".hl")
|
|
30
23
|
const files = readFiles(filePaths)
|
|
@@ -32,17 +25,39 @@ async function main() {
|
|
|
32
25
|
const { modules, validators } = typeCheck(lib, sources)
|
|
33
26
|
|
|
34
27
|
const w = new TypescriptWriter()
|
|
35
|
-
|
|
28
|
+
|
|
29
|
+
w.writeHeaders()
|
|
36
30
|
w.writeModules(modules)
|
|
37
31
|
w.writeValidators(validators)
|
|
32
|
+
|
|
38
33
|
const [js, dts] = w.finalize()
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
const jsPath = join(outDir, "index.js")
|
|
36
|
+
const dtsPath = join(outDir, "index.d.ts")
|
|
37
|
+
|
|
38
|
+
writeFileSync(jsPath, js)
|
|
39
|
+
writeFileSync(dtsPath, dts)
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
main()
|
|
45
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @param {string[]} args
|
|
46
|
+
* @returns {{outDir: string}}
|
|
47
|
+
*/
|
|
48
|
+
function parseArgs(args) {
|
|
49
|
+
let i = args.indexOf("-o")
|
|
50
|
+
if (i != -1) {
|
|
51
|
+
if (i == args.length - 1) {
|
|
52
|
+
throw new Error("expected argument after -o")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { outDir: resolve(args[i + 1]) }
|
|
56
|
+
} else {
|
|
57
|
+
return { outDir: process.cwd() }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
46
61
|
/**
|
|
47
62
|
* @param {string} dir
|
|
48
63
|
* @param {string} ext
|
|
@@ -109,7 +124,7 @@ function preparseFiles(files) {
|
|
|
109
124
|
const sourceCode = translateImportPaths(files[path], (relPath) => {
|
|
110
125
|
const absPath = resolve(join(dirname(path), relPath))
|
|
111
126
|
|
|
112
|
-
const d = partialSources[absPath]
|
|
127
|
+
const d = partialSources[absPath] ?? partialSources[absPath + ".hl"]
|
|
113
128
|
|
|
114
129
|
if (!d) {
|
|
115
130
|
throw new Error(`'${relPath}' not found`)
|
package/src/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cast } from "./runtime/index.js"
|
package/src/lib/Libg_v0_16.js
CHANGED
|
@@ -327,8 +327,16 @@ export class Lib_v0_16 {
|
|
|
327
327
|
* @returns {InternalTypeDetails}
|
|
328
328
|
*/
|
|
329
329
|
getInternalTypeDetails(dt) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
try {
|
|
331
|
+
const it = dt?.typeDetails?.internalType ?? { type: "Any" }
|
|
332
|
+
|
|
333
|
+
return this.convertInternalType(it)
|
|
334
|
+
} catch (e) {
|
|
335
|
+
if (e.message.includes("Data")) {
|
|
336
|
+
return { primitiveType: "Data" }
|
|
337
|
+
} else {
|
|
338
|
+
throw e
|
|
339
|
+
}
|
|
340
|
+
}
|
|
333
341
|
}
|
|
334
342
|
}
|
package/src/runtime/Cast.js
CHANGED
|
@@ -91,6 +91,8 @@ function schemaToUplc(schema, x) {
|
|
|
91
91
|
case "Credential":
|
|
92
92
|
case "PaymentCredential":
|
|
93
93
|
return Credential.fromAlike(x).toUplcData()
|
|
94
|
+
case "Data":
|
|
95
|
+
return x
|
|
94
96
|
case "DatumHash":
|
|
95
97
|
return DatumHash.fromAlike(x).toUplcData()
|
|
96
98
|
case "DCert":
|
|
@@ -199,6 +201,8 @@ function uplcToSchema(schema, data) {
|
|
|
199
201
|
return ByteArrayData.expect(data).bytes
|
|
200
202
|
case "Credential":
|
|
201
203
|
return Credential.fromUplcData(data)
|
|
204
|
+
case "Data":
|
|
205
|
+
return data
|
|
202
206
|
case "DCert":
|
|
203
207
|
throw new Error(
|
|
204
208
|
"can't convert UplcData back into DCert (significant loss of information)"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cast } from "./Cast.js"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./TypeSchema.js").TypeSchema} TypeSchema
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {{
|
|
6
|
+
* name: string
|
|
7
|
+
* purpose: string
|
|
8
|
+
* sourceCode: string
|
|
9
|
+
* moduleDepedencies: string[]
|
|
10
|
+
* types: {[name: string]: TypeSchema}
|
|
11
|
+
* }} Module
|
|
12
|
+
*/
|
|
13
|
+
export const _: {};
|
|
14
|
+
export type TypeSchema = import("./TypeSchema.js").TypeSchema;
|
|
15
|
+
export type Module = {
|
|
16
|
+
name: string;
|
|
17
|
+
purpose: string;
|
|
18
|
+
sourceCode: string;
|
|
19
|
+
moduleDepedencies: string[];
|
|
20
|
+
types: {
|
|
21
|
+
[name: string]: import("./TypeSchema.js").TypeSchema;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=Module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Module.d.ts","sourceRoot":"","sources":["../../src/codegen/Module.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AAEH,mBAAmB;yBAbN,OAAO,iBAAiB,EAAE,UAAU;;UAKtC,MAAM;aACH,MAAM;gBACH,MAAM;uBACC,MAAM,EAAE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* primitiveType: string
|
|
4
|
+
* } | {
|
|
5
|
+
* listItemType: TypeSchema
|
|
6
|
+
* } | {
|
|
7
|
+
* mapKeyType: TypeSchema
|
|
8
|
+
* mapValueType: TypeSchema
|
|
9
|
+
* } | {
|
|
10
|
+
* optionSomeType: TypeSchema
|
|
11
|
+
* } | {
|
|
12
|
+
* structFieldTypes: {
|
|
13
|
+
* name: string
|
|
14
|
+
* type: TypeSchema
|
|
15
|
+
* }[]
|
|
16
|
+
* } | {
|
|
17
|
+
* enumVariantTypes: {
|
|
18
|
+
* name: string,
|
|
19
|
+
* fieldTypes: {
|
|
20
|
+
* name: string
|
|
21
|
+
* type: TypeSchema
|
|
22
|
+
* }[]
|
|
23
|
+
* }[]
|
|
24
|
+
* }} TypeSchema
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @param {TypeSchema} schema
|
|
28
|
+
* @returns {[string, string]} - the first entry is the canonical type, the second is the permissive type
|
|
29
|
+
*/
|
|
30
|
+
export function genTypes(schema: TypeSchema): [string, string];
|
|
31
|
+
export type TypeSchema = {
|
|
32
|
+
primitiveType: string;
|
|
33
|
+
} | {
|
|
34
|
+
listItemType: TypeSchema;
|
|
35
|
+
} | {
|
|
36
|
+
mapKeyType: TypeSchema;
|
|
37
|
+
mapValueType: TypeSchema;
|
|
38
|
+
} | {
|
|
39
|
+
optionSomeType: TypeSchema;
|
|
40
|
+
} | {
|
|
41
|
+
structFieldTypes: {
|
|
42
|
+
name: string;
|
|
43
|
+
type: TypeSchema;
|
|
44
|
+
}[];
|
|
45
|
+
} | {
|
|
46
|
+
enumVariantTypes: {
|
|
47
|
+
name: string;
|
|
48
|
+
fieldTypes: {
|
|
49
|
+
name: string;
|
|
50
|
+
type: TypeSchema;
|
|
51
|
+
}[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=TypeSchema.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./Module.js").Module} Module
|
|
3
|
+
* @typedef {import("./Validator.js").Validator} Validator
|
|
4
|
+
*/
|
|
5
|
+
export class TypescriptWriter {
|
|
6
|
+
wjs: Writer;
|
|
7
|
+
wdts: Writer;
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} js
|
|
10
|
+
* @param {string} dts
|
|
11
|
+
* @returns {TypescriptWriter}
|
|
12
|
+
*/
|
|
13
|
+
write(js: string, dts?: string): TypescriptWriter;
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} js
|
|
16
|
+
* @param {string} dts
|
|
17
|
+
* @returns {TypescriptWriter}
|
|
18
|
+
*/
|
|
19
|
+
writeLine(js: string, dts?: string): TypescriptWriter;
|
|
20
|
+
/**
|
|
21
|
+
* @param {Module} m
|
|
22
|
+
*/
|
|
23
|
+
writeModule(m: Module): void;
|
|
24
|
+
/**
|
|
25
|
+
* @param {Validator} v
|
|
26
|
+
*/
|
|
27
|
+
writeValidator(v: Validator): void;
|
|
28
|
+
writeHeaders(): void;
|
|
29
|
+
/**
|
|
30
|
+
* @param {{[name: string]: Module}} ms
|
|
31
|
+
*/
|
|
32
|
+
writeModules(ms: {
|
|
33
|
+
[name: string]: import("./Module.js").Module;
|
|
34
|
+
}): void;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {{[name: string]: Validator}} validators
|
|
38
|
+
*/
|
|
39
|
+
writeValidators(validators: {
|
|
40
|
+
[name: string]: import("./Validator.js").Validator;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* @returns {[string, string]}
|
|
44
|
+
*/
|
|
45
|
+
finalize(): [string, string];
|
|
46
|
+
}
|
|
47
|
+
export type Module = import("./Module.js").Module;
|
|
48
|
+
export type Validator = import("./Validator.js").Validator;
|
|
49
|
+
import { Writer } from "./Writer.js";
|
|
50
|
+
//# sourceMappingURL=TypescriptWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypescriptWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/TypescriptWriter.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;IAEQ,YAAuB;IACvB,aAAwB;IAG5B;;;;OAIG;IACH,UAJW,MAAM,QACN,MAAM,GACJ,gBAAgB,CAM5B;IAED;;;;OAIG;IACH,cAJW,MAAM,QACN,MAAM,GACJ,gBAAgB,CAY5B;IAED;;OAEG;IACH,eAFW,MAAM,QAmBhB;IAED;;OAEG;IACH,kBAFW,SAAS,QAiCnB;IAED,qBAMC;IAED;;OAEG;IACH;;aA4BC;IAED;;;OAGG;IACH;;aA8BC;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,CAAC,CAI5B;CACJ;qBAnLY,OAAO,aAAa,EAAE,MAAM;wBAC5B,OAAO,gBAAgB,EAAE,SAAS;uBAJxB,aAAa"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./TypeSchema.js").TypeSchema} TypeSchema
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("./Module.js").Module} Module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Module & {
|
|
9
|
+
* hashDependencies: string[]
|
|
10
|
+
* Redeemer: TypeSchema
|
|
11
|
+
* Datum?: TypeSchema
|
|
12
|
+
* }} Validator
|
|
13
|
+
*/
|
|
14
|
+
export const _: {};
|
|
15
|
+
export type TypeSchema = import("./TypeSchema.js").TypeSchema;
|
|
16
|
+
export type Module = import("./Module.js").Module;
|
|
17
|
+
export type Validator = Module & {
|
|
18
|
+
hashDependencies: string[];
|
|
19
|
+
Redeemer: TypeSchema;
|
|
20
|
+
Datum?: TypeSchema;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=Validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../src/codegen/Validator.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AAEH;;;;;;GAMG;AAEH,mBAAmB;yBAfN,OAAO,iBAAiB,EAAE,UAAU;qBAIpC,OAAO,aAAa,EAAE,MAAM;wBAI5B,MAAM,GAAG;IACrB,gBAAoB,EAAE,MAAM,EAAE,CAAA;IAC9B,QAAY,EAAE,UAAU,CAAA;IACxB,KAAS,CAAC,EAAE,UAAU,CAAA;CACnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class Writer {
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* @readonly
|
|
5
|
+
* @type {string[]}
|
|
6
|
+
*/
|
|
7
|
+
private readonly parts;
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} part
|
|
10
|
+
* @returns {Writer}
|
|
11
|
+
*/
|
|
12
|
+
write(part: string): Writer;
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} line
|
|
15
|
+
* @returns {Writer}
|
|
16
|
+
*/
|
|
17
|
+
writeLine(line: string): Writer;
|
|
18
|
+
/**
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
finalize(): string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Writer.d.ts","sourceRoot":"","sources":["../../src/codegen/Writer.js"],"names":[],"mappings":"AAAA;IACI;;;;OAIG;IACH,uBAAK;IAML;;;OAGG;IACH,YAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;OAEG;IACH,YAFa,MAAM,CAIlB;CACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TypescriptWriter } from "./TypescriptWriter.js";
|
|
2
|
+
export { Writer } from "./Writer.js";
|
|
3
|
+
export type Module = import("./Module.js").Module;
|
|
4
|
+
export type TypeSchema = import("./TypeSchema.js").TypeSchema;
|
|
5
|
+
export type Validator = import("./Validator.js").Validator;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/types/hl2ts.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export type Lib = import("./lib/Lib.js").Lib;
|
|
3
|
+
export type SourceDetails = import("./lib/Lib.js").SourceDetails;
|
|
4
|
+
export type ModuleDetails = import("./lib/Lib.js").ModuleDetails;
|
|
5
|
+
export type ValidatorDetails = import("./lib/Lib.js").ValidatorDetails;
|
|
6
|
+
//# sourceMappingURL=hl2ts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hl2ts.d.ts","sourceRoot":"","sources":["../src/hl2ts.js"],"names":[],"mappings":";kBASa,OAAO,cAAc,EAAE,GAAG;4BAC1B,OAAO,cAAc,EAAE,aAAa;4BACpC,OAAO,cAAc,EAAE,aAAa;+BACpC,OAAO,cAAc,EAAE,gBAAgB"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* version: string
|
|
4
|
+
* typeCheck: (validators: {[name: string]: SourceDetails}, modules: {[name: string]: SourceDetails}) => ({
|
|
5
|
+
* modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}})
|
|
6
|
+
* }} Lib
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
10
|
+
* @typedef {import("../codegen/index.js").Module} ModuleDetails
|
|
11
|
+
* @typedef {import("../codegen/index.js").Validator} ValidatorDetails
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* name: string
|
|
16
|
+
* purpose: string
|
|
17
|
+
* sourceCode: string
|
|
18
|
+
* }} SourceDetails
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @param {{VERSION: string}} lib
|
|
22
|
+
* @returns {number[]}
|
|
23
|
+
*/
|
|
24
|
+
export function getVersion(lib: {
|
|
25
|
+
VERSION: string;
|
|
26
|
+
}): number[];
|
|
27
|
+
export type Lib = {
|
|
28
|
+
version: string;
|
|
29
|
+
typeCheck: (validators: {
|
|
30
|
+
[name: string]: SourceDetails;
|
|
31
|
+
}, modules: {
|
|
32
|
+
[name: string]: SourceDetails;
|
|
33
|
+
}) => {
|
|
34
|
+
modules: {
|
|
35
|
+
[name: string]: import("../codegen/Module.js").Module;
|
|
36
|
+
};
|
|
37
|
+
validators: {
|
|
38
|
+
[name: string]: import("../codegen/Validator.js").Validator;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
43
|
+
export type ModuleDetails = import("../codegen/index.js").Module;
|
|
44
|
+
export type ValidatorDetails = import("../codegen/index.js").Validator;
|
|
45
|
+
export type SourceDetails = {
|
|
46
|
+
name: string;
|
|
47
|
+
purpose: string;
|
|
48
|
+
sourceCode: string;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=Lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lib.d.ts","sourceRoot":"","sources":["../../src/lib/Lib.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AACH,gCAHW;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GACf,MAAM,EAAE,CAIpB;;aA1Ba,MAAM;;;;;;;;;;;;;;kCAOP,OAAO,qBAAqB,EAAE,UAAU;4BACxC,OAAO,qBAAqB,EAAE,MAAM;+BACpC,OAAO,qBAAqB,EAAE,SAAS;4BAIvC;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./Lib.js").Lib} Lib
|
|
3
|
+
* @typedef {import("./Lib.js").SourceDetails} SourceDetails
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import("../codegen/index.js").Module} ModuleDetails
|
|
7
|
+
* @typedef {import("../codegen/index.js").Validator} ValidatorDetails
|
|
8
|
+
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{
|
|
12
|
+
* [name: string]: string[]
|
|
13
|
+
* }} DagDependencies
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {{
|
|
17
|
+
* }} HashType
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* includes: (m: string) => boolean
|
|
22
|
+
* }} IR
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {{
|
|
26
|
+
* name: string
|
|
27
|
+
* }} EnumStatement
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {{
|
|
31
|
+
* name: string
|
|
32
|
+
* }} StructStatement
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {StructStatement | EnumStatement | any} Statement
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {{
|
|
39
|
+
* name: {value: string}
|
|
40
|
+
* filterDependencies: (all: Module[]) => Module[]
|
|
41
|
+
* statements: Statement[]
|
|
42
|
+
* }} Module
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {{
|
|
46
|
+
* name: string
|
|
47
|
+
* toIR: (ctx: any, extra: Map<string, IR>) => IR
|
|
48
|
+
* types: UserTypes
|
|
49
|
+
* mainImportedModules: Module[]
|
|
50
|
+
* mainModule: Module
|
|
51
|
+
* mainArgTypes: DataType[]
|
|
52
|
+
* }} Program
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {{
|
|
56
|
+
* typeDetails?: TypeDetails
|
|
57
|
+
* }} DataType
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {{
|
|
61
|
+
* type: string
|
|
62
|
+
* } | {
|
|
63
|
+
* type: "List"
|
|
64
|
+
* itemType: TypeSchema
|
|
65
|
+
* } | {
|
|
66
|
+
* type: "Map"
|
|
67
|
+
* keyType: TypeSchema
|
|
68
|
+
* valueType: TypeSchema
|
|
69
|
+
* } | {
|
|
70
|
+
* type: "Option"
|
|
71
|
+
* someType: TypeSchema
|
|
72
|
+
* } | {
|
|
73
|
+
* type: "Struct"
|
|
74
|
+
* fieldTypes: NamedTypeSchema[]
|
|
75
|
+
* } | {
|
|
76
|
+
* type: "Enum"
|
|
77
|
+
* variantTypes: {name: string, fieldTypes: NamedTypeSchema[]}[]
|
|
78
|
+
* }} TypeSchema
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* @typedef {{
|
|
82
|
+
* name: string
|
|
83
|
+
* } & TypeSchema} NamedTypeSchema
|
|
84
|
+
*/
|
|
85
|
+
/**
|
|
86
|
+
* @typedef {{
|
|
87
|
+
* inputType: string
|
|
88
|
+
* outputType: string
|
|
89
|
+
* internalType: TypeSchema
|
|
90
|
+
* }} TypeDetails
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* @typedef {{
|
|
94
|
+
* }} UserTypes
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* @implements {Lib}
|
|
98
|
+
*/
|
|
99
|
+
export class Lib_v0_16 implements Lib {
|
|
100
|
+
/**
|
|
101
|
+
* @param {any} lib
|
|
102
|
+
*/
|
|
103
|
+
constructor(lib: any);
|
|
104
|
+
lib: any;
|
|
105
|
+
/**
|
|
106
|
+
* @type {string}
|
|
107
|
+
*/
|
|
108
|
+
get version(): string;
|
|
109
|
+
/**
|
|
110
|
+
* @private
|
|
111
|
+
* @param {string} purpose
|
|
112
|
+
* @returns {HashType}
|
|
113
|
+
*/
|
|
114
|
+
private getValidatorType;
|
|
115
|
+
/**
|
|
116
|
+
* @private
|
|
117
|
+
* @param {SourceDetails[]} validators
|
|
118
|
+
* @param {SourceDetails[]} modules
|
|
119
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
120
|
+
* @returns {Program[]}
|
|
121
|
+
*/
|
|
122
|
+
private createPrograms;
|
|
123
|
+
/**
|
|
124
|
+
* @private
|
|
125
|
+
* @param {Program} program
|
|
126
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
127
|
+
* @returns {IR}
|
|
128
|
+
*/
|
|
129
|
+
private toTestIR;
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
* @param {Program[]} validators
|
|
133
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
134
|
+
* @returns {DagDependencies}
|
|
135
|
+
*/
|
|
136
|
+
private buildDagDependencies;
|
|
137
|
+
/**
|
|
138
|
+
* @param {{[name: string]: SourceDetails}} validators
|
|
139
|
+
* @param {{[name: string]: SourceDetails}} modules
|
|
140
|
+
* @returns {{modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}}
|
|
141
|
+
*/
|
|
142
|
+
typeCheck(validators: {
|
|
143
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
144
|
+
}, modules: {
|
|
145
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
146
|
+
}): {
|
|
147
|
+
modules: {
|
|
148
|
+
[name: string]: import("./Lib.js").ModuleDetails;
|
|
149
|
+
};
|
|
150
|
+
validators: {
|
|
151
|
+
[name: string]: import("./Lib.js").ValidatorDetails;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @param {TypeSchema} it
|
|
156
|
+
* @returns {InternalTypeDetails}
|
|
157
|
+
*/
|
|
158
|
+
convertInternalType(it: TypeSchema): InternalTypeDetails;
|
|
159
|
+
/**
|
|
160
|
+
* @param {DataType} dt
|
|
161
|
+
* @returns {InternalTypeDetails}
|
|
162
|
+
*/
|
|
163
|
+
getInternalTypeDetails(dt: DataType): InternalTypeDetails;
|
|
164
|
+
}
|
|
165
|
+
export type Lib = import("./Lib.js").Lib;
|
|
166
|
+
export type SourceDetails = import("./Lib.js").SourceDetails;
|
|
167
|
+
export type ModuleDetails = import("../codegen/index.js").Module;
|
|
168
|
+
export type ValidatorDetails = import("../codegen/index.js").Validator;
|
|
169
|
+
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
170
|
+
export type DagDependencies = {
|
|
171
|
+
[name: string]: string[];
|
|
172
|
+
};
|
|
173
|
+
export type HashType = {};
|
|
174
|
+
export type IR = {
|
|
175
|
+
includes: (m: string) => boolean;
|
|
176
|
+
};
|
|
177
|
+
export type EnumStatement = {
|
|
178
|
+
name: string;
|
|
179
|
+
};
|
|
180
|
+
export type StructStatement = {
|
|
181
|
+
name: string;
|
|
182
|
+
};
|
|
183
|
+
export type Statement = StructStatement | EnumStatement | any;
|
|
184
|
+
export type Module = {
|
|
185
|
+
name: {
|
|
186
|
+
value: string;
|
|
187
|
+
};
|
|
188
|
+
filterDependencies: (all: Module[]) => Module[];
|
|
189
|
+
statements: Statement[];
|
|
190
|
+
};
|
|
191
|
+
export type Program = {
|
|
192
|
+
name: string;
|
|
193
|
+
toIR: (ctx: any, extra: Map<string, IR>) => IR;
|
|
194
|
+
types: UserTypes;
|
|
195
|
+
mainImportedModules: Module[];
|
|
196
|
+
mainModule: Module;
|
|
197
|
+
mainArgTypes: DataType[];
|
|
198
|
+
};
|
|
199
|
+
export type DataType = {
|
|
200
|
+
typeDetails?: TypeDetails;
|
|
201
|
+
};
|
|
202
|
+
export type TypeSchema = {
|
|
203
|
+
type: string;
|
|
204
|
+
} | {
|
|
205
|
+
type: "List";
|
|
206
|
+
itemType: TypeSchema;
|
|
207
|
+
} | {
|
|
208
|
+
type: "Map";
|
|
209
|
+
keyType: TypeSchema;
|
|
210
|
+
valueType: TypeSchema;
|
|
211
|
+
} | {
|
|
212
|
+
type: "Option";
|
|
213
|
+
someType: TypeSchema;
|
|
214
|
+
} | {
|
|
215
|
+
type: "Struct";
|
|
216
|
+
fieldTypes: NamedTypeSchema[];
|
|
217
|
+
} | {
|
|
218
|
+
type: "Enum";
|
|
219
|
+
variantTypes: {
|
|
220
|
+
name: string;
|
|
221
|
+
fieldTypes: NamedTypeSchema[];
|
|
222
|
+
}[];
|
|
223
|
+
};
|
|
224
|
+
export type NamedTypeSchema = {
|
|
225
|
+
name: string;
|
|
226
|
+
} & TypeSchema;
|
|
227
|
+
export type TypeDetails = {
|
|
228
|
+
inputType: string;
|
|
229
|
+
outputType: string;
|
|
230
|
+
internalType: TypeSchema;
|
|
231
|
+
};
|
|
232
|
+
export type UserTypes = {};
|
|
233
|
+
//# sourceMappingURL=Libg_v0_16.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Libg_v0_16.d.ts","sourceRoot":"","sources":["../../src/lib/Libg_v0_16.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;;;;;GAMG;AACH;;;;;;;;;GASG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;GAGG;AAEH;;GAEG;AACH;IACI;;OAEG;IACH,iBAFW,GAAG,EAIb;IADG,SAAc;IAGlB;;OAEG;IACH,sBAEC;IAED;;;;OAIG;IACH,yBAWC;IAED;;;;;;OAMG;IACH,uBAcC;IAED;;;;;OAKG;IACH,iBAWC;IAED;;;;;OAKG;IACH,6BAeC;IAED;;;;OAIG;IACH;;;;;;;;;;;MAuEC;IAED;;;OAGG;IACH,wBAHW,UAAU,GACR,mBAAmB,CAgC/B;IAED;;;OAGG;IACH,2BAHW,QAAQ,GACN,mBAAmB,CAc/B;CACJ;kBApVY,OAAO,UAAU,EAAE,GAAG;4BACtB,OAAO,UAAU,EAAE,aAAa;4BAIhC,OAAO,qBAAqB,EAAE,MAAM;+BACpC,OAAO,qBAAqB,EAAE,SAAS;kCACvC,OAAO,qBAAqB,EAAE,UAAU;;;;uBAUxC,EACT;;kBAKe,MAAM,KAAK,OAAO;;4BAKxB;IACZ,MAAU,MAAM,CAAA;CACb;8BAIS;IACZ,MAAU,MAAM,CAAA;CACb;wBAIS,eAAe,GAAG,aAAa,GAAG,GAAG;;UAKvC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC;8BACK,MAAM,EAAE,KAAK,MAAM,EAAE;gBACnC,SAAS,EAAE;;;UAKjB,MAAM;gBACA,GAAG,SAAS,IAAI,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE;WACvC,SAAS;yBACK,MAAM,EAAE;gBACjB,MAAM;kBACJ,QAAQ,EAAE;;uBAKhB;IACZ,WAAe,CAAC,EAAE,WAAW,CAAA;CAC1B;yBAIS;IACZ,IAAQ,EAAG,MAAM,CAAA;CACd,GAAG;IACN,IAAQ,EAAM,MAAM,CAAA;IACpB,QAAY,EAAE,UAAU,CAAA;CACrB,GAAG;IACN,IAAQ,EAAO,KAAK,CAAA;IACpB,OAAW,EAAI,UAAU,CAAA;IACzB,SAAa,EAAE,UAAU,CAAA;CACtB,GAAG;IACN,IAAQ,EAAM,QAAQ,CAAA;IACtB,QAAY,EAAE,UAAU,CAAA;CACrB,GAAG;IACN,IAAQ,EAAQ,QAAQ,CAAA;IACxB,UAAc,EAAE,eAAe,EAAE,CAAA;CAC9B,GAAG;IACN,IAAQ,EAAU,MAAM,CAAA;IACxB,YAAgB,EAAE;QAAC,MAAM,MAAM,CAAC;QAAC,UAAU,EAAE,eAAe,EAAE,CAAA;KAAC,EAAE,CAAA;CAC9D;8BAIS;IACZ,MAAU,MAAM,CAAA;CACb,GAAG,UAAU;0BAIJ;IACZ,SAAa,EAAE,MAAM,CAAA;IACrB,UAAc,EAAE,MAAM,CAAA;IACtB,YAAgB,EAAE,UAAU,CAAA;CACzB;wBAIS,EACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/lib/load.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH,+BAFa,QAAQ,GAAG,CAAC,CAiCxB;kBAtDY,OAAO,UAAU,EAAE,GAAG"}
|
|
@@ -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
|
|
7
|
+
* @template TPermissive
|
|
8
|
+
*/
|
|
9
|
+
export class Cast<TStrict, TPermissive> {
|
|
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
|
+
fromUplc(data: UplcData): TStrict;
|
|
24
|
+
/**
|
|
25
|
+
* @param {TPermissive} x
|
|
26
|
+
* @returns {UplcData}
|
|
27
|
+
*/
|
|
28
|
+
toUplc(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/runtime/Cast.js"],"names":[],"mappings":"AAgCA;;;GAGG;AAEH;;;GAGG;AACH;IAOI;;OAEG;IACH,oBAFW,UAAU,EAIpB;IAXD;;;OAGG;IACH,iBAFU,UAAU,CAEd;IASN;;;OAGG;IACH,eAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;OAGG;IACH,UAHW,WAAW,GACT,QAAQ,CAIpB;CACJ;uBArCY,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,qBAAqB,EAAE,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.js"],"names":[],"mappings":""}
|
package/examples/spending/app.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Program } from "@hyperionbt/helios"
|
|
2
|
-
import { utils, match_string } from "./unspecialized.js"
|
|
3
|
-
|
|
4
|
-
const modules = [utils, ...]
|
|
5
|
-
|
|
6
|
-
export class App {
|
|
7
|
-
/**
|
|
8
|
-
* @param {typeof utils} specializedUtils
|
|
9
|
-
*/
|
|
10
|
-
constructor(specializedUtils) {
|
|
11
|
-
this.program = Program.new(match_string, modules.replace("utils", specializedUtils))
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export const utils: {
|
|
3
|
-
$name: string
|
|
4
|
-
$purpose: string
|
|
5
|
-
$sourceCode: string
|
|
6
|
-
$dependencies: []
|
|
7
|
-
}
|
|
8
|
-
export const match_string: {
|
|
9
|
-
$name: string
|
|
10
|
-
$purpose: string
|
|
11
|
-
$sourceCode: string
|
|
12
|
-
$dependencies: [typeof utils]
|
|
13
|
-
$hashDependencies: []
|
|
14
|
-
$dependsOnOwnHash: boolean
|
|
15
|
-
$Redeemer: Cast<string, string>
|
|
16
|
-
$Datum: Cast<{message: string}, {message: string}>
|
|
17
|
-
}
|
|
18
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const utils: {
|
|
4
|
-
$name: string
|
|
5
|
-
$purpose: string
|
|
6
|
-
$sourceCode: string
|
|
7
|
-
$dependencies: []
|
|
8
|
-
}
|
|
9
|
-
export const match_string: {
|
|
10
|
-
$name: string
|
|
11
|
-
$purpose: string
|
|
12
|
-
$sourceCode: string
|
|
13
|
-
$dependencies: [typeof utils]
|
|
14
|
-
$hashDependencies: []
|
|
15
|
-
$dependsOnOwnHash: boolean
|
|
16
|
-
$Redeemer: Cast<string, string>
|
|
17
|
-
$Datum: Cast<
|
|
18
|
-
{One: {message: string}} |
|
|
19
|
-
{Two: {code: bigint}},
|
|
20
|
-
{One: {message: string}} |
|
|
21
|
-
{Two: {code: bigint | number | string}}
|
|
22
|
-
>
|
|
23
|
-
}
|
|
24
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const utils = {
|
|
2
|
-
$name: "utils",
|
|
3
|
-
$purpose: "module",
|
|
4
|
-
$sourceCode: "module utils\n\nfunc compare(a: String, b: String) -> Bool {\n a == b\n}",
|
|
5
|
-
$dependencies: [],
|
|
6
|
-
}
|
|
7
|
-
export const match_string = {
|
|
8
|
-
$name: "match_string",
|
|
9
|
-
$purpose: "spending",
|
|
10
|
-
$sourceCode: "spending match_string\n\nimport { compare } from utils\n\nenum Datum {\n One {\n message: String\n }\n\n Two {\n message: String\n }\n}\n\nfunc main(datum: Datum, redeemer: String, _) -> Bool {\n compare(datum.switch{d: One => d.message, d: Two => d.message}, redeemer)\n}",
|
|
11
|
-
$dependencies: [utils],
|
|
12
|
-
$hashDependencies: [],
|
|
13
|
-
$dependsOnOwnHash: false,
|
|
14
|
-
$Redeemer: new Cast({"primitiveType":"String"}),
|
|
15
|
-
$Datum: new Cast({"enumVariantTypes":[{"name":"One","fieldTypes":[{"name":"message","type":{"primitiveType":"String"}}]},{"name":"Two","fieldTypes":[{"name":"message","type":{"primitiveType":"String"}}]}]})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const utils: {
|
|
19
|
-
$name: string
|
|
20
|
-
$purpose: string
|
|
21
|
-
$sourceCode: string
|
|
22
|
-
$dependencies: []
|
|
23
|
-
}
|
|
24
|
-
export const match_string: {
|
|
25
|
-
$name: string
|
|
26
|
-
$purpose: string
|
|
27
|
-
$sourceCode: string
|
|
28
|
-
$dependencies: [typeof utils]
|
|
29
|
-
$hashDependencies: []
|
|
30
|
-
$dependsOnOwnHash: boolean
|
|
31
|
-
$Redeemer: Cast<string, string>
|
|
32
|
-
$Datum: Cast<{One: {message: string}} | {Two: {message: string}}, {One: {message: string}} | {Two: {message: string}}>
|
|
33
|
-
}
|
|
34
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Cast } from "@helios-lang/contract-utils"
|
|
2
|
-
|
|
3
|
-
export const utils = {
|
|
4
|
-
$name: "utils",
|
|
5
|
-
$purpose: "module",
|
|
6
|
-
$sourceCode: "module utils\n\nfunc compare(a: String, b: String) -> Bool {\n a == b\n}",
|
|
7
|
-
$dependencies: [],
|
|
8
|
-
}
|
|
9
|
-
export const match_string = {
|
|
10
|
-
$name: "match_string",
|
|
11
|
-
$purpose: "spending",
|
|
12
|
-
$sourceCode: "spending match_string\n\nimport { compare } from utils\n\nstruct Datum {\n message: String\n}\n\nfunc main(datum: Datum, redeemer: String, _) -> Bool {\n compare(datum.message, redeemer)\n}",
|
|
13
|
-
$dependencies: [utils],
|
|
14
|
-
$hashDependencies: [],
|
|
15
|
-
$dependsOnOwnHash: false,
|
|
16
|
-
$Redeemer: new Cast({"primitiveType":"String"}),
|
|
17
|
-
$Datum: new Cast({"structFieldTypes":[{"name":"message","type":{"primitiveType":"String"}}]})
|
|
18
|
-
}
|