@helios-lang/contract-utils 0.1.6 → 0.1.8
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/contract.js +16 -0
- package/examples/spending/index.d.ts +29 -0
- package/examples/spending/index.js +27 -0
- package/examples/spending/minting.hl +5 -0
- package/examples/spending/package-lock.json +34 -2
- package/examples/spending/package.json +5 -0
- package/jsconfig.json +16 -0
- package/package.json +9 -4
- package/src/codegen/TypescriptWriter.js +14 -6
- package/src/hl2ts.js +2 -0
- package/src/index.js +1 -0
- package/src/lib/Lib.js +15 -0
- package/src/lib/Libg_v0_16.js +106 -5
- package/src/lib/load.js +12 -49
- package/src/runtime/Cast.js +9 -6
- package/src/runtime/ContractContext.js +35 -0
- package/src/runtime/ContractContextBuilder.js +325 -0
- package/src/runtime/PermissiveType.js +6 -0
- package/src/runtime/StrictType.js +6 -0
- package/src/runtime/index.js +3 -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 +79 -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 +9 -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/ContractContext.d.ts +44 -0
- package/types/runtime/ContractContext.d.ts.map +1 -0
- package/types/runtime/ContractContextBuilder.d.ts +133 -0
- package/types/runtime/ContractContextBuilder.d.ts.map +1 -0
- package/types/runtime/PermissiveType.d.ts +3 -0
- package/types/runtime/PermissiveType.d.ts.map +1 -0
- package/types/runtime/StrictType.d.ts +3 -0
- package/types/runtime/StrictType.d.ts.map +1 -0
- package/types/runtime/index.d.ts +4 -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,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* [name: string]: string[]
|
|
4
|
+
* }} DagDependencies
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* }} HashType
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{
|
|
12
|
+
* includes: (m: string) => boolean
|
|
13
|
+
* }} IR
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {{
|
|
17
|
+
* name: string
|
|
18
|
+
* }} EnumStatement
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {{
|
|
22
|
+
* name: string
|
|
23
|
+
* }} StructStatement
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {StructStatement | EnumStatement | any} Statement
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {{
|
|
30
|
+
* name: {value: string}
|
|
31
|
+
* filterDependencies: (all: Module[]) => Module[]
|
|
32
|
+
* statements: Statement[]
|
|
33
|
+
* }} Module
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {{
|
|
37
|
+
* name: string
|
|
38
|
+
* toIR: (ctx: any, extra: Map<string, IR>) => IR
|
|
39
|
+
* types: UserTypes
|
|
40
|
+
* mainImportedModules: Module[]
|
|
41
|
+
* mainModule: Module
|
|
42
|
+
* mainArgTypes: DataType[]
|
|
43
|
+
* }} Program
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* typeDetails?: TypeDetails
|
|
48
|
+
* }} DataType
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {{
|
|
52
|
+
* type: string
|
|
53
|
+
* } | {
|
|
54
|
+
* type: "List"
|
|
55
|
+
* itemType: TypeSchema
|
|
56
|
+
* } | {
|
|
57
|
+
* type: "Map"
|
|
58
|
+
* keyType: TypeSchema
|
|
59
|
+
* valueType: TypeSchema
|
|
60
|
+
* } | {
|
|
61
|
+
* type: "Option"
|
|
62
|
+
* someType: TypeSchema
|
|
63
|
+
* } | {
|
|
64
|
+
* type: "Struct"
|
|
65
|
+
* fieldTypes: NamedTypeSchema[]
|
|
66
|
+
* } | {
|
|
67
|
+
* type: "Enum"
|
|
68
|
+
* variantTypes: {name: string, fieldTypes: NamedTypeSchema[]}[]
|
|
69
|
+
* }} TypeSchema
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {{
|
|
73
|
+
* name: string
|
|
74
|
+
* } & TypeSchema} NamedTypeSchema
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @typedef {{
|
|
78
|
+
* inputType: string
|
|
79
|
+
* outputType: string
|
|
80
|
+
* internalType: TypeSchema
|
|
81
|
+
* }} TypeDetails
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {{
|
|
85
|
+
* }} UserTypes
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* @implements {Lib}
|
|
89
|
+
*/
|
|
90
|
+
export class Lib_v0_16 implements Lib {
|
|
91
|
+
/**
|
|
92
|
+
* @param {any} lib
|
|
93
|
+
*/
|
|
94
|
+
constructor(lib: any);
|
|
95
|
+
lib: any;
|
|
96
|
+
/**
|
|
97
|
+
* @type {string}
|
|
98
|
+
*/
|
|
99
|
+
get version(): string;
|
|
100
|
+
/**
|
|
101
|
+
* @private
|
|
102
|
+
* @param {string} purpose
|
|
103
|
+
* @returns {HashType}
|
|
104
|
+
*/
|
|
105
|
+
private getValidatorType;
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
* @param {SourceDetails[]} validators
|
|
109
|
+
* @param {SourceDetails[]} modules
|
|
110
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
111
|
+
* @returns {Program[]}
|
|
112
|
+
*/
|
|
113
|
+
private createPrograms;
|
|
114
|
+
/**
|
|
115
|
+
* @private
|
|
116
|
+
* @param {Program} program
|
|
117
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
118
|
+
* @returns {IR}
|
|
119
|
+
*/
|
|
120
|
+
private toTestIR;
|
|
121
|
+
/**
|
|
122
|
+
* @private
|
|
123
|
+
* @param {Program[]} validators
|
|
124
|
+
* @param {{[name: string]: HashType}} validatorTypes
|
|
125
|
+
* @returns {DagDependencies}
|
|
126
|
+
*/
|
|
127
|
+
private buildDagDependencies;
|
|
128
|
+
/**
|
|
129
|
+
* @param {{[name: string]: SourceDetails}} validators
|
|
130
|
+
* @param {{[name: string]: SourceDetails}} modules
|
|
131
|
+
* @returns {{modules: {[name: string]: ModuleDetails}, validators: {[name: string]: ValidatorDetails}}}
|
|
132
|
+
*/
|
|
133
|
+
typeCheck(validators: {
|
|
134
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
135
|
+
}, modules: {
|
|
136
|
+
[name: string]: import("./Lib.js").SourceDetails;
|
|
137
|
+
}): {
|
|
138
|
+
modules: {
|
|
139
|
+
[name: string]: import("./Lib.js").ModuleDetails;
|
|
140
|
+
};
|
|
141
|
+
validators: {
|
|
142
|
+
[name: string]: import("./Lib.js").ValidatorDetails;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* @param {TypeSchema} it
|
|
147
|
+
* @returns {InternalTypeDetails}
|
|
148
|
+
*/
|
|
149
|
+
convertInternalType(it: TypeSchema): InternalTypeDetails;
|
|
150
|
+
/**
|
|
151
|
+
* @param {DataType} dt
|
|
152
|
+
* @returns {InternalTypeDetails}
|
|
153
|
+
*/
|
|
154
|
+
getInternalTypeDetails(dt: DataType): InternalTypeDetails;
|
|
155
|
+
/**
|
|
156
|
+
* @param {string} main
|
|
157
|
+
* @param {string[]} modules
|
|
158
|
+
* @param {CompileOptions} options
|
|
159
|
+
* @returns {CompileOutput}
|
|
160
|
+
*/
|
|
161
|
+
compile(main: string, modules: string[], options: CompileOptions): CompileOutput;
|
|
162
|
+
}
|
|
163
|
+
export type ModuleDetails = import("../codegen/index.js").Module;
|
|
164
|
+
export type ValidatorDetails = import("../codegen/index.js").Validator;
|
|
165
|
+
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
166
|
+
export type CompileOptions = import("./Lib.js").CompileOptions;
|
|
167
|
+
export type CompileOutput = import("./Lib.js").CompileOutput;
|
|
168
|
+
export type Lib = import("./Lib.js").Lib;
|
|
169
|
+
export type SourceDetails = import("./Lib.js").SourceDetails;
|
|
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":"AAcA;;;;GAIG;AAEH;;;GA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;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":"AAIA;;GAEG;AAEH;;GAEG;AACH,+BAFa,GAAG,CAcf;kBAlBY,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=UplcData]
|
|
7
|
+
* @template [TPermissive=UplcData]
|
|
8
|
+
*/
|
|
9
|
+
export class Cast<TStrict = import("@helios-lang/ledger").UplcData, TPermissive = import("@helios-lang/ledger").UplcData> {
|
|
10
|
+
/**
|
|
11
|
+
* @param {TypeSchema} schema
|
|
12
|
+
*/
|
|
13
|
+
constructor(schema: TypeSchema);
|
|
14
|
+
/**
|
|
15
|
+
* @readonly
|
|
16
|
+
* @type {TypeSchema}
|
|
17
|
+
*/
|
|
18
|
+
readonly schema: TypeSchema;
|
|
19
|
+
/**
|
|
20
|
+
* @param {UplcData} data
|
|
21
|
+
* @returns {TStrict}
|
|
22
|
+
*/
|
|
23
|
+
fromUplcData(data: UplcData): TStrict;
|
|
24
|
+
/**
|
|
25
|
+
* @param {TPermissive} x
|
|
26
|
+
* @returns {UplcData}
|
|
27
|
+
*/
|
|
28
|
+
toUplcData(x: TPermissive): UplcData;
|
|
29
|
+
}
|
|
30
|
+
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
31
|
+
export type TypeSchema = import("../codegen/index.js").TypeSchema;
|
|
32
|
+
//# sourceMappingURL=Cast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cast.d.ts","sourceRoot":"","sources":["../../src/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,mBAHW,QAAQ,GACN,OAAO,CAInB;IAED;;;OAGG;IACH,cAHW,WAAW,GACT,QAAQ,CAIpB;CACJ;uBArCY,OAAO,mBAAmB,EAAE,QAAQ;yBACpC,OAAO,qBAAqB,EAAE,UAAU"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* $name: string
|
|
4
|
+
* $purpose: string
|
|
5
|
+
* $program: {
|
|
6
|
+
* optimized: UplcProgramV2
|
|
7
|
+
* unoptimized: UplcProgramV2
|
|
8
|
+
* }
|
|
9
|
+
* $hash: ScriptHash
|
|
10
|
+
* $Redeemer: Cast<any, any>
|
|
11
|
+
* $Datum?: Cast<any, any>
|
|
12
|
+
* }} Validator
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @template {{[name: string]: Validator}} T
|
|
16
|
+
*/
|
|
17
|
+
export class ContractContext<T extends {
|
|
18
|
+
[name: string]: Validator;
|
|
19
|
+
}> {
|
|
20
|
+
/**
|
|
21
|
+
* @param {T} validators
|
|
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";
|
|
44
|
+
//# sourceMappingURL=ContractContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/runtime/ContractContext.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH;;;IAOI;;OAEG;IACH,wBAFW,CAAC,EAIX;IAXD;;;OAGG;IACH,qBAFU,CAAC,CAED;CAQb;wBA7BY;IACZ,KAAS,EAAE,MAAM,CAAA;IACjB,QAAY,EAAE,MAAM,CAAA;IACpB,QAAY,EAAE;QACd,SAAe,EAAE,aAAa,CAAA;QAC9B,WAAiB,EAAE,aAAa,CAAA;KAC3B,CAAA;IACL,KAAS,EAAE,UAAU,CAAA;IACrB,SAAa,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7B,MAAU,CAAC,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC,CAAA;CACxB;8BAd0B,mBAAmB;2BADtB,qBAAqB;qBAE3B,WAAW"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./ContractContext.js").Validator} CompiledValidator
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @template TRedeemerStrict
|
|
6
|
+
* @template TRedeemerPermissive
|
|
7
|
+
* @typedef {import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>} MintingContext
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @template TDatumStrict
|
|
11
|
+
* @template TDatumPermissive
|
|
12
|
+
* @template TRedeemerStrict
|
|
13
|
+
* @template TRedeemerPermissive
|
|
14
|
+
* @typedef {import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>} SpendingContext
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @template TRedeemerStrict
|
|
18
|
+
* @template TRedeemerPermissive
|
|
19
|
+
* @typedef {import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>} StakingContext
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @template {Cast} C
|
|
23
|
+
* @typedef {import("./PermissiveType.js").PermissiveType<C>} PermissiveType
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @template {Cast} C
|
|
27
|
+
* @typedef {import("./StrictType.js").StrictType<C>} StrictType
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {{
|
|
31
|
+
* $name: string
|
|
32
|
+
* $sourceCode: string
|
|
33
|
+
* $dependencies: Module[]
|
|
34
|
+
* }} Module
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {{
|
|
38
|
+
* $name: string
|
|
39
|
+
* $purpose: string
|
|
40
|
+
* $sourceCode: string
|
|
41
|
+
* $dependencies: Module[]
|
|
42
|
+
* $hashDependencies: Validator[]
|
|
43
|
+
* $dependsOnOwnHash: boolean
|
|
44
|
+
* $Redeemer: Cast<any, any>
|
|
45
|
+
* $Datum?: Cast<any, any>
|
|
46
|
+
* }} Validator
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* @template {{[name: string]: Validator}} T
|
|
50
|
+
*/
|
|
51
|
+
export class ContractContextBuilder<T extends {
|
|
52
|
+
[name: string]: Validator;
|
|
53
|
+
}> {
|
|
54
|
+
/**
|
|
55
|
+
* @returns {ContractContextBuilder<{}>}
|
|
56
|
+
*/
|
|
57
|
+
static "new"(): ContractContextBuilder<{}>;
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
* @param {T} validators
|
|
61
|
+
*/
|
|
62
|
+
private constructor();
|
|
63
|
+
/**
|
|
64
|
+
* @private
|
|
65
|
+
* @readonly
|
|
66
|
+
* @type {T}
|
|
67
|
+
*/
|
|
68
|
+
private readonly validators;
|
|
69
|
+
/**
|
|
70
|
+
* @template {Validator} V
|
|
71
|
+
* @param {V} validator
|
|
72
|
+
* @returns {ContractContextBuilder<T & {
|
|
73
|
+
* [K in V["$name"]]: V
|
|
74
|
+
* }>}
|
|
75
|
+
*/
|
|
76
|
+
with<V extends Validator>(validator: V): ContractContextBuilder<T & { [K in V["$name"]]: V; }>;
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
80
|
+
* @returns {{
|
|
81
|
+
* [K in keyof T]:
|
|
82
|
+
* T[K]["$purpose"] extends "spending" ? ValidatorHash<
|
|
83
|
+
* SpendingContext<
|
|
84
|
+
* StrictType<T[K]["$Datum"]>,
|
|
85
|
+
* PermissiveType<T[K]["$Datum"]>,
|
|
86
|
+
* StrictType<T[K]["$Redeemer"]>,
|
|
87
|
+
* PermissiveType<T[K]["$Redeemer"]>
|
|
88
|
+
* >
|
|
89
|
+
* > :
|
|
90
|
+
* T[K]["$purpose"] extends "minting" ? MintingPolicyHash<
|
|
91
|
+
* MintingContext<
|
|
92
|
+
* StrictType<T[K]["$Redeemer"]>,
|
|
93
|
+
* PermissiveType<T[K]["$Redeemer"]>
|
|
94
|
+
* >
|
|
95
|
+
* > :
|
|
96
|
+
* T[K]["$purpose"] extends ("certifying" | "rewarding") ? StakingValidatorHash<
|
|
97
|
+
* StakingContext<
|
|
98
|
+
* StrictType<T[K]["$Redeemer"]>,
|
|
99
|
+
* PermissiveType<T[K]["$Redeemer"]>
|
|
100
|
+
* >
|
|
101
|
+
* > : never
|
|
102
|
+
* }}
|
|
103
|
+
*/
|
|
104
|
+
build(expectedHashes?: Option<{
|
|
105
|
+
[name: string]: string;
|
|
106
|
+
}>): { [K_1 in keyof T]: T[K_1]["$purpose"] extends "spending" ? ValidatorHash<SpendingContext<import("./StrictType.js").StrictType<T[K_1]["$Datum"]>, import("./PermissiveType.js").PermissiveType<T[K_1]["$Datum"]>, import("./StrictType.js").StrictType<T[K_1]["$Redeemer"]>, import("./PermissiveType.js").PermissiveType<T[K_1]["$Redeemer"]>>> : T[K_1]["$purpose"] extends "minting" ? MintingPolicyHash<MintingContext<import("./StrictType.js").StrictType<T[K_1]["$Redeemer"]>, import("./PermissiveType.js").PermissiveType<T[K_1]["$Redeemer"]>>> : T[K_1]["$purpose"] extends "certifying" | "rewarding" ? StakingValidatorHash<StakingContext<import("./StrictType.js").StrictType<T[K_1]["$Redeemer"]>, import("./PermissiveType.js").PermissiveType<T[K_1]["$Redeemer"]>>> : never; };
|
|
107
|
+
}
|
|
108
|
+
export type CompiledValidator = import("./ContractContext.js").Validator;
|
|
109
|
+
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
110
|
+
export type SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").SpendingContext<TDatumStrict, TDatumPermissive, TRedeemerStrict, TRedeemerPermissive>;
|
|
111
|
+
export type StakingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").StakingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
112
|
+
export type PermissiveType<C extends Cast<import("@helios-lang/ledger").UplcData, import("@helios-lang/ledger").UplcData>> = import("./PermissiveType.js").PermissiveType<C>;
|
|
113
|
+
export type StrictType<C extends Cast<import("@helios-lang/ledger").UplcData, import("@helios-lang/ledger").UplcData>> = import("./StrictType.js").StrictType<C>;
|
|
114
|
+
export type Module = {
|
|
115
|
+
$name: string;
|
|
116
|
+
$sourceCode: string;
|
|
117
|
+
$dependencies: Module[];
|
|
118
|
+
};
|
|
119
|
+
export type Validator = {
|
|
120
|
+
$name: string;
|
|
121
|
+
$purpose: string;
|
|
122
|
+
$sourceCode: string;
|
|
123
|
+
$dependencies: Module[];
|
|
124
|
+
$hashDependencies: Validator[];
|
|
125
|
+
$dependsOnOwnHash: boolean;
|
|
126
|
+
$Redeemer: Cast<any, any>;
|
|
127
|
+
$Datum?: Cast<any, any>;
|
|
128
|
+
};
|
|
129
|
+
import { ValidatorHash } from "@helios-lang/ledger";
|
|
130
|
+
import { MintingPolicyHash } from "@helios-lang/ledger";
|
|
131
|
+
import { StakingValidatorHash } from "@helios-lang/ledger";
|
|
132
|
+
import { Cast } from "./Cast.js";
|
|
133
|
+
//# sourceMappingURL=ContractContextBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/runtime/ContractContextBuilder.js"],"names":[],"mappings":"AAaA;;GAEG;AAEH;;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@
|
|
|
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 "./Cast.js";
|
|
3
|
+
//# sourceMappingURL=PermissiveType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissiveType.d.ts","sourceRoot":"","sources":["../../src/runtime/PermissiveType.js"],"names":[],"mappings":";qBAAqB,WAAW"}
|
|
@@ -0,0 +1,3 @@
|
|
|
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 "./Cast.js";
|
|
3
|
+
//# sourceMappingURL=StrictType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StrictType.d.ts","sourceRoot":"","sources":["../../src/runtime/StrictType.js"],"names":[],"mappings":";qBAAqB,WAAW"}
|
|
@@ -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
|
-
}
|