@helios-lang/contract-utils 0.2.21 → 0.2.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/package.json +1 -1
- package/src/cast/UserFunc.js +6 -4
- package/src/codegen/LoadedScriptsWriter.js +40 -2
- package/src/codegen/LoadedValidator.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 +43 -8
- package/types/cast/UserFunc.d.ts +2 -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/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 +9 -1
- package/types/context/DagCompiler.d.ts.map +1 -1
package/package.json
CHANGED
package/src/cast/UserFunc.js
CHANGED
|
@@ -16,6 +16,7 @@ import { ConstrData, UplcDataValue } from "@helios-lang/uplc"
|
|
|
16
16
|
* type: TypeSchema
|
|
17
17
|
* }[]
|
|
18
18
|
* returns: TypeSchema
|
|
19
|
+
* validatorIndices?: Record<string, number>
|
|
19
20
|
* }} UserFuncProps
|
|
20
21
|
*/
|
|
21
22
|
|
|
@@ -71,11 +72,12 @@ export class UserFunc {
|
|
|
71
72
|
namedArgs["$currentScript"]
|
|
72
73
|
)
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const index = expectSome(
|
|
76
|
+
expectSome(this.props.validatorIndices)[
|
|
77
|
+
currentScriptName
|
|
78
|
+
]
|
|
76
79
|
)
|
|
77
|
-
|
|
78
|
-
args.push(new ConstrData(0, []))
|
|
80
|
+
args.push(new ConstrData(index, []))
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
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}),\n` : ""}
|
|
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},\n` : ""}
|
|
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,\n` : ""}
|
|
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
|
/**
|
|
@@ -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
|
|
@@ -94,7 +95,10 @@ export class DagCompiler {
|
|
|
94
95
|
validator.$hashDependencies.forEach((v) => buildValidator(v))
|
|
95
96
|
|
|
96
97
|
// get the dependencies
|
|
97
|
-
const
|
|
98
|
+
const hashDepHashes = this.getHashDepHashes(
|
|
99
|
+
validator,
|
|
100
|
+
Object.keys(hashTypes)
|
|
101
|
+
)
|
|
98
102
|
const moduleDeps = getModuleDependencies(validator)
|
|
99
103
|
|
|
100
104
|
const excludeUserFuncs = new Set(Object.keys(this.cachedUserFuncs))
|
|
@@ -105,8 +109,9 @@ export class DagCompiler {
|
|
|
105
109
|
moduleDeps,
|
|
106
110
|
{
|
|
107
111
|
optimize: true,
|
|
108
|
-
hashDependencies:
|
|
112
|
+
hashDependencies: hashDepHashes,
|
|
109
113
|
allValidatorHashTypes: hashTypes,
|
|
114
|
+
allValidatorIndices: validatorIndices ?? undefined,
|
|
110
115
|
dependsOnOwnHash: validator.$dependsOnOwnHash,
|
|
111
116
|
parameters: parameters,
|
|
112
117
|
isTestnet: isTestnet,
|
|
@@ -140,7 +145,7 @@ export class DagCompiler {
|
|
|
140
145
|
Array.from(moduleDeps.values()),
|
|
141
146
|
{
|
|
142
147
|
optimize: false,
|
|
143
|
-
hashDependencies:
|
|
148
|
+
hashDependencies: hashDepHashes,
|
|
144
149
|
allValidatorHashTypes: hashTypes,
|
|
145
150
|
ownHash: validator.$dependsOnOwnHash ? ownHash : undefined,
|
|
146
151
|
parameters: parameters,
|
|
@@ -236,13 +241,14 @@ export class DagCompiler {
|
|
|
236
241
|
/**
|
|
237
242
|
* @private
|
|
238
243
|
* @param {LoadedValidator} validator
|
|
244
|
+
* @param {string[]} allValidators - add a dummy `#` for all validators that aren't hash dependencies (the optimizer will remove them, but the IR name resolution will fail if we don't have them)
|
|
239
245
|
* @returns {{[name: string]: string}} - TODO: do we really need the purpose?
|
|
240
246
|
*/
|
|
241
|
-
|
|
247
|
+
getHashDepHashes(validator, allValidators) {
|
|
242
248
|
/**
|
|
243
249
|
* @type {{[name: string]: string}}
|
|
244
250
|
*/
|
|
245
|
-
const
|
|
251
|
+
const hashes = {}
|
|
246
252
|
|
|
247
253
|
validator.$hashDependencies.forEach((dep) => {
|
|
248
254
|
const k = dep.$name
|
|
@@ -254,10 +260,16 @@ export class DagCompiler {
|
|
|
254
260
|
)
|
|
255
261
|
}
|
|
256
262
|
|
|
257
|
-
|
|
263
|
+
hashes[k] = v.toHex()
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
allValidators.forEach((v) => {
|
|
267
|
+
if (!(v in hashes)) {
|
|
268
|
+
hashes[v] = "#"
|
|
269
|
+
}
|
|
258
270
|
})
|
|
259
271
|
|
|
260
|
-
return
|
|
272
|
+
return hashes
|
|
261
273
|
}
|
|
262
274
|
|
|
263
275
|
/**
|
|
@@ -287,6 +299,29 @@ export class DagCompiler {
|
|
|
287
299
|
|
|
288
300
|
return res
|
|
289
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
|
+
}
|
|
290
325
|
}
|
|
291
326
|
|
|
292
327
|
/**
|
package/types/cast/UserFunc.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* type: TypeSchema
|
|
8
8
|
* }[]
|
|
9
9
|
* returns: TypeSchema
|
|
10
|
+
* validatorIndices?: Record<string, number>
|
|
10
11
|
* }} UserFuncProps
|
|
11
12
|
*/
|
|
12
13
|
/**
|
|
@@ -46,5 +47,6 @@ export type UserFuncProps = {
|
|
|
46
47
|
type: TypeSchema;
|
|
47
48
|
}[];
|
|
48
49
|
returns: TypeSchema;
|
|
50
|
+
validatorIndices?: Record<string, number>;
|
|
49
51
|
};
|
|
50
52
|
//# 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;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH;IAeI;;;OAGG;IACH,kBAHW,WAAW,SACX,aAAa,EAKvB;IArBD;;;;OAIG;IACH,sBAAI;IAEJ;;;;OAIG;IACH,uBAAK;IAWL;;OAEG;IACH,oBA6CC;CACJ;yBAjGY,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;KACjB,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"}
|
|
@@ -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"}
|
|
@@ -70,9 +70,10 @@ export class DagCompiler {
|
|
|
70
70
|
/**
|
|
71
71
|
* @private
|
|
72
72
|
* @param {LoadedValidator} validator
|
|
73
|
+
* @param {string[]} allValidators - add a dummy `#` for all validators that aren't hash dependencies (the optimizer will remove them, but the IR name resolution will fail if we don't have them)
|
|
73
74
|
* @returns {{[name: string]: string}} - TODO: do we really need the purpose?
|
|
74
75
|
*/
|
|
75
|
-
private
|
|
76
|
+
private getHashDepHashes;
|
|
76
77
|
/**
|
|
77
78
|
* Also returns the hash types of any hash-dependencies
|
|
78
79
|
* @private
|
|
@@ -80,6 +81,13 @@ export class DagCompiler {
|
|
|
80
81
|
* @returns {Record<string, any>}
|
|
81
82
|
*/
|
|
82
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;
|
|
83
91
|
}
|
|
84
92
|
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
85
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"}
|