@lucid-evolution/uplc 0.4.0 → 0.5.0
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/README.md +31 -0
- package/dist/size/browser/uplc_tx.d.ts +145 -0
- package/dist/size/browser/uplc_tx_bg.js +286 -4
- package/dist/size/browser/uplc_tx_bg.wasm +0 -0
- package/dist/size/browser/uplc_tx_bg.wasm.d.ts +43 -4
- package/dist/size/node/uplc_tx.d.ts +145 -0
- package/dist/size/node/uplc_tx.js +287 -4
- package/dist/size/node/uplc_tx_bg.wasm +0 -0
- package/dist/size/node/uplc_tx_bg.wasm.d.ts +43 -4
- package/dist/speed/browser/uplc_tx.d.ts +145 -0
- package/dist/speed/browser/uplc_tx_bg.js +286 -4
- package/dist/speed/browser/uplc_tx_bg.wasm +0 -0
- package/dist/speed/browser/uplc_tx_bg.wasm.d.ts +43 -4
- package/dist/speed/node/uplc_tx.d.ts +145 -0
- package/dist/speed/node/uplc_tx.js +287 -4
- package/dist/speed/node/uplc_tx_bg.wasm +0 -0
- package/dist/speed/node/uplc_tx_bg.wasm.d.ts +43 -4
- package/package.json +1 -1
|
@@ -56,6 +56,151 @@ export function eval_program_raw(
|
|
|
56
56
|
* programs; `selfTest` says whether this one gives the expected results.
|
|
57
57
|
*/
|
|
58
58
|
export function uplc_build_info(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
|
|
61
|
+
* evaluates it at a protocol version, without any program around it: the
|
|
62
|
+
* result, or how it fails, is what the machine gives for the saturated
|
|
63
|
+
* application.
|
|
64
|
+
*
|
|
65
|
+
* - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
|
|
66
|
+
* The Miller-loop builtins (68 to 70) are not supported, since their
|
|
67
|
+
* results cannot be returned.
|
|
68
|
+
* - `args`: exactly the builtin's arguments, in order, each encoded as the
|
|
69
|
+
* matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
|
|
70
|
+
* flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
|
|
71
|
+
* for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
|
|
72
|
+
* points, 5 for an array of G1 points and 6 for an array of G2 points, each
|
|
73
|
+
* list or array as the compressed points one after the other. Flat cannot
|
|
74
|
+
* encode BLS12-381 points, so they cross as their compressed bytes.
|
|
75
|
+
* - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
|
|
76
|
+
* 12 (Dijkstra). It decides which builtins are available and the semantics
|
|
77
|
+
* they have.
|
|
78
|
+
*
|
|
79
|
+
* The result's `cpu` and `mem` are the builtin's charge for the application
|
|
80
|
+
* under Plutus' default Plutus V3 cost model (not the ledger's protocol
|
|
81
|
+
* parameters), excluding the machine's per-step costs.
|
|
82
|
+
*
|
|
83
|
+
* Fails only when the inputs are malformed or unsupported: an unknown or
|
|
84
|
+
* Miller-loop tag, a number of arguments other than the builtin's arity, an
|
|
85
|
+
* argument that does not decode as its kind says or is not a constant, an
|
|
86
|
+
* invalid compressed point, a protocol version out of range, or a result that
|
|
87
|
+
* none of the kinds can encode. A builtin that fails is an
|
|
88
|
+
* [`EvalBuiltinResult`] that is not `ok`.
|
|
89
|
+
*/
|
|
90
|
+
export function eval_builtin_raw(
|
|
91
|
+
tag: number,
|
|
92
|
+
args: Uint8Array[],
|
|
93
|
+
arg_kinds: Uint8Array,
|
|
94
|
+
protocol_major_version: number,
|
|
95
|
+
): EvalBuiltinResult;
|
|
96
|
+
/**
|
|
97
|
+
* Why the builtin given to [`eval_builtin_raw`] did not return a value: the
|
|
98
|
+
* codes of the result's `error_kind`.
|
|
99
|
+
*/
|
|
100
|
+
export enum BuiltinErrorKind {
|
|
101
|
+
/**
|
|
102
|
+
* The builtin returned a value.
|
|
103
|
+
*/
|
|
104
|
+
Ok = 0,
|
|
105
|
+
/**
|
|
106
|
+
* The builtin is not available to Plutus V3 at the protocol version.
|
|
107
|
+
*/
|
|
108
|
+
NotAvailable = 1,
|
|
109
|
+
/**
|
|
110
|
+
* The builtin did not accept its arguments, which fails the application
|
|
111
|
+
* before it is costed.
|
|
112
|
+
*/
|
|
113
|
+
RejectedArguments = 2,
|
|
114
|
+
/**
|
|
115
|
+
* The builtin failed after it was costed.
|
|
116
|
+
*/
|
|
117
|
+
Failed = 3,
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* How a value of [`eval_builtin_raw`] is encoded: the codes of its
|
|
121
|
+
* `arg_kinds` and of the result's `result_kind`.
|
|
122
|
+
*/
|
|
123
|
+
export enum BuiltinValueKind {
|
|
124
|
+
/**
|
|
125
|
+
* A flat-encoded program whose body is a constant,
|
|
126
|
+
* `(program 1.1.0 (con …))`. A result in this form is always version
|
|
127
|
+
* 1.1.0.
|
|
128
|
+
*/
|
|
129
|
+
Flat = 0,
|
|
130
|
+
/**
|
|
131
|
+
* A BLS12-381 G1 point, as its 48-byte compressed encoding.
|
|
132
|
+
*/
|
|
133
|
+
G1 = 1,
|
|
134
|
+
/**
|
|
135
|
+
* A BLS12-381 G2 point, as its 96-byte compressed encoding.
|
|
136
|
+
*/
|
|
137
|
+
G2 = 2,
|
|
138
|
+
/**
|
|
139
|
+
* A list of BLS12-381 G1 points, as their compressed encodings one after
|
|
140
|
+
* the other.
|
|
141
|
+
*/
|
|
142
|
+
G1List = 3,
|
|
143
|
+
/**
|
|
144
|
+
* A list of BLS12-381 G2 points, as their compressed encodings one after
|
|
145
|
+
* the other.
|
|
146
|
+
*/
|
|
147
|
+
G2List = 4,
|
|
148
|
+
/**
|
|
149
|
+
* An array of BLS12-381 G1 points, as their compressed encodings one after
|
|
150
|
+
* the other.
|
|
151
|
+
*/
|
|
152
|
+
G1Array = 5,
|
|
153
|
+
/**
|
|
154
|
+
* An array of BLS12-381 G2 points, as their compressed encodings one after
|
|
155
|
+
* the other.
|
|
156
|
+
*/
|
|
157
|
+
G2Array = 6,
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The outcome of [`eval_builtin_raw`].
|
|
161
|
+
*/
|
|
162
|
+
export class EvalBuiltinResult {
|
|
163
|
+
private constructor();
|
|
164
|
+
free(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Whether the builtin returned a value.
|
|
167
|
+
*/
|
|
168
|
+
ok: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
|
|
171
|
+
* it did, 1 when it is not available to Plutus V3 at the protocol version,
|
|
172
|
+
* 2 when it did not accept its arguments (so the machine fails before
|
|
173
|
+
* costing it) and 3 when it failed after being costed.
|
|
174
|
+
*/
|
|
175
|
+
error_kind: number;
|
|
176
|
+
/**
|
|
177
|
+
* How `result` encodes the value, a [`BuiltinValueKind`] as for the
|
|
178
|
+
* arguments of [`eval_builtin_raw`]; 0 when there is no value.
|
|
179
|
+
*/
|
|
180
|
+
result_kind: number;
|
|
181
|
+
/**
|
|
182
|
+
* The value the builtin returned; empty when there is none.
|
|
183
|
+
*/
|
|
184
|
+
result: Uint8Array;
|
|
185
|
+
/**
|
|
186
|
+
* The CPU the builtin's cost model charges for this application, under
|
|
187
|
+
* Plutus' default cost model for Plutus V3 at the protocol version; 0
|
|
188
|
+
* when the builtin was not costed (error kinds 1 and 2). It leaves out the
|
|
189
|
+
* machine's own step costs for evaluating the application (the builtin,
|
|
190
|
+
* each force and each apply).
|
|
191
|
+
*/
|
|
192
|
+
cpu: bigint;
|
|
193
|
+
/**
|
|
194
|
+
* The memory the builtin's cost model charges for this application; see
|
|
195
|
+
* `cpu`.
|
|
196
|
+
*/
|
|
197
|
+
mem: bigint;
|
|
198
|
+
/**
|
|
199
|
+
* The evaluator's description of why the builtin did not return a value;
|
|
200
|
+
* empty when it did.
|
|
201
|
+
*/
|
|
202
|
+
error: string;
|
|
203
|
+
}
|
|
59
204
|
/**
|
|
60
205
|
* The outcome of [`eval_program_raw`].
|
|
61
206
|
*/
|
|
@@ -265,6 +265,289 @@ module.exports.uplc_build_info = function() {
|
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
|
|
270
|
+
* evaluates it at a protocol version, without any program around it: the
|
|
271
|
+
* result, or how it fails, is what the machine gives for the saturated
|
|
272
|
+
* application.
|
|
273
|
+
*
|
|
274
|
+
* - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
|
|
275
|
+
* The Miller-loop builtins (68 to 70) are not supported, since their
|
|
276
|
+
* results cannot be returned.
|
|
277
|
+
* - `args`: exactly the builtin's arguments, in order, each encoded as the
|
|
278
|
+
* matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
|
|
279
|
+
* flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
|
|
280
|
+
* for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
|
|
281
|
+
* points, 5 for an array of G1 points and 6 for an array of G2 points, each
|
|
282
|
+
* list or array as the compressed points one after the other. Flat cannot
|
|
283
|
+
* encode BLS12-381 points, so they cross as their compressed bytes.
|
|
284
|
+
* - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
|
|
285
|
+
* 12 (Dijkstra). It decides which builtins are available and the semantics
|
|
286
|
+
* they have.
|
|
287
|
+
*
|
|
288
|
+
* The result's `cpu` and `mem` are the builtin's charge for the application
|
|
289
|
+
* under Plutus' default Plutus V3 cost model (not the ledger's protocol
|
|
290
|
+
* parameters), excluding the machine's per-step costs.
|
|
291
|
+
*
|
|
292
|
+
* Fails only when the inputs are malformed or unsupported: an unknown or
|
|
293
|
+
* Miller-loop tag, a number of arguments other than the builtin's arity, an
|
|
294
|
+
* argument that does not decode as its kind says or is not a constant, an
|
|
295
|
+
* invalid compressed point, a protocol version out of range, or a result that
|
|
296
|
+
* none of the kinds can encode. A builtin that fails is an
|
|
297
|
+
* [`EvalBuiltinResult`] that is not `ok`.
|
|
298
|
+
* @param {number} tag
|
|
299
|
+
* @param {Uint8Array[]} args
|
|
300
|
+
* @param {Uint8Array} arg_kinds
|
|
301
|
+
* @param {number} protocol_major_version
|
|
302
|
+
* @returns {EvalBuiltinResult}
|
|
303
|
+
*/
|
|
304
|
+
module.exports.eval_builtin_raw = function(tag, args, arg_kinds, protocol_major_version) {
|
|
305
|
+
const ptr0 = passArrayJsValueToWasm0(args, wasm.__wbindgen_malloc);
|
|
306
|
+
const len0 = WASM_VECTOR_LEN;
|
|
307
|
+
const ptr1 = passArray8ToWasm0(arg_kinds, wasm.__wbindgen_malloc);
|
|
308
|
+
const len1 = WASM_VECTOR_LEN;
|
|
309
|
+
const ret = wasm.eval_builtin_raw(tag, ptr0, len0, ptr1, len1, protocol_major_version);
|
|
310
|
+
if (ret[2]) {
|
|
311
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
312
|
+
}
|
|
313
|
+
return EvalBuiltinResult.__wrap(ret[0]);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Why the builtin given to [`eval_builtin_raw`] did not return a value: the
|
|
318
|
+
* codes of the result's `error_kind`.
|
|
319
|
+
* @enum {0 | 1 | 2 | 3}
|
|
320
|
+
*/
|
|
321
|
+
module.exports.BuiltinErrorKind = Object.freeze({
|
|
322
|
+
/**
|
|
323
|
+
* The builtin returned a value.
|
|
324
|
+
*/
|
|
325
|
+
Ok: 0, "0": "Ok",
|
|
326
|
+
/**
|
|
327
|
+
* The builtin is not available to Plutus V3 at the protocol version.
|
|
328
|
+
*/
|
|
329
|
+
NotAvailable: 1, "1": "NotAvailable",
|
|
330
|
+
/**
|
|
331
|
+
* The builtin did not accept its arguments, which fails the application
|
|
332
|
+
* before it is costed.
|
|
333
|
+
*/
|
|
334
|
+
RejectedArguments: 2, "2": "RejectedArguments",
|
|
335
|
+
/**
|
|
336
|
+
* The builtin failed after it was costed.
|
|
337
|
+
*/
|
|
338
|
+
Failed: 3, "3": "Failed",
|
|
339
|
+
});
|
|
340
|
+
/**
|
|
341
|
+
* How a value of [`eval_builtin_raw`] is encoded: the codes of its
|
|
342
|
+
* `arg_kinds` and of the result's `result_kind`.
|
|
343
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
|
|
344
|
+
*/
|
|
345
|
+
module.exports.BuiltinValueKind = Object.freeze({
|
|
346
|
+
/**
|
|
347
|
+
* A flat-encoded program whose body is a constant,
|
|
348
|
+
* `(program 1.1.0 (con …))`. A result in this form is always version
|
|
349
|
+
* 1.1.0.
|
|
350
|
+
*/
|
|
351
|
+
Flat: 0, "0": "Flat",
|
|
352
|
+
/**
|
|
353
|
+
* A BLS12-381 G1 point, as its 48-byte compressed encoding.
|
|
354
|
+
*/
|
|
355
|
+
G1: 1, "1": "G1",
|
|
356
|
+
/**
|
|
357
|
+
* A BLS12-381 G2 point, as its 96-byte compressed encoding.
|
|
358
|
+
*/
|
|
359
|
+
G2: 2, "2": "G2",
|
|
360
|
+
/**
|
|
361
|
+
* A list of BLS12-381 G1 points, as their compressed encodings one after
|
|
362
|
+
* the other.
|
|
363
|
+
*/
|
|
364
|
+
G1List: 3, "3": "G1List",
|
|
365
|
+
/**
|
|
366
|
+
* A list of BLS12-381 G2 points, as their compressed encodings one after
|
|
367
|
+
* the other.
|
|
368
|
+
*/
|
|
369
|
+
G2List: 4, "4": "G2List",
|
|
370
|
+
/**
|
|
371
|
+
* An array of BLS12-381 G1 points, as their compressed encodings one after
|
|
372
|
+
* the other.
|
|
373
|
+
*/
|
|
374
|
+
G1Array: 5, "5": "G1Array",
|
|
375
|
+
/**
|
|
376
|
+
* An array of BLS12-381 G2 points, as their compressed encodings one after
|
|
377
|
+
* the other.
|
|
378
|
+
*/
|
|
379
|
+
G2Array: 6, "6": "G2Array",
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const EvalBuiltinResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
383
|
+
? { register: () => {}, unregister: () => {} }
|
|
384
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evalbuiltinresult_free(ptr >>> 0, 1));
|
|
385
|
+
/**
|
|
386
|
+
* The outcome of [`eval_builtin_raw`].
|
|
387
|
+
*/
|
|
388
|
+
class EvalBuiltinResult {
|
|
389
|
+
|
|
390
|
+
static __wrap(ptr) {
|
|
391
|
+
ptr = ptr >>> 0;
|
|
392
|
+
const obj = Object.create(EvalBuiltinResult.prototype);
|
|
393
|
+
obj.__wbg_ptr = ptr;
|
|
394
|
+
EvalBuiltinResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
395
|
+
return obj;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
__destroy_into_raw() {
|
|
399
|
+
const ptr = this.__wbg_ptr;
|
|
400
|
+
this.__wbg_ptr = 0;
|
|
401
|
+
EvalBuiltinResultFinalization.unregister(this);
|
|
402
|
+
return ptr;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
free() {
|
|
406
|
+
const ptr = this.__destroy_into_raw();
|
|
407
|
+
wasm.__wbg_evalbuiltinresult_free(ptr, 0);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Whether the builtin returned a value.
|
|
411
|
+
* @returns {boolean}
|
|
412
|
+
*/
|
|
413
|
+
get ok() {
|
|
414
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_ok(this.__wbg_ptr);
|
|
415
|
+
return ret !== 0;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Whether the builtin returned a value.
|
|
419
|
+
* @param {boolean} arg0
|
|
420
|
+
*/
|
|
421
|
+
set ok(arg0) {
|
|
422
|
+
wasm.__wbg_set_evalbuiltinresult_ok(this.__wbg_ptr, arg0);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
|
|
426
|
+
* it did, 1 when it is not available to Plutus V3 at the protocol version,
|
|
427
|
+
* 2 when it did not accept its arguments (so the machine fails before
|
|
428
|
+
* costing it) and 3 when it failed after being costed.
|
|
429
|
+
* @returns {number}
|
|
430
|
+
*/
|
|
431
|
+
get error_kind() {
|
|
432
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_error_kind(this.__wbg_ptr);
|
|
433
|
+
return ret;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
|
|
437
|
+
* it did, 1 when it is not available to Plutus V3 at the protocol version,
|
|
438
|
+
* 2 when it did not accept its arguments (so the machine fails before
|
|
439
|
+
* costing it) and 3 when it failed after being costed.
|
|
440
|
+
* @param {number} arg0
|
|
441
|
+
*/
|
|
442
|
+
set error_kind(arg0) {
|
|
443
|
+
wasm.__wbg_set_evalbuiltinresult_error_kind(this.__wbg_ptr, arg0);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* How `result` encodes the value, a [`BuiltinValueKind`] as for the
|
|
447
|
+
* arguments of [`eval_builtin_raw`]; 0 when there is no value.
|
|
448
|
+
* @returns {number}
|
|
449
|
+
*/
|
|
450
|
+
get result_kind() {
|
|
451
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_result_kind(this.__wbg_ptr);
|
|
452
|
+
return ret;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* How `result` encodes the value, a [`BuiltinValueKind`] as for the
|
|
456
|
+
* arguments of [`eval_builtin_raw`]; 0 when there is no value.
|
|
457
|
+
* @param {number} arg0
|
|
458
|
+
*/
|
|
459
|
+
set result_kind(arg0) {
|
|
460
|
+
wasm.__wbg_set_evalbuiltinresult_result_kind(this.__wbg_ptr, arg0);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The value the builtin returned; empty when there is none.
|
|
464
|
+
* @returns {Uint8Array}
|
|
465
|
+
*/
|
|
466
|
+
get result() {
|
|
467
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_result(this.__wbg_ptr);
|
|
468
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
469
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
470
|
+
return v1;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* The value the builtin returned; empty when there is none.
|
|
474
|
+
* @param {Uint8Array} arg0
|
|
475
|
+
*/
|
|
476
|
+
set result(arg0) {
|
|
477
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
479
|
+
wasm.__wbg_set_evalbuiltinresult_result(this.__wbg_ptr, ptr0, len0);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The CPU the builtin's cost model charges for this application, under
|
|
483
|
+
* Plutus' default cost model for Plutus V3 at the protocol version; 0
|
|
484
|
+
* when the builtin was not costed (error kinds 1 and 2). It leaves out the
|
|
485
|
+
* machine's own step costs for evaluating the application (the builtin,
|
|
486
|
+
* each force and each apply).
|
|
487
|
+
* @returns {bigint}
|
|
488
|
+
*/
|
|
489
|
+
get cpu() {
|
|
490
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
|
|
491
|
+
return BigInt.asUintN(64, ret);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The CPU the builtin's cost model charges for this application, under
|
|
495
|
+
* Plutus' default cost model for Plutus V3 at the protocol version; 0
|
|
496
|
+
* when the builtin was not costed (error kinds 1 and 2). It leaves out the
|
|
497
|
+
* machine's own step costs for evaluating the application (the builtin,
|
|
498
|
+
* each force and each apply).
|
|
499
|
+
* @param {bigint} arg0
|
|
500
|
+
*/
|
|
501
|
+
set cpu(arg0) {
|
|
502
|
+
wasm.__wbg_set_evalbuiltinresult_cpu(this.__wbg_ptr, arg0);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The memory the builtin's cost model charges for this application; see
|
|
506
|
+
* `cpu`.
|
|
507
|
+
* @returns {bigint}
|
|
508
|
+
*/
|
|
509
|
+
get mem() {
|
|
510
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_mem(this.__wbg_ptr);
|
|
511
|
+
return BigInt.asUintN(64, ret);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The memory the builtin's cost model charges for this application; see
|
|
515
|
+
* `cpu`.
|
|
516
|
+
* @param {bigint} arg0
|
|
517
|
+
*/
|
|
518
|
+
set mem(arg0) {
|
|
519
|
+
wasm.__wbg_set_evalbuiltinresult_mem(this.__wbg_ptr, arg0);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* The evaluator's description of why the builtin did not return a value;
|
|
523
|
+
* empty when it did.
|
|
524
|
+
* @returns {string}
|
|
525
|
+
*/
|
|
526
|
+
get error() {
|
|
527
|
+
let deferred1_0;
|
|
528
|
+
let deferred1_1;
|
|
529
|
+
try {
|
|
530
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_error(this.__wbg_ptr);
|
|
531
|
+
deferred1_0 = ret[0];
|
|
532
|
+
deferred1_1 = ret[1];
|
|
533
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
534
|
+
} finally {
|
|
535
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* The evaluator's description of why the builtin did not return a value;
|
|
540
|
+
* empty when it did.
|
|
541
|
+
* @param {string} arg0
|
|
542
|
+
*/
|
|
543
|
+
set error(arg0) {
|
|
544
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
545
|
+
const len0 = WASM_VECTOR_LEN;
|
|
546
|
+
wasm.__wbg_set_evalbuiltinresult_error(this.__wbg_ptr, ptr0, len0);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
module.exports.EvalBuiltinResult = EvalBuiltinResult;
|
|
550
|
+
|
|
268
551
|
const EvalProgramResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
269
552
|
? { register: () => {}, unregister: () => {} }
|
|
270
553
|
: new FinalizationRegistry(ptr => wasm.__wbg_evalprogramresult_free(ptr >>> 0, 1));
|
|
@@ -315,7 +598,7 @@ class EvalProgramResult {
|
|
|
315
598
|
* @returns {bigint}
|
|
316
599
|
*/
|
|
317
600
|
get cpu() {
|
|
318
|
-
const ret = wasm.
|
|
601
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
|
|
319
602
|
return BigInt.asUintN(64, ret);
|
|
320
603
|
}
|
|
321
604
|
/**
|
|
@@ -324,14 +607,14 @@ class EvalProgramResult {
|
|
|
324
607
|
* @param {bigint} arg0
|
|
325
608
|
*/
|
|
326
609
|
set cpu(arg0) {
|
|
327
|
-
wasm.
|
|
610
|
+
wasm.__wbg_set_evalbuiltinresult_cpu(this.__wbg_ptr, arg0);
|
|
328
611
|
}
|
|
329
612
|
/**
|
|
330
613
|
* The memory the program used.
|
|
331
614
|
* @returns {bigint}
|
|
332
615
|
*/
|
|
333
616
|
get mem() {
|
|
334
|
-
const ret = wasm.
|
|
617
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_mem(this.__wbg_ptr);
|
|
335
618
|
return BigInt.asUintN(64, ret);
|
|
336
619
|
}
|
|
337
620
|
/**
|
|
@@ -339,7 +622,7 @@ class EvalProgramResult {
|
|
|
339
622
|
* @param {bigint} arg0
|
|
340
623
|
*/
|
|
341
624
|
set mem(arg0) {
|
|
342
|
-
wasm.
|
|
625
|
+
wasm.__wbg_set_evalbuiltinresult_mem(this.__wbg_ptr, arg0);
|
|
343
626
|
}
|
|
344
627
|
/**
|
|
345
628
|
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
Binary file
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_evalbuiltinresult_free: (a: number, b: number) => void;
|
|
4
5
|
export const __wbg_evalprogramresult_free: (a: number, b: number) => void;
|
|
5
|
-
export const
|
|
6
|
+
export const __wbg_get_evalbuiltinresult_cpu: (a: number) => bigint;
|
|
7
|
+
export const __wbg_get_evalbuiltinresult_error: (a: number) => [number, number];
|
|
8
|
+
export const __wbg_get_evalbuiltinresult_error_kind: (a: number) => number;
|
|
9
|
+
export const __wbg_get_evalbuiltinresult_mem: (a: number) => bigint;
|
|
10
|
+
export const __wbg_get_evalbuiltinresult_ok: (a: number) => number;
|
|
11
|
+
export const __wbg_get_evalbuiltinresult_result: (
|
|
12
|
+
a: number,
|
|
13
|
+
) => [number, number];
|
|
14
|
+
export const __wbg_get_evalbuiltinresult_result_kind: (a: number) => number;
|
|
6
15
|
export const __wbg_get_evalprogramresult_error_kind: (a: number) => number;
|
|
7
16
|
export const __wbg_get_evalprogramresult_logs: (a: number) => [number, number];
|
|
8
|
-
export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
|
|
9
17
|
export const __wbg_get_evalprogramresult_ok: (a: number) => number;
|
|
10
|
-
export const
|
|
18
|
+
export const __wbg_set_evalbuiltinresult_cpu: (a: number, b: bigint) => void;
|
|
19
|
+
export const __wbg_set_evalbuiltinresult_error: (
|
|
20
|
+
a: number,
|
|
21
|
+
b: number,
|
|
22
|
+
c: number,
|
|
23
|
+
) => void;
|
|
24
|
+
export const __wbg_set_evalbuiltinresult_error_kind: (
|
|
25
|
+
a: number,
|
|
26
|
+
b: number,
|
|
27
|
+
) => void;
|
|
28
|
+
export const __wbg_set_evalbuiltinresult_mem: (a: number, b: bigint) => void;
|
|
29
|
+
export const __wbg_set_evalbuiltinresult_ok: (a: number, b: number) => void;
|
|
30
|
+
export const __wbg_set_evalbuiltinresult_result: (
|
|
31
|
+
a: number,
|
|
32
|
+
b: number,
|
|
33
|
+
c: number,
|
|
34
|
+
) => void;
|
|
35
|
+
export const __wbg_set_evalbuiltinresult_result_kind: (
|
|
36
|
+
a: number,
|
|
37
|
+
b: number,
|
|
38
|
+
) => void;
|
|
11
39
|
export const __wbg_set_evalprogramresult_error_kind: (
|
|
12
40
|
a: number,
|
|
13
41
|
b: number,
|
|
@@ -17,7 +45,6 @@ export const __wbg_set_evalprogramresult_logs: (
|
|
|
17
45
|
b: number,
|
|
18
46
|
c: number,
|
|
19
47
|
) => void;
|
|
20
|
-
export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
|
|
21
48
|
export const __wbg_set_evalprogramresult_ok: (a: number, b: number) => void;
|
|
22
49
|
export const apply_params_to_script: (
|
|
23
50
|
a: number,
|
|
@@ -25,6 +52,14 @@ export const apply_params_to_script: (
|
|
|
25
52
|
c: number,
|
|
26
53
|
d: number,
|
|
27
54
|
) => [number, number, number, number];
|
|
55
|
+
export const eval_builtin_raw: (
|
|
56
|
+
a: number,
|
|
57
|
+
b: number,
|
|
58
|
+
c: number,
|
|
59
|
+
d: number,
|
|
60
|
+
e: number,
|
|
61
|
+
f: number,
|
|
62
|
+
) => [number, number, number];
|
|
28
63
|
export const eval_phase_two_raw: (
|
|
29
64
|
a: number,
|
|
30
65
|
b: number,
|
|
@@ -56,6 +91,10 @@ export const eval_program_raw: (
|
|
|
56
91
|
k: number,
|
|
57
92
|
) => [number, number, number];
|
|
58
93
|
export const uplc_build_info: () => [number, number];
|
|
94
|
+
export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
|
|
95
|
+
export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
|
|
96
|
+
export const __wbg_set_evalprogramresult_cpu: (a: number, b: bigint) => void;
|
|
97
|
+
export const __wbg_get_evalprogramresult_cpu: (a: number) => bigint;
|
|
59
98
|
export const __wbindgen_export_0: WebAssembly.Table;
|
|
60
99
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
61
100
|
export const __wbindgen_realloc: (
|
|
@@ -56,6 +56,151 @@ export function eval_program_raw(
|
|
|
56
56
|
* programs; `selfTest` says whether this one gives the expected results.
|
|
57
57
|
*/
|
|
58
58
|
export function uplc_build_info(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
|
|
61
|
+
* evaluates it at a protocol version, without any program around it: the
|
|
62
|
+
* result, or how it fails, is what the machine gives for the saturated
|
|
63
|
+
* application.
|
|
64
|
+
*
|
|
65
|
+
* - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
|
|
66
|
+
* The Miller-loop builtins (68 to 70) are not supported, since their
|
|
67
|
+
* results cannot be returned.
|
|
68
|
+
* - `args`: exactly the builtin's arguments, in order, each encoded as the
|
|
69
|
+
* matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
|
|
70
|
+
* flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
|
|
71
|
+
* for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
|
|
72
|
+
* points, 5 for an array of G1 points and 6 for an array of G2 points, each
|
|
73
|
+
* list or array as the compressed points one after the other. Flat cannot
|
|
74
|
+
* encode BLS12-381 points, so they cross as their compressed bytes.
|
|
75
|
+
* - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
|
|
76
|
+
* 12 (Dijkstra). It decides which builtins are available and the semantics
|
|
77
|
+
* they have.
|
|
78
|
+
*
|
|
79
|
+
* The result's `cpu` and `mem` are the builtin's charge for the application
|
|
80
|
+
* under Plutus' default Plutus V3 cost model (not the ledger's protocol
|
|
81
|
+
* parameters), excluding the machine's per-step costs.
|
|
82
|
+
*
|
|
83
|
+
* Fails only when the inputs are malformed or unsupported: an unknown or
|
|
84
|
+
* Miller-loop tag, a number of arguments other than the builtin's arity, an
|
|
85
|
+
* argument that does not decode as its kind says or is not a constant, an
|
|
86
|
+
* invalid compressed point, a protocol version out of range, or a result that
|
|
87
|
+
* none of the kinds can encode. A builtin that fails is an
|
|
88
|
+
* [`EvalBuiltinResult`] that is not `ok`.
|
|
89
|
+
*/
|
|
90
|
+
export function eval_builtin_raw(
|
|
91
|
+
tag: number,
|
|
92
|
+
args: Uint8Array[],
|
|
93
|
+
arg_kinds: Uint8Array,
|
|
94
|
+
protocol_major_version: number,
|
|
95
|
+
): EvalBuiltinResult;
|
|
96
|
+
/**
|
|
97
|
+
* Why the builtin given to [`eval_builtin_raw`] did not return a value: the
|
|
98
|
+
* codes of the result's `error_kind`.
|
|
99
|
+
*/
|
|
100
|
+
export enum BuiltinErrorKind {
|
|
101
|
+
/**
|
|
102
|
+
* The builtin returned a value.
|
|
103
|
+
*/
|
|
104
|
+
Ok = 0,
|
|
105
|
+
/**
|
|
106
|
+
* The builtin is not available to Plutus V3 at the protocol version.
|
|
107
|
+
*/
|
|
108
|
+
NotAvailable = 1,
|
|
109
|
+
/**
|
|
110
|
+
* The builtin did not accept its arguments, which fails the application
|
|
111
|
+
* before it is costed.
|
|
112
|
+
*/
|
|
113
|
+
RejectedArguments = 2,
|
|
114
|
+
/**
|
|
115
|
+
* The builtin failed after it was costed.
|
|
116
|
+
*/
|
|
117
|
+
Failed = 3,
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* How a value of [`eval_builtin_raw`] is encoded: the codes of its
|
|
121
|
+
* `arg_kinds` and of the result's `result_kind`.
|
|
122
|
+
*/
|
|
123
|
+
export enum BuiltinValueKind {
|
|
124
|
+
/**
|
|
125
|
+
* A flat-encoded program whose body is a constant,
|
|
126
|
+
* `(program 1.1.0 (con …))`. A result in this form is always version
|
|
127
|
+
* 1.1.0.
|
|
128
|
+
*/
|
|
129
|
+
Flat = 0,
|
|
130
|
+
/**
|
|
131
|
+
* A BLS12-381 G1 point, as its 48-byte compressed encoding.
|
|
132
|
+
*/
|
|
133
|
+
G1 = 1,
|
|
134
|
+
/**
|
|
135
|
+
* A BLS12-381 G2 point, as its 96-byte compressed encoding.
|
|
136
|
+
*/
|
|
137
|
+
G2 = 2,
|
|
138
|
+
/**
|
|
139
|
+
* A list of BLS12-381 G1 points, as their compressed encodings one after
|
|
140
|
+
* the other.
|
|
141
|
+
*/
|
|
142
|
+
G1List = 3,
|
|
143
|
+
/**
|
|
144
|
+
* A list of BLS12-381 G2 points, as their compressed encodings one after
|
|
145
|
+
* the other.
|
|
146
|
+
*/
|
|
147
|
+
G2List = 4,
|
|
148
|
+
/**
|
|
149
|
+
* An array of BLS12-381 G1 points, as their compressed encodings one after
|
|
150
|
+
* the other.
|
|
151
|
+
*/
|
|
152
|
+
G1Array = 5,
|
|
153
|
+
/**
|
|
154
|
+
* An array of BLS12-381 G2 points, as their compressed encodings one after
|
|
155
|
+
* the other.
|
|
156
|
+
*/
|
|
157
|
+
G2Array = 6,
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The outcome of [`eval_builtin_raw`].
|
|
161
|
+
*/
|
|
162
|
+
export class EvalBuiltinResult {
|
|
163
|
+
private constructor();
|
|
164
|
+
free(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Whether the builtin returned a value.
|
|
167
|
+
*/
|
|
168
|
+
ok: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
|
|
171
|
+
* it did, 1 when it is not available to Plutus V3 at the protocol version,
|
|
172
|
+
* 2 when it did not accept its arguments (so the machine fails before
|
|
173
|
+
* costing it) and 3 when it failed after being costed.
|
|
174
|
+
*/
|
|
175
|
+
error_kind: number;
|
|
176
|
+
/**
|
|
177
|
+
* How `result` encodes the value, a [`BuiltinValueKind`] as for the
|
|
178
|
+
* arguments of [`eval_builtin_raw`]; 0 when there is no value.
|
|
179
|
+
*/
|
|
180
|
+
result_kind: number;
|
|
181
|
+
/**
|
|
182
|
+
* The value the builtin returned; empty when there is none.
|
|
183
|
+
*/
|
|
184
|
+
result: Uint8Array;
|
|
185
|
+
/**
|
|
186
|
+
* The CPU the builtin's cost model charges for this application, under
|
|
187
|
+
* Plutus' default cost model for Plutus V3 at the protocol version; 0
|
|
188
|
+
* when the builtin was not costed (error kinds 1 and 2). It leaves out the
|
|
189
|
+
* machine's own step costs for evaluating the application (the builtin,
|
|
190
|
+
* each force and each apply).
|
|
191
|
+
*/
|
|
192
|
+
cpu: bigint;
|
|
193
|
+
/**
|
|
194
|
+
* The memory the builtin's cost model charges for this application; see
|
|
195
|
+
* `cpu`.
|
|
196
|
+
*/
|
|
197
|
+
mem: bigint;
|
|
198
|
+
/**
|
|
199
|
+
* The evaluator's description of why the builtin did not return a value;
|
|
200
|
+
* empty when it did.
|
|
201
|
+
*/
|
|
202
|
+
error: string;
|
|
203
|
+
}
|
|
59
204
|
/**
|
|
60
205
|
* The outcome of [`eval_program_raw`].
|
|
61
206
|
*/
|