@helios-lang/contract-utils 0.2.22 → 0.2.24
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 +1 -1
- package/src/cast/UserFunc.js +22 -9
- package/src/codegen/LoadedScriptsWriter.js +42 -6
- package/src/codegen/LoadedValidator.js +1 -0
- package/src/codegen/TypeCheckedModule.js +1 -0
- package/src/codegen/TypeCheckedValidator.js +1 -0
- package/src/compiler/CompilerLib.js +3 -2
- package/src/compiler/CompilerLib_v0_17.js +3 -0
- package/src/context/DagCompiler.js +26 -1
- package/types/cast/UserFunc.d.ts +4 -0
- package/types/cast/UserFunc.d.ts.map +1 -1
- package/types/codegen/LoadedScriptsWriter.d.ts +4 -0
- package/types/codegen/LoadedScriptsWriter.d.ts.map +1 -1
- package/types/codegen/LoadedValidator.d.ts +1 -0
- package/types/codegen/LoadedValidator.d.ts.map +1 -1
- package/types/codegen/TypeCheckedModule.d.ts +1 -0
- package/types/codegen/TypeCheckedModule.d.ts.map +1 -1
- package/types/codegen/TypeCheckedValidator.d.ts +1 -0
- package/types/codegen/TypeCheckedValidator.d.ts.map +1 -1
- package/types/compiler/CompilerLib.d.ts +6 -8
- package/types/compiler/CompilerLib.d.ts.map +1 -1
- package/types/compiler/CompilerLib_v0_17.d.ts +4 -0
- package/types/compiler/CompilerLib_v0_17.d.ts.map +1 -1
- package/types/context/DagCompiler.d.ts +7 -0
- package/types/context/DagCompiler.d.ts.map +1 -1
package/package.json
CHANGED
package/src/cast/UserFunc.js
CHANGED
|
@@ -14,8 +14,10 @@ import { ConstrData, UplcDataValue } from "@helios-lang/uplc"
|
|
|
14
14
|
* arguments: {
|
|
15
15
|
* name: string
|
|
16
16
|
* type: TypeSchema
|
|
17
|
+
* isOptional: boolean
|
|
17
18
|
* }[]
|
|
18
19
|
* returns: TypeSchema
|
|
20
|
+
* validatorIndices?: Record<string, number>
|
|
19
21
|
* }} UserFuncProps
|
|
20
22
|
*/
|
|
21
23
|
|
|
@@ -55,12 +57,22 @@ export class UserFunc {
|
|
|
55
57
|
/**
|
|
56
58
|
* @type {UplcData[]}
|
|
57
59
|
*/
|
|
58
|
-
const args = this.props.arguments.map(
|
|
59
|
-
|
|
60
|
+
const args = this.props.arguments.map(
|
|
61
|
+
({ name, type, isOptional }) => {
|
|
62
|
+
if (isOptional) {
|
|
63
|
+
if (name in namedArgs) {
|
|
64
|
+
return new ConstrData(0, [namedArgs[name]])
|
|
65
|
+
} else {
|
|
66
|
+
return new ConstrData(1, [])
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
const rawArg = expectSome(namedArgs[name])
|
|
60
70
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
// TODO: apply type conversion
|
|
72
|
+
return rawArg
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
)
|
|
64
76
|
|
|
65
77
|
if (this.props.requiresScriptContext) {
|
|
66
78
|
args.push(expectSome(namedArgs["$scriptContext"]))
|
|
@@ -71,11 +83,12 @@ export class UserFunc {
|
|
|
71
83
|
namedArgs["$currentScript"]
|
|
72
84
|
)
|
|
73
85
|
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
const index = expectSome(
|
|
87
|
+
expectSome(this.props.validatorIndices)[
|
|
88
|
+
currentScriptName
|
|
89
|
+
]
|
|
76
90
|
)
|
|
77
|
-
|
|
78
|
-
args.push(new ConstrData(0, []))
|
|
91
|
+
args.push(new ConstrData(index, []))
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
const result = this.uplc.eval(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StringWriter } from "@helios-lang/codec-utils"
|
|
2
|
+
import { isSome } from "@helios-lang/type-utils"
|
|
2
3
|
import { genTypes } from "./TypeSchema.js"
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -101,6 +102,8 @@ export class LoadedScriptsWriter {
|
|
|
101
102
|
todo = todoNext
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
this.writeValidatorIndices(validators)
|
|
106
|
+
|
|
104
107
|
return this
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -240,14 +243,19 @@ export class LoadedScriptsWriter {
|
|
|
240
243
|
const fn = functions[key]
|
|
241
244
|
const t = genFuncType(fn)
|
|
242
245
|
|
|
246
|
+
let propsStr = JSON.stringify(fn)
|
|
247
|
+
if (fn.requiresCurrentScript) {
|
|
248
|
+
propsStr = `{...(${propsStr}), validatorIndices: __validatorIndices}`
|
|
249
|
+
}
|
|
250
|
+
|
|
243
251
|
this.definition.write(
|
|
244
|
-
` "${key}": (uplc) => /** @type {UserFunc<${t}>} */ (new UserFunc(uplc, ${
|
|
252
|
+
` "${key}": (uplc) => /** @type {UserFunc<${t}>} */ (new UserFunc(uplc, ${propsStr})),\n`
|
|
245
253
|
)
|
|
246
254
|
this.declaration.write(
|
|
247
255
|
` "${key}": (uplc) => UserFunc<${t}>,\n`
|
|
248
256
|
)
|
|
249
257
|
this.combined.write(
|
|
250
|
-
` "${key}": (uplc) => new UserFunc<${t}>(uplc, ${
|
|
258
|
+
` "${key}": (uplc) => new UserFunc<${t}>(uplc, ${propsStr}),\n`
|
|
251
259
|
)
|
|
252
260
|
}
|
|
253
261
|
|
|
@@ -298,11 +306,13 @@ export class LoadedScriptsWriter {
|
|
|
298
306
|
writeValidator(v) {
|
|
299
307
|
const redeemerTypes = genTypes(v.Redeemer)
|
|
300
308
|
const datumTypes = v.Datum ? genTypes(v.Datum) : undefined
|
|
309
|
+
const currentScriptIndex = v.currentScriptIndex
|
|
301
310
|
|
|
302
311
|
this.definition.write(
|
|
303
312
|
`export const ${v.name} = {
|
|
304
313
|
$name: /** @type {const} */ ("${v.name}"),
|
|
305
314
|
$purpose: /** @type {const} */ ("${v.purpose}"),
|
|
315
|
+
${isSome(currentScriptIndex) ? ` $currentScriptIndex: /** @type {const} */ (${currentScriptIndex}),` : ""}
|
|
306
316
|
$sourceCode: ${JSON.stringify(v.sourceCode)},
|
|
307
317
|
$dependencies: /** @type {const} */ ([${v.moduleDepedencies.join(", ")}]),
|
|
308
318
|
$hashDependencies: [${v.hashDependencies.filter((d) => d != v.name).join(", ")}],
|
|
@@ -315,6 +325,7 @@ ${datumTypes ? ` $Datum: (config) => /** @type {Cast<${datumTypes[0]}, ${datu
|
|
|
315
325
|
`export const ${v.name}: {
|
|
316
326
|
$name: "${v.name}"
|
|
317
327
|
$purpose: "${v.purpose}"
|
|
328
|
+
${isSome(currentScriptIndex) ? ` $currentScriptIndex: ${currentScriptIndex}` : ""}
|
|
318
329
|
$sourceCode: string
|
|
319
330
|
$dependencies: [${v.moduleDepedencies.map((d) => `typeof ${d}`).join(", ")}]
|
|
320
331
|
$hashDependencies: [${v.hashDependencies
|
|
@@ -330,6 +341,7 @@ ${datumTypes ? ` $Datum: ConfigurableCast<${datumTypes[0]}, ${datumTypes[1]}>
|
|
|
330
341
|
`export const ${v.name} = {
|
|
331
342
|
$name: "${v.name}" as const,
|
|
332
343
|
$purpose: "${v.purpose}" as const,
|
|
344
|
+
${isSome(currentScriptIndex) ? ` $currentScriptIndex: ${currentScriptIndex} as const,` : ""}
|
|
333
345
|
$sourceCode: ${JSON.stringify(v.sourceCode)} as string,
|
|
334
346
|
$dependencies: [${v.moduleDepedencies.join(", ")}] as const,
|
|
335
347
|
$hashDependencies: [${v.hashDependencies.filter((d) => d != v.name).join(", ")}],
|
|
@@ -345,6 +357,32 @@ ${datumTypes ? ` $Datum: (config: CastConfig) => new Cast<${datumTypes[0]}, $
|
|
|
345
357
|
this.declaration.write(`}\n`)
|
|
346
358
|
this.combined.write(`}\n`)
|
|
347
359
|
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @param {Record<string, TypeCheckedValidator>} validators
|
|
363
|
+
*/
|
|
364
|
+
writeValidatorIndices(validators) {
|
|
365
|
+
/**
|
|
366
|
+
* @type {Record<string, number>}
|
|
367
|
+
*/
|
|
368
|
+
const indices = {}
|
|
369
|
+
|
|
370
|
+
for (let name in validators) {
|
|
371
|
+
const v = validators[name]
|
|
372
|
+
if (isSome(v.currentScriptIndex)) {
|
|
373
|
+
indices[name] = v.currentScriptIndex
|
|
374
|
+
} else {
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
this.definition.write(
|
|
380
|
+
`const __validatorIndices = ${JSON.stringify(indices)};`
|
|
381
|
+
)
|
|
382
|
+
this.combined.write(
|
|
383
|
+
`const __validatorIndices: Record<string, number> = ${JSON.stringify(indices)};`
|
|
384
|
+
)
|
|
385
|
+
}
|
|
348
386
|
}
|
|
349
387
|
|
|
350
388
|
/**
|
|
@@ -365,10 +403,8 @@ function genFuncType(fn) {
|
|
|
365
403
|
fields.push("$currentScript: string")
|
|
366
404
|
}
|
|
367
405
|
|
|
368
|
-
fn.arguments.forEach(({ name, type: _type }, i) => {
|
|
369
|
-
|
|
370
|
-
fields.push(`${name}: UplcData`)
|
|
371
|
-
}
|
|
406
|
+
fn.arguments.forEach(({ name, type: _type, isOptional }, i) => {
|
|
407
|
+
fields.push(`${name}${isOptional ? "?" : ""}: UplcData`)
|
|
372
408
|
})
|
|
373
409
|
|
|
374
410
|
return `(args: {${fields.join(", ")}}) => UplcData`
|
|
@@ -18,6 +18,7 @@ import { UserFunc } from "../cast/UserFunc.js"
|
|
|
18
18
|
* $sourceCode: string
|
|
19
19
|
* $dependencies: ReadonlyArray<LoadedModule>
|
|
20
20
|
* $hashDependencies: ReadonlyArray<LoadedValidator>
|
|
21
|
+
* $currentScriptIndex?: number
|
|
21
22
|
* $dependsOnOwnHash: boolean
|
|
22
23
|
* $types: {[name: string]: CastLike<any, any>}
|
|
23
24
|
* $functions: {[name: string]: (uplc: UplcProgram) => UserFunc<any>}
|
|
@@ -16,8 +16,9 @@ export {}
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @typedef {{
|
|
19
|
-
* allValidatorHashTypes:
|
|
20
|
-
*
|
|
19
|
+
* allValidatorHashTypes: Record<string, ScriptHashType>
|
|
20
|
+
* allValidatorIndices?: Record<string, number>
|
|
21
|
+
* hashDependencies: Record<string, string>
|
|
21
22
|
* dependsOnOwnHash?: boolean
|
|
22
23
|
* ownHash?: string
|
|
23
24
|
* parameters?: Record<string, UplcData>
|
|
@@ -13,11 +13,13 @@ import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {{
|
|
15
15
|
* name: string
|
|
16
|
+
* currentScriptIndex: Option<number>
|
|
16
17
|
* changeParam(key: string, value: UplcData): void
|
|
17
18
|
* compile(options: {
|
|
18
19
|
* optimize?: boolean,
|
|
19
20
|
* dependsOnOwnHash?: boolean,
|
|
20
21
|
* hashDependencies?: Record<string, string>
|
|
22
|
+
* validatorIndices?: Record<string, number>
|
|
21
23
|
* excludeUserFuncs?: Set<string>
|
|
22
24
|
* onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void
|
|
23
25
|
* }): UplcProgramV2
|
|
@@ -91,6 +93,7 @@ export class CompilerLib_v0_17 {
|
|
|
91
93
|
const uplc = program.compile({
|
|
92
94
|
optimize: options.optimize,
|
|
93
95
|
dependsOnOwnHash: options.dependsOnOwnHash ?? false,
|
|
96
|
+
validatorIndices: options.allValidatorIndices,
|
|
94
97
|
hashDependencies: {
|
|
95
98
|
...options.hashDependencies,
|
|
96
99
|
...(options.ownHash ? { [program.name]: options.ownHash } : {})
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
StakingValidatorHash,
|
|
5
5
|
ValidatorHash
|
|
6
6
|
} from "@helios-lang/ledger"
|
|
7
|
-
import { None, expectSome } from "@helios-lang/type-utils"
|
|
7
|
+
import { None, expectSome, isSome } from "@helios-lang/type-utils"
|
|
8
8
|
import { UplcProgramV1, UplcProgramV2 } from "@helios-lang/uplc"
|
|
9
9
|
import { configureCast } from "../cast/index.js"
|
|
10
10
|
|
|
@@ -75,6 +75,7 @@ export class DagCompiler {
|
|
|
75
75
|
*/
|
|
76
76
|
build(validators, parameters, isTestnet, expectedHashes = None) {
|
|
77
77
|
const hashTypes = this.getHashTypes(validators)
|
|
78
|
+
const validatorIndices = this.getValidatorIndices(validators)
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* `buildValidator()` is a closure instead of a member method of DagCompiler
|
|
@@ -110,6 +111,7 @@ export class DagCompiler {
|
|
|
110
111
|
optimize: true,
|
|
111
112
|
hashDependencies: hashDepHashes,
|
|
112
113
|
allValidatorHashTypes: hashTypes,
|
|
114
|
+
allValidatorIndices: validatorIndices ?? undefined,
|
|
113
115
|
dependsOnOwnHash: validator.$dependsOnOwnHash,
|
|
114
116
|
parameters: parameters,
|
|
115
117
|
isTestnet: isTestnet,
|
|
@@ -297,6 +299,29 @@ export class DagCompiler {
|
|
|
297
299
|
|
|
298
300
|
return res
|
|
299
301
|
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* If any $currentScriptIndex is missing, None is returned
|
|
305
|
+
* @private
|
|
306
|
+
* @param {LoadedValidator[]} validators
|
|
307
|
+
* @returns {Option<Record<string, number>>}
|
|
308
|
+
*/
|
|
309
|
+
getValidatorIndices(validators) {
|
|
310
|
+
/**
|
|
311
|
+
* @type {Record<string, number>}
|
|
312
|
+
*/
|
|
313
|
+
const res = {}
|
|
314
|
+
|
|
315
|
+
for (let v of validators) {
|
|
316
|
+
if (isSome(v.$currentScriptIndex)) {
|
|
317
|
+
res[v.$name] = v.$currentScriptIndex
|
|
318
|
+
} else {
|
|
319
|
+
return None
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return res
|
|
324
|
+
}
|
|
300
325
|
}
|
|
301
326
|
|
|
302
327
|
/**
|
package/types/cast/UserFunc.d.ts
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* arguments: {
|
|
6
6
|
* name: string
|
|
7
7
|
* type: TypeSchema
|
|
8
|
+
* isOptional: boolean
|
|
8
9
|
* }[]
|
|
9
10
|
* returns: TypeSchema
|
|
11
|
+
* validatorIndices?: Record<string, number>
|
|
10
12
|
* }} UserFuncProps
|
|
11
13
|
*/
|
|
12
14
|
/**
|
|
@@ -44,7 +46,9 @@ export type UserFuncProps = {
|
|
|
44
46
|
arguments: {
|
|
45
47
|
name: string;
|
|
46
48
|
type: TypeSchema;
|
|
49
|
+
isOptional: boolean;
|
|
47
50
|
}[];
|
|
48
51
|
returns: TypeSchema;
|
|
52
|
+
validatorIndices?: Record<string, number>;
|
|
49
53
|
};
|
|
50
54
|
//# sourceMappingURL=UserFunc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserFunc.d.ts","sourceRoot":"","sources":["../../src/cast/UserFunc.js"],"names":[],"mappings":"AASA
|
|
1
|
+
{"version":3,"file":"UserFunc.d.ts","sourceRoot":"","sources":["../../src/cast/UserFunc.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH;IAeI;;;OAGG;IACH,kBAHW,WAAW,SACX,aAAa,EAKvB;IArBD;;;;OAIG;IACH,sBAAI;IAEJ;;;;OAIG;IACH,uBAAK;IAWL;;OAEG;IACH,oBAuDC;CACJ;yBA5GY,OAAO,yBAAyB,EAAE,UAAU;uBAC5C,OAAO,mBAAmB,EAAE,QAAQ;0BACpC,OAAO,mBAAmB,EAAE,WAAW;4BAOvC;IACZ,qBAAyB,EAAE,OAAO,CAAA;IAClC,qBAAyB,EAAE,OAAO,CAAA;IAClC,SAAa,EAAE;QACf,MAAY,MAAM,CAAA;QAClB,IAAU,EAAE,UAAU,CAAA;QACtB,UAAgB,EAAE,OAAO,CAAA;KACpB,EAAE,CAAA;IACP,OAAW,EAAE,UAAU,CAAA;IACvB,gBAAoB,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C"}
|
|
@@ -73,6 +73,10 @@ export class LoadedScriptsWriter {
|
|
|
73
73
|
* @param {TypeCheckedValidator} v
|
|
74
74
|
*/
|
|
75
75
|
private writeValidator;
|
|
76
|
+
/**
|
|
77
|
+
* @param {Record<string, TypeCheckedValidator>} validators
|
|
78
|
+
*/
|
|
79
|
+
writeValidatorIndices(validators: Record<string, TypeCheckedValidator>): void;
|
|
76
80
|
}
|
|
77
81
|
export type TypeCheckedModule = import("./TypeCheckedModule.js").TypeCheckedModule;
|
|
78
82
|
export type TypeCheckedUserFunc = import("./TypeCheckedModule.js").TypeCheckedUserFunc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAoC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;;;;OAKG;IACH,sBALW,MAAM,YACN,MAAM,eACN,MAAM,EAAE,GACN,mBAAmB,CAmB/B;IAED;;;;OAIG;IACH,kBAJW,MAAM,kBACN,MAAM,EAAE,GACN,mBAAmB,CAQ/B;IAED;;OAEG;IACH,qBA6BC;IAED;;OAEG;IACH,kBAFW,OAAO,MAAM,EAAE,UAAU,CAAC,QAyBpC;IAED;;OAEG;IACH,0BAFW,OAAO,MAAM,EAAE,mBAAmB,CAAC,QA8B7C;IAED;;;OAGG;IACH,oBA6BC;IAED;;;OAGG;IACH,uBAqDC;IAED;;OAEG;IACH,kCAFW,OAAO,MAAM,EAAE,oBAAoB,CAAC,QAuB9C;CACJ;gCA5XY,OAAO,wBAAwB,EAAE,iBAAiB;kCAClD,OAAO,wBAAwB,EAAE,mBAAmB;mCACpD,OAAO,2BAA2B,EAAE,oBAAoB;yBACxD,OAAO,iBAAiB,EAAE,UAAU;6BARpB,0BAA0B"}
|
|
@@ -9,6 +9,7 @@ export type LoadedValidator = {
|
|
|
9
9
|
$sourceCode: string;
|
|
10
10
|
$dependencies: ReadonlyArray<LoadedModule>;
|
|
11
11
|
$hashDependencies: ReadonlyArray<LoadedValidator>;
|
|
12
|
+
$currentScriptIndex?: number | undefined;
|
|
12
13
|
$dependsOnOwnHash: boolean;
|
|
13
14
|
$types: {
|
|
14
15
|
[name: string]: CastLike<any, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedValidator.js"],"names":[],"mappings":"6CAKa,OAAO,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;0BAIxD,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,mBAAmB,EAAE,YAAY;;;;;WAMzC,MAAM;iBACA,MAAM;mBACJ,cAAc,YAAY,CAAC;uBACvB,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"LoadedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedValidator.js"],"names":[],"mappings":"6CAKa,OAAO,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;0BAIxD,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,mBAAmB,EAAE,YAAY;;;;;WAMzC,MAAM;iBACA,MAAM;mBACJ,cAAc,YAAY,CAAC;uBACvB,cAAc,eAAe,CAAC;;uBAE9B,OAAO;;;;;+BAEU,WAAW,KAAK,SAAS,GAAG,CAAC;;eACtD,SAAS,GAAG,EAAE,GAAG,CAAC;;cAGjB,UAAU,GAAG,OAAO;YACtB,SAAS,GAAG,EAAE,GAAG,CAAC;;cAEhB,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS;;;WAM7C,MAAM;;;;;WAOQ,MAAM;;;;6DAM7B,0BAA0B,CAAC,CAAC,eAAe,CAAC,CAAC;yBAjDjC,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCheckedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedModule.js"],"names":[],"mappings":"yBAGa,OAAO,iBAAiB,EAAE,UAAU;kCAIpC;IACZ,qBAAyB,EAAE,OAAO,CAAA;IAClC,qBAAyB,EAAE,OAAO,CAAA;IAClC,SAAa,EAAE;QACf,MAAY,MAAM,CAAA;QAClB,IAAU,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"TypeCheckedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedModule.js"],"names":[],"mappings":"yBAGa,OAAO,iBAAiB,EAAE,UAAU;kCAIpC;IACZ,qBAAyB,EAAE,OAAO,CAAA;IAClC,qBAAyB,EAAE,OAAO,CAAA;IAClC,SAAa,EAAE;QACf,MAAY,MAAM,CAAA;QAClB,IAAU,EAAE,UAAU,CAAA;QACtB,UAAgB,EAAE,OAAO,CAAA;KACpB,EAAE,CAAA;IACP,OAAW,EAAE,UAAU,CAAA;CACpB;gCAIS;IACZ,MAAU,MAAM,CAAA;IAChB,OAAW,EAAE,MAAM,CAAA;IACnB,UAAc,EAAE,MAAM,CAAA;IACtB,iBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,KAAS,EAAE,OAAO,MAAM,EAAE,UAAU,CAAC,CAAA;IACrC,SAAa,CAAC,EAAE,OAAO,MAAM,EAAE,mBAAmB,CAAC,CAAA;CAChD"}
|
|
@@ -2,6 +2,7 @@ export type TypeCheckedModule = import("./TypeCheckedModule.js").TypeCheckedModu
|
|
|
2
2
|
export type TypeSchema = import("./TypeSchema.js").TypeSchema;
|
|
3
3
|
export type TypeCheckedValidator = TypeCheckedModule & {
|
|
4
4
|
hashDependencies: string[];
|
|
5
|
+
currentScriptIndex?: number;
|
|
5
6
|
Redeemer: TypeSchema;
|
|
6
7
|
Datum?: TypeSchema;
|
|
7
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCheckedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedValidator.js"],"names":[],"mappings":"gCAGa,OAAO,wBAAwB,EAAE,iBAAiB;yBAClD,OAAO,iBAAiB,EAAE,UAAU;mCAIpC,iBAAiB,GAAG;IAChC,gBAAoB,EAAE,MAAM,EAAE,CAAA;IAC9B,QAAY,EAAE,UAAU,CAAA;IACxB,KAAS,CAAC,EAAE,UAAU,CAAA;CACnB"}
|
|
1
|
+
{"version":3,"file":"TypeCheckedValidator.d.ts","sourceRoot":"","sources":["../../src/codegen/TypeCheckedValidator.js"],"names":[],"mappings":"gCAGa,OAAO,wBAAwB,EAAE,iBAAiB;yBAClD,OAAO,iBAAiB,EAAE,UAAU;mCAIpC,iBAAiB,GAAG;IAChC,gBAAoB,EAAE,MAAM,EAAE,CAAA;IAC9B,kBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,QAAY,EAAE,UAAU,CAAA;IACxB,KAAS,CAAC,EAAE,UAAU,CAAA;CACnB"}
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {{
|
|
13
|
-
* allValidatorHashTypes:
|
|
14
|
-
*
|
|
13
|
+
* allValidatorHashTypes: Record<string, ScriptHashType>
|
|
14
|
+
* allValidatorIndices?: Record<string, number>
|
|
15
|
+
* hashDependencies: Record<string, string>
|
|
15
16
|
* dependsOnOwnHash?: boolean
|
|
16
17
|
* ownHash?: string
|
|
17
18
|
* parameters?: Record<string, UplcData>
|
|
@@ -68,12 +69,9 @@ export type TypeCheckedModule = import("../codegen/index.js").TypeCheckedModule;
|
|
|
68
69
|
export type TypeCheckedValidator = import("../codegen/index.js").TypeCheckedValidator;
|
|
69
70
|
export type ScriptHashType = any;
|
|
70
71
|
export type CompileOptions = {
|
|
71
|
-
allValidatorHashTypes:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
hashDependencies: {
|
|
75
|
-
[name: string]: string;
|
|
76
|
-
};
|
|
72
|
+
allValidatorHashTypes: Record<string, ScriptHashType>;
|
|
73
|
+
allValidatorIndices?: Record<string, number> | undefined;
|
|
74
|
+
hashDependencies: Record<string, string>;
|
|
77
75
|
dependsOnOwnHash?: boolean | undefined;
|
|
78
76
|
ownHash?: string | undefined;
|
|
79
77
|
parameters?: Record<string, import("@helios-lang/uplc").UplcData> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,uCAJW,WAAW,cACX,MAAM,EAAE;;EAUlB;4BA3EY,OAAO,mBAAmB,EAAE,aAAa;uBACzC,OAAO,mBAAmB,EAAE,QAAQ;kCACpC,OAAO,qBAAqB,EAAE,UAAU;gCACxC,OAAO,qBAAqB,EAAE,iBAAiB;mCAC/C,OAAO,qBAAqB,EAAE,oBAAoB;6BAIlD,GAAG;;2BAKY,OAAO,MAAM,EAAE,cAAc,CAAC;;sBAEnC,OAAO,MAAM,EAAE,MAAM,CAAC;;;;eAI7B,OAAO;cACR,OAAO;;gCAEU,MAAM,WAAW,MAAM,iBAAiB,aAAa,KAAK,IAAI;;4BAKjF;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"}
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {{
|
|
11
11
|
* name: string
|
|
12
|
+
* currentScriptIndex: Option<number>
|
|
12
13
|
* changeParam(key: string, value: UplcData): void
|
|
13
14
|
* compile(options: {
|
|
14
15
|
* optimize?: boolean,
|
|
15
16
|
* dependsOnOwnHash?: boolean,
|
|
16
17
|
* hashDependencies?: Record<string, string>
|
|
18
|
+
* validatorIndices?: Record<string, number>
|
|
17
19
|
* excludeUserFuncs?: Set<string>
|
|
18
20
|
* onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void
|
|
19
21
|
* }): UplcProgramV2
|
|
@@ -63,11 +65,13 @@ export type ScriptHashType = import("./CompilerLib.js").ScriptHashType;
|
|
|
63
65
|
export type TypeCheckOutput = import("./CompilerLib.js").TypeCheckOutput;
|
|
64
66
|
export type Program = {
|
|
65
67
|
name: string;
|
|
68
|
+
currentScriptIndex: Option<number>;
|
|
66
69
|
changeParam(key: string, value: UplcData): void;
|
|
67
70
|
compile(options: {
|
|
68
71
|
optimize?: boolean | undefined;
|
|
69
72
|
dependsOnOwnHash?: boolean | undefined;
|
|
70
73
|
hashDependencies?: Record<string, string> | undefined;
|
|
74
|
+
validatorIndices?: Record<string, number> | undefined;
|
|
71
75
|
excludeUserFuncs?: Set<string> | undefined;
|
|
72
76
|
onCompileUserFunc?: ((name: string, uplc: UplcProgramV2) => void) | undefined;
|
|
73
77
|
}): UplcProgramV2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerLib_v0_17.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib_v0_17.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH
|
|
1
|
+
{"version":3,"file":"CompilerLib_v0_17.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib_v0_17.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH;IAOI;;OAEG;IACH,iBAFW,GAAG,EAIb;IAXD;;;OAGG;IACH,YAAG;IASH;;OAEG;IACH,sBAEC;IAED;;;OAGG;IACH,2BAHW,MAAM,GACJ,cAAc,CAM1B;IAED;;;;;OAKG;IACH,oBALW,MAAM,iBACN,MAAM,EAAE,WACR,cAAc,GACZ,aAAa,CAuDzB;IAED;;;;OAIG;IACH,4BAJW,MAAM,EAAE,iBACR,MAAM,EAAE,GACN,eAAe,CAM3B;CACJ;uBAjIY,OAAO,mBAAmB,EAAE,QAAQ;0BACpC,OAAO,kBAAkB,EAAE,WAAW;6BACtC,OAAO,kBAAkB,EAAE,cAAc;4BACzC,OAAO,kBAAkB,EAAE,aAAa;6BACxC,OAAO,kBAAkB,EAAE,cAAc;8BACzC,OAAO,kBAAkB,EAAE,eAAe;;UAK5C,MAAM;wBACQ,OAAO,MAAM,CAAC;qBACjB,MAAM,SAAS,QAAQ,GAAG,IAAI;;;;;;;oCAOlB,MAAM,QAAQ,aAAa,KAAK,IAAI;QAC7D,aAAa;;8BAvBQ,mBAAmB"}
|
|
@@ -81,6 +81,13 @@ export class DagCompiler {
|
|
|
81
81
|
* @returns {Record<string, any>}
|
|
82
82
|
*/
|
|
83
83
|
private getHashTypes;
|
|
84
|
+
/**
|
|
85
|
+
* If any $currentScriptIndex is missing, None is returned
|
|
86
|
+
* @private
|
|
87
|
+
* @param {LoadedValidator[]} validators
|
|
88
|
+
* @returns {Option<Record<string, number>>}
|
|
89
|
+
*/
|
|
90
|
+
private getValidatorIndices;
|
|
84
91
|
}
|
|
85
92
|
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
86
93
|
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DagCompiler.d.ts","sourceRoot":"","sources":["../../src/context/DagCompiler.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DagCompiler.d.ts","sourceRoot":"","sources":["../../src/context/DagCompiler.js"],"names":[],"mappings":"AAsUA;;;GAGG;AACH,iDAHW,eAAe,GACb,MAAM,EAAE,CAsBpB;AApVD;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;GAEG;AACH;IA6BI;;;OAGG;IACH,iBAHW,WAAW,cACX,UAAU,EAOpB;IArCD;;;;OAIG;IACH,qBAAG;IAEH;;;;OAIG;IACH,wBAAM;IAEN;;;;OAIG;IACH,kCAAgB;IAEhB;;;;OAIG;IACH,iCAAe;IAQX,iDAA4B;IAKhC;;;;;;OAMG;IACH,kBANW,eAAe,EAAE,cACjB,OAAO,MAAM,EAAE,GAAG,CAAC,aACnB,OAAO;;SAEL,iBAAiB,CAgI7B;IAED;;;;;OAKG;IACH,4BA6BC;IAED;;;;;OAKG;IACH,yBA0BC;IAED;;;;;OAKG;IACH,qBAoBC;IAED;;;;;OAKG;IACH,4BAeC;CACJ;0BAzTY,OAAO,mBAAmB,EAAE,WAAW;yBACvC,OAAO,kBAAkB,EAAE,UAAU;8BACrC,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;0CAC1C,OAAO,sBAAsB,EAAE,2BAA2B"}
|