@noir-lang/noirc_abi 0.8.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 ADDED
@@ -0,0 +1,20 @@
1
+ # Noir Lang ABI JavaScript Package
2
+
3
+ This JavaScript package enables users to ABI encode inputs to a Noir program, i.e. generating an initial witness.
4
+
5
+ ## Building from source
6
+
7
+ Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below:
8
+
9
+ ```bash
10
+ nix build -L github:noir-lang/noir/master#abi_wasm
11
+ ```
12
+
13
+ If you are within the noir repo and would like to build local changes, you can use:
14
+
15
+ ```bash
16
+ nix build -L #abi_wasm
17
+ ```
18
+
19
+ ## Tracking
20
+ Built from [noir-lang/noir@5724965e05a6fc812752813e747f1258d438b16b](https://github.com/noir-lang/noir/tree/5724965e05a6fc812752813e747f1258d438b16b)
@@ -0,0 +1,30 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {any} abi
5
+ * @param {any} inputs
6
+ * @param {any} return_value
7
+ * @returns {WitnessMap}
8
+ */
9
+ export function abiEncode(abi: any, inputs: any, return_value: any): WitnessMap;
10
+ /**
11
+ * @param {any} abi
12
+ * @param {WitnessMap} witness_map
13
+ * @returns {any}
14
+ */
15
+ export function abiDecode(abi: any, witness_map: WitnessMap): any;
16
+
17
+ // Map from witness index to hex string value of witness.
18
+ export type WitnessMap = Map<number, string>;
19
+
20
+
21
+ /**
22
+ * A struct representing a Trap
23
+ */
24
+ export class Trap {
25
+ free(): void;
26
+ /**
27
+ * @returns {Symbol}
28
+ */
29
+ static __wbgd_downcast_token(): Symbol;
30
+ }
@@ -0,0 +1,343 @@
1
+ let imports = {};
2
+ imports['__wbindgen_placeholder__'] = module.exports;
3
+ let wasm;
4
+ const { TextDecoder, TextEncoder } = 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
+ function isLikeNone(x) {
13
+ return x === undefined || x === null;
14
+ }
15
+
16
+ let cachedFloat64Memory0 = null;
17
+
18
+ function getFloat64Memory0() {
19
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
20
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
21
+ }
22
+ return cachedFloat64Memory0;
23
+ }
24
+
25
+ let cachedInt32Memory0 = null;
26
+
27
+ function getInt32Memory0() {
28
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
29
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
30
+ }
31
+ return cachedInt32Memory0;
32
+ }
33
+
34
+ let heap_next = heap.length;
35
+
36
+ function dropObject(idx) {
37
+ if (idx < 132) return;
38
+ heap[idx] = heap_next;
39
+ heap_next = idx;
40
+ }
41
+
42
+ function takeObject(idx) {
43
+ const ret = getObject(idx);
44
+ dropObject(idx);
45
+ return ret;
46
+ }
47
+
48
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
49
+
50
+ cachedTextDecoder.decode();
51
+
52
+ let cachedUint8Memory0 = null;
53
+
54
+ function getUint8Memory0() {
55
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
56
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
57
+ }
58
+ return cachedUint8Memory0;
59
+ }
60
+
61
+ function getStringFromWasm0(ptr, len) {
62
+ ptr = ptr >>> 0;
63
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
64
+ }
65
+
66
+ function addHeapObject(obj) {
67
+ if (heap_next === heap.length) heap.push(heap.length + 1);
68
+ const idx = heap_next;
69
+ heap_next = heap[idx];
70
+
71
+ heap[idx] = obj;
72
+ return idx;
73
+ }
74
+
75
+ let WASM_VECTOR_LEN = 0;
76
+
77
+ let cachedTextEncoder = new TextEncoder('utf-8');
78
+
79
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
80
+ ? function (arg, view) {
81
+ return cachedTextEncoder.encodeInto(arg, view);
82
+ }
83
+ : function (arg, view) {
84
+ const buf = cachedTextEncoder.encode(arg);
85
+ view.set(buf);
86
+ return {
87
+ read: arg.length,
88
+ written: buf.length
89
+ };
90
+ });
91
+
92
+ function passStringToWasm0(arg, malloc, realloc) {
93
+
94
+ if (realloc === undefined) {
95
+ const buf = cachedTextEncoder.encode(arg);
96
+ const ptr = malloc(buf.length) >>> 0;
97
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
98
+ WASM_VECTOR_LEN = buf.length;
99
+ return ptr;
100
+ }
101
+
102
+ let len = arg.length;
103
+ let ptr = malloc(len) >>> 0;
104
+
105
+ const mem = getUint8Memory0();
106
+
107
+ let offset = 0;
108
+
109
+ for (; offset < len; offset++) {
110
+ const code = arg.charCodeAt(offset);
111
+ if (code > 0x7F) break;
112
+ mem[ptr + offset] = code;
113
+ }
114
+
115
+ if (offset !== len) {
116
+ if (offset !== 0) {
117
+ arg = arg.slice(offset);
118
+ }
119
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
120
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
121
+ const ret = encodeString(arg, view);
122
+
123
+ offset += ret.written;
124
+ }
125
+
126
+ WASM_VECTOR_LEN = offset;
127
+ return ptr;
128
+ }
129
+ /**
130
+ * @param {any} abi
131
+ * @param {any} inputs
132
+ * @param {any} return_value
133
+ * @returns {WitnessMap}
134
+ */
135
+ module.exports.abiEncode = function(abi, inputs, return_value) {
136
+ try {
137
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
138
+ wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), addHeapObject(return_value));
139
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
140
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
141
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
142
+ if (r2) {
143
+ throw takeObject(r1);
144
+ }
145
+ return takeObject(r0);
146
+ } finally {
147
+ wasm.__wbindgen_add_to_stack_pointer(16);
148
+ }
149
+ };
150
+
151
+ /**
152
+ * @param {any} abi
153
+ * @param {WitnessMap} witness_map
154
+ * @returns {any}
155
+ */
156
+ module.exports.abiDecode = function(abi, witness_map) {
157
+ try {
158
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
159
+ wasm.abiDecode(retptr, addHeapObject(abi), addHeapObject(witness_map));
160
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
161
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
162
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
163
+ if (r2) {
164
+ throw takeObject(r1);
165
+ }
166
+ return takeObject(r0);
167
+ } finally {
168
+ wasm.__wbindgen_add_to_stack_pointer(16);
169
+ }
170
+ };
171
+
172
+ function handleError(f, args) {
173
+ try {
174
+ return f.apply(this, args);
175
+ } catch (e) {
176
+ wasm.__wbindgen_exn_store(addHeapObject(e));
177
+ }
178
+ }
179
+ function __wbg_adapter_32(arg0, arg1, arg2, arg3) {
180
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h111bd9fa85682cff(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
181
+ }
182
+
183
+ /**
184
+ * A struct representing a Trap
185
+ */
186
+ class Trap {
187
+
188
+ __destroy_into_raw() {
189
+ const ptr = this.__wbg_ptr;
190
+ this.__wbg_ptr = 0;
191
+
192
+ return ptr;
193
+ }
194
+
195
+ free() {
196
+ const ptr = this.__destroy_into_raw();
197
+ wasm.__wbg_trap_free(ptr);
198
+ }
199
+ /**
200
+ * @returns {Symbol}
201
+ */
202
+ static __wbgd_downcast_token() {
203
+ const ret = wasm.trap___wbgd_downcast_token();
204
+ return takeObject(ret);
205
+ }
206
+ }
207
+ module.exports.Trap = Trap;
208
+
209
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
210
+ const obj = getObject(arg1);
211
+ const ret = typeof(obj) === 'number' ? obj : undefined;
212
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
213
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
214
+ };
215
+
216
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
217
+ takeObject(arg0);
218
+ };
219
+
220
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
221
+ const ret = getStringFromWasm0(arg0, arg1);
222
+ return addHeapObject(ret);
223
+ };
224
+
225
+ module.exports.__wbindgen_is_undefined = function(arg0) {
226
+ const ret = getObject(arg0) === undefined;
227
+ return ret;
228
+ };
229
+
230
+ module.exports.__wbindgen_is_null = function(arg0) {
231
+ const ret = getObject(arg0) === null;
232
+ return ret;
233
+ };
234
+
235
+ module.exports.__wbg_new_08bf5b2e92fba7de = function() {
236
+ const ret = new Map();
237
+ return addHeapObject(ret);
238
+ };
239
+
240
+ module.exports.__wbindgen_number_new = function(arg0) {
241
+ const ret = arg0;
242
+ return addHeapObject(ret);
243
+ };
244
+
245
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
246
+ const obj = getObject(arg1);
247
+ const ret = typeof(obj) === 'string' ? obj : undefined;
248
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
249
+ var len1 = WASM_VECTOR_LEN;
250
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
251
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
252
+ };
253
+
254
+ module.exports.__wbg_new_abda76e883ba8a5f = function() {
255
+ const ret = new Error();
256
+ return addHeapObject(ret);
257
+ };
258
+
259
+ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
260
+ const ret = getObject(arg1).stack;
261
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
262
+ const len1 = WASM_VECTOR_LEN;
263
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
264
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
265
+ };
266
+
267
+ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
268
+ let deferred0_0;
269
+ let deferred0_1;
270
+ try {
271
+ deferred0_0 = arg0;
272
+ deferred0_1 = arg1;
273
+ console.error(getStringFromWasm0(arg0, arg1));
274
+ } finally {
275
+ wasm.__wbindgen_free(deferred0_0, deferred0_1);
276
+ }
277
+ };
278
+
279
+ module.exports.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) {
280
+ const ret = getObject(arg0).call(getObject(arg1));
281
+ return addHeapObject(ret);
282
+ }, arguments) };
283
+
284
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
285
+ const ret = getObject(arg0);
286
+ return addHeapObject(ret);
287
+ };
288
+
289
+ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
290
+ try {
291
+ var state0 = {a: arg1, b: arg2};
292
+ var cb0 = (arg0, arg1) => {
293
+ const a = state0.a;
294
+ state0.a = 0;
295
+ try {
296
+ return __wbg_adapter_32(a, state0.b, arg0, arg1);
297
+ } finally {
298
+ state0.a = a;
299
+ }
300
+ };
301
+ getObject(arg0).forEach(cb0);
302
+ } finally {
303
+ state0.a = state0.b = 0;
304
+ }
305
+ };
306
+
307
+ module.exports.__wbg_set_da7be7bf0e037b14 = function(arg0, arg1, arg2) {
308
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
309
+ return addHeapObject(ret);
310
+ };
311
+
312
+ module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
313
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
314
+ return addHeapObject(ret);
315
+ }, arguments) };
316
+
317
+ module.exports.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
318
+ const ret = JSON.stringify(getObject(arg0));
319
+ return addHeapObject(ret);
320
+ }, arguments) };
321
+
322
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
323
+ throw new Error(getStringFromWasm0(arg0, arg1));
324
+ };
325
+
326
+ module.exports.__wbg_static_accessor_SYMBOL_45d4d15e3c4aeb33 = function() {
327
+ const ret = Symbol;
328
+ return addHeapObject(ret);
329
+ };
330
+
331
+ module.exports.__wbindgen_is_symbol = function(arg0) {
332
+ const ret = typeof(getObject(arg0)) === 'symbol';
333
+ return ret;
334
+ };
335
+
336
+ const path = require('path').join(__dirname, 'noirc_abi_wasm_bg.wasm');
337
+ const bytes = require('fs').readFileSync(path);
338
+
339
+ const wasmModule = new WebAssembly.Module(bytes);
340
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
341
+ wasm = wasmInstance.exports;
342
+ module.exports.__wasm = wasm;
343
+
Binary file
@@ -0,0 +1,17 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function abiEncode(a: number, b: number, c: number, d: number): void;
5
+ export function abiDecode(a: number, b: number, c: number): void;
6
+ export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
7
+ export function rust_psm_stack_direction(): number;
8
+ export function rust_psm_stack_pointer(): number;
9
+ export function rust_psm_replace_stack(a: number, b: number, c: number): void;
10
+ export function __wbg_trap_free(a: number): void;
11
+ export function trap___wbgd_downcast_token(): number;
12
+ export function __wbindgen_malloc(a: number): number;
13
+ export function __wbindgen_realloc(a: number, b: number, c: number): number;
14
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
15
+ export function __wbindgen_free(a: number, b: number): void;
16
+ export function __wbindgen_exn_store(a: number): void;
17
+ export function wasm_bindgen__convert__closures__invoke2_mut__h111bd9fa85682cff(a: number, b: number, c: number, d: number): void;
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@noir-lang/noirc_abi",
3
+ "collaborators": [
4
+ "The Noir Team <team@noir-lang.org>"
5
+ ],
6
+ "version": "0.8.0",
7
+ "files": [
8
+ "nodejs",
9
+ "web",
10
+ "package.json"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "main": "./nodejs/noirc_abi_wasm.js",
16
+ "types": "./web/noirc_abi_wasm.d.ts",
17
+ "module": "./web/noirc_abi_wasm.js",
18
+ "sideEffects": false,
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/noir-lang/noir.git"
22
+ },
23
+ "packageManager": "yarn@3.5.1",
24
+ "scripts": {
25
+ "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
26
+ "test:browser": "web-test-runner",
27
+ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
28
+ },
29
+ "devDependencies": {
30
+ "@esm-bundle/chai": "^4.3.4-fix.0",
31
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
32
+ "@typescript-eslint/parser": "^5.59.5",
33
+ "@web/dev-server-esbuild": "^0.3.6",
34
+ "@web/test-runner": "^0.15.3",
35
+ "@web/test-runner-playwright": "^0.10.0",
36
+ "chai": "^4.3.7",
37
+ "eslint": "^8.40.0",
38
+ "eslint-plugin-prettier": "^4.2.1",
39
+ "mocha": "^10.2.0",
40
+ "prettier": "^2.8.8",
41
+ "ts-node": "^10.9.1",
42
+ "typescript": "^5.0.4"
43
+ }
44
+ }
@@ -0,0 +1,71 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {any} abi
5
+ * @param {any} inputs
6
+ * @param {any} return_value
7
+ * @returns {WitnessMap}
8
+ */
9
+ export function abiEncode(abi: any, inputs: any, return_value: any): WitnessMap;
10
+ /**
11
+ * @param {any} abi
12
+ * @param {WitnessMap} witness_map
13
+ * @returns {any}
14
+ */
15
+ export function abiDecode(abi: any, witness_map: WitnessMap): any;
16
+
17
+ // Map from witness index to hex string value of witness.
18
+ export type WitnessMap = Map<number, string>;
19
+
20
+
21
+ /**
22
+ * A struct representing a Trap
23
+ */
24
+ export class Trap {
25
+ free(): void;
26
+ /**
27
+ * @returns {Symbol}
28
+ */
29
+ static __wbgd_downcast_token(): Symbol;
30
+ }
31
+
32
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
33
+
34
+ export interface InitOutput {
35
+ readonly memory: WebAssembly.Memory;
36
+ readonly abiEncode: (a: number, b: number, c: number, d: number) => void;
37
+ readonly abiDecode: (a: number, b: number, c: number) => void;
38
+ readonly rust_psm_on_stack: (a: number, b: number, c: number, d: number) => void;
39
+ readonly rust_psm_stack_direction: () => number;
40
+ readonly rust_psm_stack_pointer: () => number;
41
+ readonly rust_psm_replace_stack: (a: number, b: number, c: number) => void;
42
+ readonly __wbg_trap_free: (a: number) => void;
43
+ readonly trap___wbgd_downcast_token: () => number;
44
+ readonly __wbindgen_malloc: (a: number) => number;
45
+ readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
46
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
47
+ readonly __wbindgen_free: (a: number, b: number) => void;
48
+ readonly __wbindgen_exn_store: (a: number) => void;
49
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h111bd9fa85682cff: (a: number, b: number, c: number, d: number) => void;
50
+ }
51
+
52
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
53
+ /**
54
+ * Instantiates the given `module`, which can either be bytes or
55
+ * a precompiled `WebAssembly.Module`.
56
+ *
57
+ * @param {SyncInitInput} module
58
+ *
59
+ * @returns {InitOutput}
60
+ */
61
+ export function initSync(module: SyncInitInput): InitOutput;
62
+
63
+ /**
64
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
65
+ * for everything else, calls `WebAssembly.instantiate` directly.
66
+ *
67
+ * @param {InitInput | Promise<InitInput>} module_or_path
68
+ *
69
+ * @returns {Promise<InitOutput>}
70
+ */
71
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,401 @@
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
+ function isLikeNone(x) {
10
+ return x === undefined || x === null;
11
+ }
12
+
13
+ let cachedFloat64Memory0 = null;
14
+
15
+ function getFloat64Memory0() {
16
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
17
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
18
+ }
19
+ return cachedFloat64Memory0;
20
+ }
21
+
22
+ let cachedInt32Memory0 = null;
23
+
24
+ function getInt32Memory0() {
25
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
26
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
27
+ }
28
+ return cachedInt32Memory0;
29
+ }
30
+
31
+ let heap_next = heap.length;
32
+
33
+ function dropObject(idx) {
34
+ if (idx < 132) return;
35
+ heap[idx] = heap_next;
36
+ heap_next = idx;
37
+ }
38
+
39
+ function takeObject(idx) {
40
+ const ret = getObject(idx);
41
+ dropObject(idx);
42
+ return ret;
43
+ }
44
+
45
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
46
+
47
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
48
+
49
+ let cachedUint8Memory0 = null;
50
+
51
+ function getUint8Memory0() {
52
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
53
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
54
+ }
55
+ return cachedUint8Memory0;
56
+ }
57
+
58
+ function getStringFromWasm0(ptr, len) {
59
+ ptr = ptr >>> 0;
60
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
61
+ }
62
+
63
+ function addHeapObject(obj) {
64
+ if (heap_next === heap.length) heap.push(heap.length + 1);
65
+ const idx = heap_next;
66
+ heap_next = heap[idx];
67
+
68
+ heap[idx] = obj;
69
+ return idx;
70
+ }
71
+
72
+ let WASM_VECTOR_LEN = 0;
73
+
74
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
75
+
76
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
77
+ ? function (arg, view) {
78
+ return cachedTextEncoder.encodeInto(arg, view);
79
+ }
80
+ : function (arg, view) {
81
+ const buf = cachedTextEncoder.encode(arg);
82
+ view.set(buf);
83
+ return {
84
+ read: arg.length,
85
+ written: buf.length
86
+ };
87
+ });
88
+
89
+ function passStringToWasm0(arg, malloc, realloc) {
90
+
91
+ if (realloc === undefined) {
92
+ const buf = cachedTextEncoder.encode(arg);
93
+ const ptr = malloc(buf.length) >>> 0;
94
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
95
+ WASM_VECTOR_LEN = buf.length;
96
+ return ptr;
97
+ }
98
+
99
+ let len = arg.length;
100
+ let ptr = malloc(len) >>> 0;
101
+
102
+ const mem = getUint8Memory0();
103
+
104
+ let offset = 0;
105
+
106
+ for (; offset < len; offset++) {
107
+ const code = arg.charCodeAt(offset);
108
+ if (code > 0x7F) break;
109
+ mem[ptr + offset] = code;
110
+ }
111
+
112
+ if (offset !== len) {
113
+ if (offset !== 0) {
114
+ arg = arg.slice(offset);
115
+ }
116
+ ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0;
117
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
118
+ const ret = encodeString(arg, view);
119
+
120
+ offset += ret.written;
121
+ }
122
+
123
+ WASM_VECTOR_LEN = offset;
124
+ return ptr;
125
+ }
126
+ /**
127
+ * @param {any} abi
128
+ * @param {any} inputs
129
+ * @param {any} return_value
130
+ * @returns {WitnessMap}
131
+ */
132
+ export function abiEncode(abi, inputs, return_value) {
133
+ try {
134
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
135
+ wasm.abiEncode(retptr, addHeapObject(abi), addHeapObject(inputs), addHeapObject(return_value));
136
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
137
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
138
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
139
+ if (r2) {
140
+ throw takeObject(r1);
141
+ }
142
+ return takeObject(r0);
143
+ } finally {
144
+ wasm.__wbindgen_add_to_stack_pointer(16);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * @param {any} abi
150
+ * @param {WitnessMap} witness_map
151
+ * @returns {any}
152
+ */
153
+ export function abiDecode(abi, witness_map) {
154
+ try {
155
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
+ wasm.abiDecode(retptr, addHeapObject(abi), addHeapObject(witness_map));
157
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
158
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
159
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
160
+ if (r2) {
161
+ throw takeObject(r1);
162
+ }
163
+ return takeObject(r0);
164
+ } finally {
165
+ wasm.__wbindgen_add_to_stack_pointer(16);
166
+ }
167
+ }
168
+
169
+ function handleError(f, args) {
170
+ try {
171
+ return f.apply(this, args);
172
+ } catch (e) {
173
+ wasm.__wbindgen_exn_store(addHeapObject(e));
174
+ }
175
+ }
176
+ function __wbg_adapter_32(arg0, arg1, arg2, arg3) {
177
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h111bd9fa85682cff(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
178
+ }
179
+
180
+ /**
181
+ * A struct representing a Trap
182
+ */
183
+ export class Trap {
184
+
185
+ __destroy_into_raw() {
186
+ const ptr = this.__wbg_ptr;
187
+ this.__wbg_ptr = 0;
188
+
189
+ return ptr;
190
+ }
191
+
192
+ free() {
193
+ const ptr = this.__destroy_into_raw();
194
+ wasm.__wbg_trap_free(ptr);
195
+ }
196
+ /**
197
+ * @returns {Symbol}
198
+ */
199
+ static __wbgd_downcast_token() {
200
+ const ret = wasm.trap___wbgd_downcast_token();
201
+ return takeObject(ret);
202
+ }
203
+ }
204
+
205
+ async function __wbg_load(module, imports) {
206
+ if (typeof Response === 'function' && module instanceof Response) {
207
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
208
+ try {
209
+ return await WebAssembly.instantiateStreaming(module, imports);
210
+
211
+ } catch (e) {
212
+ if (module.headers.get('Content-Type') != 'application/wasm') {
213
+ 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);
214
+
215
+ } else {
216
+ throw e;
217
+ }
218
+ }
219
+ }
220
+
221
+ const bytes = await module.arrayBuffer();
222
+ return await WebAssembly.instantiate(bytes, imports);
223
+
224
+ } else {
225
+ const instance = await WebAssembly.instantiate(module, imports);
226
+
227
+ if (instance instanceof WebAssembly.Instance) {
228
+ return { instance, module };
229
+
230
+ } else {
231
+ return instance;
232
+ }
233
+ }
234
+ }
235
+
236
+ function __wbg_get_imports() {
237
+ const imports = {};
238
+ imports.wbg = {};
239
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
240
+ const obj = getObject(arg1);
241
+ const ret = typeof(obj) === 'number' ? obj : undefined;
242
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
243
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
244
+ };
245
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
246
+ takeObject(arg0);
247
+ };
248
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
249
+ const ret = getStringFromWasm0(arg0, arg1);
250
+ return addHeapObject(ret);
251
+ };
252
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
253
+ const ret = getObject(arg0) === undefined;
254
+ return ret;
255
+ };
256
+ imports.wbg.__wbindgen_is_null = function(arg0) {
257
+ const ret = getObject(arg0) === null;
258
+ return ret;
259
+ };
260
+ imports.wbg.__wbg_new_08bf5b2e92fba7de = function() {
261
+ const ret = new Map();
262
+ return addHeapObject(ret);
263
+ };
264
+ imports.wbg.__wbindgen_number_new = function(arg0) {
265
+ const ret = arg0;
266
+ return addHeapObject(ret);
267
+ };
268
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
269
+ const obj = getObject(arg1);
270
+ const ret = typeof(obj) === 'string' ? obj : undefined;
271
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ var len1 = WASM_VECTOR_LEN;
273
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
274
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
275
+ };
276
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
277
+ const ret = new Error();
278
+ return addHeapObject(ret);
279
+ };
280
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
281
+ const ret = getObject(arg1).stack;
282
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
+ const len1 = WASM_VECTOR_LEN;
284
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
285
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
286
+ };
287
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
288
+ let deferred0_0;
289
+ let deferred0_1;
290
+ try {
291
+ deferred0_0 = arg0;
292
+ deferred0_1 = arg1;
293
+ console.error(getStringFromWasm0(arg0, arg1));
294
+ } finally {
295
+ wasm.__wbindgen_free(deferred0_0, deferred0_1);
296
+ }
297
+ };
298
+ imports.wbg.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) {
299
+ const ret = getObject(arg0).call(getObject(arg1));
300
+ return addHeapObject(ret);
301
+ }, arguments) };
302
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
303
+ const ret = getObject(arg0);
304
+ return addHeapObject(ret);
305
+ };
306
+ imports.wbg.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
307
+ try {
308
+ var state0 = {a: arg1, b: arg2};
309
+ var cb0 = (arg0, arg1) => {
310
+ const a = state0.a;
311
+ state0.a = 0;
312
+ try {
313
+ return __wbg_adapter_32(a, state0.b, arg0, arg1);
314
+ } finally {
315
+ state0.a = a;
316
+ }
317
+ };
318
+ getObject(arg0).forEach(cb0);
319
+ } finally {
320
+ state0.a = state0.b = 0;
321
+ }
322
+ };
323
+ imports.wbg.__wbg_set_da7be7bf0e037b14 = function(arg0, arg1, arg2) {
324
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
325
+ return addHeapObject(ret);
326
+ };
327
+ imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
328
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
329
+ return addHeapObject(ret);
330
+ }, arguments) };
331
+ imports.wbg.__wbg_stringify_d06ad2addc54d51e = function() { return handleError(function (arg0) {
332
+ const ret = JSON.stringify(getObject(arg0));
333
+ return addHeapObject(ret);
334
+ }, arguments) };
335
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
336
+ throw new Error(getStringFromWasm0(arg0, arg1));
337
+ };
338
+ imports.wbg.__wbg_static_accessor_SYMBOL_45d4d15e3c4aeb33 = function() {
339
+ const ret = Symbol;
340
+ return addHeapObject(ret);
341
+ };
342
+ imports.wbg.__wbindgen_is_symbol = function(arg0) {
343
+ const ret = typeof(getObject(arg0)) === 'symbol';
344
+ return ret;
345
+ };
346
+
347
+ return imports;
348
+ }
349
+
350
+ function __wbg_init_memory(imports, maybe_memory) {
351
+
352
+ }
353
+
354
+ function __wbg_finalize_init(instance, module) {
355
+ wasm = instance.exports;
356
+ __wbg_init.__wbindgen_wasm_module = module;
357
+ cachedFloat64Memory0 = null;
358
+ cachedInt32Memory0 = null;
359
+ cachedUint8Memory0 = null;
360
+
361
+
362
+ return wasm;
363
+ }
364
+
365
+ function initSync(module) {
366
+ if (wasm !== undefined) return wasm;
367
+
368
+ const imports = __wbg_get_imports();
369
+
370
+ __wbg_init_memory(imports);
371
+
372
+ if (!(module instanceof WebAssembly.Module)) {
373
+ module = new WebAssembly.Module(module);
374
+ }
375
+
376
+ const instance = new WebAssembly.Instance(module, imports);
377
+
378
+ return __wbg_finalize_init(instance, module);
379
+ }
380
+
381
+ async function __wbg_init(input) {
382
+ if (wasm !== undefined) return wasm;
383
+
384
+ if (typeof input === 'undefined') {
385
+ input = new URL('noirc_abi_wasm_bg.wasm', import.meta.url);
386
+ }
387
+ const imports = __wbg_get_imports();
388
+
389
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
390
+ input = fetch(input);
391
+ }
392
+
393
+ __wbg_init_memory(imports);
394
+
395
+ const { instance, module } = await __wbg_load(await input, imports);
396
+
397
+ return __wbg_finalize_init(instance, module);
398
+ }
399
+
400
+ export { initSync }
401
+ export default __wbg_init;
Binary file
@@ -0,0 +1,17 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function abiEncode(a: number, b: number, c: number, d: number): void;
5
+ export function abiDecode(a: number, b: number, c: number): void;
6
+ export function rust_psm_on_stack(a: number, b: number, c: number, d: number): void;
7
+ export function rust_psm_stack_direction(): number;
8
+ export function rust_psm_stack_pointer(): number;
9
+ export function rust_psm_replace_stack(a: number, b: number, c: number): void;
10
+ export function __wbg_trap_free(a: number): void;
11
+ export function trap___wbgd_downcast_token(): number;
12
+ export function __wbindgen_malloc(a: number): number;
13
+ export function __wbindgen_realloc(a: number, b: number, c: number): number;
14
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
15
+ export function __wbindgen_free(a: number, b: number): void;
16
+ export function __wbindgen_exn_store(a: number): void;
17
+ export function wasm_bindgen__convert__closures__invoke2_mut__h111bd9fa85682cff(a: number, b: number, c: number, d: number): void;