@lucid-evolution/uplc 0.2.24 → 0.4.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 +46 -0
- package/dist/size/browser/uplc_tx.d.ts +89 -0
- package/dist/size/browser/uplc_tx_bg.js +445 -0
- package/dist/size/browser/uplc_tx_bg.wasm +0 -0
- package/dist/size/browser/uplc_tx_bg.wasm.d.ts +71 -0
- package/dist/size/node/uplc_tx.d.ts +89 -0
- package/dist/size/node/uplc_tx.js +452 -0
- package/dist/size/node/uplc_tx_bg.wasm +0 -0
- package/dist/size/node/uplc_tx_bg.wasm.d.ts +71 -0
- package/dist/speed/browser/uplc_tx.d.ts +89 -0
- package/dist/speed/browser/uplc_tx.js +5 -0
- package/dist/speed/browser/uplc_tx_bg.js +445 -0
- package/dist/speed/browser/uplc_tx_bg.wasm +0 -0
- package/dist/speed/browser/uplc_tx_bg.wasm.d.ts +71 -0
- package/dist/speed/node/uplc_tx.d.ts +89 -0
- package/dist/speed/node/uplc_tx.js +452 -0
- package/dist/speed/node/uplc_tx_bg.wasm +0 -0
- package/dist/speed/node/uplc_tx_bg.wasm.d.ts +71 -0
- package/package.json +49 -7
- package/dist/browser/uplc_tx.d.ts +0 -18
- package/dist/browser/uplc_tx_bg.js +0 -183
- package/dist/browser/uplc_tx_bg.wasm +0 -0
- package/dist/browser/uplc_tx_bg.wasm.d.ts +0 -33
- package/dist/node/uplc_tx.d.ts +0 -18
- package/dist/node/uplc_tx.js +0 -191
- package/dist/node/uplc_tx_bg.wasm +0 -0
- package/dist/node/uplc_tx_bg.wasm.d.ts +0 -33
- /package/dist/{browser → size/browser}/uplc_tx.js +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function eval_phase_two_raw(
|
|
4
|
+
tx_bytes: Uint8Array,
|
|
5
|
+
utxos_bytes_x: Uint8Array[],
|
|
6
|
+
utxos_bytes_y: Uint8Array[],
|
|
7
|
+
cost_mdls_bytes: Uint8Array,
|
|
8
|
+
initial_budget_n: bigint,
|
|
9
|
+
initial_budget_d: bigint,
|
|
10
|
+
slot_config_x: bigint,
|
|
11
|
+
slot_config_y: bigint,
|
|
12
|
+
slot_config_z: number,
|
|
13
|
+
protocol_major_version?: number | null,
|
|
14
|
+
): Uint8Array[];
|
|
15
|
+
export function apply_params_to_script(
|
|
16
|
+
params_bytes: Uint8Array,
|
|
17
|
+
plutus_script_bytes: Uint8Array,
|
|
18
|
+
): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Evaluates a UPLC program applied to Data arguments, outside of any
|
|
21
|
+
* transaction: the caller builds whatever arguments the program expects,
|
|
22
|
+
* including its script context.
|
|
23
|
+
*
|
|
24
|
+
* - `program_flat`: the program, flat-encoded without a CBOR wrapper.
|
|
25
|
+
* - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
|
|
26
|
+
* - `language`: the Plutus version to evaluate as, 1, 2 or 3.
|
|
27
|
+
* - `protocol_major_version`: the protocol version whose semantics to use,
|
|
28
|
+
* from 5 (Alonzo) to 12 (Dijkstra).
|
|
29
|
+
* - `cost_model`: the cost model parameters, every one the evaluator knows
|
|
30
|
+
* for this Plutus version (350 for Plutus V3), in the ledger's order.
|
|
31
|
+
* - `budget_cpu`, `budget_mem`: the budget.
|
|
32
|
+
* - `strict_budget`: charge every step as the machine takes it, and stop the
|
|
33
|
+
* program as soon as it goes over budget, instead of charging steps and
|
|
34
|
+
* checking the budget every 200 steps as the ledger does. Only the cost of a
|
|
35
|
+
* program that fails differs: the ledger does not charge the steps it took
|
|
36
|
+
* since the budget was last checked.
|
|
37
|
+
*
|
|
38
|
+
* Fails only when the inputs are malformed or unsupported. A program that fails
|
|
39
|
+
* is an [`EvalProgramResult`] that is not `ok`.
|
|
40
|
+
*/
|
|
41
|
+
export function eval_program_raw(
|
|
42
|
+
program_flat: Uint8Array,
|
|
43
|
+
args_cbor: Uint8Array[],
|
|
44
|
+
language: number,
|
|
45
|
+
protocol_major_version: number,
|
|
46
|
+
cost_model: BigInt64Array,
|
|
47
|
+
budget_cpu: bigint,
|
|
48
|
+
budget_mem: bigint,
|
|
49
|
+
strict_budget: boolean,
|
|
50
|
+
): EvalProgramResult;
|
|
51
|
+
/**
|
|
52
|
+
* Describes this build of the evaluator as JSON: the uplc crate it was built
|
|
53
|
+
* from, the length of each Plutus version's cost model, and a digest of what a
|
|
54
|
+
* fixed set of programs evaluate to, with their costs, under Plutus V3 and the
|
|
55
|
+
* latest protocol version. Two builds with the same digest agree on those
|
|
56
|
+
* programs; `selfTest` says whether this one gives the expected results.
|
|
57
|
+
*/
|
|
58
|
+
export function uplc_build_info(): string;
|
|
59
|
+
/**
|
|
60
|
+
* The outcome of [`eval_program_raw`].
|
|
61
|
+
*/
|
|
62
|
+
export class EvalProgramResult {
|
|
63
|
+
private constructor();
|
|
64
|
+
free(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
67
|
+
* returned unit.
|
|
68
|
+
*/
|
|
69
|
+
ok: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The CPU the program used. A program that went over budget is charged
|
|
72
|
+
* what it used up to the point where the machine stopped it.
|
|
73
|
+
*/
|
|
74
|
+
cpu: bigint;
|
|
75
|
+
/**
|
|
76
|
+
* The memory the program used.
|
|
77
|
+
*/
|
|
78
|
+
mem: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
81
|
+
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
82
|
+
* returned something other than unit.
|
|
83
|
+
*/
|
|
84
|
+
error_kind: number;
|
|
85
|
+
/**
|
|
86
|
+
* The messages the program traced, in order.
|
|
87
|
+
*/
|
|
88
|
+
logs: string[];
|
|
89
|
+
}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
let wasm;
|
|
5
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
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
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
19
|
+
|
|
20
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
21
|
+
? function (arg, view) {
|
|
22
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
23
|
+
}
|
|
24
|
+
: function (arg, view) {
|
|
25
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
26
|
+
view.set(buf);
|
|
27
|
+
return {
|
|
28
|
+
read: arg.length,
|
|
29
|
+
written: buf.length
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
34
|
+
|
|
35
|
+
if (realloc === undefined) {
|
|
36
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
37
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
38
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
39
|
+
WASM_VECTOR_LEN = buf.length;
|
|
40
|
+
return ptr;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let len = arg.length;
|
|
44
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
45
|
+
|
|
46
|
+
const mem = getUint8ArrayMemory0();
|
|
47
|
+
|
|
48
|
+
let offset = 0;
|
|
49
|
+
|
|
50
|
+
for (; offset < len; offset++) {
|
|
51
|
+
const code = arg.charCodeAt(offset);
|
|
52
|
+
if (code > 0x7F) break;
|
|
53
|
+
mem[ptr + offset] = code;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (offset !== len) {
|
|
57
|
+
if (offset !== 0) {
|
|
58
|
+
arg = arg.slice(offset);
|
|
59
|
+
}
|
|
60
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
61
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
62
|
+
const ret = encodeString(arg, view);
|
|
63
|
+
|
|
64
|
+
offset += ret.written;
|
|
65
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
WASM_VECTOR_LEN = offset;
|
|
69
|
+
return ptr;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isLikeNone(x) {
|
|
73
|
+
return x === undefined || x === null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let cachedDataViewMemory0 = null;
|
|
77
|
+
|
|
78
|
+
function getDataViewMemory0() {
|
|
79
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
80
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
81
|
+
}
|
|
82
|
+
return cachedDataViewMemory0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
86
|
+
|
|
87
|
+
cachedTextDecoder.decode();
|
|
88
|
+
|
|
89
|
+
function getStringFromWasm0(ptr, len) {
|
|
90
|
+
ptr = ptr >>> 0;
|
|
91
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
95
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
96
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
97
|
+
WASM_VECTOR_LEN = arg.length;
|
|
98
|
+
return ptr;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function addToExternrefTable0(obj) {
|
|
102
|
+
const idx = wasm.__externref_table_alloc();
|
|
103
|
+
wasm.__wbindgen_export_0.set(idx, obj);
|
|
104
|
+
return idx;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
108
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
109
|
+
for (let i = 0; i < array.length; i++) {
|
|
110
|
+
const add = addToExternrefTable0(array[i]);
|
|
111
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
112
|
+
}
|
|
113
|
+
WASM_VECTOR_LEN = array.length;
|
|
114
|
+
return ptr;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function takeFromExternrefTable0(idx) {
|
|
118
|
+
const value = wasm.__wbindgen_export_0.get(idx);
|
|
119
|
+
wasm.__externref_table_dealloc(idx);
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
124
|
+
ptr = ptr >>> 0;
|
|
125
|
+
const mem = getDataViewMemory0();
|
|
126
|
+
const result = [];
|
|
127
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
128
|
+
result.push(wasm.__wbindgen_export_0.get(mem.getUint32(i, true)));
|
|
129
|
+
}
|
|
130
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @param {Uint8Array} tx_bytes
|
|
135
|
+
* @param {Uint8Array[]} utxos_bytes_x
|
|
136
|
+
* @param {Uint8Array[]} utxos_bytes_y
|
|
137
|
+
* @param {Uint8Array} cost_mdls_bytes
|
|
138
|
+
* @param {bigint} initial_budget_n
|
|
139
|
+
* @param {bigint} initial_budget_d
|
|
140
|
+
* @param {bigint} slot_config_x
|
|
141
|
+
* @param {bigint} slot_config_y
|
|
142
|
+
* @param {number} slot_config_z
|
|
143
|
+
* @param {number | null} [protocol_major_version]
|
|
144
|
+
* @returns {Uint8Array[]}
|
|
145
|
+
*/
|
|
146
|
+
module.exports.eval_phase_two_raw = function(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) {
|
|
147
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
|
|
150
|
+
const len1 = WASM_VECTOR_LEN;
|
|
151
|
+
const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
|
|
152
|
+
const len2 = WASM_VECTOR_LEN;
|
|
153
|
+
const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
|
|
154
|
+
const len3 = WASM_VECTOR_LEN;
|
|
155
|
+
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);
|
|
156
|
+
if (ret[3]) {
|
|
157
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
158
|
+
}
|
|
159
|
+
var v5 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
160
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
161
|
+
return v5;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
165
|
+
ptr = ptr >>> 0;
|
|
166
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @param {Uint8Array} params_bytes
|
|
170
|
+
* @param {Uint8Array} plutus_script_bytes
|
|
171
|
+
* @returns {Uint8Array}
|
|
172
|
+
*/
|
|
173
|
+
module.exports.apply_params_to_script = function(params_bytes, plutus_script_bytes) {
|
|
174
|
+
const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
|
|
177
|
+
const len1 = WASM_VECTOR_LEN;
|
|
178
|
+
const ret = wasm.apply_params_to_script(ptr0, len0, ptr1, len1);
|
|
179
|
+
if (ret[3]) {
|
|
180
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
181
|
+
}
|
|
182
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
183
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
184
|
+
return v3;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
188
|
+
|
|
189
|
+
function getBigUint64ArrayMemory0() {
|
|
190
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
191
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
192
|
+
}
|
|
193
|
+
return cachedBigUint64ArrayMemory0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function passArray64ToWasm0(arg, malloc) {
|
|
197
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
198
|
+
getBigUint64ArrayMemory0().set(arg, ptr / 8);
|
|
199
|
+
WASM_VECTOR_LEN = arg.length;
|
|
200
|
+
return ptr;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Evaluates a UPLC program applied to Data arguments, outside of any
|
|
204
|
+
* transaction: the caller builds whatever arguments the program expects,
|
|
205
|
+
* including its script context.
|
|
206
|
+
*
|
|
207
|
+
* - `program_flat`: the program, flat-encoded without a CBOR wrapper.
|
|
208
|
+
* - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
|
|
209
|
+
* - `language`: the Plutus version to evaluate as, 1, 2 or 3.
|
|
210
|
+
* - `protocol_major_version`: the protocol version whose semantics to use,
|
|
211
|
+
* from 5 (Alonzo) to 12 (Dijkstra).
|
|
212
|
+
* - `cost_model`: the cost model parameters, every one the evaluator knows
|
|
213
|
+
* for this Plutus version (350 for Plutus V3), in the ledger's order.
|
|
214
|
+
* - `budget_cpu`, `budget_mem`: the budget.
|
|
215
|
+
* - `strict_budget`: charge every step as the machine takes it, and stop the
|
|
216
|
+
* program as soon as it goes over budget, instead of charging steps and
|
|
217
|
+
* checking the budget every 200 steps as the ledger does. Only the cost of a
|
|
218
|
+
* program that fails differs: the ledger does not charge the steps it took
|
|
219
|
+
* since the budget was last checked.
|
|
220
|
+
*
|
|
221
|
+
* Fails only when the inputs are malformed or unsupported. A program that fails
|
|
222
|
+
* is an [`EvalProgramResult`] that is not `ok`.
|
|
223
|
+
* @param {Uint8Array} program_flat
|
|
224
|
+
* @param {Uint8Array[]} args_cbor
|
|
225
|
+
* @param {number} language
|
|
226
|
+
* @param {number} protocol_major_version
|
|
227
|
+
* @param {BigInt64Array} cost_model
|
|
228
|
+
* @param {bigint} budget_cpu
|
|
229
|
+
* @param {bigint} budget_mem
|
|
230
|
+
* @param {boolean} strict_budget
|
|
231
|
+
* @returns {EvalProgramResult}
|
|
232
|
+
*/
|
|
233
|
+
module.exports.eval_program_raw = function(program_flat, args_cbor, language, protocol_major_version, cost_model, budget_cpu, budget_mem, strict_budget) {
|
|
234
|
+
const ptr0 = passArray8ToWasm0(program_flat, wasm.__wbindgen_malloc);
|
|
235
|
+
const len0 = WASM_VECTOR_LEN;
|
|
236
|
+
const ptr1 = passArrayJsValueToWasm0(args_cbor, wasm.__wbindgen_malloc);
|
|
237
|
+
const len1 = WASM_VECTOR_LEN;
|
|
238
|
+
const ptr2 = passArray64ToWasm0(cost_model, wasm.__wbindgen_malloc);
|
|
239
|
+
const len2 = WASM_VECTOR_LEN;
|
|
240
|
+
const ret = wasm.eval_program_raw(ptr0, len0, ptr1, len1, language, protocol_major_version, ptr2, len2, budget_cpu, budget_mem, strict_budget);
|
|
241
|
+
if (ret[2]) {
|
|
242
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
243
|
+
}
|
|
244
|
+
return EvalProgramResult.__wrap(ret[0]);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Describes this build of the evaluator as JSON: the uplc crate it was built
|
|
249
|
+
* from, the length of each Plutus version's cost model, and a digest of what a
|
|
250
|
+
* fixed set of programs evaluate to, with their costs, under Plutus V3 and the
|
|
251
|
+
* latest protocol version. Two builds with the same digest agree on those
|
|
252
|
+
* programs; `selfTest` says whether this one gives the expected results.
|
|
253
|
+
* @returns {string}
|
|
254
|
+
*/
|
|
255
|
+
module.exports.uplc_build_info = function() {
|
|
256
|
+
let deferred1_0;
|
|
257
|
+
let deferred1_1;
|
|
258
|
+
try {
|
|
259
|
+
const ret = wasm.uplc_build_info();
|
|
260
|
+
deferred1_0 = ret[0];
|
|
261
|
+
deferred1_1 = ret[1];
|
|
262
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
263
|
+
} finally {
|
|
264
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const EvalProgramResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
269
|
+
? { register: () => {}, unregister: () => {} }
|
|
270
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evalprogramresult_free(ptr >>> 0, 1));
|
|
271
|
+
/**
|
|
272
|
+
* The outcome of [`eval_program_raw`].
|
|
273
|
+
*/
|
|
274
|
+
class EvalProgramResult {
|
|
275
|
+
|
|
276
|
+
static __wrap(ptr) {
|
|
277
|
+
ptr = ptr >>> 0;
|
|
278
|
+
const obj = Object.create(EvalProgramResult.prototype);
|
|
279
|
+
obj.__wbg_ptr = ptr;
|
|
280
|
+
EvalProgramResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
281
|
+
return obj;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
__destroy_into_raw() {
|
|
285
|
+
const ptr = this.__wbg_ptr;
|
|
286
|
+
this.__wbg_ptr = 0;
|
|
287
|
+
EvalProgramResultFinalization.unregister(this);
|
|
288
|
+
return ptr;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
free() {
|
|
292
|
+
const ptr = this.__destroy_into_raw();
|
|
293
|
+
wasm.__wbg_evalprogramresult_free(ptr, 0);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
297
|
+
* returned unit.
|
|
298
|
+
* @returns {boolean}
|
|
299
|
+
*/
|
|
300
|
+
get ok() {
|
|
301
|
+
const ret = wasm.__wbg_get_evalprogramresult_ok(this.__wbg_ptr);
|
|
302
|
+
return ret !== 0;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
306
|
+
* returned unit.
|
|
307
|
+
* @param {boolean} arg0
|
|
308
|
+
*/
|
|
309
|
+
set ok(arg0) {
|
|
310
|
+
wasm.__wbg_set_evalprogramresult_ok(this.__wbg_ptr, arg0);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The CPU the program used. A program that went over budget is charged
|
|
314
|
+
* what it used up to the point where the machine stopped it.
|
|
315
|
+
* @returns {bigint}
|
|
316
|
+
*/
|
|
317
|
+
get cpu() {
|
|
318
|
+
const ret = wasm.__wbg_get_evalprogramresult_cpu(this.__wbg_ptr);
|
|
319
|
+
return BigInt.asUintN(64, ret);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The CPU the program used. A program that went over budget is charged
|
|
323
|
+
* what it used up to the point where the machine stopped it.
|
|
324
|
+
* @param {bigint} arg0
|
|
325
|
+
*/
|
|
326
|
+
set cpu(arg0) {
|
|
327
|
+
wasm.__wbg_set_evalprogramresult_cpu(this.__wbg_ptr, arg0);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The memory the program used.
|
|
331
|
+
* @returns {bigint}
|
|
332
|
+
*/
|
|
333
|
+
get mem() {
|
|
334
|
+
const ret = wasm.__wbg_get_evalprogramresult_mem(this.__wbg_ptr);
|
|
335
|
+
return BigInt.asUintN(64, ret);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* The memory the program used.
|
|
339
|
+
* @param {bigint} arg0
|
|
340
|
+
*/
|
|
341
|
+
set mem(arg0) {
|
|
342
|
+
wasm.__wbg_set_evalprogramresult_mem(this.__wbg_ptr, arg0);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
346
|
+
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
347
|
+
* returned something other than unit.
|
|
348
|
+
* @returns {number}
|
|
349
|
+
*/
|
|
350
|
+
get error_kind() {
|
|
351
|
+
const ret = wasm.__wbg_get_evalprogramresult_error_kind(this.__wbg_ptr);
|
|
352
|
+
return ret;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
356
|
+
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
357
|
+
* returned something other than unit.
|
|
358
|
+
* @param {number} arg0
|
|
359
|
+
*/
|
|
360
|
+
set error_kind(arg0) {
|
|
361
|
+
wasm.__wbg_set_evalprogramresult_error_kind(this.__wbg_ptr, arg0);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The messages the program traced, in order.
|
|
365
|
+
* @returns {string[]}
|
|
366
|
+
*/
|
|
367
|
+
get logs() {
|
|
368
|
+
const ret = wasm.__wbg_get_evalprogramresult_logs(this.__wbg_ptr);
|
|
369
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
370
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
371
|
+
return v1;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The messages the program traced, in order.
|
|
375
|
+
* @param {string[]} arg0
|
|
376
|
+
*/
|
|
377
|
+
set logs(arg0) {
|
|
378
|
+
const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
379
|
+
const len0 = WASM_VECTOR_LEN;
|
|
380
|
+
wasm.__wbg_set_evalprogramresult_logs(this.__wbg_ptr, ptr0, len0);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
module.exports.EvalProgramResult = EvalProgramResult;
|
|
384
|
+
|
|
385
|
+
module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
386
|
+
const ret = arg0.buffer;
|
|
387
|
+
return ret;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
module.exports.__wbg_length_a446193dc22c12f8 = function(arg0) {
|
|
391
|
+
const ret = arg0.length;
|
|
392
|
+
return ret;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
396
|
+
const ret = new Uint8Array(arg0);
|
|
397
|
+
return ret;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
401
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
402
|
+
return ret;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
406
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
module.exports.__wbindgen_init_externref_table = function() {
|
|
410
|
+
const table = wasm.__wbindgen_export_0;
|
|
411
|
+
const offset = table.grow(4);
|
|
412
|
+
table.set(0, undefined);
|
|
413
|
+
table.set(offset + 0, undefined);
|
|
414
|
+
table.set(offset + 1, null);
|
|
415
|
+
table.set(offset + 2, true);
|
|
416
|
+
table.set(offset + 3, false);
|
|
417
|
+
;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
module.exports.__wbindgen_memory = function() {
|
|
421
|
+
const ret = wasm.memory;
|
|
422
|
+
return ret;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
module.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
426
|
+
const obj = arg1;
|
|
427
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
428
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
429
|
+
var len1 = WASM_VECTOR_LEN;
|
|
430
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
431
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
435
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
436
|
+
return ret;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
440
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const path = require('path').join(__dirname, 'uplc_tx_bg.wasm');
|
|
444
|
+
const bytes = require('fs').readFileSync(path);
|
|
445
|
+
|
|
446
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
447
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
448
|
+
wasm = wasmInstance.exports;
|
|
449
|
+
module.exports.__wasm = wasm;
|
|
450
|
+
|
|
451
|
+
wasm.__wbindgen_start();
|
|
452
|
+
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_evalprogramresult_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_get_evalprogramresult_cpu: (a: number) => bigint;
|
|
6
|
+
export const __wbg_get_evalprogramresult_error_kind: (a: number) => number;
|
|
7
|
+
export const __wbg_get_evalprogramresult_logs: (a: number) => [number, number];
|
|
8
|
+
export const __wbg_get_evalprogramresult_mem: (a: number) => bigint;
|
|
9
|
+
export const __wbg_get_evalprogramresult_ok: (a: number) => number;
|
|
10
|
+
export const __wbg_set_evalprogramresult_cpu: (a: number, b: bigint) => void;
|
|
11
|
+
export const __wbg_set_evalprogramresult_error_kind: (
|
|
12
|
+
a: number,
|
|
13
|
+
b: number,
|
|
14
|
+
) => void;
|
|
15
|
+
export const __wbg_set_evalprogramresult_logs: (
|
|
16
|
+
a: number,
|
|
17
|
+
b: number,
|
|
18
|
+
c: number,
|
|
19
|
+
) => void;
|
|
20
|
+
export const __wbg_set_evalprogramresult_mem: (a: number, b: bigint) => void;
|
|
21
|
+
export const __wbg_set_evalprogramresult_ok: (a: number, b: number) => void;
|
|
22
|
+
export const apply_params_to_script: (
|
|
23
|
+
a: number,
|
|
24
|
+
b: number,
|
|
25
|
+
c: number,
|
|
26
|
+
d: number,
|
|
27
|
+
) => [number, number, number, number];
|
|
28
|
+
export const eval_phase_two_raw: (
|
|
29
|
+
a: number,
|
|
30
|
+
b: number,
|
|
31
|
+
c: number,
|
|
32
|
+
d: number,
|
|
33
|
+
e: number,
|
|
34
|
+
f: number,
|
|
35
|
+
g: number,
|
|
36
|
+
h: number,
|
|
37
|
+
i: bigint,
|
|
38
|
+
j: bigint,
|
|
39
|
+
k: bigint,
|
|
40
|
+
l: bigint,
|
|
41
|
+
m: number,
|
|
42
|
+
n: number,
|
|
43
|
+
o: number,
|
|
44
|
+
) => [number, number, number, number];
|
|
45
|
+
export const eval_program_raw: (
|
|
46
|
+
a: number,
|
|
47
|
+
b: number,
|
|
48
|
+
c: number,
|
|
49
|
+
d: number,
|
|
50
|
+
e: number,
|
|
51
|
+
f: number,
|
|
52
|
+
g: number,
|
|
53
|
+
h: number,
|
|
54
|
+
i: bigint,
|
|
55
|
+
j: bigint,
|
|
56
|
+
k: number,
|
|
57
|
+
) => [number, number, number];
|
|
58
|
+
export const uplc_build_info: () => [number, number];
|
|
59
|
+
export const __wbindgen_export_0: WebAssembly.Table;
|
|
60
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
61
|
+
export const __wbindgen_realloc: (
|
|
62
|
+
a: number,
|
|
63
|
+
b: number,
|
|
64
|
+
c: number,
|
|
65
|
+
d: number,
|
|
66
|
+
) => number;
|
|
67
|
+
export const __externref_table_alloc: () => number;
|
|
68
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
69
|
+
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
70
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
71
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function eval_phase_two_raw(
|
|
4
|
+
tx_bytes: Uint8Array,
|
|
5
|
+
utxos_bytes_x: Uint8Array[],
|
|
6
|
+
utxos_bytes_y: Uint8Array[],
|
|
7
|
+
cost_mdls_bytes: Uint8Array,
|
|
8
|
+
initial_budget_n: bigint,
|
|
9
|
+
initial_budget_d: bigint,
|
|
10
|
+
slot_config_x: bigint,
|
|
11
|
+
slot_config_y: bigint,
|
|
12
|
+
slot_config_z: number,
|
|
13
|
+
protocol_major_version?: number | null,
|
|
14
|
+
): Uint8Array[];
|
|
15
|
+
export function apply_params_to_script(
|
|
16
|
+
params_bytes: Uint8Array,
|
|
17
|
+
plutus_script_bytes: Uint8Array,
|
|
18
|
+
): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Evaluates a UPLC program applied to Data arguments, outside of any
|
|
21
|
+
* transaction: the caller builds whatever arguments the program expects,
|
|
22
|
+
* including its script context.
|
|
23
|
+
*
|
|
24
|
+
* - `program_flat`: the program, flat-encoded without a CBOR wrapper.
|
|
25
|
+
* - `args_cbor`: the arguments, each one CBOR-encoded Data, applied in order.
|
|
26
|
+
* - `language`: the Plutus version to evaluate as, 1, 2 or 3.
|
|
27
|
+
* - `protocol_major_version`: the protocol version whose semantics to use,
|
|
28
|
+
* from 5 (Alonzo) to 12 (Dijkstra).
|
|
29
|
+
* - `cost_model`: the cost model parameters, every one the evaluator knows
|
|
30
|
+
* for this Plutus version (350 for Plutus V3), in the ledger's order.
|
|
31
|
+
* - `budget_cpu`, `budget_mem`: the budget.
|
|
32
|
+
* - `strict_budget`: charge every step as the machine takes it, and stop the
|
|
33
|
+
* program as soon as it goes over budget, instead of charging steps and
|
|
34
|
+
* checking the budget every 200 steps as the ledger does. Only the cost of a
|
|
35
|
+
* program that fails differs: the ledger does not charge the steps it took
|
|
36
|
+
* since the budget was last checked.
|
|
37
|
+
*
|
|
38
|
+
* Fails only when the inputs are malformed or unsupported. A program that fails
|
|
39
|
+
* is an [`EvalProgramResult`] that is not `ok`.
|
|
40
|
+
*/
|
|
41
|
+
export function eval_program_raw(
|
|
42
|
+
program_flat: Uint8Array,
|
|
43
|
+
args_cbor: Uint8Array[],
|
|
44
|
+
language: number,
|
|
45
|
+
protocol_major_version: number,
|
|
46
|
+
cost_model: BigInt64Array,
|
|
47
|
+
budget_cpu: bigint,
|
|
48
|
+
budget_mem: bigint,
|
|
49
|
+
strict_budget: boolean,
|
|
50
|
+
): EvalProgramResult;
|
|
51
|
+
/**
|
|
52
|
+
* Describes this build of the evaluator as JSON: the uplc crate it was built
|
|
53
|
+
* from, the length of each Plutus version's cost model, and a digest of what a
|
|
54
|
+
* fixed set of programs evaluate to, with their costs, under Plutus V3 and the
|
|
55
|
+
* latest protocol version. Two builds with the same digest agree on those
|
|
56
|
+
* programs; `selfTest` says whether this one gives the expected results.
|
|
57
|
+
*/
|
|
58
|
+
export function uplc_build_info(): string;
|
|
59
|
+
/**
|
|
60
|
+
* The outcome of [`eval_program_raw`].
|
|
61
|
+
*/
|
|
62
|
+
export class EvalProgramResult {
|
|
63
|
+
private constructor();
|
|
64
|
+
free(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the program succeeded: it did not fail and, for Plutus V3, it
|
|
67
|
+
* returned unit.
|
|
68
|
+
*/
|
|
69
|
+
ok: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The CPU the program used. A program that went over budget is charged
|
|
72
|
+
* what it used up to the point where the machine stopped it.
|
|
73
|
+
*/
|
|
74
|
+
cpu: bigint;
|
|
75
|
+
/**
|
|
76
|
+
* The memory the program used.
|
|
77
|
+
*/
|
|
78
|
+
mem: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* Why the program did not succeed: 0 when it did, 1 when it went over
|
|
81
|
+
* budget, 2 when it failed in any other way and 3 when a Plutus V3 program
|
|
82
|
+
* returned something other than unit.
|
|
83
|
+
*/
|
|
84
|
+
error_kind: number;
|
|
85
|
+
/**
|
|
86
|
+
* The messages the program traced, in order.
|
|
87
|
+
*/
|
|
88
|
+
logs: string[];
|
|
89
|
+
}
|