@lucid-evolution/uplc 0.5.0 → 0.5.1

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.
@@ -1,322 +1,3 @@
1
- let wasm;
2
- export function __wbg_set_wasm(val) {
3
- wasm = val;
4
- }
5
-
6
-
7
- let WASM_VECTOR_LEN = 0;
8
-
9
- let cachedUint8ArrayMemory0 = null;
10
-
11
- function getUint8ArrayMemory0() {
12
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
- }
15
- return cachedUint8ArrayMemory0;
16
- }
17
-
18
- const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
19
-
20
- let cachedTextEncoder = new lTextEncoder('utf-8');
21
-
22
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
23
- ? function (arg, view) {
24
- return cachedTextEncoder.encodeInto(arg, view);
25
- }
26
- : function (arg, view) {
27
- const buf = cachedTextEncoder.encode(arg);
28
- view.set(buf);
29
- return {
30
- read: arg.length,
31
- written: buf.length
32
- };
33
- });
34
-
35
- function passStringToWasm0(arg, malloc, realloc) {
36
-
37
- if (realloc === undefined) {
38
- const buf = cachedTextEncoder.encode(arg);
39
- const ptr = malloc(buf.length, 1) >>> 0;
40
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
41
- WASM_VECTOR_LEN = buf.length;
42
- return ptr;
43
- }
44
-
45
- let len = arg.length;
46
- let ptr = malloc(len, 1) >>> 0;
47
-
48
- const mem = getUint8ArrayMemory0();
49
-
50
- let offset = 0;
51
-
52
- for (; offset < len; offset++) {
53
- const code = arg.charCodeAt(offset);
54
- if (code > 0x7F) break;
55
- mem[ptr + offset] = code;
56
- }
57
-
58
- if (offset !== len) {
59
- if (offset !== 0) {
60
- arg = arg.slice(offset);
61
- }
62
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
63
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
64
- const ret = encodeString(arg, view);
65
-
66
- offset += ret.written;
67
- ptr = realloc(ptr, len, offset, 1) >>> 0;
68
- }
69
-
70
- WASM_VECTOR_LEN = offset;
71
- return ptr;
72
- }
73
-
74
- function isLikeNone(x) {
75
- return x === undefined || x === null;
76
- }
77
-
78
- let cachedDataViewMemory0 = null;
79
-
80
- function getDataViewMemory0() {
81
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
82
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
83
- }
84
- return cachedDataViewMemory0;
85
- }
86
-
87
- const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
88
-
89
- let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
90
-
91
- cachedTextDecoder.decode();
92
-
93
- function getStringFromWasm0(ptr, len) {
94
- ptr = ptr >>> 0;
95
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
96
- }
97
-
98
- function passArray8ToWasm0(arg, malloc) {
99
- const ptr = malloc(arg.length * 1, 1) >>> 0;
100
- getUint8ArrayMemory0().set(arg, ptr / 1);
101
- WASM_VECTOR_LEN = arg.length;
102
- return ptr;
103
- }
104
-
105
- function addToExternrefTable0(obj) {
106
- const idx = wasm.__externref_table_alloc();
107
- wasm.__wbindgen_export_0.set(idx, obj);
108
- return idx;
109
- }
110
-
111
- function passArrayJsValueToWasm0(array, malloc) {
112
- const ptr = malloc(array.length * 4, 4) >>> 0;
113
- for (let i = 0; i < array.length; i++) {
114
- const add = addToExternrefTable0(array[i]);
115
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
116
- }
117
- WASM_VECTOR_LEN = array.length;
118
- return ptr;
119
- }
120
-
121
- function takeFromExternrefTable0(idx) {
122
- const value = wasm.__wbindgen_export_0.get(idx);
123
- wasm.__externref_table_dealloc(idx);
124
- return value;
125
- }
126
-
127
- function getArrayJsValueFromWasm0(ptr, len) {
128
- ptr = ptr >>> 0;
129
- const mem = getDataViewMemory0();
130
- const result = [];
131
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
132
- result.push(wasm.__wbindgen_export_0.get(mem.getUint32(i, true)));
133
- }
134
- wasm.__externref_drop_slice(ptr, len);
135
- return result;
136
- }
137
- /**
138
- * @param {Uint8Array} tx_bytes
139
- * @param {Uint8Array[]} utxos_bytes_x
140
- * @param {Uint8Array[]} utxos_bytes_y
141
- * @param {Uint8Array} cost_mdls_bytes
142
- * @param {bigint} initial_budget_n
143
- * @param {bigint} initial_budget_d
144
- * @param {bigint} slot_config_x
145
- * @param {bigint} slot_config_y
146
- * @param {number} slot_config_z
147
- * @param {number | null} [protocol_major_version]
148
- * @returns {Uint8Array[]}
149
- */
150
- export function eval_phase_two_raw(tx_bytes, utxos_bytes_x, utxos_bytes_y, cost_mdls_bytes, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z, protocol_major_version) {
151
- const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
152
- const len0 = WASM_VECTOR_LEN;
153
- const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
154
- const len1 = WASM_VECTOR_LEN;
155
- const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
156
- const len2 = WASM_VECTOR_LEN;
157
- const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
158
- const len3 = WASM_VECTOR_LEN;
159
- const ret = wasm.eval_phase_two_raw(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z, !isLikeNone(protocol_major_version), isLikeNone(protocol_major_version) ? 0 : protocol_major_version);
160
- if (ret[3]) {
161
- throw takeFromExternrefTable0(ret[2]);
162
- }
163
- var v5 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
164
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
165
- return v5;
166
- }
167
-
168
- function getArrayU8FromWasm0(ptr, len) {
169
- ptr = ptr >>> 0;
170
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
171
- }
172
- /**
173
- * @param {Uint8Array} params_bytes
174
- * @param {Uint8Array} plutus_script_bytes
175
- * @returns {Uint8Array}
176
- */
177
- export function apply_params_to_script(params_bytes, plutus_script_bytes) {
178
- const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
179
- const len0 = WASM_VECTOR_LEN;
180
- const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
181
- const len1 = WASM_VECTOR_LEN;
182
- const ret = wasm.apply_params_to_script(ptr0, len0, ptr1, len1);
183
- if (ret[3]) {
184
- throw takeFromExternrefTable0(ret[2]);
185
- }
186
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
187
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
188
- return v3;
189
- }
190
-
191
- let cachedBigUint64ArrayMemory0 = null;
192
-
193
- function getBigUint64ArrayMemory0() {
194
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
195
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
196
- }
197
- return cachedBigUint64ArrayMemory0;
198
- }
199
-
200
- function passArray64ToWasm0(arg, malloc) {
201
- const ptr = malloc(arg.length * 8, 8) >>> 0;
202
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
203
- WASM_VECTOR_LEN = arg.length;
204
- return ptr;
205
- }
206
- /**
207
- * Evaluates a UPLC program applied to Data arguments, outside of any
208
- * transaction: the caller builds whatever arguments the program expects,
209
- * including its script context.
210
- *
211
- * - `program_flat`: the program, flat-encoded without a CBOR wrapper.
212
- * - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
213
- * - `language`: the Plutus version to evaluate as, 1, 2 or 3.
214
- * - `protocol_major_version`: the protocol version whose semantics to use,
215
- * from 5 (Alonzo) to 12 (Dijkstra).
216
- * - `cost_model`: the cost model parameters, every one the evaluator knows
217
- * for this Plutus version (350 for Plutus V3), in the ledger's order.
218
- * - `budget_cpu`, `budget_mem`: the budget.
219
- * - `strict_budget`: charge every step as the machine takes it, and stop the
220
- * program as soon as it goes over budget, instead of charging steps and
221
- * checking the budget every 200 steps as the ledger does. Only the cost of a
222
- * program that fails differs: the ledger does not charge the steps it took
223
- * since the budget was last checked.
224
- *
225
- * Fails only when the inputs are malformed or unsupported. A program that fails
226
- * is an [`EvalProgramResult`] that is not `ok`.
227
- * @param {Uint8Array} program_flat
228
- * @param {Uint8Array[]} args_cbor
229
- * @param {number} language
230
- * @param {number} protocol_major_version
231
- * @param {BigInt64Array} cost_model
232
- * @param {bigint} budget_cpu
233
- * @param {bigint} budget_mem
234
- * @param {boolean} strict_budget
235
- * @returns {EvalProgramResult}
236
- */
237
- export function eval_program_raw(program_flat, args_cbor, language, protocol_major_version, cost_model, budget_cpu, budget_mem, strict_budget) {
238
- const ptr0 = passArray8ToWasm0(program_flat, wasm.__wbindgen_malloc);
239
- const len0 = WASM_VECTOR_LEN;
240
- const ptr1 = passArrayJsValueToWasm0(args_cbor, wasm.__wbindgen_malloc);
241
- const len1 = WASM_VECTOR_LEN;
242
- const ptr2 = passArray64ToWasm0(cost_model, wasm.__wbindgen_malloc);
243
- const len2 = WASM_VECTOR_LEN;
244
- const ret = wasm.eval_program_raw(ptr0, len0, ptr1, len1, language, protocol_major_version, ptr2, len2, budget_cpu, budget_mem, strict_budget);
245
- if (ret[2]) {
246
- throw takeFromExternrefTable0(ret[1]);
247
- }
248
- return EvalProgramResult.__wrap(ret[0]);
249
- }
250
-
251
- /**
252
- * Describes this build of the evaluator as JSON: the uplc crate it was built
253
- * from, the length of each Plutus version's cost model, and a digest of what a
254
- * fixed set of programs evaluate to, with their costs, under Plutus V3 and the
255
- * latest protocol version. Two builds with the same digest agree on those
256
- * programs; `selfTest` says whether this one gives the expected results.
257
- * @returns {string}
258
- */
259
- export function uplc_build_info() {
260
- let deferred1_0;
261
- let deferred1_1;
262
- try {
263
- const ret = wasm.uplc_build_info();
264
- deferred1_0 = ret[0];
265
- deferred1_1 = ret[1];
266
- return getStringFromWasm0(ret[0], ret[1]);
267
- } finally {
268
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
269
- }
270
- }
271
-
272
- /**
273
- * Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
274
- * evaluates it at a protocol version, without any program around it: the
275
- * result, or how it fails, is what the machine gives for the saturated
276
- * application.
277
- *
278
- * - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
279
- * The Miller-loop builtins (68 to 70) are not supported, since their
280
- * results cannot be returned.
281
- * - `args`: exactly the builtin's arguments, in order, each encoded as the
282
- * matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
283
- * flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
284
- * for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
285
- * points, 5 for an array of G1 points and 6 for an array of G2 points, each
286
- * list or array as the compressed points one after the other. Flat cannot
287
- * encode BLS12-381 points, so they cross as their compressed bytes.
288
- * - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
289
- * 12 (Dijkstra). It decides which builtins are available and the semantics
290
- * they have.
291
- *
292
- * The result's `cpu` and `mem` are the builtin's charge for the application
293
- * under Plutus' default Plutus V3 cost model (not the ledger's protocol
294
- * parameters), excluding the machine's per-step costs.
295
- *
296
- * Fails only when the inputs are malformed or unsupported: an unknown or
297
- * Miller-loop tag, a number of arguments other than the builtin's arity, an
298
- * argument that does not decode as its kind says or is not a constant, an
299
- * invalid compressed point, a protocol version out of range, or a result that
300
- * none of the kinds can encode. A builtin that fails is an
301
- * [`EvalBuiltinResult`] that is not `ok`.
302
- * @param {number} tag
303
- * @param {Uint8Array[]} args
304
- * @param {Uint8Array} arg_kinds
305
- * @param {number} protocol_major_version
306
- * @returns {EvalBuiltinResult}
307
- */
308
- export function eval_builtin_raw(tag, args, arg_kinds, protocol_major_version) {
309
- const ptr0 = passArrayJsValueToWasm0(args, wasm.__wbindgen_malloc);
310
- const len0 = WASM_VECTOR_LEN;
311
- const ptr1 = passArray8ToWasm0(arg_kinds, wasm.__wbindgen_malloc);
312
- const len1 = WASM_VECTOR_LEN;
313
- const ret = wasm.eval_builtin_raw(tag, ptr0, len0, ptr1, len1, protocol_major_version);
314
- if (ret[2]) {
315
- throw takeFromExternrefTable0(ret[1]);
316
- }
317
- return EvalBuiltinResult.__wrap(ret[0]);
318
- }
319
-
320
1
  /**
321
2
  * Why the builtin given to [`eval_builtin_raw`] did not return a value: the
322
3
  * codes of the result's `error_kind`.
@@ -341,6 +22,7 @@ export const BuiltinErrorKind = Object.freeze({
341
22
  */
