@helios-lang/contract-utils 0.1.20 → 0.1.23
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/multi-validator/README.md +5 -0
- package/examples/{spending → multi-validator}/contract.js +7 -2
- package/examples/{spending → multi-validator}/index.d.ts +1 -1
- package/examples/{spending → multi-validator}/index.js +3 -3
- package/examples/{spending → multi-validator}/spending.hl +3 -2
- package/package.json +5 -5
- package/src/{runtime → cast}/Cast.js +31 -8
- package/src/cast/index.js +12 -0
- package/src/codegen/LoadedModule.js +9 -0
- package/src/codegen/{TypescriptWriter.js → LoadedScriptsWriter.js} +117 -107
- package/src/codegen/LoadedValidator.js +23 -0
- package/src/codegen/{Module.js → TypeCheckedModule.js} +3 -3
- package/src/codegen/{Validator.js → TypeCheckedValidator.js} +5 -8
- package/src/codegen/TypeSchema.js +4 -0
- package/src/codegen/index.js +5 -4
- package/src/compiler/CompilerLib.js +51 -0
- package/src/{lib/Libg_v0_16.js → compiler/CompilerLib_v0_16.js} +243 -255
- package/src/compiler/index.js +6 -0
- package/src/compiler/ops.js +137 -0
- package/src/context/ContractContext.js +78 -0
- package/src/context/ContractContextBuilder.js +69 -0
- package/src/context/DagCompiler.js +229 -0
- package/src/context/index.js +1 -0
- package/src/hl2ts.js +31 -59
- package/src/index.js +12 -1
- package/types/cast/Cast.d.ts +32 -0
- package/types/cast/Cast.d.ts.map +1 -0
- package/types/cast/PermissiveType.d.ts +3 -0
- package/types/cast/PermissiveType.d.ts.map +1 -0
- package/types/cast/StrictType.d.ts +3 -0
- package/types/cast/StrictType.d.ts.map +1 -0
- package/types/cast/index.d.ts +5 -0
- package/types/cast/index.d.ts.map +1 -0
- package/types/codegen/LoadedModule.d.ts +6 -0
- package/types/codegen/LoadedModule.d.ts.map +1 -0
- package/types/codegen/LoadedScriptsWriter.d.ts +56 -0
- package/types/codegen/LoadedScriptsWriter.d.ts.map +1 -0
- package/types/codegen/LoadedValidator.d.ts +16 -0
- package/types/codegen/LoadedValidator.d.ts.map +1 -0
- package/types/codegen/TypeCheckedModule.d.ts +11 -0
- package/types/codegen/TypeCheckedModule.d.ts.map +1 -0
- package/types/codegen/TypeCheckedValidator.d.ts +8 -0
- package/types/codegen/TypeCheckedValidator.d.ts.map +1 -0
- package/types/codegen/TypeSchema.d.ts +10 -0
- package/types/codegen/TypeSchema.d.ts.map +1 -1
- package/types/codegen/TypescriptWriter.d.ts +4 -4
- package/types/codegen/Validator.d.ts +1 -1
- package/types/codegen/index.d.ts +5 -4
- package/types/codegen/index.d.ts.map +1 -1
- package/types/compiler/CompilerLib.d.ts +45 -0
- package/types/compiler/CompilerLib.d.ts.map +1 -0
- package/types/compiler/CompilerLib_v0_16.d.ts +270 -0
- package/types/compiler/CompilerLib_v0_16.d.ts.map +1 -0
- package/types/compiler/index.d.ts +4 -0
- package/types/compiler/index.d.ts.map +1 -0
- package/types/compiler/ops.d.ts +24 -0
- package/types/compiler/ops.d.ts.map +1 -0
- package/types/context/ContractContext.d.ts +23 -0
- package/types/context/ContractContext.d.ts.map +1 -0
- package/types/context/ContractContextBuilder.d.ts +53 -0
- package/types/context/ContractContextBuilder.d.ts.map +1 -0
- package/types/context/DagCompiler.d.ts +64 -0
- package/types/context/DagCompiler.d.ts.map +1 -0
- package/types/context/index.d.ts +2 -0
- package/types/context/index.d.ts.map +1 -0
- package/types/hl2ts.d.ts +8 -4
- package/types/hl2ts.d.ts.map +1 -1
- package/types/index.d.ts +4 -1
- package/types/index.d.ts.map +1 -1
- package/types/lib/Lib.d.ts +13 -71
- package/types/lib/Lib.d.ts.map +1 -1
- package/types/lib/Libg_v0_16.d.ts +53 -52
- package/types/lib/Libg_v0_16.d.ts.map +1 -1
- package/types/lib/index.d.ts +0 -1
- package/types/lib/index.d.ts.map +1 -1
- package/types/lib/load.d.ts +1 -7
- package/types/lib/load.d.ts.map +1 -1
- package/types/runtime/ContractContext.d.ts +22 -43
- package/types/runtime/ContractContext.d.ts.map +1 -1
- package/types/runtime/ContractContextBuilder.d.ts +15 -123
- package/types/runtime/ContractContextBuilder.d.ts.map +1 -1
- package/types/runtime/DagCompiler.d.ts +64 -0
- package/types/runtime/DagCompiler.d.ts.map +1 -0
- package/types/runtime/PermissiveType.d.ts +1 -1
- package/types/runtime/StrictType.d.ts +1 -1
- package/types/runtime/index.d.ts +0 -2
- package/src/codegen/Writer.js +0 -37
- package/src/lib/Lib.js +0 -56
- package/src/lib/index.js +0 -6
- package/src/lib/load.js +0 -26
- package/src/runtime/ContractContext.js +0 -35
- package/src/runtime/ContractContextBuilder.js +0 -340
- package/src/runtime/index.js +0 -3
- /package/examples/{spending → multi-validator}/minting.hl +0 -0
- /package/examples/{spending → multi-validator}/package-lock.json +0 -0
- /package/examples/{spending → multi-validator}/package.json +0 -0
- /package/examples/{spending → multi-validator}/utils.hl +0 -0
- /package/src/{runtime → cast}/PermissiveType.js +0 -0
- /package/src/{runtime → cast}/StrictType.js +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../codegen/LoadedModule.js").LoadedModule} LoadedModule
|
|
3
|
+
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
4
|
+
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @template {{[name: string]: LoadedValidator}} T
|
|
8
|
+
* @typedef {import("./ContractContext.js").ContractContext<T>} ContractContext
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @template {{[name: string]: LoadedValidator}} T
|
|
12
|
+
*/
|
|
13
|
+
export class ContractContextBuilder<T extends {
|
|
14
|
+
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
15
|
+
}> {
|
|
16
|
+
/**
|
|
17
|
+
* @returns {ContractContextBuilder<{}>}
|
|
18
|
+
*/
|
|
19
|
+
static "new"(): ContractContextBuilder<{}>;
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
* @param {T} validators
|
|
23
|
+
*/
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @readonly
|
|
28
|
+
* @type {T}
|
|
29
|
+
*/
|
|
30
|
+
private readonly validators;
|
|
31
|
+
/**
|
|
32
|
+
* @template {LoadedValidator} V
|
|
33
|
+
* @param {V} validator
|
|
34
|
+
* @returns {ContractContextBuilder<T & {
|
|
35
|
+
* [K in V["$name"]]: V
|
|
36
|
+
* }>}
|
|
37
|
+
*/
|
|
38
|
+
with<V extends import("./DagCompiler.js").LoadedValidator>(validator: V): ContractContextBuilder<T & { [K in V["$name"]]: V; }>;
|
|
39
|
+
/**
|
|
40
|
+
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
41
|
+
* @returns {ContractContext<T>}
|
|
42
|
+
*/
|
|
43
|
+
build(expectedHashes?: Option<{
|
|
44
|
+
[name: string]: string;
|
|
45
|
+
}>): ContractContext<T>;
|
|
46
|
+
}
|
|
47
|
+
export type LoadedModule = import("../codegen/LoadedModule.js").LoadedModule;
|
|
48
|
+
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
49
|
+
export type CompilerLib = import("../compiler/index.js").CompilerLib;
|
|
50
|
+
export type ContractContext<T extends {
|
|
51
|
+
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
52
|
+
}> = import("./ContractContext.js").ContractContext<T>;
|
|
53
|
+
//# sourceMappingURL=ContractContextBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AACH;;;IAgBI;;OAEG;IACH,gBAFa,uBAAuB,EAAE,CAAC,CAItC;IAbD;;;OAGG;IACH,sBAEC;IAbD;;;;OAIG;IACH,4BAAU;IAiBV;;;;;;OAMG;IACH,gIAKC;IAED;;;OAGG;IACH;;SAFa,gBAAgB,CAAC,CAAC,CAU9B;CACJ;2BA/DY,OAAO,4BAA4B,EAAE,YAAY;8BACjD,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;;;KAK1C,OAAO,sBAAsB,EAAE,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {LoadedValidator} validator
|
|
3
|
+
* @returns {string[]}
|
|
4
|
+
*/
|
|
5
|
+
export function getModuleDependencies(validator: LoadedValidator): string[];
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
8
|
+
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
9
|
+
* @typedef {import("./ContractContext.js").AnyContractValidatorHash} AnyContractValidatorHash
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Compiles a set of validators that depend on eachothers hashes (forming a Directed Acyclical Graph)
|
|
13
|
+
*/
|
|
14
|
+
export class DagCompiler {
|
|
15
|
+
/**
|
|
16
|
+
* @param {CompilerLib} lib
|
|
17
|
+
*/
|
|
18
|
+
constructor(lib: CompilerLib);
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
* @readonly
|
|
22
|
+
* @type {CompilerLib}
|
|
23
|
+
*/
|
|
24
|
+
private readonly lib;
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @readonly
|
|
28
|
+
* @type {{[name: string]: AnyContractValidatorHash}}
|
|
29
|
+
*/
|
|
30
|
+
private readonly cache;
|
|
31
|
+
/**
|
|
32
|
+
* @param {LoadedValidator[]} validators
|
|
33
|
+
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
34
|
+
* @returns {{[name: string]: AnyContractValidatorHash}}
|
|
35
|
+
*/
|
|
36
|
+
build(validators: LoadedValidator[], expectedHashes?: Option<{
|
|
37
|
+
[name: string]: string;
|
|
38
|
+
}>): {
|
|
39
|
+
[name: string]: import("./ContractContext.js").AnyContractValidatorHash;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* @param {LoadedValidator} validator
|
|
44
|
+
* @param {UplcProgramV2} program
|
|
45
|
+
* @param {string} hash - although this can be derived from `program`, reuse this to save some effort
|
|
46
|
+
*/
|
|
47
|
+
private addToCache;
|
|
48
|
+
/**
|
|
49
|
+
* @private
|
|
50
|
+
* @param {LoadedValidator} validator
|
|
51
|
+
* @returns {{[name: string]: string}} - TODO: do we really need the purpose?
|
|
52
|
+
*/
|
|
53
|
+
private getHashDependencies;
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
* @param {LoadedValidator[]} validators
|
|
57
|
+
* @returns {{[name: string]: any}}
|
|
58
|
+
*/
|
|
59
|
+
private getHashTypes;
|
|
60
|
+
}
|
|
61
|
+
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
62
|
+
export type CompilerLib = import("../compiler/index.js").CompilerLib;
|
|
63
|
+
export type AnyContractValidatorHash = import("./ContractContext.js").AnyContractValidatorHash;
|
|
64
|
+
//# sourceMappingURL=DagCompiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DagCompiler.d.ts","sourceRoot":"","sources":["../../src/context/DagCompiler.js"],"names":[],"mappings":"AA4MA;;;GAGG;AACH,iDAHW,eAAe,GACb,MAAM,EAAE,CAsBpB;AA3ND;;;;GAIG;AAEH;;GAEG;AACH;IAeI;;OAEG;IACH,iBAFW,WAAW,EAKrB;IApBD;;;;OAIG;IACH,qBAAG;IAEH;;;;OAIG;IACH,uBAAK;IAUL;;;;OAIG;IACH,kBAJW,eAAe,EAAE;;;;MAkF3B;IAED;;;;;OAKG;IACH,mBA6BC;IAED;;;;OAIG;IACH,4BAoBC;IAED;;;;OAIG;IACH,qBAMC;CACJ;8BAhMY,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;uCAC1C,OAAO,sBAAsB,EAAE,wBAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.js"],"names":[],"mappings":""}
|
package/types/hl2ts.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
2
|
+
export type CompilerLib = import("./compiler/CompilerLib.js").CompilerLib;
|
|
3
|
+
export type ModuleDetails = import("./compiler/CompilerLib.js").TypeCheckedModule;
|
|
4
|
+
export type ValidatorDetails = import("./compiler/CompilerLib.js").TypeCheckedValidator;
|
|
5
|
+
export type SourceDetails = {
|
|
6
|
+
name: string;
|
|
7
|
+
purpose: string;
|
|
8
|
+
sourceCode: string;
|
|
9
|
+
};
|
|
6
10
|
//# sourceMappingURL=hl2ts.d.ts.map
|
package/types/hl2ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hl2ts.d.ts","sourceRoot":"","sources":["../src/hl2ts.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"hl2ts.d.ts","sourceRoot":"","sources":["../src/hl2ts.js"],"names":[],"mappings":";0BAUa,OAAO,2BAA2B,EAAE,WAAW;4BAC/C,OAAO,2BAA2B,EAAE,iBAAiB;+BACrD,OAAO,2BAA2B,EAAE,oBAAoB;4BAIxD;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { Cast
|
|
1
|
+
export { Cast } from "./cast/index.js";
|
|
2
|
+
export { ContractContextBuilder } from "./context/index.js";
|
|
3
|
+
export type StrictType<C extends import("./cast/Cast.js").Cast<any, any>> = import("./cast/index.js").StrictType<C>;
|
|
4
|
+
export type PermissiveType<C extends import("./cast/Cast.js").Cast<any, any>> = import("./cast/index.js").PermissiveType<C>;
|
|
2
5
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;4EAKa,OAAO,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;gFAKvC,OAAO,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC"}
|
package/types/lib/Lib.d.ts
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* otherValidators: {[name: string]: {purpose: string, hash: string}},
|
|
5
|
-
* dependsOnOwnHash?: boolean,
|
|
6
|
-
* ownHash?: string,
|
|
7
|
-
* optimize: boolean
|
|
8
|
-
* }} CompileOptions
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {{
|
|
12
|
-
* cborHex: string
|
|
13
|
-
* prettyIR: string
|
|
14
|
-
* }} CompileOutput
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {{
|
|
18
|
-
* isMainnet?: boolean
|
|
19
|
-
* checkCasts?: boolean
|
|
20
|
-
* moduleOrder?: string[]
|
|
21
|
-
* }} LibOptions
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {{
|
|
25
|
-
* version: string
|
|
26
|
-
* getValidatorType: (purpose: string) => any
|
|
27
|
-
* typeCheck: (validators: {[name: string]: SourceDetails}, modules: {[name: string]: SourceDetails}) => ({
|
|
28
|
-
* modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}})
|
|
29
|
-
* compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput
|
|
30
|
-
* }} Lib
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
34
|
-
* @typedef {import("../codegen/index.js").Module} ModuleDetails
|
|
35
|
-
* @typedef {import("../codegen/index.js").Validator} ValidatorDetails
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {{
|
|
39
|
-
* name: string
|
|
40
|
-
* purpose: string
|
|
41
|
-
* sourceCode: string
|
|
42
|
-
* }} SourceDetails
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
* @param {{VERSION: string}} lib
|
|
46
|
-
* @returns {number[]}
|
|
47
|
-
*/
|
|
48
|
-
export function getVersion(lib: {
|
|
49
|
-
VERSION: string;
|
|
50
|
-
}): number[];
|
|
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;
|
|
51
4
|
export type CompileOptions = {
|
|
52
|
-
|
|
5
|
+
allValidatorHashTypes: {
|
|
53
6
|
[name: string]: any;
|
|
54
7
|
};
|
|
55
|
-
|
|
56
|
-
[name: string]:
|
|
57
|
-
purpose: string;
|
|
58
|
-
hash: string;
|
|
59
|
-
};
|
|
8
|
+
hashDependencies: {
|
|
9
|
+
[name: string]: string;
|
|
60
10
|
};
|
|
61
11
|
dependsOnOwnHash?: boolean | undefined;
|
|
62
12
|
ownHash?: string | undefined;
|
|
@@ -66,34 +16,26 @@ export type CompileOutput = {
|
|
|
66
16
|
cborHex: string;
|
|
67
17
|
prettyIR: string;
|
|
68
18
|
};
|
|
69
|
-
export type
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
19
|
+
export type SourceDetails = {
|
|
20
|
+
name: string;
|
|
21
|
+
purpose: string;
|
|
22
|
+
sourceCode: string;
|
|
73
23
|
};
|
|
74
24
|
export type Lib = {
|
|
75
25
|
version: string;
|
|
76
|
-
|
|
26
|
+
getScriptHashType: (purpose: string) => any;
|
|
77
27
|
typeCheck: (validators: {
|
|
78
28
|
[name: string]: SourceDetails;
|
|
79
29
|
}, modules: {
|
|
80
30
|
[name: string]: SourceDetails;
|
|
81
31
|
}) => {
|
|
82
32
|
modules: {
|
|
83
|
-
[name: string]: import("../codegen/
|
|
33
|
+
[name: string]: import("../codegen/TypeCheckedModule.js").TypeCheckedModule;
|
|
84
34
|
};
|
|
85
35
|
validators: {
|
|
86
|
-
[name: string]: import("../codegen/
|
|
36
|
+
[name: string]: import("../codegen/TypeCheckedValidator.js").TypeCheckedValidator;
|
|
87
37
|
};
|
|
88
38
|
};
|
|
89
39
|
compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput;
|
|
90
40
|
};
|
|
91
|
-
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
92
|
-
export type ModuleDetails = import("../codegen/index.js").Module;
|
|
93
|
-
export type ValidatorDetails = import("../codegen/index.js").Validator;
|
|
94
|
-
export type SourceDetails = {
|
|
95
|
-
name: string;
|
|
96
|
-
purpose: string;
|
|
97
|
-
sourceCode: string;
|
|
98
|
-
};
|
|
99
41
|
//# sourceMappingURL=Lib.d.ts.map
|
package/types/lib/Lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lib.d.ts","sourceRoot":"","sources":["../../src/lib/Lib.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Lib.d.ts","sourceRoot":"","sources":["../../src/lib/Lib.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;4BAIS;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;CACnB;;aAKU,MAAM;iCACc,MAAM,KAAK,GAAG;;;;;;;;;;;;;oBAK3B,MAAM,WAAW,MAAM,EAAE,WAAW,cAAc,KAAK,aAAa"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import("../codegen/index.js").
|
|
3
|
-
* @typedef {import("../codegen/index.js").
|
|
2
|
+
* @typedef {import("../codegen/index.js").TypeCheckedModule} ModuleDetails
|
|
3
|
+
* @typedef {import("../codegen/index.js").TypeCheckedValidator} ValidatorDetails
|
|
4
4
|
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
5
5
|
* @typedef {import("./Lib.js").CompileOptions} CompileOptions
|
|
6
6
|
* @typedef {import("./Lib.js").CompileOutput} CompileOutput
|
|
7
7
|
* @typedef {import("./Lib.js").Lib} Lib
|
|
8
|
-
* @typedef {import("./Lib.js").LibOptions} LibOptions
|
|
9
8
|
* @typedef {import("./Lib.js").SourceDetails} SourceDetails
|
|
10
9
|
*/
|
|
11
10
|
/**
|
|
@@ -15,7 +14,7 @@
|
|
|
15
14
|
*/
|
|
16
15
|
/**
|
|
17
16
|
* @typedef {{
|
|
18
|
-
* }}
|
|
17
|
+
* }} ScriptHashType
|
|
19
18
|
*/
|
|
20
19
|
/**
|
|
21
20
|
* @typedef {{
|
|
@@ -100,15 +99,8 @@
|
|
|
100
99
|
export class Lib_v0_16 implements Lib {
|
|
101
100
|
/**
|
|
102
101
|
* @param {any} lib
|
|
103
|
-
* @param {LibOptions} options
|
|
104
102
|
*/
|
|
105
|
-
constructor(lib: any
|
|
106
|
-
/**
|
|
107
|
-
* @private
|
|
108
|
-
* @readonly
|
|
109
|
-
* @type {LibOptions}
|
|
110
|
-
*/
|
|
111
|
-
private readonly options;
|
|
103
|
+
constructor(lib: any);
|
|
112
104
|
lib: any;
|
|
113
105
|
/**
|
|
114
106
|
* @type {string}
|
|
@@ -116,83 +108,92 @@ export class Lib_v0_16 implements Lib {
|
|
|
116
108
|
get version(): string;
|
|
117
109
|
/**
|
|
118
110
|
* @param {string} purpose
|
|
119
|
-
* @returns {
|
|
111
|
+
* @returns {ScriptHashType}
|
|
112
|
+
*/
|
|
113
|
+
getScriptHashType(purpose: string): ScriptHashType;
|
|
114
|
+
/**
|
|
115
|
+
* @param {{[name: string]: SourceDetails}} validators
|
|
116
|
+
* @param {{[name: string]: SourceDetails}} modules
|
|
117
|
+
* @returns {{modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}}
|
|
118
|
+
*/
|
|
119
|
+
typeCheck(validators: {
|
|
120
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
121
|
+
}, modules: {
|
|
122
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
123
|
+
}): {
|
|
124
|
+
modules: {
|
|
125
|
+
[name: string]: import("./Lib.js").TypeCheckedModule;
|
|
126
|
+
};
|
|
127
|
+
validators: {
|
|
128
|
+
[name: string]: import("./Lib.js").TypeCheckedValidator;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Generate additional IR definitions
|
|
133
|
+
* * dependency on own precalculated hash (eg. unoptimized program should use hash of optimized program)
|
|
134
|
+
* * dependency on own hash through methods defined on the ScriptContext
|
|
135
|
+
* * dependency on hashes of other validators
|
|
136
|
+
* @private
|
|
137
|
+
* @param {string} name - name of the validator being compiled
|
|
138
|
+
* @param {string} purpose - purpose the validator being compiled
|
|
139
|
+
* @param {number} nPosParams
|
|
140
|
+
* @param {CompileOptions} options
|
|
141
|
+
* @returns {Map<string, IR>}
|
|
142
|
+
*/
|
|
143
|
+
private generateExtraIRDefinitions;
|
|
144
|
+
/**
|
|
145
|
+
* @param {string} main
|
|
146
|
+
* @param {string[]} modules
|
|
147
|
+
* @param {CompileOptions} options
|
|
148
|
+
* @returns {CompileOutput}
|
|
120
149
|
*/
|
|
121
|
-
|
|
150
|
+
compile(main: string, modules: string[], options: CompileOptions): CompileOutput;
|
|
122
151
|
/**
|
|
123
152
|
* @private
|
|
124
153
|
* @param {SourceDetails[]} validators
|
|
125
154
|
* @param {SourceDetails[]} modules
|
|
126
|
-
* @param {{[name: string]:
|
|
155
|
+
* @param {{[name: string]: ScriptHashType}} validatorTypes
|
|
127
156
|
* @returns {Program[]}
|
|
128
157
|
*/
|
|
129
158
|
private createPrograms;
|
|
130
159
|
/**
|
|
131
160
|
* @private
|
|
132
161
|
* @param {Program} program
|
|
133
|
-
* @param {{[name: string]:
|
|
162
|
+
* @param {{[name: string]: ScriptHashType}} validatorTypes
|
|
134
163
|
* @returns {IR}
|
|
135
164
|
*/
|
|
136
165
|
private toTestIR;
|
|
137
166
|
/**
|
|
138
167
|
* @private
|
|
139
168
|
* @param {Program[]} validators
|
|
140
|
-
* @param {{[name: string]:
|
|
169
|
+
* @param {{[name: string]: ScriptHashType}} validatorTypes
|
|
141
170
|
* @returns {DagDependencies}
|
|
142
171
|
*/
|
|
143
172
|
private buildDagDependencies;
|
|
144
173
|
/**
|
|
145
|
-
* @
|
|
146
|
-
* @param {{[name: string]: SourceDetails}} modules
|
|
147
|
-
* @returns {{modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}}
|
|
148
|
-
*/
|
|
149
|
-
typeCheck(validators: {
|
|
150
|
-
[name: string]: import("./Lib.js").SourceDetails;
|
|
151
|
-
}, modules: {
|
|
152
|
-
[name: string]: import("./Lib.js").SourceDetails;
|
|
153
|
-
}): {
|
|
154
|
-
modules: {
|
|
155
|
-
[name: string]: import("./Lib.js").ModuleDetails;
|
|
156
|
-
};
|
|
157
|
-
validators: {
|
|
158
|
-
[name: string]: import("./Lib.js").ValidatorDetails;
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
174
|
+
* @private
|
|
162
175
|
* @param {TypeSchema} it
|
|
163
176
|
* @returns {InternalTypeDetails}
|
|
164
177
|
*/
|
|
165
|
-
convertInternalType
|
|
178
|
+
private convertInternalType;
|
|
166
179
|
/**
|
|
180
|
+
* @private
|
|
167
181
|
* @param {DataType} dt
|
|
168
182
|
* @returns {InternalTypeDetails}
|
|
169
183
|
*/
|
|
170
|
-
getInternalTypeDetails
|
|
171
|
-
/**
|
|
172
|
-
* @param {string[]} modules
|
|
173
|
-
* @returns {string[]}
|
|
174
|
-
*/
|
|
175
|
-
sortModules(modules: string[]): string[];
|
|
176
|
-
/**
|
|
177
|
-
* @param {string} main
|
|
178
|
-
* @param {string[]} modules
|
|
179
|
-
* @param {CompileOptions} options
|
|
180
|
-
* @returns {CompileOutput}
|
|
181
|
-
*/
|
|
182
|
-
compile(main: string, modules: string[], options: CompileOptions): CompileOutput;
|
|
184
|
+
private getInternalTypeDetails;
|
|
183
185
|
}
|
|
184
|
-
export type ModuleDetails = import("../codegen/index.js").
|
|
185
|
-
export type ValidatorDetails = import("../codegen/index.js").
|
|
186
|
+
export type ModuleDetails = import("../codegen/index.js").TypeCheckedModule;
|
|
187
|
+
export type ValidatorDetails = import("../codegen/index.js").TypeCheckedValidator;
|
|
186
188
|
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
187
189
|
export type CompileOptions = import("./Lib.js").CompileOptions;
|
|
188
190
|
export type CompileOutput = import("./Lib.js").CompileOutput;
|
|
189
191
|
export type Lib = import("./Lib.js").Lib;
|
|
190
|
-
export type LibOptions = import("./Lib.js").LibOptions;
|
|
191
192
|
export type SourceDetails = import("./Lib.js").SourceDetails;
|
|
192
193
|
export type DagDependencies = {
|
|
193
194
|
[name: string]: string[];
|
|
194
195
|
};
|
|
195
|
-
export type
|
|
196
|
+
export type ScriptHashType = {};
|
|
196
197
|
export type IR = {
|
|
197
198
|
includes: (m: string) => boolean;
|
|
198
199
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Libg_v0_16.d.ts","sourceRoot":"","sources":["../../src/lib/Libg_v0_16.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"Libg_v0_16.d.ts","sourceRoot":"","sources":["../../src/lib/Libg_v0_16.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;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;;;OAGG;IACH,2BAHW,MAAM,GACJ,cAAc,CAa1B;IAED;;;;OAIG;IACH;;;;;;;;;;;MAuEC;IAED;;;;;;;;;;;OAWG;IACH,mCAoDC;IAED;;;;;OAKG;IACH,cALW,MAAM,WACN,MAAM,EAAE,WACR,cAAc,GACZ,aAAa,CAyCzB;IAED;;;;;;OAMG;IACH,uBAcC;IAED;;;;;OAKG;IACH,iBAWC;IAED;;;;;OAKG;IACH,6BAeC;IAED;;;;OAIG;IACH,4BA8BC;IAED;;;;OAIG;IACH,+BAYC;CACJ;4BArcY,OAAO,qBAAqB,EAAE,iBAAiB;+BAC/C,OAAO,qBAAqB,EAAE,oBAAoB;kCAClD,OAAO,qBAAqB,EAAE,UAAU;6BACxC,OAAO,UAAU,EAAE,cAAc;4BACjC,OAAO,UAAU,EAAE,aAAa;kBAChC,OAAO,UAAU,EAAE,GAAG;4BACtB,OAAO,UAAU,EAAE,aAAa;;;;6BAUhC,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"}
|
package/types/lib/index.d.ts
CHANGED
package/types/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.js"],"names":[],"mappings":";kBAGa,OAAO,UAAU,EAAE,GAAG
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.js"],"names":[],"mappings":";kBAGa,OAAO,UAAU,EAAE,GAAG"}
|
package/types/lib/load.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {import("./Lib.js").Lib} Lib
|
|
3
|
-
* @typedef {import("./Lib.js").LibOptions} LibOptions
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @param {LibOptions} options
|
|
7
2
|
* @returns {Lib}
|
|
8
3
|
*/
|
|
9
|
-
export function loadLibrary(
|
|
4
|
+
export function loadLibrary(): Lib;
|
|
10
5
|
export type Lib = import("./Lib.js").Lib;
|
|
11
|
-
export type LibOptions = import("./Lib.js").LibOptions;
|
|
12
6
|
//# sourceMappingURL=load.d.ts.map
|
package/types/lib/load.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/lib/load.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/lib/load.js"],"names":[],"mappings":"AAeA;;GAEG;AACH,+BAFa,GAAG,CAcf;kBA1BY,OAAO,UAAU,EAAE,GAAG"}
|
|
@@ -1,44 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor(validators: T);
|
|
24
|
-
/**
|
|
25
|
-
* @readonly
|
|
26
|
-
* @type {T}
|
|
27
|
-
*/
|
|
28
|
-
readonly validators: T;
|
|
29
|
-
}
|
|
30
|
-
export type Validator = {
|
|
31
|
-
$name: string;
|
|
32
|
-
$purpose: string;
|
|
33
|
-
$program: {
|
|
34
|
-
optimized: UplcProgramV2;
|
|
35
|
-
unoptimized: UplcProgramV2;
|
|
36
|
-
};
|
|
37
|
-
$hash: ScriptHash;
|
|
38
|
-
$Redeemer: Cast<any, any>;
|
|
39
|
-
$Datum?: Cast<any, any>;
|
|
40
|
-
};
|
|
41
|
-
import { UplcProgramV2 } from "@helios-lang/uplc";
|
|
42
|
-
import { ScriptHash } from "@helios-lang/ledger";
|
|
43
|
-
import { Cast } from "./Cast.js";
|
|
1
|
+
export type LoadedValidator = import("../codegen/index.js").LoadedValidator;
|
|
2
|
+
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
3
|
+
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
|
|
4
|
+
export type StakingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
5
|
+
export type PermissiveType<C extends Cast<any, any>> = import("../cast/index.js").PermissiveType<C>;
|
|
6
|
+
export type StrictType<C extends Cast<any, any>> = import("../cast/index.js").StrictType<C>;
|
|
7
|
+
export type AnyContractValidatorHash = (ValidatorHash<SpendingContext<any, any, any, any>> | MintingPolicyHash<MintingContext<any, any>> | StakingValidatorHash<StakingContext<any, any>>);
|
|
8
|
+
export type ContractValidatorHash<V extends import("../codegen/LoadedValidator.js").LoadedValidator> = V extends {
|
|
9
|
+
"$purpose": "spending";
|
|
10
|
+
"$Datum": Cast;
|
|
11
|
+
} ? ValidatorHash<SpendingContext<StrictType<V["$Datum"]>, PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : V extends {
|
|
12
|
+
"$purpose": "minting";
|
|
13
|
+
} ? MintingPolicyHash<MintingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : V extends {
|
|
14
|
+
"$purpose": ("certifying" | "rewarding");
|
|
15
|
+
} ? StakingValidatorHash<StakingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : never;
|
|
16
|
+
export type ContractContext<T extends {
|
|
17
|
+
[name: string]: import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
18
|
+
}> = { [K in keyof T]: ContractValidatorHash<T[K]>; };
|
|
19
|
+
import { Cast } from "../cast/index.js";
|
|
20
|
+
import { ValidatorHash } from "@helios-lang/ledger";
|
|
21
|
+
import { MintingPolicyHash } from "@helios-lang/ledger";
|
|
22
|
+
import { StakingValidatorHash } from "@helios-lang/ledger";
|
|
44
23
|
//# sourceMappingURL=ContractContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/runtime/ContractContext.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/runtime/ContractContext.js"],"names":[],"mappings":"8BAQa,OAAO,qBAAqB,EAAE,eAAe;mEAM7C,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;oGAQlF,OAAO,qBAAqB,EAAE,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,CAAC;mEAMnH,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;uDAKlF,OAAO,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;mDAK5C,OAAO,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;uCAIxC,CACZ,cAAkB,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GACtD,kBAAsB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,GAC/C,qBAAyB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,CAC/C;uGAKS,CAAC,SAAS;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAC,GAAG,cACjE,gBACA,WAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACjC,eAAyB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACrC,WAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,EACpC,eAAyB,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,GACP,CAAO,SAAS;IAAC,UAAU,EAAE,SAAS,CAAA;CAAC,GAAG,kBAC1C,eACA,WAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,EACpC,eAAyB,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,GACP,CAAO,SAAS;IAAC,UAAU,EAAE,CAAC,YAAY,GAAG,WAAW,CAAC,CAAA;CAAC,GAAG,qBAC7D,eACA,WAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,EACpC,eAAyB,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,GAAG,KAAK;;;;qBAjEK,kBAAkB;8BADhC,qBAAqB;kCAArB,qBAAqB;qCAArB,qBAAqB"}
|