@lucid-evolution/uplc 0.2.1 → 0.2.3
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 +7 -0
- package/dist/browser/index.mjs +8578 -0
- package/dist/browser/uplc_tx_bg.wasm +0 -0
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.d.ts +36 -0
- package/dist/node/index.js +225 -0
- package/dist/node/index.mjs +221 -0
- package/dist/node/uplc_tx_bg.wasm +0 -0
- package/package.json +9 -5
- package/dist/uplc_tx.js +0 -256
- package/dist/uplc_tx_bg-2ZM6JWAH.wasm +0 -0
- /package/dist/{uplc_tx.d.ts → browser/index.d.mts} +0 -0
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
declare 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
|
+
declare function apply_params_to_script(
|
|
32
|
+
params_bytes: Uint8Array,
|
|
33
|
+
plutus_script_bytes: Uint8Array,
|
|
34
|
+
): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export { apply_params_to_script, eval_phase_two_raw };
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
declare 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
|
+
declare function apply_params_to_script(
|
|
32
|
+
params_bytes: Uint8Array,
|
|
33
|
+
plutus_script_bytes: Uint8Array,
|
|
34
|
+
): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export { apply_params_to_script, eval_phase_two_raw };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/uplc_tx.js
|
|
34
|
+
var require_uplc_tx = __commonJS({
|
|
35
|
+
"src/uplc_tx.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var imports = {};
|
|
38
|
+
imports["__wbindgen_placeholder__"] = module2.exports;
|
|
39
|
+
var wasm;
|
|
40
|
+
var { TextDecoder } = require("util");
|
|
41
|
+
var heap = new Array(128).fill(void 0);
|
|
42
|
+
heap.push(void 0, null, true, false);
|
|
43
|
+
function getObject(idx) {
|
|
44
|
+
return heap[idx];
|
|
45
|
+
}
|
|
46
|
+
var heap_next = heap.length;
|
|
47
|
+
function dropObject(idx) {
|
|
48
|
+
if (idx < 132)
|
|
49
|
+
return;
|
|
50
|
+
heap[idx] = heap_next;
|
|
51
|
+
heap_next = idx;
|
|
52
|
+
}
|
|
53
|
+
function takeObject(idx) {
|
|
54
|
+
const ret = getObject(idx);
|
|
55
|
+
dropObject(idx);
|
|
56
|
+
return ret;
|
|
57
|
+
}
|
|
58
|
+
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
59
|
+
cachedTextDecoder.decode();
|
|
60
|
+
var cachedUint8Memory0 = null;
|
|
61
|
+
function getUint8Memory0() {
|
|
62
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
63
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
64
|
+
}
|
|
65
|
+
return cachedUint8Memory0;
|
|
66
|
+
}
|
|
67
|
+
function getStringFromWasm0(ptr, len) {
|
|
68
|
+
ptr = ptr >>> 0;
|
|
69
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
70
|
+
}
|
|
71
|
+
function addHeapObject(obj) {
|
|
72
|
+
if (heap_next === heap.length)
|
|
73
|
+
heap.push(heap.length + 1);
|
|
74
|
+
const idx = heap_next;
|
|
75
|
+
heap_next = heap[idx];
|
|
76
|
+
heap[idx] = obj;
|
|
77
|
+
return idx;
|
|
78
|
+
}
|
|
79
|
+
var WASM_VECTOR_LEN = 0;
|
|
80
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
81
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
82
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
83
|
+
WASM_VECTOR_LEN = arg.length;
|
|
84
|
+
return ptr;
|
|
85
|
+
}
|
|
86
|
+
var cachedUint32Memory0 = null;
|
|
87
|
+
function getUint32Memory0() {
|
|
88
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
89
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
90
|
+
}
|
|
91
|
+
return cachedUint32Memory0;
|
|
92
|
+
}
|
|
93
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
94
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
95
|
+
const mem = getUint32Memory0();
|
|
96
|
+
for (let i = 0; i < array.length; i++) {
|
|
97
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
98
|
+
}
|
|
99
|
+
WASM_VECTOR_LEN = array.length;
|
|
100
|
+
return ptr;
|
|
101
|
+
}
|
|
102
|
+
var cachedInt32Memory0 = null;
|
|
103
|
+
function getInt32Memory0() {
|
|
104
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
105
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
106
|
+
}
|
|
107
|
+
return cachedInt32Memory0;
|
|
108
|
+
}
|
|
109
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
110
|
+
ptr = ptr >>> 0;
|
|
111
|
+
const mem = getUint32Memory0();
|
|
112
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
113
|
+
const result = [];
|
|
114
|
+
for (let i = 0; i < slice.length; i++) {
|
|
115
|
+
result.push(takeObject(slice[i]));
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
module2.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) {
|
|
120
|
+
try {
|
|
121
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
122
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
|
|
123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
124
|
+
const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
|
|
125
|
+
const len1 = WASM_VECTOR_LEN;
|
|
126
|
+
const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
|
|
127
|
+
const len2 = WASM_VECTOR_LEN;
|
|
128
|
+
const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
|
|
129
|
+
const len3 = WASM_VECTOR_LEN;
|
|
130
|
+
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);
|
|
131
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
132
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
133
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
134
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
135
|
+
if (r3) {
|
|
136
|
+
throw takeObject(r2);
|
|
137
|
+
}
|
|
138
|
+
var v5 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
139
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
140
|
+
return v5;
|
|
141
|
+
} finally {
|
|
142
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
146
|
+
ptr = ptr >>> 0;
|
|
147
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
148
|
+
}
|
|
149
|
+
module2.exports.apply_params_to_script = function(params_bytes, plutus_script_bytes) {
|
|
150
|
+
try {
|
|
151
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
152
|
+
const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
|
|
153
|
+
const len0 = WASM_VECTOR_LEN;
|
|
154
|
+
const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
|
|
155
|
+
const len1 = WASM_VECTOR_LEN;
|
|
156
|
+
wasm.apply_params_to_script(retptr, ptr0, len0, ptr1, len1);
|
|
157
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
158
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
159
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
160
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
161
|
+
if (r3) {
|
|
162
|
+
throw takeObject(r2);
|
|
163
|
+
}
|
|
164
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
165
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
166
|
+
return v3;
|
|
167
|
+
} finally {
|
|
168
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
module2.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
172
|
+
takeObject(arg0);
|
|
173
|
+
};
|
|
174
|
+
module2.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
175
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
176
|
+
return addHeapObject(ret);
|
|
177
|
+
};
|
|
178
|
+
module2.exports.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
179
|
+
const ret = getObject(arg0).buffer;
|
|
180
|
+
return addHeapObject(ret);
|
|
181
|
+
};
|
|
182
|
+
module2.exports.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
183
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
184
|
+
return addHeapObject(ret);
|
|
185
|
+
};
|
|
186
|
+
module2.exports.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
187
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
188
|
+
return addHeapObject(ret);
|
|
189
|
+
};
|
|
190
|
+
module2.exports.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
191
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
192
|
+
};
|
|
193
|
+
module2.exports.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
194
|
+
const ret = getObject(arg0).length;
|
|
195
|
+
return ret;
|
|
196
|
+
};
|
|
197
|
+
module2.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
198
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
199
|
+
};
|
|
200
|
+
module2.exports.__wbindgen_memory = function() {
|
|
201
|
+
const ret = wasm.memory;
|
|
202
|
+
return addHeapObject(ret);
|
|
203
|
+
};
|
|
204
|
+
var path = require("path").join(__dirname, "uplc_tx_bg.wasm");
|
|
205
|
+
var bytes = require("fs").readFileSync(path);
|
|
206
|
+
var wasmModule = new WebAssembly.Module(bytes);
|
|
207
|
+
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
208
|
+
wasm = wasmInstance.exports;
|
|
209
|
+
module2.exports.__wasm = wasm;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// src/index.ts
|
|
214
|
+
var src_exports = {};
|
|
215
|
+
__export(src_exports, {
|
|
216
|
+
apply_params_to_script: () => import_uplc_tx.apply_params_to_script,
|
|
217
|
+
eval_phase_two_raw: () => import_uplc_tx.eval_phase_two_raw
|
|
218
|
+
});
|
|
219
|
+
module.exports = __toCommonJS(src_exports);
|
|
220
|
+
var import_uplc_tx = __toESM(require_uplc_tx());
|
|
221
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
222
|
+
0 && (module.exports = {
|
|
223
|
+
apply_params_to_script,
|
|
224
|
+
eval_phase_two_raw
|
|
225
|
+
});
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined")
|
|
11
|
+
return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// src/uplc_tx.js
|
|
35
|
+
var require_uplc_tx = __commonJS({
|
|
36
|
+
"src/uplc_tx.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var imports = {};
|
|
39
|
+
imports["__wbindgen_placeholder__"] = module.exports;
|
|
40
|
+
var wasm;
|
|
41
|
+
var { TextDecoder } = __require("util");
|
|
42
|
+
var heap = new Array(128).fill(void 0);
|
|
43
|
+
heap.push(void 0, null, true, false);
|
|
44
|
+
function getObject(idx) {
|
|
45
|
+
return heap[idx];
|
|
46
|
+
}
|
|
47
|
+
var heap_next = heap.length;
|
|
48
|
+
function dropObject(idx) {
|
|
49
|
+
if (idx < 132)
|
|
50
|
+
return;
|
|
51
|
+
heap[idx] = heap_next;
|
|
52
|
+
heap_next = idx;
|
|
53
|
+
}
|
|
54
|
+
function takeObject(idx) {
|
|
55
|
+
const ret = getObject(idx);
|
|
56
|
+
dropObject(idx);
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
59
|
+
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
60
|
+
cachedTextDecoder.decode();
|
|
61
|
+
var cachedUint8Memory0 = null;
|
|
62
|
+
function getUint8Memory0() {
|
|
63
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
64
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
65
|
+
}
|
|
66
|
+
return cachedUint8Memory0;
|
|
67
|
+
}
|
|
68
|
+
function getStringFromWasm0(ptr, len) {
|
|
69
|
+
ptr = ptr >>> 0;
|
|
70
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
71
|
+
}
|
|
72
|
+
function addHeapObject(obj) {
|
|
73
|
+
if (heap_next === heap.length)
|
|
74
|
+
heap.push(heap.length + 1);
|
|
75
|
+
const idx = heap_next;
|
|
76
|
+
heap_next = heap[idx];
|
|
77
|
+
heap[idx] = obj;
|
|
78
|
+
return idx;
|
|
79
|
+
}
|
|
80
|
+
var WASM_VECTOR_LEN = 0;
|
|
81
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
82
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
83
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
84
|
+
WASM_VECTOR_LEN = arg.length;
|
|
85
|
+
return ptr;
|
|
86
|
+
}
|
|
87
|
+
var cachedUint32Memory0 = null;
|
|
88
|
+
function getUint32Memory0() {
|
|
89
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
90
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
91
|
+
}
|
|
92
|
+
return cachedUint32Memory0;
|
|
93
|
+
}
|
|
94
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
95
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
96
|
+
const mem = getUint32Memory0();
|
|
97
|
+
for (let i = 0; i < array.length; i++) {
|
|
98
|
+
mem[ptr / 4 + i] = addHeapObject(array[i]);
|
|
99
|
+
}
|
|
100
|
+
WASM_VECTOR_LEN = array.length;
|
|
101
|
+
return ptr;
|
|
102
|
+
}
|
|
103
|
+
var cachedInt32Memory0 = null;
|
|
104
|
+
function getInt32Memory0() {
|
|
105
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
106
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
107
|
+
}
|
|
108
|
+
return cachedInt32Memory0;
|
|
109
|
+
}
|
|
110
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
111
|
+
ptr = ptr >>> 0;
|
|
112
|
+
const mem = getUint32Memory0();
|
|
113
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
114
|
+
const result = [];
|
|
115
|
+
for (let i = 0; i < slice.length; i++) {
|
|
116
|
+
result.push(takeObject(slice[i]));
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
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) {
|
|
121
|
+
try {
|
|
122
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
123
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_malloc);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
const ptr1 = passArrayJsValueToWasm0(utxos_bytes_x, wasm.__wbindgen_malloc);
|
|
126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
127
|
+
const ptr2 = passArrayJsValueToWasm0(utxos_bytes_y, wasm.__wbindgen_malloc);
|
|
128
|
+
const len2 = WASM_VECTOR_LEN;
|
|
129
|
+
const ptr3 = passArray8ToWasm0(cost_mdls_bytes, wasm.__wbindgen_malloc);
|
|
130
|
+
const len3 = WASM_VECTOR_LEN;
|
|
131
|
+
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);
|
|
132
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
133
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
134
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
135
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
136
|
+
if (r3) {
|
|
137
|
+
throw takeObject(r2);
|
|
138
|
+
}
|
|
139
|
+
var v5 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
140
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
141
|
+
return v5;
|
|
142
|
+
} finally {
|
|
143
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
147
|
+
ptr = ptr >>> 0;
|
|
148
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
149
|
+
}
|
|
150
|
+
module.exports.apply_params_to_script = function(params_bytes, plutus_script_bytes) {
|
|
151
|
+
try {
|
|
152
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
153
|
+
const ptr0 = passArray8ToWasm0(params_bytes, wasm.__wbindgen_malloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ptr1 = passArray8ToWasm0(plutus_script_bytes, wasm.__wbindgen_malloc);
|
|
156
|
+
const len1 = WASM_VECTOR_LEN;
|
|
157
|
+
wasm.apply_params_to_script(retptr, ptr0, len0, ptr1, len1);
|
|
158
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
159
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
160
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
161
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
162
|
+
if (r3) {
|
|
163
|
+
throw takeObject(r2);
|
|
164
|
+
}
|
|
165
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
166
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
167
|
+
return v3;
|
|
168
|
+
} finally {
|
|
169
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
173
|
+
takeObject(arg0);
|
|
174
|
+
};
|
|
175
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
176
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
177
|
+
return addHeapObject(ret);
|
|
178
|
+
};
|
|
179
|
+
module.exports.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
180
|
+
const ret = getObject(arg0).buffer;
|
|
181
|
+
return addHeapObject(ret);
|
|
182
|
+
};
|
|
183
|
+
module.exports.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
184
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
185
|
+
return addHeapObject(ret);
|
|
186
|
+
};
|
|
187
|
+
module.exports.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
188
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
189
|
+
return addHeapObject(ret);
|
|
190
|
+
};
|
|
191
|
+
module.exports.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
192
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
193
|
+
};
|
|
194
|
+
module.exports.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
195
|
+
const ret = getObject(arg0).length;
|
|
196
|
+
return ret;
|
|
197
|
+
};
|
|
198
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
199
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
200
|
+
};
|
|
201
|
+
module.exports.__wbindgen_memory = function() {
|
|
202
|
+
const ret = wasm.memory;
|
|
203
|
+
return addHeapObject(ret);
|
|
204
|
+
};
|
|
205
|
+
var path = __require("path").join(__dirname, "uplc_tx_bg.wasm");
|
|
206
|
+
var bytes = __require("fs").readFileSync(path);
|
|
207
|
+
var wasmModule = new WebAssembly.Module(bytes);
|
|
208
|
+
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
209
|
+
wasm = wasmInstance.exports;
|
|
210
|
+
module.exports.__wasm = wasm;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// src/index.ts
|
|
215
|
+
var import_uplc_tx = __toESM(require_uplc_tx());
|
|
216
|
+
var export_apply_params_to_script = import_uplc_tx.apply_params_to_script;
|
|
217
|
+
var export_eval_phase_two_raw = import_uplc_tx.eval_phase_two_raw;
|
|
218
|
+
export {
|
|
219
|
+
export_apply_params_to_script as apply_params_to_script,
|
|
220
|
+
export_eval_phase_two_raw as eval_phase_two_raw
|
|
221
|
+
};
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/uplc",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"main": "./dist/
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"main": "./dist/node/index.js",
|
|
5
|
+
"module": "./dist/node/index.mjs",
|
|
6
|
+
"browser": "./dist/browser/index.mjs",
|
|
7
|
+
"types": "./dist/node/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist"
|
|
9
10
|
],
|
|
@@ -15,10 +16,13 @@
|
|
|
15
16
|
"./snippets/*"
|
|
16
17
|
],
|
|
17
18
|
"devDependencies": {
|
|
19
|
+
"@geut/esbuild-plugin-brode": "^2.0.14",
|
|
20
|
+
"esbuild-copy-files-plugin": "^1.2.0",
|
|
21
|
+
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
18
22
|
"esbuild-plugin-wasm": "^1.1.0",
|
|
19
23
|
"tsup": "^8.0.2"
|
|
20
24
|
},
|
|
21
25
|
"scripts": {
|
|
22
|
-
"build": "tsup
|
|
26
|
+
"build": "tsup"
|
|
23
27
|
}
|
|
24
28
|
}
|