342
23
  Failed: 3, "3": "Failed",
343
24
  });
25
+
344
26
  /**
345
27
  * How a value of [`eval_builtin_raw`] is encoded: the codes of its
346
28
  * `arg_kinds` and of the result's `result_kind`.
@@ -383,47 +65,37 @@ export const BuiltinValueKind = Object.freeze({
383
65
  G2Array: 6, "6": "G2Array",
384
66
  });
385
67
 
386
- const EvalBuiltinResultFinalization = (typeof FinalizationRegistry === 'undefined')
387
- ? { register: () => {}, unregister: () => {} }
388
- : new FinalizationRegistry(ptr => wasm.__wbg_evalbuiltinresult_free(ptr >>> 0, 1));
389
68
  /**
390
69
  * The outcome of [`eval_builtin_raw`].
391
70
  */
392
71
  export class EvalBuiltinResult {
393
-
394
72
  static __wrap(ptr) {
395
- ptr = ptr >>> 0;
396
73
  const obj = Object.create(EvalBuiltinResult.prototype);
397
74
  obj.__wbg_ptr = ptr;
398
75
  EvalBuiltinResultFinalization.register(obj, obj.__wbg_ptr, obj);
399
76
  return obj;
400
77
  }
401
-
402
78
  __destroy_into_raw() {
403
79
  const ptr = this.__wbg_ptr;
404
80
  this.__wbg_ptr = 0;
405
81
  EvalBuiltinResultFinalization.unregister(this);
406
82
  return ptr;
407
83
  }
408
-
409
84
  free() {
410
85
  const ptr = this.__destroy_into_raw();
411
86
  wasm.__wbg_evalbuiltinresult_free(ptr, 0);
412
87
  }
413
88
  /**
414
- * Whether the builtin returned a value.
415
- * @returns {boolean}
416
- */
417
- get ok() {
418
- const ret = wasm.__wbg_get_evalbuiltinresult_ok(this.__wbg_ptr);
419
- return ret !== 0;
420
- }
421
- /**
422
- * Whether the builtin returned a value.
423
- * @param {boolean} arg0
89
+ * The CPU the builtin's cost model charges for this application, under
90
+ * Plutus' default cost model for Plutus V3 at the protocol version; 0
91
+ * when the builtin was not costed (error kinds 1 and 2). It leaves out the
92
+ * machine's own step costs for evaluating the application (the builtin,
93
+ * each force and each apply).
94
+ * @returns {bigint}
424
95
  */
425
- set ok(arg0) {
426
- wasm.__wbg_set_evalbuiltinresult_ok(this.__wbg_ptr, arg0);
96
+ get cpu() {
97
+ const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
98
+ return BigInt.asUintN(64, ret);
427
99
  }
428
100
  /**
429
101
  * Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
@@ -437,14 +109,38 @@ export class EvalBuiltinResult {
437
109
  return ret;
438
110
  }
439
111
  /**
440
- * Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
441
- * it did, 1 when it is not available to Plutus V3 at the protocol version,
442
- * 2 when it did not accept its arguments (so the machine fails before
443
- * costing it) and 3 when it failed after being costed.
444
- * @param {number} arg0
112
+ * The evaluator's description of why the builtin did not return a value;
113
+ * empty when it did.
114
+ * @returns {string}
445
115
  */
446
- set error_kind(arg0) {
447
- wasm.__wbg_set_evalbuiltinresult_error_kind(this.__wbg_ptr, arg0);
116
+ get error() {
117
+ let deferred1_0;
118
+ let deferred1_1;
119
+ try {
120
+ const ret = wasm.__wbg_get_evalbuiltinresult_error(this.__wbg_ptr);
121
+ deferred1_0 = ret[0];
122
+ deferred1_1 = ret[1];
123
+ return getStringFromWasm0(ret[0], ret[1]);
124
+ } finally {
125
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
126
+ }
127
+ }
128
+ /**
129
+ * The memory the builtin's cost model charges for this application; see
130
+ * `cpu`.
131
+ * @returns {bigint}
132
+ */
133
+ get mem() {
134
+ const ret = wasm.__wbg_get_evalbuiltinresult_mem(this.__wbg_ptr);
135
+ return BigInt.asUintN(64, ret);
136
+ }
137
+ /**
138
+ * Whether the builtin returned a value.
139
+ * @returns {boolean}
140
+ */
141
+ get ok() {
142
+ const ret = wasm.__wbg_get_evalbuiltinresult_ok(this.__wbg_ptr);
143
+ return ret !== 0;
448
144
  }
449
145
  /**
450
146
  * How `result` encodes the value, a [`BuiltinValueKind`] as for the
@@ -455,14 +151,6 @@ export class EvalBuiltinResult {
455
151
  const ret = wasm.__wbg_get_evalbuiltinresult_result_kind(this.__wbg_ptr);
456
152
  return ret;
457
153
  }
458
- /**
459
- * How `result` encodes the value, a [`BuiltinValueKind`] as for the
460
- * arguments of [`eval_builtin_raw`]; 0 when there is no value.
461
- * @param {number} arg0
462
- */
463
- set result_kind(arg0) {
464
- wasm.__wbg_set_evalbuiltinresult_result_kind(this.__wbg_ptr, arg0);
465
- }
466
154
  /**
467
155
  * The value the builtin returned; empty when there is none.
468
156
  * @returns {Uint8Array}
@@ -473,6 +161,60 @@ export class EvalBuiltinResult {
473
161
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
474
162
  return v1;
475
163
  }
164
+ /**
165
+ * The CPU the builtin's cost model charges for this application, under
166
+ * Plutus' default cost model for Plutus V3 at the protocol version; 0
167
+ * when the builtin was not costed (error kinds 1 and 2). It leaves out the
168
+ * machine's own step costs for evaluating the application (the builtin,
169
+ * each force and each apply).
170
+ * @param {bigint} arg0
171
+ */
172
+ set cpu(arg0) {
173
+ wasm.__wbg_set_evalbuiltinresult_cpu(this.__wbg_ptr, arg0);
174
+ }
175
+ /**
176
+ * Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
177
+ * it did, 1 when it is not available to Plutus V3 at the protocol version,
178
+ * 2 when it did not accept its arguments (so the machine fails before
179
+ * costing it) and 3 when it failed after being costed.
180
+ * @param {number} arg0
181
+ */
182
+ set error_kind(arg0) {
183
+ wasm.__wbg_set_evalbuiltinresult_error_kind(this.__wbg_ptr, arg0);
184
+ }
185
+ /**
186
+ * The evaluator's description of why the builtin did not return a value;
187
+ * empty when it did.
188
+ * @param {string} arg0
189
+ */
190
+ set error(arg0) {
191
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
+ const len0 = WASM_VECTOR_LEN;
193
+ wasm.__wbg_set_evalbuiltinresult_error(this.__wbg_ptr, ptr0, len0);
194
+ }
195
+ /**
196
+ * The memory the builtin's cost model charges for this application; see
197
+ * `cpu`.
198
+ * @param {bigint} arg0
199
+ */
200
+ set mem(arg0) {
201
+ wasm.__wbg_set_evalbuiltinresult_mem(this.__wbg_ptr, arg0);
202
+ }
203
+ /**
204
+ * Whether the builtin returned a value.
205
+ * @param {boolean} arg0
206
+ */
207
+ set ok(arg0) {
208
+ wasm.__wbg_set_evalbuiltinresult_ok(this.__wbg_ptr, arg0);
209
+ }
210
+ /**
211
+ * How `result` encodes the value, a [`BuiltinValueKind`] as for the
212
+ * arguments of [`eval_builtin_raw`]; 0 when there is no value.
213
+ * @param {number} arg0
214
+ */
215
+ set result_kind(arg0) {
216
+ wasm.__wbg_set_evalbuiltinresult_result_kind(this.__wbg_ptr, arg0);
217
+ }
476
218
  /**
477
219
  * The value the builtin returned; empty when there is none.
478
220
  * @param {Uint8Array} arg0
@@ -482,246 +224,477 @@ export class EvalBuiltinResult {
482
224
  const len0 = WASM_VECTOR_LEN;
483
225
  wasm.__wbg_set_evalbuiltinresult_result(this.__wbg_ptr, ptr0, len0);
484
226
  }
227
+ }
228
+ if (Symbol.dispose) EvalBuiltinResult.prototype[Symbol.dispose] = EvalBuiltinResult.prototype.free;
229
+
230
+ /**
231
+ * The outcome of [`eval_program_raw`].
232
+ */
233
+ export class EvalProgramResult {
234
+ static __wrap(ptr) {
235
+ const obj = Object.create(EvalProgramResult.prototype);
236
+ obj.__wbg_ptr = ptr;
237
+ EvalProgramResultFinalization.register(obj, obj.__wbg_ptr, obj);
238
+ return obj;
239
+ }
240
+ __destroy_into_raw() {
241
+ const ptr = this.__wbg_ptr;
242
+ this.__wbg_ptr = 0;
243
+ EvalProgramResultFinalization.unregister(this);
244
+ return ptr;
245
+ }
246
+ free() {
247
+ const ptr = this.__destroy_into_raw();
248
+ wasm.__wbg_evalprogramresult_free(ptr, 0);
249
+ }
250
+ /**
251
+ * The CPU the program used. A program that went over budget is charged
252
+ * what it used up to the point where the machine stopped it.
253
+ * @returns {bigint}
254
+ */
255
+ get cpu() {
256
+ const ret = wasm.__wbg_get_evalprogramresult_cpu(this.__wbg_ptr);
257
+ return BigInt.asUintN(64, ret);
258
+ }
259
+ /**
260
+ * Why the program did not succeed: 0 when it did, 1 when it went over
261
+ * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
262
+ * returned something other than unit.
263
+ * @returns {number}
264
+ */
265
+ get error_kind() {
266
+ const ret = wasm.__wbg_get_evalprogramresult_error_kind(this.__wbg_ptr);
267
+ return ret;
268
+ }
269
+ /**
270
+ * The messages the program traced, in order.
271
+ * @returns {string[]}
272
+ */
273
+ get logs() {
274
+ const ret = wasm.__wbg_get_evalprogramresult_logs(this.__wbg_ptr);
275
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
276
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
277
+ return v1;
278
+ }
485
279
  /**
486
- * The CPU the builtin's cost model charges for this application, under
487
- * Plutus' default cost model for Plutus V3 at the protocol version; 0
488
- * when the builtin was not costed (error kinds 1 and 2). It leaves out the
489
- * machine's own step costs for evaluating the application (the builtin,
490
- * each force and each apply).
280
+ * The memory the program used.
491
281
  * @returns {bigint}
492
282
  */
493
- get cpu() {
494
- const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
283
+ get mem() {
284
+ const ret = wasm.__wbg_get_evalprogramresult_mem(this.__wbg_ptr);
495
285
  return BigInt.asUintN(64, ret);
496
286
  }
497
287
  /**
498
- * The CPU the builtin's cost model charges for this application, under
499
- * Plutus' default cost model for Plutus V3 at the protocol version; 0
500
- * when the builtin was not costed (error kinds 1 and 2). It leaves out the
501
- * machine's own step costs for evaluating the application (the builtin,
502
- * each force and each apply).
288
+ * Whether the program succeeded: it did not fail and, for Plutus V3, it
289
+ * returned unit.
290
+ * @returns {boolean}
291
+ */
292
+ get ok() {
293
+ const ret = wasm.__wbg_get_evalprogramresult_ok(this.__wbg_ptr);
294
+ return ret !== 0;
295
+ }
296
+ /**
297
+ * The CPU the program used. A program that went over budget is charged
298
+ * what it used up to the point where the machine stopped it.
503
299
  * @param {bigint} arg0
504
300
  */
505
301
  set cpu(arg0) {
506
- wasm.__wbg_set_evalbuiltinresult_cpu(this.__wbg_ptr, arg0);
302
+ wasm.__wbg_set_evalprogramresult_cpu(this.__wbg_ptr, arg0);
507
303
  }
508
304
  /**
509
- * The memory the builtin's cost model charges for this application; see
510
- * `cpu`.
511
- * @returns {bigint}
305
+ * Why the program did not succeed: 0 when it did, 1 when it went over
306
+ * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
307
+ * returned something other than unit.
308
+ * @param {number} arg0
512
309
  */
513
- get mem() {
514
- const ret = wasm.__wbg_get_evalbuiltinresult_mem(this.__wbg_ptr);
515
- return BigInt.asUintN(64, ret);
310
+ set error_kind(arg0) {
311
+ wasm.__wbg_set_evalprogramresult_error_kind(this.__wbg_ptr, arg0);
516
312
  }
517
313
  /**
518
- * The memory the builtin's cost model charges for this application; see
519
- * `cpu`.
520
- * @param {bigint} arg0
314
+ * The messages the program traced, in order.
315
+ * @param {string[]} arg0
521
316
  */
522
- set mem(arg0) {
523
- wasm.__wbg_set_evalbuiltinresult_mem(this.__wbg_ptr, arg0);
317
+ set logs(arg0) {
318
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ wasm.__wbg_set_evalprogramresult_logs(this.__wbg_ptr, ptr0, len0);
524
321
  }
525
322
  /**
526
- * The evaluator's description of why the builtin did not return a value;
527
- * empty when it did.
528
- * @returns {string}
323
+ * The memory the program used.
324
+ * @param {bigint} arg0
529
325
  */
530
- get error() {
531
- let deferred1_0;
532
- let deferred1_1;
533
- try {
534
- const ret = wasm.__wbg_get_evalbuiltinresult_error(this.__wbg_ptr);
535
- deferred1_0 = ret[0];
536
- deferred1_1 = ret[1];
537
- return getStringFromWasm0(ret[0], ret[1]);
538
- } finally {
539
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
540
- }
326
+ set mem(arg0) {
327
+ wasm.__wbg_set_evalprogramresult_mem(this.__wbg_ptr, arg0);
541
328
  }
542
329
  /**
543
- * The evaluator's description of why the builtin did not return a value;
544
- * empty when it did.
545
- * @param {string} arg0
330
+ * Whether the program succeeded: it did not fail and, for Plutus V3, it
331
+ * returned unit.
332
+ * @param {boolean} arg0
546
333
  */
547
- set error(arg0) {
548
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
549
- const len0 = WASM_VECTOR_LEN;
550
- wasm.__wbg_set_evalbuiltinresult_error(this.__wbg_ptr, ptr0, len0);
334
+ set ok(arg0) {
335
+ wasm.__wbg_set_evalprogramresult_ok(this.__wbg_ptr, arg0);
336
+ }
337
+ }
338
+ if (Symbol.dispose) EvalProgramResult.prototype[Symbol.dispose] = EvalProgramResult.prototype.free;
339
+
340
+ /**
341
+ * @param {Uint8Array} params_bytes
342
+ * @param {Uint8Array} plutus_script_bytes
343
+ * @returns {Uint8Array}
344
+ */
345
+ export function apply_params_to_script(params_bytes, plutus_script_bytes) {
346
+ const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
347
+ const len0 = WASM_VECTOR_LEN;
348
+ const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
349
+ const len1 = WASM_VECTOR_LEN;
350
+ const ret = wasm.apply_params_to_script(ptr0, len0, ptr1, len1);
351
+ if (ret[3]) {
352
+ throw takeFromExternrefTable0(ret[2]);
353
+ }
354
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
355
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
356
+ return v3;
357
+ }
358
+
359
+ /**
360
+ * Evaluates the builtin `tag` applied to `args` as a Plutus V3 script
361
+ * evaluates it at a protocol version, without any program around it: the
362
+ * result, or how it fails, is what the machine gives for the saturated
363
+ * application.
364
+ *
365
+ * - `tag`: the builtin's flat tag (0 for addInteger to 100 for scaleValue).
366
+ * The Miller-loop builtins (68 to 70) are not supported, since their
367
+ * results cannot be returned.
368
+ * - `args`: exactly the builtin's arguments, in order, each encoded as the
369
+ * matching entry of `arg_kinds` says, a [`BuiltinValueKind`]: 0 for a
370
+ * flat-encoded `(program 1.1.0 (con …))`, 1 for a compressed G1 point, 2
371
+ * for a compressed G2 point, 3 for a list of G1 points, 4 for a list of G2
372
+ * points, 5 for an array of G1 points and 6 for an array of G2 points, each
373
+ * list or array as the compressed points one after the other. Flat cannot
374
+ * encode BLS12-381 points, so they cross as their compressed bytes.
375
+ * - `protocol_major_version`: from 9 (Chang, which introduced Plutus V3) to
376
+ * 12 (Dijkstra). It decides which builtins are available and the semantics
377
+ * they have.
378
+ *
379
+ * The result's `cpu` and `mem` are the builtin's charge for the application
380
+ * under Plutus' default Plutus V3 cost model (not the ledger's protocol
381
+ * parameters), excluding the machine's per-step costs.
382
+ *
383
+ * Fails only when the inputs are malformed or unsupported: an unknown or
384
+ * Miller-loop tag, a number of arguments other than the builtin's arity, an
385
+ * argument that does not decode as its kind says or is not a constant, an
386
+ * invalid compressed point, a protocol version out of range, or a result that
387
+ * none of the kinds can encode. A builtin that fails is an
388
+ * [`EvalBuiltinResult`] that is not `ok`.
389
+ * @param {number} tag
390
+ * @param {Uint8Array[]} args
391
+ * @param {Uint8Array} arg_kinds
392
+ * @param {number} protocol_major_version
393
+ * @returns {EvalBuiltinResult}
394
+ */
395
+ export function eval_builtin_raw(tag, args, arg_kinds, protocol_major_version) {
396
+ const ptr0 = passArrayJsValueToWasm0(args, wasm.__wbindgen_malloc);
397
+ const len0 = WASM_VECTOR_LEN;
398
+ const ptr1 = passArray8ToWasm0(arg_kinds, wasm.__wbindgen_malloc);
399
+ const len1 = WASM_VECTOR_LEN;
400
+ const ret = wasm.eval_builtin_raw(tag, ptr0, len0, ptr1, len1, protocol_major_version);
401
+ if (ret[2]) {
402
+ throw takeFromExternrefTable0(ret[1]);
403
+ }
404
+ return EvalBuiltinResult.__wrap(ret[0]);
405
+ }
406
+
407
+ /**
408
+ * @param {Uint8Array} tx_bytes
409
+ * @param {Uint8Array[]} utxos_bytes_x
410
+ * @param {Uint8Array[]} utxos_bytes_y
411
+ * @param {Uint8Array} cost_mdls_bytes
412
+ * @param {bigint} initial_budget_n
413
+ * @param {bigint} initial_budget_d
414
+ * @param {bigint} slot_config_x
415
+ * @param {bigint} slot_config_y
416
+ * @param {number} slot_config_z
417
+ * @param {number | null} [protocol_major_version]
418
+ * @returns {Uint8Array[]}
419
+ */
420
+ export function eval_phase_two_raw(tx_bytes, utxos_bytes_x, utxos_bytes_y, cost_mdls_bytes, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z, protocol_major_version) {
421
+ const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
422
+ const len0 = WASM_VECTOR_LEN;
423
+ const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
424
+ const len1 = WASM_VECTOR_LEN;
425
+ const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
426
+ const len2 = WASM_VECTOR_LEN;
427
+ const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
428
+ const len3 = WASM_VECTOR_LEN;
429
+ const ret = wasm.eval_phase_two_raw(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z, !isLikeNone(protocol_major_version), isLikeNone(protocol_major_version) ? 0 : protocol_major_version);
430
+ if (ret[3]) {
431
+ throw takeFromExternrefTable0(ret[2]);
432
+ }
433
+ var v5 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
434
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
435
+ return v5;
436
+ }
437
+
438
+ /**
439
+ * Evaluates a UPLC program applied to Data arguments, outside of any
440
+ * transaction: the caller builds whatever arguments the program expects,
441
+ * including its script context.
442
+ *
443
+ * - `program_flat`: the program, flat-encoded without a CBOR wrapper.
444
+ * - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
445
+ * - `language`: the Plutus version to evaluate as, 1, 2 or 3.
446
+ * - `protocol_major_version`: the protocol version whose semantics to use,
447
+ * from 5 (Alonzo) to 12 (Dijkstra).
448
+ * - `cost_model`: the cost model parameters, every one the evaluator knows
449
+ * for this Plutus version (350 for Plutus V3), in the ledger's order.
450
+ * - `budget_cpu`, `budget_mem`: the budget.
451
+ * - `strict_budget`: charge every step as the machine takes it, and stop the
452
+ * program as soon as it goes over budget, instead of charging steps and
453
+ * checking the budget every 200 steps as the ledger does. Only the cost of a
454
+ * program that fails differs: the ledger does not charge the steps it took
455
+ * since the budget was last checked.
456
+ *
457
+ * Fails only when the inputs are malformed or unsupported. A program that fails
458
+ * is an [`EvalProgramResult`] that is not `ok`.
459
+ * @param {Uint8Array} program_flat
460
+ * @param {Uint8Array[]} args_cbor
461
+ * @param {number} language
462
+ * @param {number} protocol_major_version
463
+ * @param {BigInt64Array} cost_model
464
+ * @param {bigint} budget_cpu
465
+ * @param {bigint} budget_mem
466
+ * @param {boolean} strict_budget
467
+ * @returns {EvalProgramResult}
468
+ */
469
+ export function eval_program_raw(program_flat, args_cbor, language, protocol_major_version, cost_model, budget_cpu, budget_mem, strict_budget) {
470
+ const ptr0 = passArray8ToWasm0(program_flat, wasm.__wbindgen_malloc);
471
+ const len0 = WASM_VECTOR_LEN;
472
+ const ptr1 = passArrayJsValueToWasm0(args_cbor, wasm.__wbindgen_malloc);
473
+ const len1 = WASM_VECTOR_LEN;
474
+ const ptr2 = passArray64ToWasm0(cost_model, wasm.__wbindgen_malloc);
475
+ const len2 = WASM_VECTOR_LEN;
476
+ const ret = wasm.eval_program_raw(ptr0, len0, ptr1, len1, language, protocol_major_version, ptr2, len2, budget_cpu, budget_mem, strict_budget);
477
+ if (ret[2]) {
478
+ throw takeFromExternrefTable0(ret[1]);
479
+ }
480
+ return EvalProgramResult.__wrap(ret[0]);
481
+ }
482
+
483
+ /**
484
+ * Describes this build of the evaluator as JSON: the uplc crate it was built
485
+ * from, the length of each Plutus version's cost model, and a digest of what a
486
+ * fixed set of programs evaluate to, with their costs, under Plutus V3 and the
487
+ * latest protocol version. Two builds with the same digest agree on those
488
+ * programs; `selfTest` says whether this one gives the expected results.
489
+ * @returns {string}
490
+ */
491
+ export function uplc_build_info() {
492
+ let deferred1_0;
493
+ let deferred1_1;
494
+ try {
495
+ const ret = wasm.uplc_build_info();
496
+ deferred1_0 = ret[0];
497
+ deferred1_1 = ret[1];
498
+ return getStringFromWasm0(ret[0], ret[1]);
499
+ } finally {
500
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
551
501
  }
552
502
  }
553
-
503
+ export function __wbg___wbindgen_string_get_b0ca35b86a603356(arg0, arg1) {
504
+ const obj = arg1;
505
+ const ret = typeof(obj) === 'string' ? obj : undefined;
506
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
507
+ var len1 = WASM_VECTOR_LEN;
508
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
509
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
510
+ }
511
+ export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
512
+ throw new Error(getStringFromWasm0(arg0, arg1));
513
+ }
514
+ export function __wbg_length_1f0964f4a5e2c6d8(arg0) {
515
+ const ret = arg0.length;
516
+ return ret;
517
+ }
518
+ export function __wbg_new_from_slice_77cdfb7977362f3c(arg0, arg1) {
519
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
520
+ return ret;
521
+ }
522
+ export function __wbg_prototypesetcall_4770620bbe4688a0(arg0, arg1, arg2) {
523
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
524
+ }
525
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
526
+ // Cast intrinsic for `Ref(String) -> Externref`.
527
+ const ret = getStringFromWasm0(arg0, arg1);
528
+ return ret;
529
+ }
530
+ export function __wbindgen_init_externref_table() {
531
+ const table = wasm.__wbindgen_externrefs;
532
+ const offset = table.grow(4);
533
+ table.set(0, undefined);
534
+ table.set(offset + 0, undefined);
535
+ table.set(offset + 1, null);
536
+ table.set(offset + 2, true);
537
+ table.set(offset + 3, false);
538
+ }
539
+ const EvalBuiltinResultFinalization = (typeof FinalizationRegistry === 'undefined')
540
+ ? { register: () => {}, unregister: () => {} }
541
+ : new FinalizationRegistry(ptr => wasm.__wbg_evalbuiltinresult_free(ptr, 1));
554
542
  const EvalProgramResultFinalization = (typeof FinalizationRegistry === 'undefined')
555
543
  ? { register: () => {}, unregister: () => {} }
556
- : new FinalizationRegistry(ptr => wasm.__wbg_evalprogramresult_free(ptr >>> 0, 1));
557
- /**
558
- * The outcome of [`eval_program_raw`].
559
- */
560
- export class EvalProgramResult {
544
+ : new FinalizationRegistry(ptr => wasm.__wbg_evalprogramresult_free(ptr, 1));
561
545
 
562
- static __wrap(ptr) {
563
- ptr = ptr >>> 0;
564
- const obj = Object.create(EvalProgramResult.prototype);
565
- obj.__wbg_ptr = ptr;
566
- EvalProgramResultFinalization.register(obj, obj.__wbg_ptr, obj);
567
- return obj;
568
- }
546
+ function addToExternrefTable0(obj) {
547
+ const idx = wasm.__externref_table_alloc();
548
+ wasm.__wbindgen_externrefs.set(idx, obj);
549
+ return idx;
550
+ }
569
551
 
570
- __destroy_into_raw() {
571
- const ptr = this.__wbg_ptr;
572
- this.__wbg_ptr = 0;
573
- EvalProgramResultFinalization.unregister(this);
574
- return ptr;
552
+ function getArrayJsValueFromWasm0(ptr, len) {
553
+ ptr = ptr >>> 0;
554
+ const mem = getDataViewMemory0();
555
+ const result = [];
556
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
557
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
575
558
  }
559
+ wasm.__externref_drop_slice(ptr, len);
560
+ return result;
561
+ }
576
562
 
577
- free() {
578
- const ptr = this.__destroy_into_raw();
579
- wasm.__wbg_evalprogramresult_free(ptr, 0);
580
- }
581
- /**
582
- * Whether the program succeeded: it did not fail and, for Plutus V3, it
583
- * returned unit.
584
- * @returns {boolean}
585
- */
586
- get ok() {
587
- const ret = wasm.__wbg_get_evalprogramresult_ok(this.__wbg_ptr);
588
- return ret !== 0;
589
- }
590
- /**
591
- * Whether the program succeeded: it did not fail and, for Plutus V3, it
592
- * returned unit.
593
- * @param {boolean} arg0
594
- */
595
- set ok(arg0) {
596
- wasm.__wbg_set_evalprogramresult_ok(this.__wbg_ptr, arg0);
597
- }
598
- /**
599
- * The CPU the program used. A program that went over budget is charged
600
- * what it used up to the point where the machine stopped it.
601
- * @returns {bigint}
602
- */
603
- get cpu() {
604
- const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
605
- return BigInt.asUintN(64, ret);
606
- }
607
- /**
608
- * The CPU the program used. A program that went over budget is charged
609
- * what it used up to the point where the machine stopped it.
610
- * @param {bigint} arg0
611
- */
612
- set cpu(arg0) {
613
- wasm.__wbg_set_evalbuiltinresult_cpu(this.__wbg_ptr, arg0);
614
- }
615
- /**
616
- * The memory the program used.
617
- * @returns {bigint}
618
- */
619
- get mem() {
620
- const ret = wasm.__wbg_get_evalbuiltinresult_mem(this.__wbg_ptr);
621
- return BigInt.asUintN(64, ret);
622
- }
623
- /**
624
- * The memory the program used.
625
- * @param {bigint} arg0
626
- */
627
- set mem(arg0) {
628
- wasm.__wbg_set_evalbuiltinresult_mem(this.__wbg_ptr, arg0);
629
- }
630
- /**
631
- * Why the program did not succeed: 0 when it did, 1 when it went over
632
- * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
633
- * returned something other than unit.
634
- * @returns {number}
635
- */
636
- get error_kind() {
637
- const ret = wasm.__wbg_get_evalprogramresult_error_kind(this.__wbg_ptr);
638
- return ret;
563
+ function getArrayU8FromWasm0(ptr, len) {
564
+ ptr = ptr >>> 0;
565
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
566
+ }
567
+
568
+ let cachedBigUint64ArrayMemory0 = null;
569
+ function getBigUint64ArrayMemory0() {
570
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
571
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
639
572
  }
640
- /**
641
- * Why the program did not succeed: 0 when it did, 1 when it went over
642
- * budget, 2 when it failed in any other way and 3 when a Plutus V3 program
643
- * returned something other than unit.
644
- * @param {number} arg0
645
- */
646
- set error_kind(arg0) {
647
- wasm.__wbg_set_evalprogramresult_error_kind(this.__wbg_ptr, arg0);
573
+ return cachedBigUint64ArrayMemory0;
574
+ }
575
+
576
+ let cachedDataViewMemory0 = null;
577
+ function getDataViewMemory0() {
578
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
579
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
648
580
  }
649
- /**
650
- * The messages the program traced, in order.
651
- * @returns {string[]}
652
- */
653
- get logs() {
654
- const ret = wasm.__wbg_get_evalprogramresult_logs(this.__wbg_ptr);
655
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
656
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
657
- return v1;
581
+ return cachedDataViewMemory0;
582
+ }
583
+
584
+ function getStringFromWasm0(ptr, len) {
585
+ return decodeText(ptr >>> 0, len);
586
+ }
587
+
588
+ let cachedUint8ArrayMemory0 = null;
589
+ function getUint8ArrayMemory0() {
590
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
591
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
658
592
  }
659
- /**
660
- * The messages the program traced, in order.
661
- * @param {string[]} arg0
662
- */
663
- set logs(arg0) {
664
- const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
665
- const len0 = WASM_VECTOR_LEN;
666
- wasm.__wbg_set_evalprogramresult_logs(this.__wbg_ptr, ptr0, len0);
593
+ return cachedUint8ArrayMemory0;
594
+ }
595
+
596
+ function isLikeNone(x) {
597
+ return x === undefined || x === null;
598
+ }
599
+
600
+ function passArray64ToWasm0(arg, malloc) {
601
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
602
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
603
+ WASM_VECTOR_LEN = arg.length;
604
+ return ptr;
605
+ }
606
+
607
+ function passArray8ToWasm0(arg, malloc) {
608
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
609
+ getUint8ArrayMemory0().set(arg, ptr / 1);
610
+ WASM_VECTOR_LEN = arg.length;
611
+ return ptr;
612
+ }
613
+
614
+ function passArrayJsValueToWasm0(array, malloc) {
615
+ const ptr = malloc(array.length * 4, 4) >>> 0;
616
+ for (let i = 0; i < array.length; i++) {
617
+ const add = addToExternrefTable0(array[i]);
618
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
667
619
  }
620
+ WASM_VECTOR_LEN = array.length;
621
+ return ptr;
668
622
  }
669
623
 
670
- export function __wbg_buffer_609cc3eee51ed158(arg0) {
671
- const ret = arg0.buffer;
672
- return ret;
673
- };
624
+ function passStringToWasm0(arg, malloc, realloc) {
625
+ if (realloc === undefined) {
626
+ const buf = cachedTextEncoder.encode(arg);
627
+ const ptr = malloc(buf.length, 1) >>> 0;
628
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
629
+ WASM_VECTOR_LEN = buf.length;
630
+ return ptr;
631
+ }
674
632
 
675
- export function __wbg_length_a446193dc22c12f8(arg0) {
676
- const ret = arg0.length;
677
- return ret;
678
- };
633
+ let len = arg.length;
634
+ let ptr = malloc(len, 1) >>> 0;
679
635
 
680
- export function __wbg_new_a12002a7f91c75be(arg0) {
681
- const ret = new Uint8Array(arg0);
682
- return ret;
683
- };
636
+ const mem = getUint8ArrayMemory0();
684
637
 
685
- export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(arg0, arg1, arg2) {
686
- const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
687
- return ret;
688
- };
638
+ let offset = 0;
689
639
 
690
- export function __wbg_set_65595bdd868b3009(arg0, arg1, arg2) {
691
- arg0.set(arg1, arg2 >>> 0);
692
- };
640
+ for (; offset < len; offset++) {
641
+ const code = arg.charCodeAt(offset);
642
+ if (code > 0x7F) break;
643
+ mem[ptr + offset] = code;
644
+ }
645
+ if (offset !== len) {
646
+ if (offset !== 0) {
647
+ arg = arg.slice(offset);
648
+ }
649
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
650
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
651
+ const ret = cachedTextEncoder.encodeInto(arg, view);
693
652
 
694
- export function __wbindgen_init_externref_table() {
695
- const table = wasm.__wbindgen_export_0;
696
- const offset = table.grow(4);
697
- table.set(0, undefined);
698
- table.set(offset + 0, undefined);
699
- table.set(offset + 1, null);
700
- table.set(offset + 2, true);
701
- table.set(offset + 3, false);
702
- ;
703
- };
653
+ offset += ret.written;
654
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
655
+ }
704
656
 
705
- export function __wbindgen_memory() {
706
- const ret = wasm.memory;
707
- return ret;
708
- };
657
+ WASM_VECTOR_LEN = offset;
658
+ return ptr;
659
+ }
709
660
 
710
- export function __wbindgen_string_get(arg0, arg1) {
711
- const obj = arg1;
712
- const ret = typeof(obj) === 'string' ? obj : undefined;
713
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
714
- var len1 = WASM_VECTOR_LEN;
715
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
716
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
717
- };
661
+ function takeFromExternrefTable0(idx) {
662
+ const value = wasm.__wbindgen_externrefs.get(idx);
663
+ wasm.__externref_table_dealloc(idx);
664
+ return value;
665
+ }
718
666
 
719
- export function __wbindgen_string_new(arg0, arg1) {
720
- const ret = getStringFromWasm0(arg0, arg1);
721
- return ret;
722
- };
667
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
668
+ cachedTextDecoder.decode();
669
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
670
+ let numBytesDecoded = 0;
671
+ function decodeText(ptr, len) {
672
+ numBytesDecoded += len;
673
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
674
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
675
+ cachedTextDecoder.decode();
676
+ numBytesDecoded = len;
677
+ }
678
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
679
+ }
680
+
681
+ const cachedTextEncoder = new TextEncoder();
682
+
683
+ if (!('encodeInto' in cachedTextEncoder)) {
684
+ cachedTextEncoder.encodeInto = function (arg, view) {
685
+ const buf = cachedTextEncoder.encode(arg);
686
+ view.set(buf);
687
+ return {
688
+ read: arg.length,
689
+ written: buf.length
690
+ };
691
+ };
692
+ }
693
+
694
+ let WASM_VECTOR_LEN = 0;
723
695
 
724
- export function __wbindgen_throw(arg0, arg1) {
725
- throw new Error(getStringFromWasm0(arg0, arg1));
726
- };
727
696
 
697
+ let wasm;
698
+ export function __wbg_set_wasm(val) {
699
+ wasm = val;
700
+ }