@helios-lang/contract-utils 0.2.16 → 0.2.18
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 +64 -3
- package/src/codegen/LoadedModule.js +6 -1
- package/src/codegen/LoadedScriptsWriter.js +7 -6
- package/src/codegen/LoadedValidator.js +3 -1
- package/src/compiler/CompilerLib.js +3 -0
- package/src/compiler/CompilerLib_v0_17.js +26 -2
- package/src/context/ContractContext.js +24 -6
- package/src/context/ContractContextBuilder.js +41 -12
- package/src/context/ContractContextCache.js +111 -23
- package/src/context/DagCompiler.js +74 -17
- package/types/cast/UserFunc.d.ts +15 -6
- package/types/cast/UserFunc.d.ts.map +1 -1
- package/types/codegen/LoadedModule.d.ts +5 -0
- package/types/codegen/LoadedModule.d.ts.map +1 -1
- package/types/codegen/LoadedScriptsWriter.d.ts.map +1 -1
- package/types/codegen/LoadedValidator.d.ts +5 -0
- package/types/codegen/LoadedValidator.d.ts.map +1 -1
- package/types/compiler/CompilerLib.d.ts +6 -0
- package/types/compiler/CompilerLib.d.ts.map +1 -1
- package/types/compiler/CompilerLib_v0_17.d.ts +12 -4
- package/types/compiler/CompilerLib_v0_17.d.ts.map +1 -1
- package/types/context/ContractContext.d.ts +16 -5
- package/types/context/ContractContext.d.ts.map +1 -1
- package/types/context/ContractContextBuilder.d.ts.map +1 -1
- package/types/context/ContractContextCache.d.ts +43 -9
- package/types/context/ContractContextCache.d.ts.map +1 -1
- package/types/context/DagCompiler.d.ts +26 -6
- package/types/context/DagCompiler.d.ts.map +1 -1
package/package.json
CHANGED
package/src/cast/UserFunc.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export {}
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @typedef {import("@helios-lang/type-utils").TypeSchema} TypeSchema
|
|
5
3
|
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
4
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
6
5
|
*/
|
|
7
6
|
|
|
7
|
+
import { expectSome, isLeft } from "@helios-lang/type-utils"
|
|
8
|
+
import { ConstrData, UplcDataValue } from "@helios-lang/uplc"
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* @typedef {{
|
|
10
12
|
* requiresScriptContext: boolean
|
|
@@ -22,15 +24,74 @@ export {}
|
|
|
22
24
|
*/
|
|
23
25
|
export class UserFunc {
|
|
24
26
|
/**
|
|
27
|
+
* @private
|
|
28
|
+
* @readonly
|
|
29
|
+
* @type {UplcProgram}
|
|
30
|
+
*/
|
|
31
|
+
uplc
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
25
35
|
* @readonly
|
|
26
36
|
* @type {UserFuncProps}
|
|
27
37
|
*/
|
|
28
38
|
props
|
|
29
39
|
|
|
30
40
|
/**
|
|
41
|
+
* @param {UplcProgram} uplc
|
|
31
42
|
* @param {UserFuncProps} props
|
|
32
43
|
*/
|
|
33
|
-
constructor(props) {
|
|
44
|
+
constructor(uplc, props) {
|
|
45
|
+
this.uplc = uplc
|
|
34
46
|
this.props = props
|
|
35
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @type {T}
|
|
51
|
+
*/
|
|
52
|
+
get evalUnsafe() {
|
|
53
|
+
return /** @type {any} */ (
|
|
54
|
+
(namedArgs) => {
|
|
55
|
+
/**
|
|
56
|
+
* @type {UplcData[]}
|
|
57
|
+
*/
|
|
58
|
+
const args = this.props.arguments.map(({ name, type }) => {
|
|
59
|
+
const rawArg = expectSome(namedArgs[name])
|
|
60
|
+
|
|
61
|
+
// TODO: apply type conversion
|
|
62
|
+
return rawArg
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if (this.props.requiresScriptContext) {
|
|
66
|
+
args.push(expectSome(namedArgs["$scriptContext"]))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (this.props.requiresCurrentScript) {
|
|
70
|
+
const currentScriptName = expectSome(
|
|
71
|
+
namedArgs["$currentScript"]
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
console.error(
|
|
75
|
+
`TODO: convert ${currentScriptName} to correct ConstrData`
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
args.push(new ConstrData(0, []))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const result = this.uplc.eval(
|
|
82
|
+
args.map((a) => new UplcDataValue(a))
|
|
83
|
+
).result
|
|
84
|
+
|
|
85
|
+
if (isLeft(result)) {
|
|
86
|
+
throw new Error(result.left.error)
|
|
87
|
+
} else if (result.right instanceof UplcDataValue) {
|
|
88
|
+
return result.right.value
|
|
89
|
+
} else {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`${result.right.toString()} isn't a UplcDataValue`
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
36
97
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { UserFunc } from "../cast/UserFunc.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
5
|
+
*/
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* @template TStrict
|
|
@@ -13,5 +17,6 @@ export {}
|
|
|
13
17
|
* $sourceCode: string
|
|
14
18
|
* $dependencies: ReadonlyArray<LoadedModule>
|
|
15
19
|
* $types: {[name: string]: CastLike<any, any>}
|
|
20
|
+
* $functions: {[name: string]: (uplc: UplcProgram) => UserFunc<any>}
|
|
16
21
|
* }} LoadedModule
|
|
17
22
|
*/
|
|
@@ -241,11 +241,13 @@ export class LoadedScriptsWriter {
|
|
|
241
241
|
const t = genFuncType(fn)
|
|
242
242
|
|
|
243
243
|
this.definition.write(
|
|
244
|
-
` ${key}: /** @type {UserFunc<${t}>} */ (new UserFunc(${JSON.stringify(fn)})),\n`
|
|
244
|
+
` "${key}": (uplc) => /** @type {UserFunc<${t}>} */ (new UserFunc(uplc, ${JSON.stringify(fn)})),\n`
|
|
245
|
+
)
|
|
246
|
+
this.declaration.write(
|
|
247
|
+
` "${key}": (uplc) => UserFunc<${t}>,\n`
|
|
245
248
|
)
|
|
246
|
-
this.declaration.write(` ${key}: UserFunc<${t}>,\n`)
|
|
247
249
|
this.combined.write(
|
|
248
|
-
` ${key}: new UserFunc<${t}>(${JSON.stringify(fn)}),\n`
|
|
250
|
+
` "${key}": (uplc) => new UserFunc<${t}>(uplc, ${JSON.stringify(fn)}),\n`
|
|
249
251
|
)
|
|
250
252
|
}
|
|
251
253
|
|
|
@@ -282,6 +284,7 @@ export class LoadedScriptsWriter {
|
|
|
282
284
|
)
|
|
283
285
|
|
|
284
286
|
this.writeTypes(m.types)
|
|
287
|
+
this.writeFunctions(m.functions ?? {})
|
|
285
288
|
|
|
286
289
|
this.definition.write(`}\n`)
|
|
287
290
|
this.declaration.write(`}\n`)
|
|
@@ -336,9 +339,7 @@ ${datumTypes ? ` $Datum: (config: CastConfig) => new Cast<${datumTypes[0]}, $
|
|
|
336
339
|
)
|
|
337
340
|
|
|
338
341
|
this.writeTypes(v.types)
|
|
339
|
-
|
|
340
|
-
this.writeFunctions(v.functions)
|
|
341
|
-
}
|
|
342
|
+
this.writeFunctions(v.functions ?? {})
|
|
342
343
|
|
|
343
344
|
this.definition.write(`}\n`)
|
|
344
345
|
this.declaration.write(`}\n`)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserFunc } from "../cast/UserFunc.js"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @template TStrict
|
|
@@ -7,6 +7,7 @@ import { Cast } from "../cast/Cast.js"
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
10
11
|
* @typedef {import("./LoadedModule.js").LoadedModule} LoadedModule
|
|
11
12
|
*/
|
|
12
13
|
|
|
@@ -18,6 +19,7 @@ import { Cast } from "../cast/Cast.js"
|
|
|
18
19
|
* $hashDependencies: ReadonlyArray<LoadedValidator>
|
|
19
20
|
* $dependsOnOwnHash: boolean
|
|
20
21
|
* $types: {[name: string]: CastLike<any, any>}
|
|
22
|
+
* $functions: {[name: string]: (uplc: UplcProgram) => UserFunc<any>}
|
|
21
23
|
* $Redeemer: CastLike<any, any>
|
|
22
24
|
* } & (
|
|
23
25
|
* {
|
|
@@ -3,6 +3,7 @@ import { readHeader } from "@helios-lang/compiler-utils"
|
|
|
3
3
|
export {}
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
6
7
|
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
7
8
|
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
8
9
|
* @typedef {import("../codegen/index.js").TypeCheckedModule} TypeCheckedModule
|
|
@@ -22,6 +23,8 @@ export {}
|
|
|
22
23
|
* parameters?: Record<string, UplcData>
|
|
23
24
|
* isTestnet: boolean
|
|
24
25
|
* optimize: boolean
|
|
26
|
+
* excludeUserFuncs?: Set<string>
|
|
27
|
+
* onCompileUserFunc?: (name: string, cborHex: string, plutusVersion: PlutusVersion) => void
|
|
25
28
|
* }} CompileOptions
|
|
26
29
|
*/
|
|
27
30
|
|
|
@@ -14,7 +14,13 @@ import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
|
14
14
|
* @typedef {{
|
|
15
15
|
* name: string
|
|
16
16
|
* changeParam(key: string, value: UplcData): void
|
|
17
|
-
* compile(options: {
|
|
17
|
+
* compile(options: {
|
|
18
|
+
* optimize?: boolean,
|
|
19
|
+
* dependsOnOwnHash?: boolean,
|
|
20
|
+
* hashDependencies?: Record<string, string>
|
|
21
|
+
* excludeUserFuncs?: Set<string>
|
|
22
|
+
* onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void
|
|
23
|
+
* }): UplcProgramV2
|
|
18
24
|
* }} Program
|
|
19
25
|
*/
|
|
20
26
|
|
|
@@ -77,6 +83,8 @@ export class CompilerLib_v0_17 {
|
|
|
77
83
|
})
|
|
78
84
|
}
|
|
79
85
|
|
|
86
|
+
const onCompileUserFunc = options.onCompileUserFunc
|
|
87
|
+
|
|
80
88
|
/**
|
|
81
89
|
* @type {UplcProgramV2}
|
|
82
90
|
*/
|
|
@@ -86,7 +94,23 @@ export class CompilerLib_v0_17 {
|
|
|
86
94
|
hashDependencies: {
|
|
87
95
|
...options.hashDependencies,
|
|
88
96
|
...(options.ownHash ? { [program.name]: options.ownHash } : {})
|
|
89
|
-
}
|
|
97
|
+
},
|
|
98
|
+
...(options.excludeUserFuncs
|
|
99
|
+
? {
|
|
100
|
+
excludeUserFuncs: options.excludeUserFuncs
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
103
|
+
...(onCompileUserFunc
|
|
104
|
+
? {
|
|
105
|
+
onCompileUserFunc: (name, uplc) => {
|
|
106
|
+
onCompileUserFunc(
|
|
107
|
+
name,
|
|
108
|
+
bytesToHex(uplc.toCbor()),
|
|
109
|
+
"PlutusScriptV2"
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
: {})
|
|
90
114
|
})
|
|
91
115
|
|
|
92
116
|
return {
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
MintingPolicyHash,
|
|
5
5
|
ScriptHash
|
|
6
6
|
} from "@helios-lang/ledger"
|
|
7
|
-
import { Cast } from "../cast/index.js"
|
|
7
|
+
import { Cast, UserFunc } from "../cast/index.js"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
10
11
|
* @typedef {import("../codegen/index.js").LoadedModule} LoadedModule
|
|
11
12
|
* @typedef {import("../codegen/index.js").LoadedValidator} LoadedValidator
|
|
12
13
|
*/
|
|
@@ -67,7 +68,7 @@ import { Cast } from "../cast/index.js"
|
|
|
67
68
|
* PermissiveType<V["$Redeemer"]>
|
|
68
69
|
* >
|
|
69
70
|
* >
|
|
70
|
-
* } & ContractTypesContext<V["$types"]> :
|
|
71
|
+
* } & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> :
|
|
71
72
|
* V extends {"$purpose": "minting", "$Redeemer": CastLike<any, any>} ? {
|
|
72
73
|
* $hash: MintingPolicyHash<
|
|
73
74
|
* MintingContext<
|
|
@@ -75,7 +76,7 @@ import { Cast } from "../cast/index.js"
|
|
|
75
76
|
* PermissiveType<V["$Redeemer"]>
|
|
76
77
|
* >
|
|
77
78
|
* >
|
|
78
|
-
* } & ContractTypesContext<V["$types"]> :
|
|
79
|
+
* } & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> :
|
|
79
80
|
* V extends {"$purpose": ("certifying" | "rewarding" | "staking"), "$Redeemer": CastLike<any, any>} ? {
|
|
80
81
|
* $hash: StakingValidatorHash<
|
|
81
82
|
* StakingContext<
|
|
@@ -83,23 +84,40 @@ import { Cast } from "../cast/index.js"
|
|
|
83
84
|
* PermissiveType<V["$Redeemer"]>
|
|
84
85
|
* >
|
|
85
86
|
* >
|
|
86
|
-
* } & ContractTypesContext<V["$types"]> :
|
|
87
|
+
* } & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> :
|
|
88
|
+
* V extends {"$purpose": "mixed", "$Datum": CastLike<any, any>, "$Redeemer": CastLike<any, any>} ? {
|
|
89
|
+
* $hash: ScriptHash<
|
|
90
|
+
* SpendingContext<
|
|
91
|
+
* StrictType<V["$Datum"]>,
|
|
92
|
+
* PermissiveType<V["$Datum"]>,
|
|
93
|
+
* StrictType<V["$Redeemer"]>,
|
|
94
|
+
* PermissiveType<V["$Redeemer"]>
|
|
95
|
+
* >
|
|
96
|
+
* >
|
|
97
|
+
* } & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> :
|
|
87
98
|
* never
|
|
88
99
|
* } ContractValidatorContexts
|
|
89
100
|
*/
|
|
90
101
|
|
|
91
102
|
/**
|
|
92
103
|
* @template {LoadedModule} V
|
|
93
|
-
* @typedef {ContractTypesContext<V["$types"]>} ContractModuleContexts
|
|
104
|
+
* @typedef {ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]>} ContractModuleContexts
|
|
94
105
|
*/
|
|
95
106
|
|
|
96
107
|
/**
|
|
97
|
-
* @template {{[typeName:string]: CastLike<any, any>}} T
|
|
108
|
+
* @template {{[typeName: string]: CastLike<any, any>}} T
|
|
98
109
|
* @typedef {{
|
|
99
110
|
* [K in keyof T]: Cast<StrictType<T[K]>, PermissiveType<T[K]>>
|
|
100
111
|
* }} ContractTypesContext
|
|
101
112
|
*/
|
|
102
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @template {{[funcName: string]: (uplc: UplcProgram) => UserFunc<any>}} T
|
|
116
|
+
* @typedef {{
|
|
117
|
+
* [K in keyof T]: UserFunc<T[K]>
|
|
118
|
+
* }} ContractUserFuncsContext
|
|
119
|
+
*/
|
|
120
|
+
|
|
103
121
|
/**
|
|
104
122
|
* @template {{[name: string]: LoadedValidator}} Vs
|
|
105
123
|
* @template {{[name: string]: LoadedModule}} Ms
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { expectSome } from "@helios-lang/type-utils"
|
|
2
|
+
import { configureCast } from "../cast/Cast.js"
|
|
1
3
|
import { loadCompilerLib } from "../compiler/index.js"
|
|
2
4
|
import { DagCompiler } from "./DagCompiler.js"
|
|
3
|
-
import { configureCast } from "../cast/Cast.js"
|
|
4
5
|
import { contractContextCache } from "./ContractContextCache.js"
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -118,7 +119,7 @@ export class ContractContextBuilder {
|
|
|
118
119
|
|
|
119
120
|
const cached = contractContextCache.shift()
|
|
120
121
|
|
|
121
|
-
const
|
|
122
|
+
const compiled = cached
|
|
122
123
|
? cached
|
|
123
124
|
: dagCompiler.build(
|
|
124
125
|
Object.values(this.validators),
|
|
@@ -127,11 +128,11 @@ export class ContractContextBuilder {
|
|
|
127
128
|
props.expectedHashes
|
|
128
129
|
)
|
|
129
130
|
|
|
130
|
-
contractContextCache.push(
|
|
131
|
+
contractContextCache.push(compiled)
|
|
131
132
|
|
|
132
133
|
if (props.dumpHashes) {
|
|
133
|
-
for (let name in
|
|
134
|
-
console.log(`${name}: ${
|
|
134
|
+
for (let name in compiled.validators) {
|
|
135
|
+
console.log(`${name}: ${compiled.validators[name].toHex()},`)
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -141,27 +142,55 @@ export class ContractContextBuilder {
|
|
|
141
142
|
const res = {}
|
|
142
143
|
|
|
143
144
|
for (let name in this.modules) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
const mod = this.modules[name]
|
|
146
|
+
|
|
147
|
+
res[name] = {
|
|
148
|
+
...Object.fromEntries(
|
|
149
|
+
Object.entries(mod.$types).map(([typeName, castLike]) => [
|
|
147
150
|
typeName,
|
|
148
151
|
configureCast(castLike, castConfig)
|
|
149
|
-
]
|
|
152
|
+
])
|
|
153
|
+
),
|
|
154
|
+
...Object.fromEntries(
|
|
155
|
+
Object.entries(mod.$functions).map(
|
|
156
|
+
([funcKey, userFunc]) => [
|
|
157
|
+
funcKey,
|
|
158
|
+
userFunc(
|
|
159
|
+
expectSome(
|
|
160
|
+
compiled.userFuncs[`${name}::${funcKey}`]
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
]
|
|
164
|
+
)
|
|
150
165
|
)
|
|
151
|
-
|
|
166
|
+
}
|
|
152
167
|
}
|
|
153
168
|
|
|
154
169
|
for (let name in this.validators) {
|
|
170
|
+
const validator = this.validators[name]
|
|
171
|
+
|
|
155
172
|
res[name] = {
|
|
156
173
|
...Object.fromEntries(
|
|
157
|
-
Object.entries(
|
|
174
|
+
Object.entries(validator.$types).map(
|
|
158
175
|
([typeName, castLike]) => [
|
|
159
176
|
typeName,
|
|
160
177
|
configureCast(castLike, castConfig)
|
|
161
178
|
]
|
|
162
179
|
)
|
|
163
180
|
),
|
|
164
|
-
|
|
181
|
+
...Object.fromEntries(
|
|
182
|
+
Object.entries(validator.$functions).map(
|
|
183
|
+
([funcKey, userFunc]) => [
|
|
184
|
+
funcKey,
|
|
185
|
+
userFunc(
|
|
186
|
+
expectSome(
|
|
187
|
+
compiled.userFuncs[`${name}::${funcKey}`]
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
]
|
|
191
|
+
)
|
|
192
|
+
),
|
|
193
|
+
$hash: compiled.validators[name]
|
|
165
194
|
}
|
|
166
195
|
}
|
|
167
196
|
|
|
@@ -12,26 +12,45 @@ import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
15
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
15
16
|
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
16
17
|
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
17
18
|
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
* @typedef {{
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* validators: {[name: string]: AnyContractValidatorContext}
|
|
24
|
+
* userFuncs: {[name: string]: UplcProgram}
|
|
25
|
+
* }} CacheEntry
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {{[name: string]: {
|
|
30
|
+
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
31
|
+
* bytes: number[]
|
|
32
|
+
* unoptimizedCborHex?: string
|
|
33
|
+
* optimizedCborHex: string
|
|
34
|
+
* plutusVersion: PlutusVersion
|
|
35
|
+
* castConfig: CastConfig
|
|
36
|
+
* datum?: TypeSchema
|
|
37
|
+
* redeemer: TypeSchema
|
|
38
|
+
* }}} CacheEntryValidatorsJson
|
|
22
39
|
*/
|
|
23
40
|
|
|
24
41
|
/**
|
|
25
42
|
* @typedef {{[name: string]: {
|
|
26
|
-
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
27
|
-
* bytes: number[]
|
|
28
43
|
* unoptimizedCborHex?: string
|
|
29
44
|
* optimizedCborHex: string
|
|
30
45
|
* plutusVersion: PlutusVersion
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
* }}} CacheEntryUserFuncsJson
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {{
|
|
51
|
+
* validators: CacheEntryValidatorsJson
|
|
52
|
+
* userFuncs: CacheEntryUserFuncsJson
|
|
53
|
+
* }} CacheEntryJson
|
|
35
54
|
*/
|
|
36
55
|
|
|
37
56
|
class ContractContextCache {
|
|
@@ -69,10 +88,13 @@ class ContractContextCache {
|
|
|
69
88
|
/**
|
|
70
89
|
* @type {CacheEntry}
|
|
71
90
|
*/
|
|
72
|
-
const res = {
|
|
91
|
+
const res = {
|
|
92
|
+
validators: {},
|
|
93
|
+
userFuncs: {}
|
|
94
|
+
}
|
|
73
95
|
|
|
74
|
-
for (let name in entry) {
|
|
75
|
-
const props = entry[name]
|
|
96
|
+
for (let name in entry.validators) {
|
|
97
|
+
const props = entry.validators[name]
|
|
76
98
|
|
|
77
99
|
let program =
|
|
78
100
|
props.plutusVersion == "PlutusScriptV1"
|
|
@@ -97,7 +119,7 @@ class ContractContextCache {
|
|
|
97
119
|
|
|
98
120
|
switch (props.purpose) {
|
|
99
121
|
case "spending": {
|
|
100
|
-
res[name] = new ValidatorHash(props.bytes, {
|
|
122
|
+
res.validators[name] = new ValidatorHash(props.bytes, {
|
|
101
123
|
datum: new Cast(
|
|
102
124
|
expectSome(props.datum),
|
|
103
125
|
props.castConfig
|
|
@@ -108,24 +130,65 @@ class ContractContextCache {
|
|
|
108
130
|
break
|
|
109
131
|
}
|
|
110
132
|
case "minting": {
|
|
111
|
-
res[name] = new MintingPolicyHash(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
res.validators[name] = new MintingPolicyHash(
|
|
134
|
+
props.bytes,
|
|
135
|
+
{
|
|
136
|
+
redeemer: redeemer,
|
|
137
|
+
program: program
|
|
138
|
+
}
|
|
139
|
+
)
|
|
115
140
|
break
|
|
116
141
|
}
|
|
117
142
|
case "staking": {
|
|
118
|
-
res[name] = new StakingValidatorHash(
|
|
143
|
+
res.validators[name] = new StakingValidatorHash(
|
|
144
|
+
props.bytes,
|
|
145
|
+
{
|
|
146
|
+
redeemer: redeemer,
|
|
147
|
+
program: program
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
break
|
|
151
|
+
}
|
|
152
|
+
case "mixed": {
|
|
153
|
+
res.validators[name] = new ScriptHash(props.bytes, {
|
|
154
|
+
datum: new Cast(
|
|
155
|
+
expectSome(props.datum),
|
|
156
|
+
props.castConfig
|
|
157
|
+
),
|
|
119
158
|
redeemer: redeemer,
|
|
120
159
|
program: program
|
|
121
160
|
})
|
|
122
|
-
break
|
|
123
161
|
}
|
|
124
162
|
default:
|
|
125
163
|
throw new Error("unhandled purpose")
|
|
126
164
|
}
|
|
127
165
|
}
|
|
128
166
|
|
|
167
|
+
for (let name in entry.userFuncs) {
|
|
168
|
+
const props = entry.userFuncs[name]
|
|
169
|
+
|
|
170
|
+
let program =
|
|
171
|
+
props.plutusVersion == "PlutusScriptV1"
|
|
172
|
+
? UplcProgramV1.fromCbor(props.optimizedCborHex)
|
|
173
|
+
: UplcProgramV2.fromCbor(props.optimizedCborHex)
|
|
174
|
+
|
|
175
|
+
if (props.unoptimizedCborHex) {
|
|
176
|
+
if (program instanceof UplcProgramV1) {
|
|
177
|
+
program = program.withAlt(
|
|
178
|
+
UplcProgramV1.fromCbor(props.unoptimizedCborHex)
|
|
179
|
+
)
|
|
180
|
+
} else if (program instanceof UplcProgramV2) {
|
|
181
|
+
program = program.withAlt(
|
|
182
|
+
UplcProgramV2.fromCbor(props.unoptimizedCborHex)
|
|
183
|
+
)
|
|
184
|
+
} else {
|
|
185
|
+
throw new Error("unhandled Plutus version")
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
res.userFuncs[name] = program
|
|
190
|
+
}
|
|
191
|
+
|
|
129
192
|
return res
|
|
130
193
|
})
|
|
131
194
|
}
|
|
@@ -160,12 +223,17 @@ class ContractContextCache {
|
|
|
160
223
|
toJson() {
|
|
161
224
|
return this.cache.map((entry) => {
|
|
162
225
|
/**
|
|
163
|
-
* @type {
|
|
226
|
+
* @type {CacheEntryValidatorsJson}
|
|
164
227
|
*/
|
|
165
|
-
const
|
|
228
|
+
const resValidators = {}
|
|
166
229
|
|
|
167
|
-
|
|
168
|
-
|
|
230
|
+
/**
|
|
231
|
+
* @type {CacheEntryUserFuncsJson}
|
|
232
|
+
*/
|
|
233
|
+
const resUserFuncs = {}
|
|
234
|
+
|
|
235
|
+
for (let name in entry.validators) {
|
|
236
|
+
const hash = entry.validators[name]
|
|
169
237
|
|
|
170
238
|
const purpose =
|
|
171
239
|
hash instanceof ValidatorHash
|
|
@@ -206,7 +274,7 @@ class ContractContextCache {
|
|
|
206
274
|
}
|
|
207
275
|
}
|
|
208
276
|
|
|
209
|
-
|
|
277
|
+
resValidators[name] = {
|
|
210
278
|
purpose: purpose,
|
|
211
279
|
bytes: hash.bytes,
|
|
212
280
|
optimizedCborHex: bytesToHex(hash.context.program.toCbor()),
|
|
@@ -220,7 +288,27 @@ class ContractContextCache {
|
|
|
220
288
|
}
|
|
221
289
|
}
|
|
222
290
|
|
|
223
|
-
|
|
291
|
+
for (let name in entry.userFuncs) {
|
|
292
|
+
const userFunc = entry.userFuncs[name]
|
|
293
|
+
|
|
294
|
+
resUserFuncs[name] = {
|
|
295
|
+
optimizedCborHex: bytesToHex(userFunc.toCbor()),
|
|
296
|
+
unoptimizedCborHex: /** @type {UplcProgramV2} */ (userFunc)
|
|
297
|
+
.alt
|
|
298
|
+
? bytesToHex(
|
|
299
|
+
/** @type {UplcProgramV2} */ (
|
|
300
|
+
userFunc
|
|
301
|
+
).alt.toCbor()
|
|
302
|
+
)
|
|
303
|
+
: undefined,
|
|
304
|
+
plutusVersion: userFunc.plutusVersion
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
validators: resValidators,
|
|
310
|
+
userFuncs: resUserFuncs
|
|
311
|
+
}
|
|
224
312
|
})
|
|
225
313
|
}
|
|
226
314
|
}
|
|
@@ -4,17 +4,25 @@ import {
|
|
|
4
4
|
StakingValidatorHash,
|
|
5
5
|
ValidatorHash
|
|
6
6
|
} from "@helios-lang/ledger"
|
|
7
|
-
import { None } from "@helios-lang/type-utils"
|
|
8
|
-
import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
7
|
+
import { None, expectSome } from "@helios-lang/type-utils"
|
|
8
|
+
import { UplcProgramV1, UplcProgramV2 } from "@helios-lang/uplc"
|
|
9
9
|
import { configureCast } from "../cast/index.js"
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
12
13
|
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
13
14
|
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
14
15
|
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
15
16
|
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
16
17
|
*/
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* validators: {[name: string]: AnyContractValidatorContext}
|
|
22
|
+
* userFuncs: {[name: string]: UplcProgram}
|
|
23
|
+
* }} DagCompilerOutput
|
|
24
|
+
*/
|
|
25
|
+
|
|
18
26
|
/**
|
|
19
27
|
* Compiles a set of validators that depend on eachothers hashes (forming a Directed Acyclical Graph)
|
|
20
28
|
*/
|
|
@@ -38,7 +46,14 @@ export class DagCompiler {
|
|
|
38
46
|
* @readonly
|
|
39
47
|
* @type {{[name: string]: AnyContractValidatorContext}}
|
|
40
48
|
*/
|
|
41
|
-
|
|
49
|
+
cachedValidators
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @private
|
|
53
|
+
* @readonly
|
|
54
|
+
* @type {{[name: string]: UplcProgram}}
|
|
55
|
+
*/
|
|
56
|
+
cachedUserFuncs
|
|
42
57
|
|
|
43
58
|
/**
|
|
44
59
|
* @param {CompilerLib} lib
|
|
@@ -47,7 +62,8 @@ export class DagCompiler {
|
|
|
47
62
|
constructor(lib, castConfig) {
|
|
48
63
|
this.lib = lib
|
|
49
64
|
this.castConfig = castConfig
|
|
50
|
-
this.
|
|
65
|
+
this.cachedValidators = {}
|
|
66
|
+
this.cachedUserFuncs = {}
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
/**
|
|
@@ -55,7 +71,7 @@ export class DagCompiler {
|
|
|
55
71
|
* @param {Record<string, any>} parameters
|
|
56
72
|
* @param {boolean} isTestnet
|
|
57
73
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
58
|
-
* @returns {
|
|
74
|
+
* @returns {DagCompilerOutput}
|
|
59
75
|
*/
|
|
60
76
|
build(validators, parameters, isTestnet, expectedHashes = None) {
|
|
61
77
|
const hashTypes = this.getHashTypes(validators)
|
|
@@ -70,7 +86,7 @@ export class DagCompiler {
|
|
|
70
86
|
const sourceCode = validator.$sourceCode
|
|
71
87
|
|
|
72
88
|
// if already built before, return immediately
|
|
73
|
-
if (name in this.
|
|
89
|
+
if (name in this.cachedValidators) {
|
|
74
90
|
return
|
|
75
91
|
}
|
|
76
92
|
|
|
@@ -81,17 +97,26 @@ export class DagCompiler {
|
|
|
81
97
|
const hashDeps = this.getHashDependencies(validator)
|
|
82
98
|
const moduleDeps = getModuleDependencies(validator)
|
|
83
99
|
|
|
100
|
+
const excludeUserFuncs = new Set(Object.keys(this.cachedUserFuncs))
|
|
101
|
+
|
|
84
102
|
// optimized compilation
|
|
85
103
|
const { cborHex: optimizedCborHex } = this.lib.compile(
|
|
86
104
|
sourceCode,
|
|
87
105
|
moduleDeps,
|
|
88
106
|
{
|
|
89
|
-
optimize:
|
|
107
|
+
optimize: true,
|
|
90
108
|
hashDependencies: hashDeps,
|
|
91
109
|
allValidatorHashTypes: hashTypes,
|
|
92
110
|
dependsOnOwnHash: validator.$dependsOnOwnHash,
|
|
93
111
|
parameters: parameters,
|
|
94
|
-
isTestnet: isTestnet
|
|
112
|
+
isTestnet: isTestnet,
|
|
113
|
+
excludeUserFuncs: excludeUserFuncs,
|
|
114
|
+
onCompileUserFunc: (name, cborHex, plutusVersion) => {
|
|
115
|
+
this.cachedUserFuncs[name] =
|
|
116
|
+
plutusVersion == "PlutusScriptV1"
|
|
117
|
+
? UplcProgramV1.fromCbor(cborHex)
|
|
118
|
+
: UplcProgramV2.fromCbor(cborHex)
|
|
119
|
+
}
|
|
95
120
|
}
|
|
96
121
|
)
|
|
97
122
|
|
|
@@ -114,20 +139,49 @@ export class DagCompiler {
|
|
|
114
139
|
validator.$sourceCode,
|
|
115
140
|
Array.from(moduleDeps.values()),
|
|
116
141
|
{
|
|
117
|
-
optimize:
|
|
142
|
+
optimize: false,
|
|
118
143
|
hashDependencies: hashDeps,
|
|
119
144
|
allValidatorHashTypes: hashTypes,
|
|
120
145
|
ownHash: validator.$dependsOnOwnHash ? ownHash : undefined,
|
|
121
146
|
parameters: parameters,
|
|
122
|
-
isTestnet: isTestnet
|
|
147
|
+
isTestnet: isTestnet,
|
|
148
|
+
excludeUserFuncs: excludeUserFuncs,
|
|
149
|
+
onCompileUserFunc: (name, cborHex, plutusVersion) => {
|
|
150
|
+
const prev = expectSome(this.cachedUserFuncs[name])
|
|
151
|
+
|
|
152
|
+
if (plutusVersion == "PlutusScriptV1") {
|
|
153
|
+
if (prev instanceof UplcProgramV1) {
|
|
154
|
+
this.cachedUserFuncs[name] =
|
|
155
|
+
UplcProgramV1.fromCbor(cborHex).withAlt(
|
|
156
|
+
prev
|
|
157
|
+
)
|
|
158
|
+
} else {
|
|
159
|
+
throw new Error("previous not UplcProgramV1")
|
|
160
|
+
}
|
|
161
|
+
} else if (plutusVersion == "PlutusScriptV2") {
|
|
162
|
+
if (prev instanceof UplcProgramV2) {
|
|
163
|
+
this.cachedUserFuncs[name] =
|
|
164
|
+
UplcProgramV2.fromCbor(cborHex).withAlt(
|
|
165
|
+
prev
|
|
166
|
+
)
|
|
167
|
+
} else {
|
|
168
|
+
throw new Error("previous not UplcProgramV2")
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
throw new Error(
|
|
172
|
+
`unhandled PlutusVersion ${plutusVersion}`
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
123
176
|
}
|
|
124
177
|
)
|
|
125
178
|
|
|
179
|
+
// TODO: with source mapping
|
|
126
180
|
const unoptimizedProgram =
|
|
127
181
|
UplcProgramV2.fromCbor(unoptimizedCborHex)
|
|
128
182
|
|
|
129
183
|
// add result to cache (unoptimizedProgram is attached to optimizedProgram)
|
|
130
|
-
this.
|
|
184
|
+
this.addValidatorToCache(
|
|
131
185
|
validator,
|
|
132
186
|
optimizedProgram.withAlt(unoptimizedProgram),
|
|
133
187
|
ownHash
|
|
@@ -136,7 +190,10 @@ export class DagCompiler {
|
|
|
136
190
|
|
|
137
191
|
validators.forEach((v) => buildValidator(v))
|
|
138
192
|
|
|
139
|
-
return
|
|
193
|
+
return {
|
|
194
|
+
validators: this.cachedValidators,
|
|
195
|
+
userFuncs: this.cachedUserFuncs
|
|
196
|
+
}
|
|
140
197
|
}
|
|
141
198
|
|
|
142
199
|
/**
|
|
@@ -145,20 +202,20 @@ export class DagCompiler {
|
|
|
145
202
|
* @param {UplcProgramV2} program
|
|
146
203
|
* @param {string} hash - although this can be derived from `program`, reuse this to save some effort
|
|
147
204
|
*/
|
|
148
|
-
|
|
205
|
+
addValidatorToCache(validator, program, hash) {
|
|
149
206
|
const name = validator.$name
|
|
150
207
|
const redeemer = configureCast(validator.$Redeemer, this.castConfig)
|
|
151
208
|
|
|
152
209
|
switch (validator.$purpose) {
|
|
153
210
|
case "spending":
|
|
154
|
-
this.
|
|
211
|
+
this.cachedValidators[name] = new ValidatorHash(hash, {
|
|
155
212
|
program,
|
|
156
213
|
redeemer,
|
|
157
214
|
datum: configureCast(validator.$Datum, this.castConfig)
|
|
158
215
|
})
|
|
159
216
|
break
|
|
160
217
|
case "minting":
|
|
161
|
-
this.
|
|
218
|
+
this.cachedValidators[name] = new MintingPolicyHash(hash, {
|
|
162
219
|
program,
|
|
163
220
|
redeemer
|
|
164
221
|
})
|
|
@@ -166,7 +223,7 @@ export class DagCompiler {
|
|
|
166
223
|
case "certifying":
|
|
167
224
|
case "rewarding":
|
|
168
225
|
case "staking":
|
|
169
|
-
this.
|
|
226
|
+
this.cachedValidators[name] = new StakingValidatorHash(hash, {
|
|
170
227
|
program,
|
|
171
228
|
redeemer
|
|
172
229
|
})
|
|
@@ -189,7 +246,7 @@ export class DagCompiler {
|
|
|
189
246
|
|
|
190
247
|
validator.$hashDependencies.forEach((dep) => {
|
|
191
248
|
const k = dep.$name
|
|
192
|
-
const v = this.
|
|
249
|
+
const v = this.cachedValidators[k]
|
|
193
250
|
|
|
194
251
|
if (!v) {
|
|
195
252
|
throw new Error(
|
package/types/cast/UserFunc.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import("@helios-lang/type-utils").TypeSchema} TypeSchema
|
|
3
|
-
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
4
|
-
*/
|
|
5
1
|
/**
|
|
6
2
|
* @typedef {{
|
|
7
3
|
* requiresScriptContext: boolean
|
|
@@ -18,17 +14,30 @@
|
|
|
18
14
|
*/
|
|
19
15
|
export class UserFunc<T> {
|
|
20
16
|
/**
|
|
17
|
+
* @param {UplcProgram} uplc
|
|
21
18
|
* @param {UserFuncProps} props
|
|
22
19
|
*/
|
|
23
|
-
constructor(props: UserFuncProps);
|
|
20
|
+
constructor(uplc: UplcProgram, props: UserFuncProps);
|
|
24
21
|
/**
|
|
22
|
+
* @private
|
|
23
|
+
* @readonly
|
|
24
|
+
* @type {UplcProgram}
|
|
25
|
+
*/
|
|
26
|
+
private readonly uplc;
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
25
29
|
* @readonly
|
|
26
30
|
* @type {UserFuncProps}
|
|
27
31
|
*/
|
|
28
|
-
readonly props
|
|
32
|
+
private readonly props;
|
|
33
|
+
/**
|
|
34
|
+
* @type {T}
|
|
35
|
+
*/
|
|
36
|
+
get evalUnsafe(): T;
|
|
29
37
|
}
|
|
30
38
|
export type TypeSchema = import("@helios-lang/type-utils").TypeSchema;
|
|
31
39
|
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
40
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
32
41
|
export type UserFuncProps = {
|
|
33
42
|
requiresScriptContext: boolean;
|
|
34
43
|
requiresCurrentScript: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserFunc.d.ts","sourceRoot":"","sources":["../../src/cast/UserFunc.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UserFunc.d.ts","sourceRoot":"","sources":["../../src/cast/UserFunc.js"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH;IAeI;;;OAGG;IACH,kBAHW,WAAW,SACX,aAAa,EAKvB;IArBD;;;;OAIG;IACH,sBAAI;IAEJ;;;;OAIG;IACH,uBAAK;IAWL;;OAEG;IACH,oBA4CC;CACJ;yBA/FY,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;CACpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
1
2
|
export type CastLike<TStrict, TPermissive> = import("../cast/Cast.js").CastLike<TStrict, TPermissive>;
|
|
2
3
|
export type LoadedModule = {
|
|
3
4
|
$name: string;
|
|
@@ -7,5 +8,9 @@ export type LoadedModule = {
|
|
|
7
8
|
$types: {
|
|
8
9
|
[name: string]: CastLike<any, any>;
|
|
9
10
|
};
|
|
11
|
+
$functions: {
|
|
12
|
+
[name: string]: (uplc: UplcProgram) => UserFunc<any>;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
15
|
+
import { UserFunc } from "../cast/UserFunc.js";
|
|
11
16
|
//# sourceMappingURL=LoadedModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedModule.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoadedModule.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedModule.js"],"names":[],"mappings":"0BAGa,OAAO,mBAAmB,EAAE,WAAW;6CAMvC,OAAO,iBAAiB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;;WAKzD,MAAM;cACH,QAAQ;iBACL,MAAM;mBACJ,cAAc,YAAY,CAAC;;;;;+BAEN,WAAW,KAAK,SAAS,GAAG,CAAC;;;yBAnB7C,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;;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,CAkC/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,
|
|
1
|
+
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;;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,CAkC/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,QAyB7C;IAED;;;OAGG;IACH,oBA6BC;IAED;;;OAGG;IACH,uBAiDC;CACJ;gCAvVY,OAAO,wBAAwB,EAAE,iBAAiB;kCAClD,OAAO,wBAAwB,EAAE,mBAAmB;mCACpD,OAAO,2BAA2B,EAAE,oBAAoB;yBACxD,OAAO,iBAAiB,EAAE,UAAU;6BAPpB,0BAA0B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type CastLike<TStrict, TPermissive> = import("../cast/Cast.js").CastLike<TStrict, TPermissive>;
|
|
2
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
2
3
|
export type LoadedModule = import("./LoadedModule.js").LoadedModule;
|
|
3
4
|
export type LoadedValidator = {
|
|
4
5
|
$name: string;
|
|
@@ -9,6 +10,9 @@ export type LoadedValidator = {
|
|
|
9
10
|
$types: {
|
|
10
11
|
[name: string]: CastLike<any, any>;
|
|
11
12
|
};
|
|
13
|
+
$functions: {
|
|
14
|
+
[name: string]: (uplc: UplcProgram) => UserFunc<any>;
|
|
15
|
+
};
|
|
12
16
|
$Redeemer: CastLike<any, any>;
|
|
13
17
|
} & ({
|
|
14
18
|
$purpose: "spending" | "mixed";
|
|
@@ -27,4 +31,5 @@ export type NamedDependenciesToObject<N extends readonly {
|
|
|
27
31
|
$name: name;
|
|
28
32
|
}>; };
|
|
29
33
|
export type ExtractDependencies<V extends LoadedValidator> = NamedDependenciesToObject<V["$dependencies"]>;
|
|
34
|
+
import { UserFunc } from "../cast/UserFunc.js";
|
|
30
35
|
//# sourceMappingURL=LoadedValidator.d.ts.map
|
|
@@ -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;
|
|
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;;WAKzC,MAAM;iBACA,MAAM;mBACJ,cAAc,YAAY,CAAC;uBACvB,cAAc,eAAe,CAAC;uBAC9B,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;yBA/CjC,qBAAqB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
2
3
|
* @typedef {import("@helios-lang/uplc").UplcData} UplcData
|
|
3
4
|
* @typedef {import("../codegen/index.js").TypeSchema} InternalTypeDetails
|
|
4
5
|
* @typedef {import("../codegen/index.js").TypeCheckedModule} TypeCheckedModule
|
|
@@ -16,6 +17,8 @@
|
|
|
16
17
|
* parameters?: Record<string, UplcData>
|
|
17
18
|
* isTestnet: boolean
|
|
18
19
|
* optimize: boolean
|
|
20
|
+
* excludeUserFuncs?: Set<string>
|
|
21
|
+
* onCompileUserFunc?: (name: string, cborHex: string, plutusVersion: PlutusVersion) => void
|
|
19
22
|
* }} CompileOptions
|
|
20
23
|
*/
|
|
21
24
|
/**
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
export function getValidatorTypes(lib: CompilerLib, validators: string[]): {
|
|
59
62
|
[name: string]: any;
|
|
60
63
|
};
|
|
64
|
+
export type PlutusVersion = import("@helios-lang/uplc").PlutusVersion;
|
|
61
65
|
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
62
66
|
export type InternalTypeDetails = import("../codegen/index.js").TypeSchema;
|
|
63
67
|
export type TypeCheckedModule = import("../codegen/index.js").TypeCheckedModule;
|
|
@@ -75,6 +79,8 @@ export type CompileOptions = {
|
|
|
75
79
|
parameters?: Record<string, import("@helios-lang/uplc").UplcData> | undefined;
|
|
76
80
|
isTestnet: boolean;
|
|
77
81
|
optimize: boolean;
|
|
82
|
+
excludeUserFuncs?: Set<string> | undefined;
|
|
83
|
+
onCompileUserFunc?: ((name: string, cborHex: string, plutusVersion: PlutusVersion) => void) | undefined;
|
|
78
84
|
};
|
|
79
85
|
export type CompileOutput = {
|
|
80
86
|
cborHex: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"CompilerLib.d.ts","sourceRoot":"","sources":["../../src/compiler/CompilerLib.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AAEH;;GAEG;AAEH;;;;GAIG;AACH,uCAJW,WAAW,cACX,MAAM,EAAE;;EAUlB;4BA1EY,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;;;;;;;;;;;eAUA,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"}
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
* @typedef {{
|
|
11
11
|
* name: string
|
|
12
12
|
* changeParam(key: string, value: UplcData): void
|
|
13
|
-
* compile(options: {
|
|
13
|
+
* compile(options: {
|
|
14
|
+
* optimize?: boolean,
|
|
15
|
+
* dependsOnOwnHash?: boolean,
|
|
16
|
+
* hashDependencies?: Record<string, string>
|
|
17
|
+
* excludeUserFuncs?: Set<string>
|
|
18
|
+
* onCompileUserFunc?: (name: string, uplc: UplcProgramV2) => void
|
|
19
|
+
* }): UplcProgramV2
|
|
14
20
|
* }} Program
|
|
15
21
|
*/
|
|
16
22
|
/**
|
|
@@ -59,9 +65,11 @@ export type Program = {
|
|
|
59
65
|
name: string;
|
|
60
66
|
changeParam(key: string, value: UplcData): void;
|
|
61
67
|
compile(options: {
|
|
62
|
-
optimize?: boolean;
|
|
63
|
-
dependsOnOwnHash?: boolean;
|
|
64
|
-
hashDependencies?: Record<string, string
|
|
68
|
+
optimize?: boolean | undefined;
|
|
69
|
+
dependsOnOwnHash?: boolean | undefined;
|
|
70
|
+
hashDependencies?: Record<string, string> | undefined;
|
|
71
|
+
excludeUserFuncs?: Set<string> | undefined;
|
|
72
|
+
onCompileUserFunc?: ((name: string, uplc: UplcProgramV2) => void) | undefined;
|
|
65
73
|
}): UplcProgramV2;
|
|
66
74
|
};
|
|
67
75
|
import { UplcProgramV2 } from "@helios-lang/uplc";
|
|
@@ -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;;;;;;;;;;;;GAYG;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,CAsDzB;IAED;;;;OAIG;IACH,4BAJW,MAAM,EAAE,iBACR,MAAM,EAAE,GACN,eAAe,CAM3B;CACJ;uBA9HY,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;qBACK,MAAM,SAAS,QAAQ,GAAG,IAAI;;;;;;oCAMlB,MAAM,QAAQ,aAAa,KAAK,IAAI;QAC7D,aAAa;;8BArBQ,mBAAmB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
1
2
|
export type LoadedModule = import("../codegen/index.js").LoadedModule;
|
|
2
3
|
export type LoadedValidator = import("../codegen/index.js").LoadedValidator;
|
|
3
4
|
export type MintingContext<TRedeemerStrict, TRedeemerPermissive> = import("@helios-lang/ledger").MintingContext<TRedeemerStrict, TRedeemerPermissive>;
|
|
@@ -13,29 +14,39 @@ export type ContractValidatorContexts<V extends import("../codegen/LoadedValidat
|
|
|
13
14
|
"$Redeemer": CastLike<any, any>;
|
|
14
15
|
} ? {
|
|
15
16
|
$hash: ValidatorHash<SpendingContext<StrictType<V["$Datum"]>, PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
16
|
-
} & ContractTypesContext<V["$types"]> : V extends {
|
|
17
|
+
} & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> : V extends {
|
|
17
18
|
"$purpose": "minting";
|
|
18
19
|
"$Redeemer": CastLike<any, any>;
|
|
19
20
|
} ? {
|
|
20
21
|
$hash: MintingPolicyHash<MintingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
21
|
-
} & ContractTypesContext<V["$types"]> : V extends {
|
|
22
|
+
} & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> : V extends {
|
|
22
23
|
"$purpose": ("certifying" | "rewarding" | "staking");
|
|
23
24
|
"$Redeemer": CastLike<any, any>;
|
|
24
25
|
} ? {
|
|
25
26
|
$hash: StakingValidatorHash<StakingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
26
|
-
} & ContractTypesContext<V["$types"]> :
|
|
27
|
-
|
|
27
|
+
} & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> : V extends {
|
|
28
|
+
"$purpose": "mixed";
|
|
29
|
+
"$Datum": CastLike<any, any>;
|
|
30
|
+
"$Redeemer": CastLike<any, any>;
|
|
31
|
+
} ? {
|
|
32
|
+
$hash: ScriptHash<SpendingContext<StrictType<V["$Datum"]>, PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
33
|
+
} & ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]> : never;
|
|
34
|
+
export type ContractModuleContexts<V extends import("../codegen/LoadedModule.js").LoadedModule> = ContractTypesContext<V["$types"]> & ContractUserFuncsContext<V["$functions"]>;
|
|
28
35
|
export type ContractTypesContext<T extends {
|
|
29
36
|
[typeName: string]: CastLike<any, any>;
|
|
30
37
|
}> = { [K in keyof T]: Cast<import("../cast/StrictType.js").StrictType<T[K]>, import("../cast/PermissiveType.js").PermissiveType<T[K]>>; };
|
|
38
|
+
export type ContractUserFuncsContext<T extends {
|
|
39
|
+
[funcName: string]: (uplc: UplcProgram) => UserFunc<any>;
|
|
40
|
+
}> = { [K in keyof T]: UserFunc<T[K]>; };
|
|
31
41
|
export type ContractContext<Vs extends {
|
|
32
42
|
[name: string]: import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
33
43
|
}, Ms extends {
|
|
34
44
|
[name: string]: import("../codegen/LoadedModule.js").LoadedModule;
|
|
35
|
-
}> = { [K in keyof Vs]: ContractValidatorContexts<Vs[K]>; } & { [K_1 in keyof Ms]:
|
|
45
|
+
}> = { [K in keyof Vs]: ContractValidatorContexts<Vs[K]>; } & { [K_1 in keyof Ms]: ContractModuleContexts<Ms[K_1]>; };
|
|
36
46
|
import { ValidatorHash } from "@helios-lang/ledger";
|
|
37
47
|
import { MintingPolicyHash } from "@helios-lang/ledger";
|
|
38
48
|
import { StakingValidatorHash } from "@helios-lang/ledger";
|
|
39
49
|
import { ScriptHash } from "@helios-lang/ledger";
|
|
40
50
|
import { Cast } from "../cast/index.js";
|
|
51
|
+
import { UserFunc } from "../cast/index.js";
|
|
41
52
|
//# sourceMappingURL=ContractContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"0BASa,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,qBAAqB,EAAE,YAAY;8BAC1C,OAAO,qBAAqB,EAAE,eAAe;mEAM7C,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;oGAQlF,OAAO,qBAAqB,EAAE,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,CAAC;mEAMnH,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;6CAMlF,OAAO,kBAAkB,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;2DAKzD,OAAO,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;uDAK5C,OAAO,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;0CAIxC,CACZ,cAAkB,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GACtD,kBAAsB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,GAC/C,qBAAyB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,GAClD,UAAc,CACX;2GAKS,CAAC,SAAS;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAChH,KAAa,EAAE,cACf,gBACA,WAAuB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACnC,eAA2B,CAAC,CAAC,QAAQ,CAAC,CAAC,EACvC,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC,GACvF,CAAO,SAAS;IAAC,UAAU,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAC3E,KAAa,EAAE,kBACf,eACA,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC,GACvF,CAAO,SAAS;IAAC,UAAU,EAAE,CAAC,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IAC1G,KAAa,EAAE,qBACf,eACA,WAAuB,CAAC,CAAC,WAAW,CAAC,CAAC,EACtC,eAA2B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC,GACvF,CAAO,SAAS;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;IAAC,WAAW,EAAE,SAAS,GAAG,EAAE,GAAG,CAAC,CAAA;CAAC,GAAG;IACvG,KAAa,EAAE,WACf,gBACA,WAAwB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACpC,eAA4B,CAAC,CAAC,QAAQ,CAAC,CAAC,EACxC,WAAwB,CAAC,CAAC,WAAW,CAAC,CAAC,EACvC,eAA4B,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACH,CAAA;CACF,GAAG,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC,GACvF,KAAW;kGAMC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC;;;;;+BAWhD,WAAW,KAAK,SAAS,GAAG,CAAC;;;;;;;8BA7GhE,qBAAqB;kCAArB,qBAAqB;qCAArB,qBAAqB;2BAArB,qBAAqB;qBACG,kBAAkB;yBAAlB,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;;;GAOG;AAEH;;;GAGG;AACH;;;;;IAwBI;;OAEG;IACH,gBAFa,uBAAuB,EAAE,EAAE,EAAE,CAAC,CAI1C;IAfD;;;;OAIG;IACH,sBAGC;IArBD;;;;OAIG;IACH,4BAAU;IAEV;;;OAGG;IACH,kBAFU,EAAE,CAEL;IAmBP;;;;;;;OAOG;IACH,8JAaC;IAED;;;;;;;OAOG;IACH,sIAQC;IAED;;;OAGG;IACH,aAHW,yBAAyB,GACvB,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAsFnC;CACJ;yBA/LY,OAAO,kBAAkB,EAAE,UAAU;2BACrC,OAAO,4BAA4B,EAAE,YAAY;8BACjD,OAAO,+BAA+B,EAAE,eAAe;0BACvD,OAAO,sBAAsB,EAAE,WAAW;wFAK1C,OAAO,+BAA+B,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;;;KAM9D,OAAO,sBAAsB,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC;;eAKnD,OAAO"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
export const contractContextCache: ContractContextCache;
|
|
2
2
|
export type PlutusVersion = import("@helios-lang/uplc").PlutusVersion;
|
|
3
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
3
4
|
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
4
5
|
export type TypeSchema = import("../codegen/index.js").TypeSchema;
|
|
5
6
|
export type AnyContractValidatorContext = import("./ContractContext.js").AnyContractValidatorContext;
|
|
6
7
|
export type CacheEntry = {
|
|
7
|
-
|
|
8
|
+
validators: {
|
|
9
|
+
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
|
10
|
+
};
|
|
11
|
+
userFuncs: {
|
|
12
|
+
[name: string]: import("@helios-lang/uplc").UplcProgram;
|
|
13
|
+
};
|
|
8
14
|
};
|
|
9
|
-
export type
|
|
15
|
+
export type CacheEntryValidatorsJson = {
|
|
10
16
|
[name: string]: {
|
|
11
17
|
purpose: "minting" | "spending" | "staking" | "mixed";
|
|
12
18
|
bytes: number[];
|
|
@@ -18,26 +24,54 @@ export type CacheEntryJson = {
|
|
|
18
24
|
redeemer: TypeSchema;
|
|
19
25
|
};
|
|
20
26
|
};
|
|
27
|
+
export type CacheEntryUserFuncsJson = {
|
|
28
|
+
[name: string]: {
|
|
29
|
+
unoptimizedCborHex?: string | undefined;
|
|
30
|
+
optimizedCborHex: string;
|
|
31
|
+
plutusVersion: PlutusVersion;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type CacheEntryJson = {
|
|
35
|
+
validators: CacheEntryValidatorsJson;
|
|
36
|
+
userFuncs: CacheEntryUserFuncsJson;
|
|
37
|
+
};
|
|
21
38
|
/**
|
|
22
39
|
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
40
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
23
41
|
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
24
42
|
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
25
43
|
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
26
44
|
*/
|
|
27
45
|
/**
|
|
28
|
-
* @typedef {{
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* validators: {[name: string]: AnyContractValidatorContext}
|
|
48
|
+
* userFuncs: {[name: string]: UplcProgram}
|
|
49
|
+
* }} CacheEntry
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {{[name: string]: {
|
|
53
|
+
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
54
|
+
* bytes: number[]
|
|
55
|
+
* unoptimizedCborHex?: string
|
|
56
|
+
* optimizedCborHex: string
|
|
57
|
+
* plutusVersion: PlutusVersion
|
|
58
|
+
* castConfig: CastConfig
|
|
59
|
+
* datum?: TypeSchema
|
|
60
|
+
* redeemer: TypeSchema
|
|
61
|
+
* }}} CacheEntryValidatorsJson
|
|
29
62
|
*/
|
|
30
63
|
/**
|
|
31
64
|
* @typedef {{[name: string]: {
|
|
32
|
-
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
33
|
-
* bytes: number[]
|
|
34
65
|
* unoptimizedCborHex?: string
|
|
35
66
|
* optimizedCborHex: string
|
|
36
67
|
* plutusVersion: PlutusVersion
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
68
|
+
* }}} CacheEntryUserFuncsJson
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {{
|
|
72
|
+
* validators: CacheEntryValidatorsJson
|
|
73
|
+
* userFuncs: CacheEntryUserFuncsJson
|
|
74
|
+
* }} CacheEntryJson
|
|
41
75
|
*/
|
|
42
76
|
declare class ContractContextCache {
|
|
43
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"AA2TA,wDAA8D;4BA9SjD,OAAO,mBAAmB,EAAE,aAAa;0BACzC,OAAO,mBAAmB,EAAE,WAAW;yBACvC,OAAO,kBAAkB,EAAE,UAAU;yBACrC,OAAO,qBAAqB,EAAE,UAAU;0CACxC,OAAO,sBAAsB,EAAE,2BAA2B;;;;;;;;;;;iBAYvD,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO;eAC9C,MAAM,EAAE;;0BAEG,MAAM;uBACT,aAAa;oBAChB,UAAU;;kBAEZ,UAAU;;;;;;0BAOJ,MAAM;uBACT,aAAa;;;6BAKpB;IACZ,UAAc,EAAE,wBAAwB,CAAA;IACxC,SAAa,EAAE,uBAAuB,CAAA;CACnC;AAxCJ;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;IACI;;OAEG;IACH,OAFU,UAAU,EAAE,CAEjB;IAEL;;;OAGG;IACH,GAFU,MAAM,CAEf;IAED;;OAEG;IACH,SAFU,OAAO,CAEV;IAQP,eAEC;IAED;;OAEG;IACH,WAFW,cAAc,EAAE,QA8G1B;IAED;;OAEG;IACH,aAFW,UAAU,QAMpB;IAED;;OAEG;IACH,SAFa,OAAO,UAAU,CAAC,CAY9B;IAED;;OAEG;IACH,UAFY,cAAc,EAAE,CA4F3B;CACJ"}
|
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function getModuleDependencies(validator: LoadedValidator): string[];
|
|
6
6
|
/**
|
|
7
|
+
* @typedef {import("@helios-lang/uplc").UplcProgram} UplcProgram
|
|
7
8
|
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
8
9
|
* @typedef {import("../codegen/LoadedValidator.js").LoadedValidator} LoadedValidator
|
|
9
10
|
* @typedef {import("../compiler/index.js").CompilerLib} CompilerLib
|
|
10
11
|
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
11
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* validators: {[name: string]: AnyContractValidatorContext}
|
|
16
|
+
* userFuncs: {[name: string]: UplcProgram}
|
|
17
|
+
* }} DagCompilerOutput
|
|
18
|
+
*/
|
|
12
19
|
/**
|
|
13
20
|
* Compiles a set of validators that depend on eachothers hashes (forming a Directed Acyclical Graph)
|
|
14
21
|
*/
|
|
@@ -35,27 +42,31 @@ export class DagCompiler {
|
|
|
35
42
|
* @readonly
|
|
36
43
|
* @type {{[name: string]: AnyContractValidatorContext}}
|
|
37
44
|
*/
|
|
38
|
-
private readonly
|
|
45
|
+
private readonly cachedValidators;
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
* @readonly
|
|
49
|
+
* @type {{[name: string]: UplcProgram}}
|
|
50
|
+
*/
|
|
51
|
+
private readonly cachedUserFuncs;
|
|
39
52
|
castConfig: import("../cast/Cast.js").CastConfig;
|
|
40
53
|
/**
|
|
41
54
|
* @param {LoadedValidator[]} validators
|
|
42
55
|
* @param {Record<string, any>} parameters
|
|
43
56
|
* @param {boolean} isTestnet
|
|
44
57
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
45
|
-
* @returns {
|
|
58
|
+
* @returns {DagCompilerOutput}
|
|
46
59
|
*/
|
|
47
60
|
build(validators: LoadedValidator[], parameters: Record<string, any>, isTestnet: boolean, expectedHashes?: Option<{
|
|
48
61
|
[name: string]: string;
|
|
49
|
-
}>):
|
|
50
|
-
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
|
51
|
-
};
|
|
62
|
+
}>): DagCompilerOutput;
|
|
52
63
|
/**
|
|
53
64
|
* @private
|
|
54
65
|
* @param {LoadedValidator} validator
|
|
55
66
|
* @param {UplcProgramV2} program
|
|
56
67
|
* @param {string} hash - although this can be derived from `program`, reuse this to save some effort
|
|
57
68
|
*/
|
|
58
|
-
private
|
|
69
|
+
private addValidatorToCache;
|
|
59
70
|
/**
|
|
60
71
|
* @private
|
|
61
72
|
* @param {LoadedValidator} validator
|
|
@@ -69,8 +80,17 @@ export class DagCompiler {
|
|
|
69
80
|
*/
|
|
70
81
|
private getHashTypes;
|
|
71
82
|
}
|
|
83
|
+
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
72
84
|
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
73
85
|
export type LoadedValidator = import("../codegen/LoadedValidator.js").LoadedValidator;
|
|
74
86
|
export type CompilerLib = import("../compiler/index.js").CompilerLib;
|
|
75
87
|
export type AnyContractValidatorContext = import("./ContractContext.js").AnyContractValidatorContext;
|
|
88
|
+
export type DagCompilerOutput = {
|
|
89
|
+
validators: {
|
|
90
|
+
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
|
91
|
+
};
|
|
92
|
+
userFuncs: {
|
|
93
|
+
[name: string]: import("@helios-lang/uplc").UplcProgram;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
76
96
|
//# sourceMappingURL=DagCompiler.d.ts.map
|
|
@@ -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":"AAoRA;;;GAGG;AACH,iDAHW,eAAe,GACb,MAAM,EAAE,CAsBpB;AAlSD;;;;;;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,CA2H7B;IAED;;;;;OAKG;IACH,4BA6BC;IAED;;;;OAIG;IACH,4BAoBC;IAED;;;;OAIG;IACH,qBAMC;CACJ;0BAvQY,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"}
|