@lucid-evolution/uplc 0.4.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.
- package/README.md +39 -0
- package/dist/recover-from-trap.js +44 -0
- package/dist/size/browser/uplc_tx.d.ts +191 -35
- package/dist/size/browser/uplc_tx.js +5 -1
- package/dist/size/browser/uplc_tx_bg.js +612 -357
- package/dist/size/browser/uplc_tx_bg.wasm +0 -0
- package/dist/size/browser/uplc_tx_bg.wasm.d.ts +46 -7
- package/dist/size/node/uplc_tx.d.ts +193 -35
- package/dist/size/node/uplc_tx.js +755 -336
- package/dist/size/node/uplc_tx_bg.wasm +0 -0
- package/dist/size/node/uplc_tx_bg.wasm.d.ts +46 -7
- package/dist/size/node.d.ts +11 -0
- package/dist/size/node.js +17 -0
- package/dist/speed/browser/uplc_tx.d.ts +191 -35
- package/dist/speed/browser/uplc_tx.js +5 -1
- package/dist/speed/browser/uplc_tx_bg.js +612 -357
- package/dist/speed/browser/uplc_tx_bg.wasm +0 -0
- package/dist/speed/browser/uplc_tx_bg.wasm.d.ts +46 -7
- package/dist/speed/node/uplc_tx.d.ts +193 -35
- package/dist/speed/node/uplc_tx.js +755 -336
- package/dist/speed/node/uplc_tx_bg.wasm +0 -0
- package/dist/speed/node/uplc_tx_bg.wasm.d.ts +46 -7
- package/dist/speed/node.d.ts +11 -0
- package/dist/speed/node.js +17 -0
- package/package.json +12 -12
|
@@ -1,139 +1,409 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Why the builtin given to [`eval_builtin_raw`] did not return a value: the
|
|
3
|
+
* codes of the result's `error_kind`.
|
|
4
|
+
* @enum {0 | 1 | 2 | 3}
|
|
5
|
+
*/
|
|
6
|
+
export const BuiltinErrorKind = Object.freeze({
|
|
7
|
+
/**
|
|
8
|
+
* The builtin returned a value.
|
|
9
|
+
*/
|
|
10
|
+
Ok: 0, "0": "Ok",
|
|
11
|
+
/**
|
|
12
|
+
* The builtin is not available to Plutus V3 at the protocol version.
|
|
13
|
+
*/
|
|
14
|
+
NotAvailable: 1, "1": "NotAvailable",
|
|
15
|
+
/**
|
|
16
|
+
* The builtin did not accept its arguments, which fails the application
|
|
17
|
+
* before it is costed.
|
|
18
|
+
*/
|
|
19
|
+
RejectedArguments: 2, "2": "RejectedArguments",
|
|
20
|
+
/**
|
|
21
|
+
* The builtin failed after it was costed.
|
|
22
|
+
*/
|
|
23
|
+
Failed: 3, "3": "Failed",
|
|
33
24
|
});
|
|
34
25
|
|
|
35
|
-
|
|
26
|
+
/**
|
|
27
|
+
* How a value of [`eval_builtin_raw`] is encoded: the codes of its
|
|
28
|
+
* `arg_kinds` and of the result's `result_kind`.
|
|
29
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
|
|
30
|
+
*/
|
|
31
|
+
export const BuiltinValueKind = Object.freeze({
|
|
32
|
+
/**
|
|
33
|
+
* A flat-encoded program whose body is a constant,
|
|
34
|
+
* `(program 1.1.0 (con …))`. A result in this form is always version
|
|
35
|
+
* 1.1.0.
|
|
36
|
+
*/
|
|
37
|
+
Flat: 0, "0": "Flat",
|
|
38
|
+
/**
|
|
39
|
+
* A BLS12-381 G1 point, as its 48-byte compressed encoding.
|
|
40
|
+
*/
|
|
41
|
+
G1: 1, "1": "G1",
|
|
42
|
+
/**
|
|
43
|
+
* A BLS12-381 G2 point, as its 96-byte compressed encoding.
|
|
44
|
+
*/
|
|
45
|
+
G2: 2, "2": "G2",
|
|
46
|
+
/**
|
|
47
|
+
* A list of BLS12-381 G1 points, as their compressed encodings one after
|
|
48
|
+
* the other.
|
|
49
|
+
*/
|
|
50
|
+
G1List: 3, "3": "G1List",
|
|
51
|
+
/**
|
|
52
|
+
* A list of BLS12-381 G2 points, as their compressed encodings one after
|
|
53
|
+
* the other.
|
|
54
|
+
*/
|
|
55
|
+
G2List: 4, "4": "G2List",
|
|
56
|
+
/**
|
|
57
|
+
* An array of BLS12-381 G1 points, as their compressed encodings one after
|
|
58
|
+
* the other.
|
|
59
|
+
*/
|
|
60
|
+
G1Array: 5, "5": "G1Array",
|
|
61
|
+
/**
|
|
62
|
+
* An array of BLS12-381 G2 points, as their compressed encodings one after
|
|
63
|
+
* the other.
|
|
64
|
+
*/
|
|
65
|
+
G2Array: 6, "6": "G2Array",
|
|
66
|
+
});
|
|
36
67
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The outcome of [`eval_builtin_raw`].
|
|
70
|
+
*/
|
|
71
|
+
export class EvalBuiltinResult {
|
|
72
|
+
static __wrap(ptr) {
|
|
73
|
+
const obj = Object.create(EvalBuiltinResult.prototype);
|
|
74
|
+
obj.__wbg_ptr = ptr;
|
|
75
|
+
EvalBuiltinResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
__destroy_into_raw() {
|
|
79
|
+
const ptr = this.__wbg_ptr;
|
|
80
|
+
this.__wbg_ptr = 0;
|
|
81
|
+
EvalBuiltinResultFinalization.unregister(this);
|
|
42
82
|
return ptr;
|
|
43
83
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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;
|
|
84
|
+
free() {
|
|
85
|
+
const ptr = this.__destroy_into_raw();
|
|
86
|
+
wasm.__wbg_evalbuiltinresult_free(ptr, 0);
|
|
56
87
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
/**
|
|
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}
|
|
95
|
+
*/
|
|
96
|
+
get cpu() {
|
|
97
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_cpu(this.__wbg_ptr);
|
|
98
|
+
return BigInt.asUintN(64, ret);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Why the builtin did not return a value, a [`BuiltinErrorKind`]: 0 when
|
|
102
|
+
* it did, 1 when it is not available to Plutus V3 at the protocol version,
|
|
103
|
+
* 2 when it did not accept its arguments (so the machine fails before
|
|
104
|
+
* costing it) and 3 when it failed after being costed.
|
|
105
|
+
* @returns {number}
|
|
106
|
+
*/
|
|
107
|
+
get error_kind() {
|
|
108
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_error_kind(this.__wbg_ptr);
|
|
109
|
+
return ret;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The evaluator's description of why the builtin did not return a value;
|
|
113
|
+
* empty when it did.
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
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);
|
|
61
126
|
}
|
|
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
127
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* How `result` encodes the value, a [`BuiltinValueKind`] as for the
|
|
147
|
+
* arguments of [`eval_builtin_raw`]; 0 when there is no value.
|
|
148
|
+
* @returns {number}
|
|
149
|
+
*/
|
|
150
|
+
get result_kind() {
|
|
151
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_result_kind(this.__wbg_ptr);
|
|
152
|
+
return ret;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The value the builtin returned; empty when there is none.
|
|
156
|
+
* @returns {Uint8Array}
|
|
157
|
+
*/
|
|
158
|
+
get result() {
|
|
159
|
+
const ret = wasm.__wbg_get_evalbuiltinresult_result(this.__wbg_ptr);
|
|
160
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
161
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
162
|
+
return v1;
|
|
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
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The value the builtin returned; empty when there is none.
|
|
220
|
+
* @param {Uint8Array} arg0
|
|
221
|
+
*/
|
|
222
|
+
set result(arg0) {
|
|
223
|
+
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
224
|
+
const len0 = WASM_VECTOR_LEN;
|
|
225
|
+
wasm.__wbg_set_evalbuiltinresult_result(this.__wbg_ptr, ptr0, len0);
|
|
83
226
|
}
|
|
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
227
|
}
|
|
228
|
+
if (Symbol.dispose) EvalBuiltinResult.prototype[Symbol.dispose] = EvalBuiltinResult.prototype.free;
|
|
110
229
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The memory the program used.
|
|
281
|
+
* @returns {bigint}
|
|
282
|
+
*/
|
|
283
|
+
get mem() {
|
|
284
|
+
const ret = wasm.__wbg_get_evalprogramresult_mem(this.__wbg_ptr);
|
|
285
|
+
return BigInt.asUintN(64, ret);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
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.
|
|
299
|
+
* @param {bigint} arg0
|
|
300
|
+
*/
|
|
301
|
+
set cpu(arg0) {
|
|
302
|
+
wasm.__wbg_set_evalprogramresult_cpu(this.__wbg_ptr, arg0);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
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
|
|
309
|
+
*/
|
|
310
|
+
set error_kind(arg0) {
|
|
311
|
+
wasm.__wbg_set_evalprogramresult_error_kind(this.__wbg_ptr, arg0);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The messages the program traced, in order.
|
|
315
|
+
* @param {string[]} arg0
|
|
316
|
+
*/
|
|
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);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* The memory the program used.
|
|
324
|
+
* @param {bigint} arg0
|
|
325
|
+
*/
|
|
326
|
+
set mem(arg0) {
|
|
327
|
+
wasm.__wbg_set_evalprogramresult_mem(this.__wbg_ptr, arg0);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
331
|
+
* returned unit.
|
|
332
|
+
* @param {boolean} arg0
|
|
333
|
+
*/
|
|
334
|
+
set ok(arg0) {
|
|
335
|
+
wasm.__wbg_set_evalprogramresult_ok(this.__wbg_ptr, arg0);
|
|
116
336
|
}
|
|
117
|
-
WASM_VECTOR_LEN = array.length;
|
|
118
|
-
return ptr;
|
|
119
337
|
}
|
|
338
|
+
if (Symbol.dispose) EvalProgramResult.prototype[Symbol.dispose] = EvalProgramResult.prototype.free;
|
|
120
339
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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;
|
|
125
357
|
}
|
|
126
358
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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]);
|
|
133
403
|
}
|
|
134
|
-
|
|
135
|
-
return result;
|
|
404
|
+
return EvalBuiltinResult.__wrap(ret[0]);
|
|
136
405
|
}
|
|
406
|
+
|
|
137
407
|
/**
|
|
138
408
|
* @param {Uint8Array} tx_bytes
|
|
139
409
|
* @param {Uint8Array[]} utxos_bytes_x
|
|
@@ -165,36 +435,166 @@ export function eval_phase_two_raw(tx_bytes, utxos_bytes_x, utxos_bytes_y, cost_
|
|
|
165
435
|
return v5;
|
|
166
436
|
}
|
|
167
437
|
|
|
168
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
169
|
-
ptr = ptr >>> 0;
|
|
170
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
171
|
-
}
|
|
172
438
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
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}
|
|
176
468
|
*/
|
|
177
|
-
export function
|
|
178
|
-
const ptr0 = passArray8ToWasm0(
|
|
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);
|
|
179
471
|
const len0 = WASM_VECTOR_LEN;
|
|
180
|
-
const ptr1 =
|
|
472
|
+
const ptr1 = passArrayJsValueToWasm0(args_cbor, wasm.__wbindgen_malloc);
|
|
181
473
|
const len1 = WASM_VECTOR_LEN;
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
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]);
|
|
185
479
|
}
|
|
186
|
-
|
|
187
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
188
|
-
return v3;
|
|
480
|
+
return EvalProgramResult.__wrap(ret[0]);
|
|
189
481
|
}
|
|
190
482
|
|
|
191
|
-
|
|
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);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
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));
|
|
542
|
+
const EvalProgramResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
543
|
+
? { register: () => {}, unregister: () => {} }
|
|
544
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evalprogramresult_free(ptr, 1));
|
|
545
|
+
|
|
546
|
+
function addToExternrefTable0(obj) {
|
|
547
|
+
const idx = wasm.__externref_table_alloc();
|
|
548
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
549
|
+
return idx;
|
|
550
|
+
}
|
|
551
|
+
|
|
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)));
|
|
558
|
+
}
|
|
559
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
560
|
+
return result;
|
|
561
|
+
}
|
|
192
562
|
|
|
563
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
564
|
+
ptr = ptr >>> 0;
|
|
565
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
193
569
|
function getBigUint64ArrayMemory0() {
|
|
194
570
|
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
195
571
|
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
196
572
|
}
|
|
197
|
-
return cachedBigUint64ArrayMemory0;
|
|
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);
|
|
580
|
+
}
|
|
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);
|
|
592
|
+
}
|
|
593
|
+
return cachedUint8ArrayMemory0;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function isLikeNone(x) {
|
|
597
|
+
return x === undefined || x === null;
|
|
198
598
|
}
|
|
199
599
|
|
|
200
600
|
function passArray64ToWasm0(arg, malloc) {
|
|
@@ -203,243 +603,98 @@ function passArray64ToWasm0(arg, malloc) {
|
|
|
203
603
|
WASM_VECTOR_LEN = arg.length;
|
|
204
604
|
return ptr;
|
|
205
605
|
}
|
|
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
606
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
}
|
|
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;
|
|
270
612
|
}
|
|
271
613
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
*
|
|
277
|
-
*/
|
|
278
|
-
export class EvalProgramResult {
|
|
279
|
-
|
|
280
|
-
static __wrap(ptr) {
|
|
281
|
-
ptr = ptr >>> 0;
|
|
282
|
-
const obj = Object.create(EvalProgramResult.prototype);
|
|
283
|
-
obj.__wbg_ptr = ptr;
|
|
284
|
-
EvalProgramResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
285
|
-
return obj;
|
|
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);
|
|
286
619
|
}
|
|
620
|
+
WASM_VECTOR_LEN = array.length;
|
|
621
|
+
return ptr;
|
|
622
|
+
}
|
|
287
623
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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;
|
|
292
630
|
return ptr;
|
|
293
631
|
}
|
|
294
632
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
wasm.__wbg_evalprogramresult_free(ptr, 0);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
301
|
-
* returned unit.
|
|
302
|
-
* @returns {boolean}
|
|
303
|
-
*/
|
|
304
|
-
get ok() {
|
|
305
|
-
const ret = wasm.__wbg_get_evalprogramresult_ok(this.__wbg_ptr);
|
|
306
|
-
return ret !== 0;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
310
|
-
* returned unit.
|
|
311
|
-
* @param {boolean} arg0
|
|
312
|
-
*/
|
|
313
|
-
set ok(arg0) {
|
|
314
|
-
wasm.__wbg_set_evalprogramresult_ok(this.__wbg_ptr, arg0);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* The CPU the program used. A program that went over budget is charged
|
|
318
|
-
* what it used up to the point where the machine stopped it.
|
|
319
|
-
* @returns {bigint}
|
|
320
|
-
*/
|
|
321
|
-
get cpu() {
|
|
322
|
-
const ret = wasm.__wbg_get_evalprogramresult_cpu(this.__wbg_ptr);
|
|
323
|
-
return BigInt.asUintN(64, ret);
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* The CPU the program used. A program that went over budget is charged
|
|
327
|
-
* what it used up to the point where the machine stopped it.
|
|
328
|
-
* @param {bigint} arg0
|
|
329
|
-
*/
|
|
330
|
-
set cpu(arg0) {
|
|
331
|
-
wasm.__wbg_set_evalprogramresult_cpu(this.__wbg_ptr, arg0);
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* The memory the program used.
|
|
335
|
-
* @returns {bigint}
|
|
336
|
-
*/
|
|
337
|
-
get mem() {
|
|
338
|
-
const ret = wasm.__wbg_get_evalprogramresult_mem(this.__wbg_ptr);
|
|
339
|
-
return BigInt.asUintN(64, ret);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* The memory the program used.
|
|
343
|
-
* @param {bigint} arg0
|
|
344
|
-
*/
|
|
345
|
-
set mem(arg0) {
|
|
346
|
-
wasm.__wbg_set_evalprogramresult_mem(this.__wbg_ptr, arg0);
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
350
|
-
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
351
|
-
* returned something other than unit.
|
|
352
|
-
* @returns {number}
|
|
353
|
-
*/
|
|
354
|
-
get error_kind() {
|
|
355
|
-
const ret = wasm.__wbg_get_evalprogramresult_error_kind(this.__wbg_ptr);
|
|
356
|
-
return ret;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
360
|
-
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
361
|
-
* returned something other than unit.
|
|
362
|
-
* @param {number} arg0
|
|
363
|
-
*/
|
|
364
|
-
set error_kind(arg0) {
|
|
365
|
-
wasm.__wbg_set_evalprogramresult_error_kind(this.__wbg_ptr, arg0);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* The messages the program traced, in order.
|
|
369
|
-
* @returns {string[]}
|
|
370
|
-
*/
|
|
371
|
-
get logs() {
|
|
372
|
-
const ret = wasm.__wbg_get_evalprogramresult_logs(this.__wbg_ptr);
|
|
373
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
374
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
375
|
-
return v1;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* The messages the program traced, in order.
|
|
379
|
-
* @param {string[]} arg0
|
|
380
|
-
*/
|
|
381
|
-
set logs(arg0) {
|
|
382
|
-
const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
383
|
-
const len0 = WASM_VECTOR_LEN;
|
|
384
|
-
wasm.__wbg_set_evalprogramresult_logs(this.__wbg_ptr, ptr0, len0);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
633
|
+
let len = arg.length;
|
|
634
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
387
635
|
|
|
388
|
-
|
|
389
|
-
const ret = arg0.buffer;
|
|
390
|
-
return ret;
|
|
391
|
-
};
|
|
636
|
+
const mem = getUint8ArrayMemory0();
|
|
392
637
|
|
|
393
|
-
|
|
394
|
-
const ret = arg0.length;
|
|
395
|
-
return ret;
|
|
396
|
-
};
|
|
638
|
+
let offset = 0;
|
|
397
639
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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);
|
|
402
652
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
};
|
|
653
|
+
offset += ret.written;
|
|
654
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
655
|
+
}
|
|
407
656
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
657
|
+
WASM_VECTOR_LEN = offset;
|
|
658
|
+
return ptr;
|
|
659
|
+
}
|
|
411
660
|
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
table.set(offset + 1, null);
|
|
418
|
-
table.set(offset + 2, true);
|
|
419
|
-
table.set(offset + 3, false);
|
|
420
|
-
;
|
|
421
|
-
};
|
|
661
|
+
function takeFromExternrefTable0(idx) {
|
|
662
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
663
|
+
wasm.__externref_table_dealloc(idx);
|
|
664
|
+
return value;
|
|
665
|
+
}
|
|
422
666
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
+
}
|
|
427
680
|
|
|
428
|
-
|
|
429
|
-
const obj = arg1;
|
|
430
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
431
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
432
|
-
var len1 = WASM_VECTOR_LEN;
|
|
433
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
434
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
435
|
-
};
|
|
681
|
+
const cachedTextEncoder = new TextEncoder();
|
|
436
682
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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;
|
|
441
695
|
|
|
442
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
443
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
444
|
-
};
|
|
445
696
|
|
|
697
|
+
let wasm;
|
|
698
|
+
export function __wbg_set_wasm(val) {
|
|
699
|
+
wasm = val;
|
|
700
|
+
}
|