@helios-lang/contract-utils 0.2.8 → 0.2.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.
- package/package.json +3 -3
- package/src/cast/Cast.js +314 -219
- package/src/codegen/TypeSchema.js +139 -143
- package/src/compiler/CompilerLib.js +29 -4
- package/src/compiler/CompilerLib_v0_16.js +75 -51
- package/src/compiler/CompilerLib_v0_17.js +107 -0
- package/src/compiler/ops.js +5 -0
- package/src/context/ContractContextBuilder.js +1 -0
- package/src/context/DagCompiler.js +9 -8
- package/src/hl2ts.js +3 -4
- package/types/cast/Cast.d.ts.map +1 -1
- package/types/codegen/TypeCheckedModule.d.ts +1 -1
- package/types/codegen/TypeSchema.d.ts +3 -56
- package/types/codegen/TypeSchema.d.ts.map +1 -1
- package/types/compiler/CompilerLib.d.ts +66 -3
- package/types/compiler/CompilerLib.d.ts.map +1 -1
- package/types/compiler/CompilerLib_v0_16.d.ts +38 -39
- package/types/compiler/CompilerLib_v0_16.d.ts.map +1 -1
- package/types/compiler/CompilerLib_v0_17.d.ts +68 -0
- package/types/compiler/CompilerLib_v0_17.d.ts.map +1 -0
- package/types/compiler/ops.d.ts.map +1 -1
- package/types/context/ContractContextBuilder.d.ts.map +1 -1
- package/types/context/ContractContextCache.d.ts +1 -1
- package/types/context/DagCompiler.d.ts +2 -1
- package/types/context/DagCompiler.d.ts.map +1 -1
- package/types/hl2ts.d.ts.map +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { bytesToHex } from "@helios-lang/codec-utils"
|
|
2
|
+
import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
6
|
+
* @typedef {import("./CompilerLib.js").CompilerLib} CompilerLib
|
|
7
|
+
* @typedef {import("./CompilerLib.js").CompileOptions} CompileOptions
|
|
8
|
+
* @typedef {import("./CompilerLib.js").CompileOutput} CompileOutput
|
|
9
|
+
* @typedef {import("./CompilerLib.js").ScriptHashType} ScriptHashType
|
|
10
|
+
* @typedef {import("./CompilerLib.js").TypeCheckOutput} TypeCheckOutput
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* name: string
|
|
16
|
+
* changeParam(key: string, value: UplcData): void
|
|
17
|
+
* compile(options: {optimize?: boolean, dependsOnOwnHash?: boolean, hashDependencies?: Record<string, string>}): UplcProgramV2
|
|
18
|
+
* }} Program
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @implements {CompilerLib}
|
|
23
|
+
*/
|
|
24
|
+
export class CompilerLib_v0_17 {
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @type {any}
|
|
28
|
+
*/
|
|
29
|
+
lib
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {any} lib
|
|
33
|
+
*/
|
|
34
|
+
constructor(lib) {
|
|
35
|
+
this.lib = lib
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
get version() {
|
|
42
|
+
return this.lib.VERSION
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} purpose
|
|
47
|
+
* @returns {ScriptHashType}
|
|
48
|
+
*/
|
|
49
|
+
getScriptHashType(purpose) {
|
|
50
|
+
const { getScriptHashType } = this.lib
|
|
51
|
+
|
|
52
|
+
return getScriptHashType(purpose)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} mainSource
|
|
57
|
+
* @param {string[]} moduleSources
|
|
58
|
+
* @param {CompileOptions} options
|
|
59
|
+
* @returns {CompileOutput}
|
|
60
|
+
*/
|
|
61
|
+
compile(mainSource, moduleSources, options) {
|
|
62
|
+
const { Program } = this.lib
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @type {Program}
|
|
66
|
+
*/
|
|
67
|
+
const program = new Program(mainSource, {
|
|
68
|
+
moduleSources: moduleSources,
|
|
69
|
+
validatorTypes: options.allValidatorHashTypes,
|
|
70
|
+
isTestnet: options.isTestnet,
|
|
71
|
+
throwCompilerErrors: true
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
if (options.parameters) {
|
|
75
|
+
Object.entries(options.parameters).forEach(([key, value]) => {
|
|
76
|
+
program.changeParam(key, value)
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @type {UplcProgramV2}
|
|
82
|
+
*/
|
|
83
|
+
const uplc = program.compile({
|
|
84
|
+
optimize: options.optimize,
|
|
85
|
+
dependsOnOwnHash: options.dependsOnOwnHash ?? false,
|
|
86
|
+
hashDependencies: {
|
|
87
|
+
...options.hashDependencies,
|
|
88
|
+
...(options.ownHash ? { [program.name]: options.ownHash } : {})
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
cborHex: bytesToHex(uplc.toCbor())
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {string[]} validatorSources
|
|
99
|
+
* @param {string[]} moduleSources
|
|
100
|
+
* @returns {TypeCheckOutput}
|
|
101
|
+
*/
|
|
102
|
+
typeCheck(validatorSources, moduleSources) {
|
|
103
|
+
const { analyzeMulti } = this.lib
|
|
104
|
+
|
|
105
|
+
return analyzeMulti(validatorSources, moduleSources)
|
|
106
|
+
}
|
|
107
|
+
}
|
package/src/compiler/ops.js
CHANGED
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
readHeader
|
|
5
5
|
} from "@helios-lang/compiler-utils"
|
|
6
6
|
import { CompilerLib_v0_16 } from "./CompilerLib_v0_16.js"
|
|
7
|
+
import { CompilerLib_v0_17 } from "./CompilerLib_v0_17.js"
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {import("./CompilerLib.js").CompilerLib} CompilerLib
|
|
11
|
+
* @typedef {import("./CompilerLib.js")}
|
|
10
12
|
* @typedef {import("./CompilerLib.js").TypeCheckOutput} TypeCheckOutput
|
|
11
13
|
*/
|
|
12
14
|
|
|
@@ -30,6 +32,8 @@ export function loadCompilerLib() {
|
|
|
30
32
|
switch (minor) {
|
|
31
33
|
case 16:
|
|
32
34
|
return new CompilerLib_v0_16(unsafeLib)
|
|
35
|
+
case 17:
|
|
36
|
+
return new CompilerLib_v0_17(unsafeLib)
|
|
33
37
|
}
|
|
34
38
|
default:
|
|
35
39
|
throw new Error(
|
|
@@ -85,6 +89,7 @@ function splitValidatorsAndModules(scripts) {
|
|
|
85
89
|
case "module":
|
|
86
90
|
modules.set(name, s)
|
|
87
91
|
break
|
|
92
|
+
case "mixed":
|
|
88
93
|
case "minting":
|
|
89
94
|
case "spending":
|
|
90
95
|
case "certifying":
|
|
@@ -53,10 +53,11 @@ export class DagCompiler {
|
|
|
53
53
|
/**
|
|
54
54
|
* @param {LoadedValidator[]} validators
|
|
55
55
|
* @param {Record<string, any>} parameters
|
|
56
|
+
* @param {boolean} isTestnet
|
|
56
57
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
57
58
|
* @returns {{[name: string]: AnyContractValidatorContext}}
|
|
58
59
|
*/
|
|
59
|
-
build(validators, parameters, expectedHashes = None) {
|
|
60
|
+
build(validators, parameters, isTestnet, expectedHashes = None) {
|
|
60
61
|
const hashTypes = this.getHashTypes(validators)
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -81,15 +82,16 @@ export class DagCompiler {
|
|
|
81
82
|
const moduleDeps = getModuleDependencies(validator)
|
|
82
83
|
|
|
83
84
|
// optimized compilation
|
|
84
|
-
const { cborHex: optimizedCborHex
|
|
85
|
+
const { cborHex: optimizedCborHex } = this.lib.compile(
|
|
85
86
|
sourceCode,
|
|
86
87
|
moduleDeps,
|
|
87
88
|
{
|
|
88
|
-
optimize:
|
|
89
|
+
optimize: false,
|
|
89
90
|
hashDependencies: hashDeps,
|
|
90
91
|
allValidatorHashTypes: hashTypes,
|
|
91
92
|
dependsOnOwnHash: validator.$dependsOnOwnHash,
|
|
92
|
-
parameters: parameters
|
|
93
|
+
parameters: parameters,
|
|
94
|
+
isTestnet: isTestnet
|
|
93
95
|
}
|
|
94
96
|
)
|
|
95
97
|
|
|
@@ -101,8 +103,6 @@ export class DagCompiler {
|
|
|
101
103
|
// optionally assert the own hash is equal to a given hash
|
|
102
104
|
if (expectedHashes && name in expectedHashes) {
|
|
103
105
|
if (expectedHashes[name] != ownHash) {
|
|
104
|
-
console.log(prettyIR)
|
|
105
|
-
|
|
106
106
|
throw new Error(
|
|
107
107
|
`expected hash ${expectedHashes[name]} for validator ${name}, got ${ownHash}`
|
|
108
108
|
)
|
|
@@ -114,11 +114,12 @@ export class DagCompiler {
|
|
|
114
114
|
validator.$sourceCode,
|
|
115
115
|
Array.from(moduleDeps.values()),
|
|
116
116
|
{
|
|
117
|
-
optimize:
|
|
117
|
+
optimize: true,
|
|
118
118
|
hashDependencies: hashDeps,
|
|
119
119
|
allValidatorHashTypes: hashTypes,
|
|
120
120
|
ownHash: validator.$dependsOnOwnHash ? ownHash : undefined,
|
|
121
|
-
parameters: parameters
|
|
121
|
+
parameters: parameters,
|
|
122
|
+
isTestnet: isTestnet
|
|
122
123
|
}
|
|
123
124
|
)
|
|
124
125
|
|
package/src/hl2ts.js
CHANGED
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
existsSync,
|
|
5
|
-
fstat,
|
|
6
5
|
mkdirSync,
|
|
7
6
|
promises,
|
|
8
7
|
readFileSync,
|
|
9
8
|
writeFileSync
|
|
10
9
|
} from "node:fs"
|
|
11
10
|
import { dirname, join, resolve } from "node:path"
|
|
12
|
-
import { Cli,
|
|
11
|
+
import { Cli, EnumOpt, StringOpt } from "@helios-lang/cli-utils"
|
|
12
|
+
import { None } from "@helios-lang/type-utils"
|
|
13
13
|
import { LoadedScriptsWriter } from "./codegen/index.js"
|
|
14
14
|
import { loadCompilerLib } from "./compiler/index.js"
|
|
15
|
-
import { typeCheckFiles
|
|
16
|
-
import { None } from "@helios-lang/type-utils"
|
|
15
|
+
import { typeCheckFiles } from "./compiler/ops.js"
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* @typedef {import("./compiler/CompilerLib.js").CompilerLib} CompilerLib
|
package/types/cast/Cast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/cast/Cast.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/cast/Cast.js"],"names":[],"mappings":"AAucA;;;;;;GAMG;AACH,kGAHW,UAAU,8BASpB;AAlbD;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;IAaI;;;OAGG;IACH,oBAHW,UAAU,UACV,UAAU,EAKpB;IAnBD;;;OAGG;IACH,iBAFU,UAAU,CAEd;IAEN;;;OAGG;IACH,iBAFU,UAAU,CAEd;IAWN;;;OAGG;IACH,mBAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;OAGG;IACH,cAHW,WAAW,GACT,QAAQ,CAIpB;CACJ;uBAhEY,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,qBAAqB,EAAE,UAAU;yBAIxC;IACZ,SAAa,EAAE,OAAO,CAAA;CACnB;8DAMkB,UAAU,KAAK,KAAK,OAAO,EAAE,WAAW,CAAC;;;;6CAOlD,KAAK,OAAO,EAAE,WAAW,CAAC,GAAG,iBAAiB,OAAO,EAAE,WAAW,CAAC"}
|
|
@@ -5,7 +5,7 @@ export type TypeCheckedModule = {
|
|
|
5
5
|
sourceCode: string;
|
|
6
6
|
moduleDepedencies: string[];
|
|
7
7
|
types: {
|
|
8
|
-
[name: string]: import("
|
|
8
|
+
[name: string]: import("@helios-lang/type-utils").TypeSchema;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=TypeCheckedModule.d.ts.map
|
|
@@ -1,64 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
|
6
|
-
* @typedef {{
|
|
7
|
-
* primitiveType: string
|
|
8
|
-
* } | {
|
|
9
|
-
* listItemType: TypeSchema
|
|
10
|
-
* } | {
|
|
11
|
-
* mapKeyType: TypeSchema
|
|
12
|
-
* mapValueType: TypeSchema
|
|
13
|
-
* } | {
|
|
14
|
-
* optionSomeType: TypeSchema
|
|
15
|
-
* } | {
|
|
16
|
-
* structFieldTypes: {
|
|
17
|
-
* name: string
|
|
18
|
-
* type: TypeSchema
|
|
19
|
-
* }[]
|
|
20
|
-
* } | {
|
|
21
|
-
* enumVariantTypes: {
|
|
22
|
-
* name: string,
|
|
23
|
-
* fieldTypes: {
|
|
24
|
-
* name: string
|
|
25
|
-
* type: TypeSchema
|
|
26
|
-
* }[]
|
|
27
|
-
* }[]
|
|
28
|
-
* }} TypeSchema
|
|
2
|
+
* @typedef {import("@helios-lang/type-utils").TypeSchema} TypeSchema
|
|
29
3
|
*/
|
|
30
4
|
/**
|
|
5
|
+
* TODO: handle recursive data structures
|
|
31
6
|
* @param {TypeSchema} schema
|
|
32
7
|
* @returns {[string, string]} - the first entry is the canonical type, the second is the permissive type
|
|
33
8
|
*/
|
|
34
9
|
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
|
-
*/
|
|
41
|
-
export type TypeSchema = {
|
|
42
|
-
primitiveType: string;
|
|
43
|
-
} | {
|
|
44
|
-
listItemType: TypeSchema;
|
|
45
|
-
} | {
|
|
46
|
-
mapKeyType: TypeSchema;
|
|
47
|
-
mapValueType: TypeSchema;
|
|
48
|
-
} | {
|
|
49
|
-
optionSomeType: TypeSchema;
|
|
50
|
-
} | {
|
|
51
|
-
structFieldTypes: {
|
|
52
|
-
name: string;
|
|
53
|
-
type: TypeSchema;
|
|
54
|
-
}[];
|
|
55
|
-
} | {
|
|
56
|
-
enumVariantTypes: {
|
|
57
|
-
name: string;
|
|
58
|
-
fieldTypes: {
|
|
59
|
-
name: string;
|
|
60
|
-
type: TypeSchema;
|
|
61
|
-
}[];
|
|
62
|
-
}[];
|
|
63
|
-
};
|
|
10
|
+
export type TypeSchema = import("@helios-lang/type-utils").TypeSchema;
|
|
64
11
|
//# sourceMappingURL=TypeSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSchema.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeSchema.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"TypeSchema.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeSchema.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,iCAHW,UAAU,GACR,CAAC,MAAM,EAAE,MAAM,CAAC,CAkJ5B;yBAxJY,OAAO,yBAAyB,EAAE,UAAU"}
|
|
@@ -1,6 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
3
|
+
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
4
|
+
* @typedef {import("../codegen/index.js").TypeCheckedModule} TypeCheckedModule
|
|
5
|
+
* @typedef {import("../codegen/index.js").TypeCheckedValidator} TypeCheckedValidator
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {any} ScriptHashType
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{
|
|
12
|
+
* allValidatorHashTypes: {[name: string]: ScriptHashType}
|
|
13
|
+
* hashDependencies: {[name: string]: string}
|
|
14
|
+
* dependsOnOwnHash?: boolean
|
|
15
|
+
* ownHash?: string
|
|
16
|
+
* parameters?: Record<string, UplcData>
|
|
17
|
+
* isTestnet: boolean
|
|
18
|
+
* optimize: boolean
|
|
19
|
+
* }} CompileOptions
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* cborHex: string
|
|
24
|
+
* }} CompileOutput
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {{
|
|
28
|
+
* modules: {[name: string]: TypeCheckedModule}
|
|
29
|
+
* validators: {[name: string]: TypeCheckedValidator}
|
|
30
|
+
* }} TypeCheckOutput
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {{
|
|
34
|
+
* name: string
|
|
35
|
+
* purpose: string
|
|
36
|
+
* sourceCode: string
|
|
37
|
+
* }} SourceDetails
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {{
|
|
41
|
+
* version: string
|
|
42
|
+
* getScriptHashType: (purpose: string) => ScriptHashType
|
|
43
|
+
* typeCheck: (validators: string[], modules: string[]) => ({
|
|
44
|
+
* modules: {[name: string]: TypeCheckedModule},
|
|
45
|
+
* validators: {[name: string]: TypeCheckedValidator}
|
|
46
|
+
* })
|
|
47
|
+
* compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput
|
|
48
|
+
* }} CompilerLib
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {Record<string, string[]>} DagDependencies
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* @param {CompilerLib} lib
|
|
55
|
+
* @param {string[]} validators
|
|
56
|
+
* @returns {{[name: string]: ScriptHashType}}
|
|
57
|
+
*/
|
|
58
|
+
export function getValidatorTypes(lib: CompilerLib, validators: string[]): {
|
|
59
|
+
[name: string]: any;
|
|
60
|
+
};
|
|
61
|
+
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
1
62
|
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
2
63
|
export type TypeCheckedModule = import("../codegen/index.js").TypeCheckedModule;
|
|
3
64
|
export type TypeCheckedValidator = import("../codegen/index.js").TypeCheckedValidator;
|
|
65
|
+
export type ScriptHashType = any;
|
|
4
66
|
export type CompileOptions = {
|
|
5
67
|
allValidatorHashTypes: {
|
|
6
68
|
[name: string]: any;
|
|
@@ -10,12 +72,12 @@ export type CompileOptions = {
|
|
|
10
72
|
};
|
|
11
73
|
dependsOnOwnHash?: boolean | undefined;
|
|
12
74
|
ownHash?: string | undefined;
|
|
13
|
-
parameters?: Record<string,
|
|
75
|
+
parameters?: Record<string, import("@helios-lang/uplc").UplcData> | undefined;
|
|
76
|
+
isTestnet: boolean;
|
|
14
77
|
optimize: boolean;
|
|
15
78
|
};
|
|
16
79
|
export type CompileOutput = {
|
|
17
80
|
cborHex: string;
|
|
18
|
-
prettyIR: string;
|
|
19
81
|
};
|
|
20
82
|
export type TypeCheckOutput = {
|
|
21
83
|
modules: {
|
|
@@ -32,7 +94,7 @@ export type SourceDetails = {
|
|
|
32
94
|
};
|
|
33
95
|
export type CompilerLib = {
|
|
34
96
|
version: string;
|
|
35
|
-
getScriptHashType: (purpose: string) =>
|
|
97
|
+
getScriptHashType: (purpose: string) => ScriptHashType;
|
|
36
98
|
typeCheck: (validators: string[], modules: string[]) => {
|
|
37
99
|
modules: {
|
|
38
100
|
[name: string]: import("../codegen/TypeCheckedModule.js").TypeCheckedModule;
|
|
@@ -43,4 +105,5 @@ export type CompilerLib = {
|
|
|
43
105
|
};
|
|
44
106
|
compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput;
|
|
45
107
|
};
|
|
108
|
+
export type DagDependencies = Record<string, string[]>;
|
|
46
109
|
//# sourceMappingURL=CompilerLib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;GAUG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,uCAJW,WAAW,cACX,MAAM,EAAE;;EAUlB;uBAvEY,OAAO,mBAAmB,EAAE,QAAQ;kCACpC,OAAO,qBAAqB,EAAE,UAAU;gCACxC,OAAO,qBAAqB,EAAE,iBAAiB;mCAC/C,OAAO,qBAAqB,EAAE,oBAAoB;6BAIlD,GAAG;;;;;;;;;;;eAUA,OAAO;cACR,OAAO;;4BAKT;IACZ,OAAW,EAAE,MAAM,CAAA;CAChB;;;;;;;;;4BAWS;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB;;aAKU,MAAM;iCACc,MAAM,KAAK,cAAc;4BAC9B,MAAM,EAAE,WAAW,MAAM,EAAE;;;;;;;;oBAInC,MAAM,WAAW,MAAM,EAAE,WAAW,cAAc,KAAK,aAAa;;8BAK5E,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
2
3
|
* @typedef {import("../codegen/index.js").TypeCheckedModule} TypeCheckedModule
|
|
3
4
|
* @typedef {import("../codegen/index.js").TypeCheckedValidator} TypeCheckedValidator
|
|
4
|
-
* @typedef {import("../codegen/index.js").TypeSchema}
|
|
5
|
+
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
5
6
|
* @typedef {import("./CompilerLib.js").CompileOptions} CompileOptions
|
|
6
7
|
* @typedef {import("./CompilerLib.js").CompileOutput} CompileOutput
|
|
7
8
|
* @typedef {import("./CompilerLib.js").CompilerLib} CompilerLib
|
|
9
|
+
* @typedef {import("./CompilerLib.js").DagDependencies} DagDependencies
|
|
10
|
+
* @typedef {import("./CompilerLib.js").ScriptHashType} ScriptHashType
|
|
8
11
|
* @typedef {import("./CompilerLib.js").SourceDetails} SourceDetails
|
|
9
12
|
* @typedef {import("./CompilerLib.js").TypeCheckOutput} TypeCheckOutput
|
|
10
13
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {{
|
|
13
|
-
* [name: string]: string[]
|
|
14
|
-
* }} DagDependencies
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {{
|
|
18
|
-
* }} ScriptHashType
|
|
19
|
-
*/
|
|
20
14
|
/**
|
|
21
15
|
* @typedef {{
|
|
22
16
|
* includes: (m: string) => boolean
|
|
@@ -85,32 +79,32 @@
|
|
|
85
79
|
* type: string
|
|
86
80
|
* } | {
|
|
87
81
|
* type: "List"
|
|
88
|
-
* itemType:
|
|
82
|
+
* itemType: TypeSchema16
|
|
89
83
|
* } | {
|
|
90
84
|
* type: "Map"
|
|
91
|
-
* keyType:
|
|
92
|
-
* valueType:
|
|
85
|
+
* keyType: TypeSchema16
|
|
86
|
+
* valueType: TypeSchema16
|
|
93
87
|
* } | {
|
|
94
88
|
* type: "Option"
|
|
95
|
-
* someType:
|
|
89
|
+
* someType: TypeSchema16
|
|
96
90
|
* } | {
|
|
97
91
|
* type: "Struct"
|
|
98
|
-
* fieldTypes:
|
|
92
|
+
* fieldTypes: NamedTypeSchema16[]
|
|
99
93
|
* } | {
|
|
100
94
|
* type: "Enum"
|
|
101
|
-
* variantTypes: {name: string, fieldTypes:
|
|
102
|
-
* }}
|
|
95
|
+
* variantTypes: {name: string, fieldTypes: NamedTypeSchema16[]}[]
|
|
96
|
+
* }} TypeSchema16
|
|
103
97
|
*/
|
|
104
98
|
/**
|
|
105
99
|
* @typedef {{
|
|
106
100
|
* name: string
|
|
107
|
-
* } &
|
|
101
|
+
* } & TypeSchema16} NamedTypeSchema16
|
|
108
102
|
*/
|
|
109
103
|
/**
|
|
110
104
|
* @typedef {{
|
|
111
105
|
* inputType: string
|
|
112
106
|
* outputType: string
|
|
113
|
-
* internalType:
|
|
107
|
+
* internalType: TypeSchema16
|
|
114
108
|
* }} TypeDetails
|
|
115
109
|
*/
|
|
116
110
|
/**
|
|
@@ -164,7 +158,7 @@ export class CompilerLib_v0_16 implements CompilerLib {
|
|
|
164
158
|
* @param {CompileOptions} options
|
|
165
159
|
* @returns {Map<string, IR>}
|
|
166
160
|
*/
|
|
167
|
-
private
|
|
161
|
+
private genExtraIRDefs;
|
|
168
162
|
/**
|
|
169
163
|
* @private
|
|
170
164
|
* @param {string[]} validators
|
|
@@ -189,8 +183,8 @@ export class CompilerLib_v0_16 implements CompilerLib {
|
|
|
189
183
|
private buildDagDependencies;
|
|
190
184
|
/**
|
|
191
185
|
* @private
|
|
192
|
-
* @param {
|
|
193
|
-
* @returns {
|
|
186
|
+
* @param {TypeSchema16} it
|
|
187
|
+
* @returns {TypeSchema}
|
|
194
188
|
*/
|
|
195
189
|
private convertInternalType;
|
|
196
190
|
/**
|
|
@@ -198,7 +192,7 @@ export class CompilerLib_v0_16 implements CompilerLib {
|
|
|
198
192
|
* TODO: make sure it works for all structs and enums
|
|
199
193
|
* @private
|
|
200
194
|
* @param {DataType} dt
|
|
201
|
-
* @returns {
|
|
195
|
+
* @returns {TypeSchema}
|
|
202
196
|
*/
|
|
203
197
|
private getInternalTypeDetails;
|
|
204
198
|
/**
|
|
@@ -208,19 +202,24 @@ export class CompilerLib_v0_16 implements CompilerLib {
|
|
|
208
202
|
* @returns {Record<string, Record<string, DataType>>}}
|
|
209
203
|
*/
|
|
210
204
|
private getProgramTypes;
|
|
205
|
+
/**
|
|
206
|
+
* @private
|
|
207
|
+
* @param {any} program
|
|
208
|
+
* @param {Option<Record<string, UplcData>>} parameters
|
|
209
|
+
*/
|
|
210
|
+
private setParameters;
|
|
211
211
|
}
|
|
212
|
+
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
212
213
|
export type TypeCheckedModule = import("../codegen/index.js").TypeCheckedModule;
|
|
213
214
|
export type TypeCheckedValidator = import("../codegen/index.js").TypeCheckedValidator;
|
|
214
|
-
export type
|
|
215
|
+
export type TypeSchema = import("../codegen/index.js").TypeSchema;
|
|
215
216
|
export type CompileOptions = import("./CompilerLib.js").CompileOptions;
|
|
216
217
|
export type CompileOutput = import("./CompilerLib.js").CompileOutput;
|
|
217
218
|
export type CompilerLib = import("./CompilerLib.js").CompilerLib;
|
|
219
|
+
export type DagDependencies = import("./CompilerLib.js").DagDependencies;
|
|
220
|
+
export type ScriptHashType = import("./CompilerLib.js").ScriptHashType;
|
|
218
221
|
export type SourceDetails = import("./CompilerLib.js").SourceDetails;
|
|
219
222
|
export type TypeCheckOutput = import("./CompilerLib.js").TypeCheckOutput;
|
|
220
|
-
export type DagDependencies = {
|
|
221
|
-
[name: string]: string[];
|
|
222
|
-
};
|
|
223
|
-
export type ScriptHashType = {};
|
|
224
223
|
export type IR = {
|
|
225
224
|
includes: (m: string) => boolean;
|
|
226
225
|
};
|
|
@@ -251,7 +250,7 @@ export type Program = {
|
|
|
251
250
|
mainArgTypes: DataType[];
|
|
252
251
|
throwErrors(): any;
|
|
253
252
|
evalTypes(validatorTypes: {
|
|
254
|
-
[name: string]:
|
|
253
|
+
[name: string]: any;
|
|
255
254
|
}): TopScope;
|
|
256
255
|
};
|
|
257
256
|
export type TopScope = {
|
|
@@ -266,35 +265,35 @@ export type Scope = {
|
|
|
266
265
|
export type DataType = {
|
|
267
266
|
typeDetails?: TypeDetails;
|
|
268
267
|
};
|
|
269
|
-
export type
|
|
268
|
+
export type TypeSchema16 = {
|
|
270
269
|
type: string;
|
|
271
270
|
} | {
|
|
272
271
|
type: "List";
|
|
273
|
-
itemType:
|
|
272
|
+
itemType: TypeSchema16;
|
|
274
273
|
} | {
|
|
275
274
|
type: "Map";
|
|
276
|
-
keyType:
|
|
277
|
-
valueType:
|
|
275
|
+
keyType: TypeSchema16;
|
|
276
|
+
valueType: TypeSchema16;
|
|
278
277
|
} | {
|
|
279
278
|
type: "Option";
|
|
280
|
-
someType:
|
|
279
|
+
someType: TypeSchema16;
|
|
281
280
|
} | {
|
|
282
281
|
type: "Struct";
|
|
283
|
-
fieldTypes:
|
|
282
|
+
fieldTypes: NamedTypeSchema16[];
|
|
284
283
|
} | {
|
|
285
284
|
type: "Enum";
|
|
286
285
|
variantTypes: {
|
|
287
286
|
name: string;
|
|
288
|
-
fieldTypes:
|
|
287
|
+
fieldTypes: NamedTypeSchema16[];
|
|
289
288
|
}[];
|
|
290
289
|
};
|
|
291
|
-
export type
|
|
290
|
+
export type NamedTypeSchema16 = {
|
|
292
291
|
name: string;
|
|
293
|
-
} &
|
|
292
|
+
} & TypeSchema16;
|
|
294
293
|
export type TypeDetails = {
|
|
295
294
|
inputType: string;
|
|
296
295
|
outputType: string;
|
|
297
|
-
internalType:
|
|
296
|
+
internalType: TypeSchema16;
|
|
298
297
|
};
|
|
299
298
|
export type UserTypes = {};
|
|
300
299
|
//# sourceMappingURL=CompilerLib_v0_16.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerLib_v0_16.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib_v0_16.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompilerLib_v0_16.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib_v0_16.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAE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