@lucid-evolution/uplc 0.2.4 → 0.2.5
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/dist/browser/uplc_tx.d.ts +94 -0
- package/dist/browser/uplc_tx.js +290 -0
- package/dist/browser/uplc_tx_bg.wasm +0 -0
- package/dist/browser/uplc_tx_bg.wasm.d.ts +29 -0
- package/dist/{browser/index.d.mts → node/uplc_tx.d.ts} +2 -4
- package/dist/node/uplc_tx.js +220 -0
- package/dist/node/uplc_tx_bg.wasm.d.ts +29 -0
- package/package.json +8 -13
- package/dist/browser/index.mjs +0 -3607
- package/dist/node/index.d.mts +0 -36
- package/dist/node/index.d.ts +0 -36
- package/dist/node/index.js +0 -225
- package/dist/node/index.mjs +0 -221
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {Uint8Array} tx_bytes
|
|
5
|
+
* @param {(Uint8Array)[]} utxos_bytes_x
|
|
6
|
+
* @param {(Uint8Array)[]} utxos_bytes_y
|
|
7
|
+
* @param {Uint8Array} cost_mdls_bytes
|
|
8
|
+
* @param {bigint} initial_budget_n
|
|
9
|
+
* @param {bigint} initial_budget_d
|
|
10
|
+
* @param {bigint} slot_config_x
|
|
11
|
+
* @param {bigint} slot_config_y
|
|
12
|
+
* @param {number} slot_config_z
|
|
13
|
+
* @returns {(Uint8Array)[]}
|
|
14
|
+
*/
|
|
15
|
+
export function eval_phase_two_raw(
|
|
16
|
+
tx_bytes: Uint8Array,
|
|
17
|
+
utxos_bytes_x: Uint8Array[],
|
|
18
|
+
utxos_bytes_y: Uint8Array[],
|
|
19
|
+
cost_mdls_bytes: Uint8Array,
|
|
20
|
+
initial_budget_n: bigint,
|
|
21
|
+
initial_budget_d: bigint,
|
|
22
|
+
slot_config_x: bigint,
|
|
23
|
+
slot_config_y: bigint,
|
|
24
|
+
slot_config_z: number,
|
|
25
|
+
): Uint8Array[];
|
|
26
|
+
/**
|
|
27
|
+
* @param {Uint8Array} params_bytes
|
|
28
|
+
* @param {Uint8Array} plutus_script_bytes
|
|
29
|
+
* @returns {Uint8Array}
|
|
30
|
+
*/
|
|
31
|
+
export function apply_params_to_script(
|
|
32
|
+
params_bytes: Uint8Array,
|
|
33
|
+
plutus_script_bytes: Uint8Array,
|
|
34
|
+
): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export type InitInput =
|
|
37
|
+
| RequestInfo
|
|
38
|
+
| URL
|
|
39
|
+
| Response
|
|
40
|
+
| BufferSource
|
|
41
|
+
| WebAssembly.Module;
|
|
42
|
+
|
|
43
|
+
export interface InitOutput {
|
|
44
|
+
readonly memory: WebAssembly.Memory;
|
|
45
|
+
readonly eval_phase_two_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: number,
|
|
55
|
+
j: number,
|
|
56
|
+
k: number,
|
|
57
|
+
l: number,
|
|
58
|
+
m: number,
|
|
59
|
+
n: number,
|
|
60
|
+
) => void;
|
|
61
|
+
readonly apply_params_to_script: (
|
|
62
|
+
a: number,
|
|
63
|
+
b: number,
|
|
64
|
+
c: number,
|
|
65
|
+
d: number,
|
|
66
|
+
e: number,
|
|
67
|
+
) => void;
|
|
68
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
69
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
70
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
74
|
+
/**
|
|
75
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
76
|
+
* a precompiled `WebAssembly.Module`.
|
|
77
|
+
*
|
|
78
|
+
* @param {SyncInitInput} module
|
|
79
|
+
*
|
|
80
|
+
* @returns {InitOutput}
|
|
81
|
+
*/
|
|
82
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
86
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
87
|
+
*
|
|
88
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<InitOutput>}
|
|
91
|
+
*/
|
|
92
|
+
export default function __wbg_init(
|
|
93
|
+
module_or_path?: InitInput | Promise<InitInput>,
|
|
94
|
+
): Promise<InitOutput>;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const heap = new Array(128).fill(undefined);
|
|
4
|
+
|
|
5
|
+
heap.push(undefined, null, true, false);
|
|
6
|
+
|
|
7
|
+
function getObject(idx) { return heap[idx]; }
|
|
8
|
+
|
|
9
|
+
let heap_next = heap.length;
|
|
10
|
+
|
|
11
|
+
function dropObject(idx) {
|
|
12
|
+
if (idx < 132) return;
|
|
13
|
+
heap[idx] = heap_next;
|
|
14
|
+
heap_next = idx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function takeObject(idx) {
|
|
18
|
+
const ret = getObject(idx);
|
|
19
|
+
dropObject(idx);
|
|
20
|
+
return ret;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
24
|
+
|
|
25
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
26
|
+
|
|
27
|
+
let cachedUint8Memory0 = null;
|
|
28
|
+
|
|
29
|
+
function getUint8Memory0() {
|
|
30
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
31
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
32
|
+
}
|
|
33
|
+
return cachedUint8Memory0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getStringFromWasm0(ptr, len) {
|
|
37
|
+
ptr = ptr >>> 0;
|
|
38
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function addHeapObject(obj) {
|
|
42
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
43
|
+
const idx = heap_next;
|
|
44
|
+
heap_next = heap[idx];
|
|
45
|
+
|
|
46
|
+
heap[idx] = obj;
|
|
47
|
+
return idx;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let WASM_VECTOR_LEN = 0;
|
|
51
|
+
|
|
52
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
53
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
54
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
55
|
+
WASM_VECTOR_LEN = arg.length;
|
|
56
|
+
return ptr;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let cachedUint32Memory0 = null;
|
|
60
|
+
|
|
61
|
+
function getUint32Memory0() {
|
|
62
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
63
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
64
|
+
}
|
|
65
|
+
return cachedUint32Memory0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
69
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
70
|
+
const mem = getUint32Memory0();
|
|
71
|
+
for (let i = 0; i < array.length; i++) {
|
|
72
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
73
|
+
}
|
|
74
|
+
WASM_VECTOR_LEN = array.length;
|
|
75
|
+
return ptr;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let cachedInt32Memory0 = null;
|
|
79
|
+
|
|
80
|
+
function getInt32Memory0() {
|
|
81
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
82
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
83
|
+
}
|
|
84
|
+
return cachedInt32Memory0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
88
|
+
ptr = ptr >>> 0;
|
|
89
|
+
const mem = getUint32Memory0();
|
|
90
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
91
|
+
const result = [];
|
|
92
|
+
for (let i = 0; i < slice.length; i++) {
|
|
93
|
+
result.push(takeObject(slice[i]));
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {Uint8Array} tx_bytes
|
|
99
|
+
* @param {(Uint8Array)[]} utxos_bytes_x
|
|
100
|
+
* @param {(Uint8Array)[]} utxos_bytes_y
|
|
101
|
+
* @param {Uint8Array} cost_mdls_bytes
|
|
102
|
+
* @param {bigint} initial_budget_n
|
|
103
|
+
* @param {bigint} initial_budget_d
|
|
104
|
+
* @param {bigint} slot_config_x
|
|
105
|
+
* @param {bigint} slot_config_y
|
|
106
|
+
* @param {number} slot_config_z
|
|
107
|
+
* @returns {(Uint8Array)[]}
|
|
108
|
+
*/
|
|
109
|
+
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) {
|
|
110
|
+
try {
|
|
111
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
112
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
|
|
113
|
+
const len0 = WASM_VECTOR_LEN;
|
|
114
|
+
const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
|
|
115
|
+
const len1 = WASM_VECTOR_LEN;
|
|
116
|
+
const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
|
|
117
|
+
const len2 = WASM_VECTOR_LEN;
|
|
118
|
+
const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
|
|
119
|
+
const len3 = WASM_VECTOR_LEN;
|
|
120
|
+
wasm.eval_phase_two_raw(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z);
|
|
121
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
122
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
123
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
124
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
125
|
+
if (r3) {
|
|
126
|
+
throw takeObject(r2);
|
|
127
|
+
}
|
|
128
|
+
var v5 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
129
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
130
|
+
return v5;
|
|
131
|
+
} finally {
|
|
132
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
137
|
+
ptr = ptr >>> 0;
|
|
138
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @param {Uint8Array} params_bytes
|
|
142
|
+
* @param {Uint8Array} plutus_script_bytes
|
|
143
|
+
* @returns {Uint8Array}
|
|
144
|
+
*/
|
|
145
|
+
export function apply_params_to_script(params_bytes, plutus_script_bytes) {
|
|
146
|
+
try {
|
|
147
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
+
const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
|
|
149
|
+
const len0 = WASM_VECTOR_LEN;
|
|
150
|
+
const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
|
|
151
|
+
const len1 = WASM_VECTOR_LEN;
|
|
152
|
+
wasm.apply_params_to_script(retptr, ptr0, len0, ptr1, len1);
|
|
153
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
154
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
155
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
156
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
157
|
+
if (r3) {
|
|
158
|
+
throw takeObject(r2);
|
|
159
|
+
}
|
|
160
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
161
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
162
|
+
return v3;
|
|
163
|
+
} finally {
|
|
164
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function __wbg_load(module, imports) {
|
|
169
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
170
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
171
|
+
try {
|
|
172
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
173
|
+
|
|
174
|
+
} catch (e) {
|
|
175
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
176
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
177
|
+
|
|
178
|
+
} else {
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const bytes = await module.arrayBuffer();
|
|
185
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
186
|
+
|
|
187
|
+
} else {
|
|
188
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
189
|
+
|
|
190
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
191
|
+
return { instance, module };
|
|
192
|
+
|
|
193
|
+
} else {
|
|
194
|
+
return instance;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function __wbg_get_imports() {
|
|
200
|
+
const imports = {};
|
|
201
|
+
imports.wbg = {};
|
|
202
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
203
|
+
takeObject(arg0);
|
|
204
|
+
};
|
|
205
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
206
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
207
|
+
return addHeapObject(ret);
|
|
208
|
+
};
|
|
209
|
+
imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
210
|
+
const ret = getObject(arg0).buffer;
|
|
211
|
+
return addHeapObject(ret);
|
|
212
|
+
};
|
|
213
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
214
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
215
|
+
return addHeapObject(ret);
|
|
216
|
+
};
|
|
217
|
+
imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
218
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
219
|
+
return addHeapObject(ret);
|
|
220
|
+
};
|
|
221
|
+
imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
222
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
223
|
+
};
|
|
224
|
+
imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
225
|
+
const ret = getObject(arg0).length;
|
|
226
|
+
return ret;
|
|
227
|
+
};
|
|
228
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
229
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
230
|
+
};
|
|
231
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
232
|
+
const ret = wasm.memory;
|
|
233
|
+
return addHeapObject(ret);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
return imports;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function __wbg_finalize_init(instance, module) {
|
|
244
|
+
wasm = instance.exports;
|
|
245
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
246
|
+
cachedInt32Memory0 = null;
|
|
247
|
+
cachedUint32Memory0 = null;
|
|
248
|
+
cachedUint8Memory0 = null;
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
return wasm;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function initSync(module) {
|
|
255
|
+
if (wasm !== undefined) return wasm;
|
|
256
|
+
|
|
257
|
+
const imports = __wbg_get_imports();
|
|
258
|
+
|
|
259
|
+
__wbg_init_memory(imports);
|
|
260
|
+
|
|
261
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
262
|
+
module = new WebAssembly.Module(module);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
266
|
+
|
|
267
|
+
return __wbg_finalize_init(instance, module);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async function __wbg_init(input) {
|
|
271
|
+
if (wasm !== undefined) return wasm;
|
|
272
|
+
|
|
273
|
+
if (typeof input === 'undefined') {
|
|
274
|
+
input = new URL('uplc_tx_bg.wasm', import.meta.url);
|
|
275
|
+
}
|
|
276
|
+
const imports = __wbg_get_imports();
|
|
277
|
+
|
|
278
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
279
|
+
input = fetch(input);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
__wbg_init_memory(imports);
|
|
283
|
+
|
|
284
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
285
|
+
|
|
286
|
+
return __wbg_finalize_init(instance, module);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export { initSync }
|
|
290
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function eval_phase_two_raw(
|
|
5
|
+
a: number,
|
|
6
|
+
b: number,
|
|
7
|
+
c: number,
|
|
8
|
+
d: number,
|
|
9
|
+
e: number,
|
|
10
|
+
f: number,
|
|
11
|
+
g: number,
|
|
12
|
+
h: number,
|
|
13
|
+
i: number,
|
|
14
|
+
j: number,
|
|
15
|
+
k: number,
|
|
16
|
+
l: number,
|
|
17
|
+
m: number,
|
|
18
|
+
n: number,
|
|
19
|
+
): void;
|
|
20
|
+
export function apply_params_to_script(
|
|
21
|
+
a: number,
|
|
22
|
+
b: number,
|
|
23
|
+
c: number,
|
|
24
|
+
d: number,
|
|
25
|
+
e: number,
|
|
26
|
+
): void;
|
|
27
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
28
|
+
export function __wbindgen_malloc(a: number, b: number): number;
|
|
29
|
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @param {number} slot_config_z
|
|
13
13
|
* @returns {(Uint8Array)[]}
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
export function eval_phase_two_raw(
|
|
16
16
|
tx_bytes: Uint8Array,
|
|
17
17
|
utxos_bytes_x: Uint8Array[],
|
|
18
18
|
utxos_bytes_y: Uint8Array[],
|
|
@@ -28,9 +28,7 @@ declare function eval_phase_two_raw(
|
|
|
28
28
|
* @param {Uint8Array} plutus_script_bytes
|
|
29
29
|
* @returns {Uint8Array}
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
export function apply_params_to_script(
|
|
32
32
|
params_bytes: Uint8Array,
|
|
33
33
|
plutus_script_bytes: Uint8Array,
|
|
34
34
|
): Uint8Array;
|
|
35
|
-
|
|
36
|
-
export { apply_params_to_script, eval_phase_two_raw };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
let imports = {};
|
|
2
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
3
|
+
let wasm;
|
|
4
|
+
const { TextDecoder } = require(`util`);
|
|
5
|
+
|
|
6
|
+
const heap = new Array(128).fill(undefined);
|
|
7
|
+
|
|
8
|
+
heap.push(undefined, null, true, false);
|
|
9
|
+
|
|
10
|
+
function getObject(idx) { return heap[idx]; }
|
|
11
|
+
|
|
12
|
+
let heap_next = heap.length;
|
|
13
|
+
|
|
14
|
+
function dropObject(idx) {
|
|
15
|
+
if (idx < 132) return;
|
|
16
|
+
heap[idx] = heap_next;
|
|
17
|
+
heap_next = idx;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function takeObject(idx) {
|
|
21
|
+
const ret = getObject(idx);
|
|
22
|
+
dropObject(idx);
|
|
23
|
+
return ret;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
27
|
+
|
|
28
|
+
cachedTextDecoder.decode();
|
|
29
|
+
|
|
30
|
+
let cachedUint8Memory0 = null;
|
|
31
|
+
|
|
32
|
+
function getUint8Memory0() {
|
|
33
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
34
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
35
|
+
}
|
|
36
|
+
return cachedUint8Memory0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getStringFromWasm0(ptr, len) {
|
|
40
|
+
ptr = ptr >>> 0;
|
|
41
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function addHeapObject(obj) {
|
|
45
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
46
|
+
const idx = heap_next;
|
|
47
|
+
heap_next = heap[idx];
|
|
48
|
+
|
|
49
|
+
heap[idx] = obj;
|
|
50
|
+
return idx;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let WASM_VECTOR_LEN = 0;
|
|
54
|
+
|
|
55
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
56
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
57
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
58
|
+
WASM_VECTOR_LEN = arg.length;
|
|
59
|
+
return ptr;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let cachedUint32Memory0 = null;
|
|
63
|
+
|
|
64
|
+
function getUint32Memory0() {
|
|
65
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
66
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
67
|
+
}
|
|
68
|
+
return cachedUint32Memory0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
72
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
73
|
+
const mem = getUint32Memory0();
|
|
74
|
+
for (let i = 0; i < array.length; i++) {
|
|
75
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
76
|
+
}
|
|
77
|
+
WASM_VECTOR_LEN = array.length;
|
|
78
|
+
return ptr;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let cachedInt32Memory0 = null;
|
|
82
|
+
|
|
83
|
+
function getInt32Memory0() {
|
|
84
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
85
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
86
|
+
}
|
|
87
|
+
return cachedInt32Memory0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
91
|
+
ptr = ptr >>> 0;
|
|
92
|
+
const mem = getUint32Memory0();
|
|
93
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
94
|
+
const result = [];
|
|
95
|
+
for (let i = 0; i < slice.length; i++) {
|
|
96
|
+
result.push(takeObject(slice[i]));
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @param {Uint8Array} tx_bytes
|
|
102
|
+
* @param {(Uint8Array)[]} utxos_bytes_x
|
|
103
|
+
* @param {(Uint8Array)[]} utxos_bytes_y
|
|
104
|
+
* @param {Uint8Array} cost_mdls_bytes
|
|
105
|
+
* @param {bigint} initial_budget_n
|
|
106
|
+
* @param {bigint} initial_budget_d
|
|
107
|
+
* @param {bigint} slot_config_x
|
|
108
|
+
* @param {bigint} slot_config_y
|
|
109
|
+
* @param {number} slot_config_z
|
|
110
|
+
* @returns {(Uint8Array)[]}
|
|
111
|
+
*/
|
|
112
|
+
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) {
|
|
113
|
+
try {
|
|
114
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
115
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
|
|
116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
117
|
+
const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
|
|
118
|
+
const len1 = WASM_VECTOR_LEN;
|
|
119
|
+
const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
|
|
120
|
+
const len2 = WASM_VECTOR_LEN;
|
|
121
|
+
const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
|
|
122
|
+
const len3 = WASM_VECTOR_LEN;
|
|
123
|
+
wasm.eval_phase_two_raw(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, initial_budget_n, initial_budget_d, slot_config_x, slot_config_y, slot_config_z);
|
|
124
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
125
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
126
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
127
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
128
|
+
if (r3) {
|
|
129
|
+
throw takeObject(r2);
|
|
130
|
+
}
|
|
131
|
+
var v5 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
132
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
133
|
+
return v5;
|
|
134
|
+
} finally {
|
|
135
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
140
|
+
ptr = ptr >>> 0;
|
|
141
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @param {Uint8Array} params_bytes
|
|
145
|
+
* @param {Uint8Array} plutus_script_bytes
|
|
146
|
+
* @returns {Uint8Array}
|
|
147
|
+
*/
|
|
148
|
+
module.exports.apply_params_to_script = function(params_bytes, plutus_script_bytes) {
|
|
149
|
+
try {
|
|
150
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
151
|
+
const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
|
|
152
|
+
const len0 = WASM_VECTOR_LEN;
|
|
153
|
+
const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
|
|
154
|
+
const len1 = WASM_VECTOR_LEN;
|
|
155
|
+
wasm.apply_params_to_script(retptr, ptr0, len0, ptr1, len1);
|
|
156
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
157
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
158
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
159
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
160
|
+
if (r3) {
|
|
161
|
+
throw takeObject(r2);
|
|
162
|
+
}
|
|
163
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
164
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
165
|
+
return v3;
|
|
166
|
+
} finally {
|
|
167
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
172
|
+
takeObject(arg0);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
176
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
177
|
+
return addHeapObject(ret);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
module.exports.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
181
|
+
const ret = getObject(arg0).buffer;
|
|
182
|
+
return addHeapObject(ret);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
module.exports.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
186
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
187
|
+
return addHeapObject(ret);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
module.exports.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
191
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
192
|
+
return addHeapObject(ret);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
module.exports.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
196
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
module.exports.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
200
|
+
const ret = getObject(arg0).length;
|
|
201
|
+
return ret;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
205
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
module.exports.__wbindgen_memory = function() {
|
|
209
|
+
const ret = wasm.memory;
|
|
210
|
+
return addHeapObject(ret);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const path = require('path').join(__dirname, 'uplc_tx_bg.wasm');
|
|
214
|
+
const bytes = require('fs').readFileSync(path);
|
|
215
|
+
|
|
216
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
217
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
218
|
+
wasm = wasmInstance.exports;
|
|
219
|
+
module.exports.__wasm = wasm;
|
|
220
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function eval_phase_two_raw(
|
|
5
|
+
a: number,
|
|
6
|
+
b: number,
|
|
7
|
+
c: number,
|
|
8
|
+
d: number,
|
|
9
|
+
e: number,
|
|
10
|
+
f: number,
|
|
11
|
+
g: number,
|
|
12
|
+
h: number,
|
|
13
|
+
i: number,
|
|
14
|
+
j: number,
|
|
15
|
+
k: number,
|
|
16
|
+
l: number,
|
|
17
|
+
m: number,
|
|
18
|
+
n: number,
|
|
19
|
+
): void;
|
|
20
|
+
export function apply_params_to_script(
|
|
21
|
+
a: number,
|
|
22
|
+
b: number,
|
|
23
|
+
c: number,
|
|
24
|
+
d: number,
|
|
25
|
+
e: number,
|
|
26
|
+
): void;
|
|
27
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
28
|
+
export function __wbindgen_malloc(a: number, b: number): number;
|
|
29
|
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|