@helios-lang/contract-utils 0.1.19 → 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 +6 -6
- 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 -254
- 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
|
@@ -1,57 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import("../codegen/LoadedModule.js").LoadedModule} LoadedModule
|
|
3
|
+
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
2
4
|
* @typedef {import("../lib/index.js").Lib} Lib
|
|
3
|
-
* @typedef {import("../lib/index.js").LibOptions} LibOptions
|
|
4
|
-
* @typedef {import("./ContractContext.js").Validator} CompiledValidator
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* @template
|
|
8
|
-
* @
|
|
9
|
-
* @typedef {import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
|
|
7
|
+
* @template {{[name: string]: LoadedValidator}} T
|
|
8
|
+
* @typedef {import("./ContractContext.js").ContractContext<T>} ContractContext
|
|
10
9
|
*/
|
|
11
10
|
/**
|
|
12
|
-
* @template
|
|
13
|
-
* @template TDatumPermissive
|
|
14
|
-
* @template TRedeemerStrict
|
|
15
|
-
* @template TRedeemerPermissive
|
|
16
|
-
* @typedef {import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>} SpendingContext
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* @template TRedeemerStrict
|
|
20
|
-
* @template TRedeemerPermissive
|
|
21
|
-
* @typedef {import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>} StakingContext
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @template {Cast} C
|
|
25
|
-
* @typedef {import("./PermissiveType.js").PermissiveType<C>} PermissiveType
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* @template {Cast} C
|
|
29
|
-
* @typedef {import("./StrictType.js").StrictType<C>} StrictType
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {{
|
|
33
|
-
* $name: string
|
|
34
|
-
* $sourceCode: string
|
|
35
|
-
* $dependencies: Module[]
|
|
36
|
-
* }} Module
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* @typedef {{
|
|
40
|
-
* $name: string
|
|
41
|
-
* $purpose: string
|
|
42
|
-
* $sourceCode: string
|
|
43
|
-
* $dependencies: Module[]
|
|
44
|
-
* $hashDependencies: Validator[]
|
|
45
|
-
* $dependsOnOwnHash: boolean
|
|
46
|
-
* $Redeemer: Cast<any, any>
|
|
47
|
-
* $Datum?: Cast<any, any>
|
|
48
|
-
* }} Validator
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* @template {{[name: string]: Validator}} T
|
|
11
|
+
* @template {{[name: string]: LoadedValidator}} T
|
|
52
12
|
*/
|
|
53
13
|
export class ContractContextBuilder<T extends {
|
|
54
|
-
[name: string]:
|
|
14
|
+
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
55
15
|
}> {
|
|
56
16
|
/**
|
|
57
17
|
* @returns {ContractContextBuilder<{}>}
|
|
@@ -60,7 +20,6 @@ export class ContractContextBuilder<T extends {
|
|
|
60
20
|
/**
|
|
61
21
|
* @private
|
|
62
22
|
* @param {T} validators
|
|
63
|
-
* @param {Option<Module[]>} forcedModules
|
|
64
23
|
*/
|
|
65
24
|
private constructor();
|
|
66
25
|
/**
|
|
@@ -70,92 +29,25 @@ export class ContractContextBuilder<T extends {
|
|
|
70
29
|
*/
|
|
71
30
|
private readonly validators;
|
|
72
31
|
/**
|
|
73
|
-
* @
|
|
74
|
-
* @readonly
|
|
75
|
-
* @type {Option<Module[]>}
|
|
76
|
-
*/
|
|
77
|
-
private readonly forcedModules;
|
|
78
|
-
/**
|
|
79
|
-
* @param {Module[]} modules
|
|
80
|
-
* @returns {ContractContextBuilder<T>}
|
|
81
|
-
*/
|
|
82
|
-
setModules(modules: Module[]): ContractContextBuilder<T>;
|
|
83
|
-
/**
|
|
84
|
-
* @template {Validator} V
|
|
32
|
+
* @template {LoadedValidator} V
|
|
85
33
|
* @param {V} validator
|
|
86
34
|
* @returns {ContractContextBuilder<T & {
|
|
87
35
|
* [K in V["$name"]]: V
|
|
88
36
|
* }>}
|
|
89
37
|
*/
|
|
90
|
-
with<V extends
|
|
91
|
-
/**
|
|
92
|
-
* @private
|
|
93
|
-
* @param {Validator} validator
|
|
94
|
-
* @returns {Map<string, string>}
|
|
95
|
-
*/
|
|
96
|
-
private getModules;
|
|
97
|
-
/**
|
|
98
|
-
* @private
|
|
99
|
-
* @param {Lib} lib
|
|
100
|
-
* @returns {{[name: string]: any}}
|
|
101
|
-
*/
|
|
102
|
-
private getValidatorTypes;
|
|
38
|
+
with<V extends import("./DagCompiler.js").LoadedValidator>(validator: V): ContractContextBuilder<T & { [K in V["$name"]]: V; }>;
|
|
103
39
|
/**
|
|
104
40
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
105
|
-
* @
|
|
106
|
-
* @returns {{
|
|
107
|
-
* [K in keyof T]:
|
|
108
|
-
* T[K]["$purpose"] extends "spending" ? ValidatorHash<
|
|
109
|
-
* SpendingContext<
|
|
110
|
-
* StrictType<T[K]["$Datum"]>,
|
|
111
|
-
* PermissiveType<T[K]["$Datum"]>,
|
|
112
|
-
* StrictType<T[K]["$Redeemer"]>,
|
|
113
|
-
* PermissiveType<T[K]["$Redeemer"]>
|
|
114
|
-
* >
|
|
115
|
-
* > :
|
|
116
|
-
* T[K]["$purpose"] extends "minting" ? MintingPolicyHash<
|
|
117
|
-
* MintingContext<
|
|
118
|
-
* StrictType<T[K]["$Redeemer"]>,
|
|
119
|
-
* PermissiveType<T[K]["$Redeemer"]>
|
|
120
|
-
* >
|
|
121
|
-
* > :
|
|
122
|
-
* T[K]["$purpose"] extends ("certifying" | "rewarding") ? StakingValidatorHash<
|
|
123
|
-
* StakingContext<
|
|
124
|
-
* StrictType<T[K]["$Redeemer"]>,
|
|
125
|
-
* PermissiveType<T[K]["$Redeemer"]>
|
|
126
|
-
* >
|
|
127
|
-
* > : never
|
|
128
|
-
* }}
|
|
41
|
+
* @returns {ContractContext<T>}
|
|
129
42
|
*/
|
|
130
43
|
build(expectedHashes?: Option<{
|
|
131
44
|
[name: string]: string;
|
|
132
|
-
}
|
|
45
|
+
}>): ContractContext<T>;
|
|
133
46
|
}
|
|
47
|
+
export type LoadedModule = import("../codegen/LoadedModule.js").LoadedModule;
|
|
48
|
+
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
134
49
|
export type Lib = import("../lib/index.js").Lib;
|
|
135
|
-
export type
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
|
|
139
|
-
export type StakingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
140
|
-
export type PermissiveType<C extends Cast<import("@helios-lang/ledger").UplcData, import("@helios-lang/ledger").UplcData>> = import("./PermissiveType.js").PermissiveType<C>;
|
|
141
|
-
export type StrictType<C extends Cast<import("@helios-lang/ledger").UplcData, import("@helios-lang/ledger").UplcData>> = import("./StrictType.js").StrictType<C>;
|
|
142
|
-
export type Module = {
|
|
143
|
-
$name: string;
|
|
144
|
-
$sourceCode: string;
|
|
145
|
-
$dependencies: Module[];
|
|
146
|
-
};
|
|
147
|
-
export type Validator = {
|
|
148
|
-
$name: string;
|
|
149
|
-
$purpose: string;
|
|
150
|
-
$sourceCode: string;
|
|
151
|
-
$dependencies: Module[];
|
|
152
|
-
$hashDependencies: Validator[];
|
|
153
|
-
$dependsOnOwnHash: boolean;
|
|
154
|
-
$Redeemer: Cast<any, any>;
|
|
155
|
-
$Datum?: Cast<any, any>;
|
|
156
|
-
};
|
|
157
|
-
import { ValidatorHash } from "@helios-lang/ledger";
|
|
158
|
-
import { MintingPolicyHash } from "@helios-lang/ledger";
|
|
159
|
-
import { StakingValidatorHash } from "@helios-lang/ledger";
|
|
160
|
-
import { Cast } from "./Cast.js";
|
|
50
|
+
export type ContractContext<T extends {
|
|
51
|
+
[name: string]: import("./DagCompiler.js").LoadedValidator;
|
|
52
|
+
}> = import("./ContractContext.js").ContractContext<T>;
|
|
161
53
|
//# sourceMappingURL=ContractContextBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/runtime/ContractContextBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/runtime/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;kBACvD,OAAO,iBAAiB,EAAE,GAAG;;;KAK7B,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("../lib/index.js").Lib} Lib
|
|
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 {Lib} lib
|
|
17
|
+
*/
|
|
18
|
+
constructor(lib: Lib);
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
* @readonly
|
|
22
|
+
* @type {Lib}
|
|
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 Lib = import("../lib/index.js").Lib;
|
|
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/runtime/DagCompiler.js"],"names":[],"mappings":"AA4MA;;;GAGG;AACH,iDAHW,eAAe,GACb,MAAM,EAAE,CAsBpB;AA3ND;;;;GAIG;AAEH;;GAEG;AACH;IAeI;;OAEG;IACH,iBAFW,GAAG,EAKb;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;kBACvD,OAAO,iBAAiB,EAAE,GAAG;uCAC7B,OAAO,sBAAsB,EAAE,wBAAwB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type PermissiveType<C extends Cast<import("@helios-lang/uplc/types/data/UplcData.js").UplcData, import("@helios-lang/uplc/types/data/UplcData.js").UplcData>> = C extends Cast<any, infer TPermissive> ? TPermissive : never;
|
|
2
|
-
import { Cast } from "
|
|
2
|
+
import { Cast } from "../cast/Cast.js";
|
|
3
3
|
//# sourceMappingURL=PermissiveType.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type StrictType<C extends Cast<import("@helios-lang/uplc/types/data/UplcData.js").UplcData, import("@helios-lang/uplc/types/data/UplcData.js").UplcData>> = C extends Cast<infer TStrict, any> ? TStrict : never;
|
|
2
|
-
import { Cast } from "
|
|
2
|
+
import { Cast } from "../cast/Cast.js";
|
|
3
3
|
//# sourceMappingURL=StrictType.d.ts.map
|
package/types/runtime/index.d.ts
CHANGED
package/src/codegen/Writer.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class Writer {
|
|
2
|
-
/**
|
|
3
|
-
* @private
|
|
4
|
-
* @readonly
|
|
5
|
-
* @type {string[]}
|
|
6
|
-
*/
|
|
7
|
-
parts
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this.parts = []
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} part
|
|
15
|
-
* @returns {Writer}
|
|
16
|
-
*/
|
|
17
|
-
write(part) {
|
|
18
|
-
this.parts.push(part)
|
|
19
|
-
return this
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {string} line
|
|
24
|
-
* @returns {Writer}
|
|
25
|
-
*/
|
|
26
|
-
writeLine(line) {
|
|
27
|
-
this.parts.push(`${line}\n`)
|
|
28
|
-
return this
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
finalize() {
|
|
35
|
-
return this.parts.join("")
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/lib/Lib.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {{
|
|
3
|
-
* allValidatorTypes: {[name: string]: any},
|
|
4
|
-
* otherValidators: {[name: string]: {purpose: string, hash: string}},
|
|
5
|
-
* dependsOnOwnHash?: boolean,
|
|
6
|
-
* ownHash?: string,
|
|
7
|
-
* optimize: boolean
|
|
8
|
-
* }} CompileOptions
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {{
|
|
13
|
-
* cborHex: string
|
|
14
|
-
* prettyIR: string
|
|
15
|
-
* }} CompileOutput
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {{
|
|
20
|
-
* isMainnet?: boolean
|
|
21
|
-
* checkCasts?: boolean
|
|
22
|
-
* moduleOrder?: string[]
|
|
23
|
-
* }} LibOptions
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {{
|
|
28
|
-
* version: string
|
|
29
|
-
* getValidatorType: (purpose: string) => any
|
|
30
|
-
* typeCheck: (validators: {[name: string]: SourceDetails}, modules: {[name: string]: SourceDetails}) => ({
|
|
31
|
-
* modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}})
|
|
32
|
-
* compile: (main: string, modules: string[], options: CompileOptions) => CompileOutput
|
|
33
|
-
* }} Lib
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
38
|
-
* @typedef {import("../codegen/index.js").Module} ModuleDetails
|
|
39
|
-
* @typedef {import("../codegen/index.js").Validator} ValidatorDetails
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {{
|
|
44
|
-
* name: string
|
|
45
|
-
* purpose: string
|
|
46
|
-
* sourceCode: string
|
|
47
|
-
* }} SourceDetails
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @param {{VERSION: string}} lib
|
|
52
|
-
* @returns {number[]}
|
|
53
|
-
*/
|
|
54
|
-
export function getVersion(lib) {
|
|
55
|
-
return lib.VERSION.split(".").map((v) => Number(v))
|
|
56
|
-
}
|
package/src/lib/index.js
DELETED
package/src/lib/load.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as lib from "@helios-lang/compiler"
|
|
2
|
-
import { getVersion } from "./Lib.js"
|
|
3
|
-
import { Lib_v0_16 } from "./Libg_v0_16.js"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {import("./Lib.js").Lib} Lib
|
|
7
|
-
* @typedef {import("./Lib.js").LibOptions} LibOptions
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {LibOptions} options
|
|
12
|
-
* @returns {Lib}
|
|
13
|
-
*/
|
|
14
|
-
export function loadLibrary(options = {}) {
|
|
15
|
-
const [major, minor] = getVersion(lib)
|
|
16
|
-
|
|
17
|
-
switch (major) {
|
|
18
|
-
case 0:
|
|
19
|
-
switch (minor) {
|
|
20
|
-
case 16:
|
|
21
|
-
return new Lib_v0_16(lib, options)
|
|
22
|
-
}
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(`compiler version ${lib.VERSION} not supported`)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ScriptHash } from "@helios-lang/ledger"
|
|
2
|
-
import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
3
|
-
import { Cast } from "./Cast.js"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {{
|
|
7
|
-
* $name: string
|
|
8
|
-
* $purpose: string
|
|
9
|
-
* $program: {
|
|
10
|
-
* optimized: UplcProgramV2
|
|
11
|
-
* unoptimized: UplcProgramV2
|
|
12
|
-
* }
|
|
13
|
-
* $hash: ScriptHash
|
|
14
|
-
* $Redeemer: Cast<any, any>
|
|
15
|
-
* $Datum?: Cast<any, any>
|
|
16
|
-
* }} Validator
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @template {{[name: string]: Validator}} T
|
|
21
|
-
*/
|
|
22
|
-
export class ContractContext {
|
|
23
|
-
/**
|
|
24
|
-
* @readonly
|
|
25
|
-
* @type {T}
|
|
26
|
-
*/
|
|
27
|
-
validators
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @param {T} validators
|
|
31
|
-
*/
|
|
32
|
-
constructor(validators) {
|
|
33
|
-
this.validators = validators
|
|
34
|
-
}
|
|
35
|
-
}
|