@helios-lang/contract-utils 0.2.58 → 0.2.59
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.59",
|
|
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",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@helios-lang/cli-utils": "^0.1.6",
|
|
29
|
-
"@helios-lang/codec-utils": "^0.1.
|
|
29
|
+
"@helios-lang/codec-utils": "^0.1.35",
|
|
30
30
|
"@helios-lang/compiler-utils": "^0.1.25",
|
|
31
|
-
"@helios-lang/ledger": "^0.4.
|
|
31
|
+
"@helios-lang/ledger": "^0.4.11",
|
|
32
32
|
"@helios-lang/type-utils": "^0.1.21",
|
|
33
|
-
"@helios-lang/uplc": "^0.3.
|
|
33
|
+
"@helios-lang/uplc": "^0.3.6"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "pnpm run prettify && pnpm run build:types && pnpm run test:suite",
|
|
@@ -31,7 +31,9 @@ import { UplcProgramV2 } from "@helios-lang/uplc"
|
|
|
31
31
|
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
32
32
|
* bytes: number[]
|
|
33
33
|
* unoptimizedCborHex?: string
|
|
34
|
+
* unoptimizedIr?: string
|
|
34
35
|
* optimizedCborHex: string
|
|
36
|
+
* optimizedIr?: string
|
|
35
37
|
* plutusVersion: PlutusVersion
|
|
36
38
|
* castConfig: CastConfig
|
|
37
39
|
* datum?: TypeSchema
|
|
@@ -106,17 +108,25 @@ class ContractContextCache {
|
|
|
106
108
|
*/
|
|
107
109
|
let program =
|
|
108
110
|
props.plutusVersion == "PlutusScriptV1"
|
|
109
|
-
? UplcProgramV1.fromCbor(props.optimizedCborHex
|
|
110
|
-
|
|
111
|
+
? UplcProgramV1.fromCbor(props.optimizedCborHex, {
|
|
112
|
+
ir: props.optimizedIr
|
|
113
|
+
})
|
|
114
|
+
: UplcProgramV2.fromCbor(props.optimizedCborHex, {
|
|
115
|
+
ir: props.optimizedIr
|
|
116
|
+
})
|
|
111
117
|
|
|
112
118
|
if (props.unoptimizedCborHex) {
|
|
113
119
|
if (program.plutusVersion == "PlutusScriptV1") {
|
|
114
120
|
program = program.withAlt(
|
|
115
|
-
UplcProgramV1.fromCbor(props.unoptimizedCborHex
|
|
121
|
+
UplcProgramV1.fromCbor(props.unoptimizedCborHex, {
|
|
122
|
+
ir: props.unoptimizedIr
|
|
123
|
+
})
|
|
116
124
|
)
|
|
117
125
|
} else if (program.plutusVersion == "PlutusScriptV2") {
|
|
118
126
|
program = program.withAlt(
|
|
119
|
-
UplcProgramV2.fromCbor(props.unoptimizedCborHex
|
|
127
|
+
UplcProgramV2.fromCbor(props.unoptimizedCborHex, {
|
|
128
|
+
ir: props.unoptimizedIr
|
|
129
|
+
})
|
|
120
130
|
)
|
|
121
131
|
} else {
|
|
122
132
|
throw new Error("unhandled Plutus version")
|
|
@@ -176,44 +186,30 @@ class ContractContextCache {
|
|
|
176
186
|
for (let name in entry.userFuncs) {
|
|
177
187
|
const props = entry.userFuncs[name]
|
|
178
188
|
|
|
179
|
-
const optimizedIr = props.optimizedIr
|
|
180
|
-
const optimizedProps = optimizedIr
|
|
181
|
-
? { ir: () => optimizedIr }
|
|
182
|
-
: {}
|
|
183
|
-
|
|
184
189
|
/**
|
|
185
190
|
* @type {UplcProgram}
|
|
186
191
|
*/
|
|
187
192
|
let program =
|
|
188
193
|
props.plutusVersion == "PlutusScriptV1"
|
|
189
|
-
? UplcProgramV1.fromCbor(
|
|
190
|
-
props.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
optimizedProps
|
|
196
|
-
)
|
|
194
|
+
? UplcProgramV1.fromCbor(props.optimizedCborHex, {
|
|
195
|
+
ir: props.optimizedIr
|
|
196
|
+
})
|
|
197
|
+
: UplcProgramV2.fromCbor(props.optimizedCborHex, {
|
|
198
|
+
ir: props.optimizedIr
|
|
199
|
+
})
|
|
197
200
|
|
|
198
201
|
if (props.unoptimizedCborHex) {
|
|
199
|
-
const unoptimizedIr = props.unoptimizedIr
|
|
200
|
-
const unoptimizedProps = unoptimizedIr
|
|
201
|
-
? { ir: () => unoptimizedIr }
|
|
202
|
-
: {}
|
|
203
|
-
|
|
204
202
|
if (program.plutusVersion == "PlutusScriptV1") {
|
|
205
203
|
program = program.withAlt(
|
|
206
|
-
UplcProgramV1.fromCbor(
|
|
207
|
-
props.
|
|
208
|
-
|
|
209
|
-
)
|
|
204
|
+
UplcProgramV1.fromCbor(props.unoptimizedCborHex, {
|
|
205
|
+
ir: props.unoptimizedIr
|
|
206
|
+
})
|
|
210
207
|
)
|
|
211
208
|
} else if (program.plutusVersion == "PlutusScriptV2") {
|
|
212
209
|
program = program.withAlt(
|
|
213
|
-
UplcProgramV2.fromCbor(
|
|
214
|
-
props.
|
|
215
|
-
|
|
216
|
-
)
|
|
210
|
+
UplcProgramV2.fromCbor(props.unoptimizedCborHex, {
|
|
211
|
+
ir: props.unoptimizedIr
|
|
212
|
+
})
|
|
217
213
|
)
|
|
218
214
|
} else {
|
|
219
215
|
throw new Error("unhandled Plutus version")
|
|
@@ -311,6 +307,12 @@ class ContractContextCache {
|
|
|
311
307
|
unoptimizedCborHex: hash.context.program.alt
|
|
312
308
|
? bytesToHex(hash.context.program.alt.toCbor())
|
|
313
309
|
: undefined,
|
|
310
|
+
optimizedIr:
|
|
311
|
+
/** @type {UplcProgramV2} */ (hash.context.program)
|
|
312
|
+
.ir ?? undefined,
|
|
313
|
+
unoptimizedIr:
|
|
314
|
+
/** @type {UplcProgramV2} */ (hash.context.program).alt
|
|
315
|
+
?.ir ?? undefined,
|
|
314
316
|
plutusVersion: hash.context.program.plutusVersion,
|
|
315
317
|
castConfig: redeemer.config,
|
|
316
318
|
redeemer: redeemer.schema,
|
|
@@ -320,11 +322,10 @@ class ContractContextCache {
|
|
|
320
322
|
|
|
321
323
|
for (let name in entry.userFuncs) {
|
|
322
324
|
const userFunc = entry.userFuncs[name]
|
|
323
|
-
const optimizedIr = userFunc.ir
|
|
324
325
|
|
|
325
326
|
resUserFuncs[name] = {
|
|
326
327
|
optimizedCborHex: bytesToHex(userFunc.toCbor()),
|
|
327
|
-
optimizedIr:
|
|
328
|
+
optimizedIr: userFunc.ir ?? undefined,
|
|
328
329
|
unoptimizedCborHex: /** @type {UplcProgramV2} */ (userFunc)
|
|
329
330
|
.alt
|
|
330
331
|
? bytesToHex(
|
|
@@ -18,7 +18,9 @@ export type CacheEntryValidatorsJson = {
|
|
|
18
18
|
purpose: "minting" | "spending" | "staking" | "mixed";
|
|
19
19
|
bytes: number[];
|
|
20
20
|
unoptimizedCborHex?: string;
|
|
21
|
+
unoptimizedIr?: string;
|
|
21
22
|
optimizedCborHex: string;
|
|
23
|
+
optimizedIr?: string;
|
|
22
24
|
plutusVersion: PlutusVersion;
|
|
23
25
|
castConfig: CastConfig;
|
|
24
26
|
datum?: TypeSchema;
|
|
@@ -58,7 +60,9 @@ export type CacheEntryJson = {
|
|
|
58
60
|
* purpose: "minting" | "spending" | "staking" | "mixed"
|
|
59
61
|
* bytes: number[]
|
|
60
62
|
* unoptimizedCborHex?: string
|
|
63
|
+
* unoptimizedIr?: string
|
|
61
64
|
* optimizedCborHex: string
|
|
65
|
+
* optimizedIr?: string
|
|
62
66
|
* plutusVersion: PlutusVersion
|
|
63
67
|
* castConfig: CastConfig
|
|
64
68
|
* datum?: TypeSchema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"
|
|
1
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