@helios-lang/contract-utils 0.2.1 → 0.2.3
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 +3 -3
- package/src/context/ContractContext.js +1 -1
- package/src/context/ContractContextBuilder.js +11 -8
- package/src/context/ContractContextCache.js +222 -0
- package/src/context/DagCompiler.js +1 -1
- package/src/context/index.js +1 -0
- package/src/index.js +1 -1
- package/types/context/ContractContext.d.ts +1 -1
- package/types/context/ContractContext.d.ts.map +1 -1
- package/types/context/ContractContextBuilder.d.ts.map +1 -1
- package/types/context/ContractContextCache.d.ts +75 -0
- package/types/context/ContractContextCache.d.ts.map +1 -0
- package/types/context/DagCompiler.d.ts +1 -1
- package/types/context/index.d.ts +1 -0
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@helios-lang/cli-utils": "^0.1.4",
|
|
39
39
|
"@helios-lang/codec-utils": "^0.1.29",
|
|
40
40
|
"@helios-lang/compiler-utils": "^0.1.22",
|
|
41
|
-
"@helios-lang/ledger": "^0.2.
|
|
41
|
+
"@helios-lang/ledger": "^0.2.3",
|
|
42
42
|
"@helios-lang/type-utils": "^0.1.8",
|
|
43
|
-
"@helios-lang/uplc": "^0.1.
|
|
43
|
+
"@helios-lang/uplc": "^0.1.28"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -59,7 +59,7 @@ import { Cast } from "../cast/index.js"
|
|
|
59
59
|
* @typedef {V extends {"$purpose": "spending", "$Datum": CastLike<any, any>, "$Redeemer": CastLike<any, any>} ? {
|
|
60
60
|
* $hash: ValidatorHash<
|
|
61
61
|
* SpendingContext<
|
|
62
|
-
* V["$Datum"]
|
|
62
|
+
* StrictType<V["$Datum"]>,
|
|
63
63
|
* PermissiveType<V["$Datum"]>,
|
|
64
64
|
* StrictType<V["$Redeemer"]>,
|
|
65
65
|
* PermissiveType<V["$Redeemer"]>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { None } from "@helios-lang/type-utils"
|
|
2
1
|
import { loadCompilerLib } from "../compiler/index.js"
|
|
3
2
|
import { DagCompiler } from "./DagCompiler.js"
|
|
4
3
|
import { configureCast } from "../cast/Cast.js"
|
|
4
|
+
import { contractContextCache } from "./ContractContextCache.js"
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
@@ -114,13 +114,16 @@ export class ContractContextBuilder {
|
|
|
114
114
|
|
|
115
115
|
const dagCompiler = new DagCompiler(lib, castConfig)
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
const cached = contractContextCache.shift()
|
|
118
|
+
|
|
119
|
+
const hashes = cached
|
|
120
|
+
? cached
|
|
121
|
+
: dagCompiler.build(
|
|
122
|
+
Object.values(this.validators),
|
|
123
|
+
props.expectedHashes
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
contractContextCache.push(hashes)
|
|
124
127
|
|
|
125
128
|
/**
|
|
126
129
|
* @type {any}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { bytesToHex } from "@helios-lang/codec-utils"
|
|
2
|
+
import {
|
|
3
|
+
MintingPolicyHash,
|
|
4
|
+
StakingValidatorHash,
|
|
5
|
+
ValidatorHash
|
|
6
|
+
} from "@helios-lang/ledger"
|
|
7
|
+
import { Cast } from "../cast/Cast.js"
|
|
8
|
+
import { None, expectSome } from "@helios-lang/type-utils"
|
|
9
|
+
import { UplcProgramV1 } from "@helios-lang/uplc"
|
|
10
|
+
import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
14
|
+
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
15
|
+
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
16
|
+
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{[name: string]: AnyContractValidatorContext}} CacheEntry
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {{[name: string]: {
|
|
25
|
+
* purpose: "minting" | "spending" | "staking"
|
|
26
|
+
* bytes: number[]
|
|
27
|
+
* unoptimizedCborHex?: string
|
|
28
|
+
* optimizedCborHex: string
|
|
29
|
+
* plutusVersion: PlutusVersion
|
|
30
|
+
* castConfig: CastConfig
|
|
31
|
+
* datum?: TypeSchema
|
|
32
|
+
* redeemer: TypeSchema
|
|
33
|
+
* }}} CacheEntryJson
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
class ContractContextCache {
|
|
37
|
+
/**
|
|
38
|
+
* @type {CacheEntry[]}
|
|
39
|
+
*/
|
|
40
|
+
cache
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Load count
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
i
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
*/
|
|
51
|
+
enabled
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
this.cache = []
|
|
55
|
+
this.enabled = false
|
|
56
|
+
this.i = 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
enable() {
|
|
60
|
+
this.enabled = true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {CacheEntryJson[]} json
|
|
65
|
+
*/
|
|
66
|
+
load(json) {
|
|
67
|
+
this.cache = json.map((entry) => {
|
|
68
|
+
/**
|
|
69
|
+
* @type {CacheEntry}
|
|
70
|
+
*/
|
|
71
|
+
const res = {}
|
|
72
|
+
|
|
73
|
+
for (let name in entry) {
|
|
74
|
+
const props = entry[name]
|
|
75
|
+
|
|
76
|
+
let program =
|
|
77
|
+
props.plutusVersion == "PlutusScriptV1"
|
|
78
|
+
? UplcProgramV1.fromCbor(props.optimizedCborHex)
|
|
79
|
+
: UplcProgramV2.fromCbor(props.optimizedCborHex)
|
|
80
|
+
|
|
81
|
+
if (props.unoptimizedCborHex) {
|
|
82
|
+
if (program instanceof UplcProgramV1) {
|
|
83
|
+
program = program.withAlt(
|
|
84
|
+
UplcProgramV1.fromCbor(props.unoptimizedCborHex)
|
|
85
|
+
)
|
|
86
|
+
} else if (program instanceof UplcProgramV2) {
|
|
87
|
+
program = program.withAlt(
|
|
88
|
+
UplcProgramV2.fromCbor(props.unoptimizedCborHex)
|
|
89
|
+
)
|
|
90
|
+
} else {
|
|
91
|
+
throw new Error("unhandled Plutus version")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let redeemer = new Cast(props.redeemer, props.castConfig)
|
|
96
|
+
|
|
97
|
+
switch (props.purpose) {
|
|
98
|
+
case "spending": {
|
|
99
|
+
res[name] = new ValidatorHash(props.bytes, {
|
|
100
|
+
datum: new Cast(
|
|
101
|
+
expectSome(props.datum),
|
|
102
|
+
props.castConfig
|
|
103
|
+
),
|
|
104
|
+
redeemer: redeemer,
|
|
105
|
+
program: program
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
case "minting": {
|
|
109
|
+
res[name] = new MintingPolicyHash(props.bytes, {
|
|
110
|
+
redeemer: redeemer,
|
|
111
|
+
program: program
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
case "staking": {
|
|
115
|
+
res[name] = new StakingValidatorHash(props.bytes, {
|
|
116
|
+
redeemer: redeemer,
|
|
117
|
+
program: program
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
default:
|
|
121
|
+
throw new Error("unhandled purpose")
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return res
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {CacheEntry} hashes
|
|
131
|
+
*/
|
|
132
|
+
push(hashes) {
|
|
133
|
+
if (this.enabled) {
|
|
134
|
+
this.cache.push(hashes)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @returns {Option<CacheEntry>}
|
|
140
|
+
*/
|
|
141
|
+
shift() {
|
|
142
|
+
if (this.i >= this.cache.length) {
|
|
143
|
+
return None
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const res = this.cache[this.i]
|
|
147
|
+
|
|
148
|
+
this.i += 1
|
|
149
|
+
|
|
150
|
+
return res
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @return {CacheEntryJson[]}
|
|
155
|
+
*/
|
|
156
|
+
toJson() {
|
|
157
|
+
return this.cache.map((entry) => {
|
|
158
|
+
/**
|
|
159
|
+
* @type {CacheEntryJson}
|
|
160
|
+
*/
|
|
161
|
+
const res = {}
|
|
162
|
+
|
|
163
|
+
for (let name in entry) {
|
|
164
|
+
const hash = entry[name]
|
|
165
|
+
|
|
166
|
+
const purpose =
|
|
167
|
+
hash instanceof ValidatorHash
|
|
168
|
+
? "spending"
|
|
169
|
+
: hash instanceof MintingPolicyHash
|
|
170
|
+
? "minting"
|
|
171
|
+
: hash instanceof StakingValidatorHash
|
|
172
|
+
? "staking"
|
|
173
|
+
: "unknown"
|
|
174
|
+
if (purpose == "unknown") {
|
|
175
|
+
throw new Error("unhandled hash type")
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const redeemer =
|
|
179
|
+
hash.context.redeemer instanceof Cast
|
|
180
|
+
? hash.context.redeemer
|
|
181
|
+
: None
|
|
182
|
+
|
|
183
|
+
if (!redeemer) {
|
|
184
|
+
throw new Error("Redeemer is not a Cast type")
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @type {Option<Cast>}
|
|
189
|
+
*/
|
|
190
|
+
let datum = None
|
|
191
|
+
|
|
192
|
+
if (hash instanceof ValidatorHash) {
|
|
193
|
+
datum =
|
|
194
|
+
hash.context.datum instanceof Cast
|
|
195
|
+
? hash.context.datum
|
|
196
|
+
: None
|
|
197
|
+
|
|
198
|
+
if (!datum) {
|
|
199
|
+
throw new Error("Datum is not a Cast type")
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
res[name] = {
|
|
204
|
+
purpose: purpose,
|
|
205
|
+
bytes: hash.bytes,
|
|
206
|
+
optimizedCborHex: bytesToHex(hash.context.program.toCbor()),
|
|
207
|
+
unoptimizedCborHex: hash.context.program.alt
|
|
208
|
+
? bytesToHex(hash.context.program.alt.toCbor())
|
|
209
|
+
: undefined,
|
|
210
|
+
plutusVersion: hash.context.program.plutusVersion,
|
|
211
|
+
castConfig: redeemer.config,
|
|
212
|
+
redeemer: redeemer.schema,
|
|
213
|
+
datum: datum?.schema
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return res
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export const contractContextCache = new ContractContextCache()
|
|
@@ -55,7 +55,7 @@ export class DagCompiler {
|
|
|
55
55
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
56
56
|
* @returns {{[name: string]: AnyContractValidatorContext}}
|
|
57
57
|
*/
|
|
58
|
-
build(validators,
|
|
58
|
+
build(validators, expectedHashes = None) {
|
|
59
59
|
const hashTypes = this.getHashTypes(validators)
|
|
60
60
|
|
|
61
61
|
/**
|
package/src/context/index.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./cast/index.js"
|
|
2
|
-
export
|
|
2
|
+
export * from "./context/index.js"
|
|
3
3
|
export { typeCheckFiles, typeCheckScripts } from "./compiler/ops.js"
|
|
4
4
|
export { LoadedScriptsWriter } from "./codegen/LoadedScriptsWriter.js"
|
|
5
5
|
export { loadCompilerLib } from "./compiler/ops.js"
|
|
@@ -12,7 +12,7 @@ export type ContractValidatorContexts<V extends import("../codegen/LoadedValidat
|
|
|
12
12
|
"$Datum": CastLike<any, any>;
|
|
13
13
|
"$Redeemer": CastLike<any, any>;
|
|
14
14
|
} ? {
|
|
15
|
-
$hash: ValidatorHash<SpendingContext<V["$Datum"]
|
|
15
|
+
$hash: ValidatorHash<SpendingContext<StrictType<V["$Datum"]>, PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>>;
|
|
16
16
|
} & ContractTypesContext<V["$types"]> : V extends {
|
|
17
17
|
"$purpose": "minting";
|
|
18
18
|
"$Redeemer": CastLike<any, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"2BAQa,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,k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/ContractContextBuilder.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;GAKG;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,
|
|
1
|
+
{"version":3,"file":"ContractContextBuilder.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextBuilder.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;GAKG;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,CAkDnC;CACJ;yBAzJY,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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const contractContextCache: ContractContextCache;
|
|
2
|
+
export type PlutusVersion = import("@helios-lang/uplc").PlutusVersion;
|
|
3
|
+
export type CastConfig = import("../cast/index.js").CastConfig;
|
|
4
|
+
export type TypeSchema = import("../codegen/index.js").TypeSchema;
|
|
5
|
+
export type AnyContractValidatorContext = import("./ContractContext.js").AnyContractValidatorContext;
|
|
6
|
+
export type CacheEntry = {
|
|
7
|
+
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
|
8
|
+
};
|
|
9
|
+
export type CacheEntryJson = {
|
|
10
|
+
[name: string]: {
|
|
11
|
+
purpose: "minting" | "spending" | "staking";
|
|
12
|
+
bytes: number[];
|
|
13
|
+
unoptimizedCborHex?: string | undefined;
|
|
14
|
+
optimizedCborHex: string;
|
|
15
|
+
plutusVersion: PlutusVersion;
|
|
16
|
+
castConfig: CastConfig;
|
|
17
|
+
datum?: import("../codegen/TypeSchema.js").TypeSchema | undefined;
|
|
18
|
+
redeemer: TypeSchema;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import("@helios-lang/uplc").PlutusVersion} PlutusVersion
|
|
23
|
+
* @typedef {import("../cast/index.js").CastConfig} CastConfig
|
|
24
|
+
* @typedef {import("../codegen/index.js").TypeSchema} TypeSchema
|
|
25
|
+
* @typedef {import("./ContractContext.js").AnyContractValidatorContext} AnyContractValidatorContext
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{[name: string]: AnyContractValidatorContext}} CacheEntry
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {{[name: string]: {
|
|
32
|
+
* purpose: "minting" | "spending" | "staking"
|
|
33
|
+
* bytes: number[]
|
|
34
|
+
* unoptimizedCborHex?: string
|
|
35
|
+
* optimizedCborHex: string
|
|
36
|
+
* plutusVersion: PlutusVersion
|
|
37
|
+
* castConfig: CastConfig
|
|
38
|
+
* datum?: TypeSchema
|
|
39
|
+
* redeemer: TypeSchema
|
|
40
|
+
* }}} CacheEntryJson
|
|
41
|
+
*/
|
|
42
|
+
declare class ContractContextCache {
|
|
43
|
+
/**
|
|
44
|
+
* @type {CacheEntry[]}
|
|
45
|
+
*/
|
|
46
|
+
cache: CacheEntry[];
|
|
47
|
+
/**
|
|
48
|
+
* Load count
|
|
49
|
+
* @type {number}
|
|
50
|
+
*/
|
|
51
|
+
i: number;
|
|
52
|
+
/**
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
*/
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
enable(): void;
|
|
57
|
+
/**
|
|
58
|
+
* @param {CacheEntryJson[]} json
|
|
59
|
+
*/
|
|
60
|
+
load(json: CacheEntryJson[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* @param {CacheEntry} hashes
|
|
63
|
+
*/
|
|
64
|
+
push(hashes: CacheEntry): void;
|
|
65
|
+
/**
|
|
66
|
+
* @returns {Option<CacheEntry>}
|
|
67
|
+
*/
|
|
68
|
+
shift(): Option<CacheEntry>;
|
|
69
|
+
/**
|
|
70
|
+
* @return {CacheEntryJson[]}
|
|
71
|
+
*/
|
|
72
|
+
toJson(): CacheEntryJson[];
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=ContractContextCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"AA6NA,wDAA8D;4BAjNjD,OAAO,mBAAmB,EAAE,aAAa;yBACzC,OAAO,kBAAkB,EAAE,UAAU;yBACrC,OAAO,qBAAqB,EAAE,UAAU;0CACxC,OAAO,sBAAsB,EAAE,2BAA2B;;;;;;iBASzD,SAAS,GAAG,UAAU,GAAG,SAAS;eACpC,MAAM,EAAE;;0BAEG,MAAM;uBACT,aAAa;oBAChB,UAAU;;kBAEZ,UAAU;;;AApBzB;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;;;;;;;GAWG;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,QA+D1B;IAED;;OAEG;IACH,aAFW,UAAU,QAMpB;IAED;;OAEG;IACH,SAFa,OAAO,UAAU,CAAC,CAY9B;IAED;;OAEG;IACH,UAFY,cAAc,EAAE,CAiE3B;CACJ"}
|
|
@@ -42,7 +42,7 @@ export class DagCompiler {
|
|
|
42
42
|
* @param {Option<{[name: string]: string}>} expectedHashes
|
|
43
43
|
* @returns {{[name: string]: AnyContractValidatorContext}}
|
|
44
44
|
*/
|
|
45
|
-
build(validators: LoadedValidator[],
|
|
45
|
+
build(validators: LoadedValidator[], expectedHashes?: Option<{
|
|
46
46
|
[name: string]: string;
|
|
47
47
|
}>): {
|
|
48
48
|
[name: string]: import("./ContractContext.js").AnyContractValidatorContext;
|
package/types/context/index.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./cast/index.js";
|
|
2
|
-
export
|
|
2
|
+
export * from "./context/index.js";
|
|
3
3
|
export { LoadedScriptsWriter } from "./codegen/LoadedScriptsWriter.js";
|
|
4
4
|
export { typeCheckFiles, typeCheckScripts, loadCompilerLib } from "./compiler/ops.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|