@provablehq/wasm-account-tools 0.1.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.
@@ -0,0 +1,671 @@
1
+ /* @ts-self-types="./index.d.ts" */
2
+
3
+ /**
4
+ * Public address of an Aleo account.
5
+ */
6
+ class Address {
7
+ static __wrap(ptr) {
8
+ ptr = ptr >>> 0;
9
+ const obj = Object.create(Address.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ AddressFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
13
+ }
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ AddressFinalization.unregister(this);
18
+ return ptr;
19
+ }
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_address_free(ptr, 0);
23
+ }
24
+ /**
25
+ * Create an address from a little-endian boolean bit array.
26
+ *
27
+ * @param {Array} bits Little-endian boolean array representing the bits of the address.
28
+ * @returns {Address} The address object.
29
+ * @param {Array<any>} bits
30
+ * @returns {Address}
31
+ */
32
+ static fromBitsLe(bits) {
33
+ try {
34
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
35
+ wasm.address_fromBitsLe(retptr, addHeapObject(bits));
36
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
37
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
38
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
39
+ if (r2) {
40
+ throw takeObject(r1);
41
+ }
42
+ return Address.__wrap(r0);
43
+ } finally {
44
+ wasm.__wbindgen_add_to_stack_pointer(16);
45
+ }
46
+ }
47
+ /**
48
+ * Create an address from a Uint8Array of little-endian bytes.
49
+ *
50
+ * @param {Uint8Array} bytes Little-endian byte array representing the address.
51
+ * @returns {Address} The address object.
52
+ * @param {Uint8Array} bytes
53
+ * @returns {Address}
54
+ */
55
+ static fromBytesLe(bytes) {
56
+ try {
57
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
58
+ wasm.address_fromBytesLe(retptr, addHeapObject(bytes));
59
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
60
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
61
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
62
+ if (r2) {
63
+ throw takeObject(r1);
64
+ }
65
+ return Address.__wrap(r0);
66
+ } finally {
67
+ wasm.__wbindgen_add_to_stack_pointer(16);
68
+ }
69
+ }
70
+ /**
71
+ * Create an address from an array of Field elements.
72
+ *
73
+ * @param {Array} fields An array of Field objects.
74
+ * @returns {Address} The address object.
75
+ * @param {Array<any>} fields
76
+ * @returns {Address}
77
+ */
78
+ static fromFields(fields) {
79
+ try {
80
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
81
+ wasm.address_fromFields(retptr, addHeapObject(fields));
82
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
83
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
84
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
85
+ if (r2) {
86
+ throw takeObject(r1);
87
+ }
88
+ return Address.__wrap(r0);
89
+ } finally {
90
+ wasm.__wbindgen_add_to_stack_pointer(16);
91
+ }
92
+ }
93
+ /**
94
+ * Derive the address corresponding to a program ID.
95
+ *
96
+ * The encoding matches the snarkVM convention: each identifier component (name and network)
97
+ * is encoded as a field element by packing the UTF-8 bytes into a little-endian bit array,
98
+ * then the pair is hashed to a group element using Poseidon4 with domain "AleoPoseidon4".
99
+ * This is network-agnostic since both MainnetV0 and TestnetV0 use identical Poseidon
100
+ * parameters over the same curve.
101
+ *
102
+ * @param {string} program_id The program ID string (e.g. "credits.aleo").
103
+ * @returns {Address} The address corresponding to the program ID.
104
+ * @param {string} program_id
105
+ * @returns {Address}
106
+ */
107
+ static fromProgramId(program_id) {
108
+ try {
109
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
110
+ const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
111
+ const len0 = WASM_VECTOR_LEN;
112
+ wasm.address_fromProgramId(retptr, ptr0, len0);
113
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
114
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
115
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
116
+ if (r2) {
117
+ throw takeObject(r1);
118
+ }
119
+ return Address.__wrap(r0);
120
+ } finally {
121
+ wasm.__wbindgen_add_to_stack_pointer(16);
122
+ }
123
+ }
124
+ /**
125
+ * Create an Aleo address from its string representation.
126
+ *
127
+ * @param {string} address String representation of an address.
128
+ * @returns {Address} The address object.
129
+ * @param {string} address
130
+ * @returns {Address}
131
+ */
132
+ static from_string(address) {
133
+ try {
134
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
135
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ wasm.address_from_string(retptr, ptr0, len0);
138
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
139
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
140
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
141
+ if (r2) {
142
+ throw takeObject(r1);
143
+ }
144
+ return Address.__wrap(r0);
145
+ } finally {
146
+ wasm.__wbindgen_add_to_stack_pointer(16);
147
+ }
148
+ }
149
+ /**
150
+ * Check if the input is a valid Aleo address.
151
+ *
152
+ * @param {string | Uint8Array} address Either a string representation or a little-endian
153
+ * Uint8Array of bytes.
154
+ * @returns {boolean} True if the input is a valid address, false otherwise.
155
+ * @param {any} address
156
+ * @returns {boolean}
157
+ */
158
+ static isValid(address) {
159
+ const ret = wasm.address_isValid(addHeapObject(address));
160
+ return ret !== 0;
161
+ }
162
+ /**
163
+ * Get the little-endian boolean bit array representation of the address.
164
+ *
165
+ * @returns {Array} Little-endian boolean bit array.
166
+ * @returns {Array<any>}
167
+ */
168
+ toBitsLe() {
169
+ const ret = wasm.address_toBitsLe(this.__wbg_ptr);
170
+ return takeObject(ret);
171
+ }
172
+ /**
173
+ * Get the little-endian byte array representation of the address.
174
+ *
175
+ * @returns {Uint8Array} Little-endian byte array of the address.
176
+ * @returns {Uint8Array}
177
+ */
178
+ toBytesLe() {
179
+ try {
180
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
181
+ wasm.address_toBytesLe(retptr, this.__wbg_ptr);
182
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
183
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
184
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
185
+ if (r2) {
186
+ throw takeObject(r1);
187
+ }
188
+ return takeObject(r0);
189
+ } finally {
190
+ wasm.__wbindgen_add_to_stack_pointer(16);
191
+ }
192
+ }
193
+ /**
194
+ * Get the field element array representation of the address.
195
+ *
196
+ * @returns {Array} Array of Field objects.
197
+ * @returns {Array<any>}
198
+ */
199
+ toFields() {
200
+ try {
201
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
202
+ wasm.address_toFields(retptr, this.__wbg_ptr);
203
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
204
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
205
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
206
+ if (r2) {
207
+ throw takeObject(r1);
208
+ }
209
+ return takeObject(r0);
210
+ } finally {
211
+ wasm.__wbindgen_add_to_stack_pointer(16);
212
+ }
213
+ }
214
+ /**
215
+ * Get the string representation of the address.
216
+ *
217
+ * @returns {string} String representation of the address.
218
+ * @returns {string}
219
+ */
220
+ to_string() {
221
+ let deferred1_0;
222
+ let deferred1_1;
223
+ try {
224
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
225
+ wasm.address_to_string(retptr, this.__wbg_ptr);
226
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
227
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
228
+ deferred1_0 = r0;
229
+ deferred1_1 = r1;
230
+ return getStringFromWasm0(r0, r1);
231
+ } finally {
232
+ wasm.__wbindgen_add_to_stack_pointer(16);
233
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
234
+ }
235
+ }
236
+ }
237
+ if (Symbol.dispose) Address.prototype[Symbol.dispose] = Address.prototype.free;
238
+
239
+ /**
240
+ * Field element, exposed for use with Address field serialization.
241
+ */
242
+ class Field {
243
+ static __wrap(ptr) {
244
+ ptr = ptr >>> 0;
245
+ const obj = Object.create(Field.prototype);
246
+ obj.__wbg_ptr = ptr;
247
+ FieldFinalization.register(obj, obj.__wbg_ptr, obj);
248
+ return obj;
249
+ }
250
+ static __unwrap(jsValue) {
251
+ if (!(jsValue instanceof Field)) {
252
+ return 0;
253
+ }
254
+ return jsValue.__destroy_into_raw();
255
+ }
256
+ __destroy_into_raw() {
257
+ const ptr = this.__wbg_ptr;
258
+ this.__wbg_ptr = 0;
259
+ FieldFinalization.unregister(this);
260
+ return ptr;
261
+ }
262
+ free() {
263
+ const ptr = this.__destroy_into_raw();
264
+ wasm.__wbg_field_free(ptr, 0);
265
+ }
266
+ /**
267
+ * Create a field element from a Uint8Array of little-endian bytes.
268
+ *
269
+ * @param {Uint8Array} bytes Little-endian byte array.
270
+ * @returns {Field} The field element.
271
+ * @param {Uint8Array} bytes
272
+ * @returns {Field}
273
+ */
274
+ static fromBytesLe(bytes) {
275
+ try {
276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
+ wasm.field_fromBytesLe(retptr, addBorrowedObject(bytes));
278
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
281
+ if (r2) {
282
+ throw takeObject(r1);
283
+ }
284
+ return Field.__wrap(r0);
285
+ } finally {
286
+ wasm.__wbindgen_add_to_stack_pointer(16);
287
+ heap[stack_pointer++] = undefined;
288
+ }
289
+ }
290
+ /**
291
+ * Creates a field element from its string representation.
292
+ *
293
+ * @param {string} field String representation of a field element.
294
+ * @returns {Field} The field element.
295
+ * @param {string} field
296
+ * @returns {Field}
297
+ */
298
+ static fromString(field) {
299
+ try {
300
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
301
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
302
+ const len0 = WASM_VECTOR_LEN;
303
+ wasm.field_fromString(retptr, ptr0, len0);
304
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
305
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
306
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
307
+ if (r2) {
308
+ throw takeObject(r1);
309
+ }
310
+ return Field.__wrap(r0);
311
+ } finally {
312
+ wasm.__wbindgen_add_to_stack_pointer(16);
313
+ }
314
+ }
315
+ /**
316
+ * Encode the field element as a Uint8Array of little-endian bytes.
317
+ *
318
+ * @returns {Uint8Array} Little-endian byte array of the field element.
319
+ * @returns {Uint8Array}
320
+ */
321
+ toBytesLe() {
322
+ try {
323
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
324
+ wasm.field_toBytesLe(retptr, this.__wbg_ptr);
325
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
326
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
327
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
328
+ if (r2) {
329
+ throw takeObject(r1);
330
+ }
331
+ return takeObject(r0);
332
+ } finally {
333
+ wasm.__wbindgen_add_to_stack_pointer(16);
334
+ }
335
+ }
336
+ /**
337
+ * Returns the string representation of the field element.
338
+ *
339
+ * @returns {string} String representation of the field element.
340
+ * @returns {string}
341
+ */
342
+ toString() {
343
+ let deferred1_0;
344
+ let deferred1_1;
345
+ try {
346
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
+ wasm.field_toString(retptr, this.__wbg_ptr);
348
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
+ deferred1_0 = r0;
351
+ deferred1_1 = r1;
352
+ return getStringFromWasm0(r0, r1);
353
+ } finally {
354
+ wasm.__wbindgen_add_to_stack_pointer(16);
355
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
356
+ }
357
+ }
358
+ }
359
+ if (Symbol.dispose) Field.prototype[Symbol.dispose] = Field.prototype.free;
360
+
361
+ function __wbg_get_imports() {
362
+ const import0 = {
363
+ __proto__: null,
364
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
365
+ const v = getObject(arg0);
366
+ const ret = typeof(v) === 'boolean' ? v : undefined;
367
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
368
+ },
369
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
370
+ const obj = getObject(arg1);
371
+ const ret = typeof(obj) === 'string' ? obj : undefined;
372
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
373
+ var len1 = WASM_VECTOR_LEN;
374
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
375
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
376
+ },
377
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
378
+ throw new Error(getStringFromWasm0(arg0, arg1));
379
+ },
380
+ __wbg_field_new: function(arg0) {
381
+ const ret = Field.__wrap(arg0);
382
+ return addHeapObject(ret);
383
+ },
384
+ __wbg_field_unwrap: function(arg0) {
385
+ const ret = Field.__unwrap(getObject(arg0));
386
+ return ret;
387
+ },
388
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
389
+ const ret = getObject(arg0)[arg1 >>> 0];
390
+ return addHeapObject(ret);
391
+ },
392
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
393
+ let result;
394
+ try {
395
+ result = getObject(arg0) instanceof Uint8Array;
396
+ } catch (_) {
397
+ result = false;
398
+ }
399
+ const ret = result;
400
+ return ret;
401
+ },
402
+ __wbg_length_32ed9a279acd054c: function(arg0) {
403
+ const ret = getObject(arg0).length;
404
+ return ret;
405
+ },
406
+ __wbg_length_35a7bace40f36eac: function(arg0) {
407
+ const ret = getObject(arg0).length;
408
+ return ret;
409
+ },
410
+ __wbg_new_3eb36ae241fe6f44: function() {
411
+ const ret = new Array();
412
+ return addHeapObject(ret);
413
+ },
414
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
415
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
416
+ return addHeapObject(ret);
417
+ },
418
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
419
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
420
+ },
421
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
422
+ const ret = getObject(arg0).push(getObject(arg1));
423
+ return ret;
424
+ },
425
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
426
+ // Cast intrinsic for `Ref(String) -> Externref`.
427
+ const ret = getStringFromWasm0(arg0, arg1);
428
+ return addHeapObject(ret);
429
+ },
430
+ __wbindgen_object_drop_ref: function(arg0) {
431
+ takeObject(arg0);
432
+ },
433
+ };
434
+ return {
435
+ __proto__: null,
436
+ "./index_bg.js": import0,
437
+ };
438
+ }
439
+
440
+ const AddressFinalization = (typeof FinalizationRegistry === 'undefined')
441
+ ? { register: () => {}, unregister: () => {} }
442
+ : new FinalizationRegistry(ptr => wasm.__wbg_address_free(ptr >>> 0, 1));
443
+ const FieldFinalization = (typeof FinalizationRegistry === 'undefined')
444
+ ? { register: () => {}, unregister: () => {} }
445
+ : new FinalizationRegistry(ptr => wasm.__wbg_field_free(ptr >>> 0, 1));
446
+
447
+ function addHeapObject(obj) {
448
+ if (heap_next === heap.length) heap.push(heap.length + 1);
449
+ const idx = heap_next;
450
+ heap_next = heap[idx];
451
+
452
+ heap[idx] = obj;
453
+ return idx;
454
+ }
455
+
456
+ function addBorrowedObject(obj) {
457
+ if (stack_pointer == 1) throw new Error('out of js stack');
458
+ heap[--stack_pointer] = obj;
459
+ return stack_pointer;
460
+ }
461
+
462
+ function dropObject(idx) {
463
+ if (idx < 132) return;
464
+ heap[idx] = heap_next;
465
+ heap_next = idx;
466
+ }
467
+
468
+ function getArrayU8FromWasm0(ptr, len) {
469
+ ptr = ptr >>> 0;
470
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
471
+ }
472
+
473
+ let cachedDataViewMemory0 = null;
474
+ function getDataViewMemory0() {
475
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
476
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
477
+ }
478
+ return cachedDataViewMemory0;
479
+ }
480
+
481
+ function getStringFromWasm0(ptr, len) {
482
+ ptr = ptr >>> 0;
483
+ return decodeText(ptr, len);
484
+ }
485
+
486
+ let cachedUint8ArrayMemory0 = null;
487
+ function getUint8ArrayMemory0() {
488
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
489
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
490
+ }
491
+ return cachedUint8ArrayMemory0;
492
+ }
493
+
494
+ function getObject(idx) { return heap[idx]; }
495
+
496
+ let heap = new Array(128).fill(undefined);
497
+ heap.push(undefined, null, true, false);
498
+
499
+ let heap_next = heap.length;
500
+
501
+ function isLikeNone(x) {
502
+ return x === undefined || x === null;
503
+ }
504
+
505
+ function passStringToWasm0(arg, malloc, realloc) {
506
+ if (realloc === undefined) {
507
+ const buf = cachedTextEncoder.encode(arg);
508
+ const ptr = malloc(buf.length, 1) >>> 0;
509
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
510
+ WASM_VECTOR_LEN = buf.length;
511
+ return ptr;
512
+ }
513
+
514
+ let len = arg.length;
515
+ let ptr = malloc(len, 1) >>> 0;
516
+
517
+ const mem = getUint8ArrayMemory0();
518
+
519
+ let offset = 0;
520
+
521
+ for (; offset < len; offset++) {
522
+ const code = arg.charCodeAt(offset);
523
+ if (code > 0x7F) break;
524
+ mem[ptr + offset] = code;
525
+ }
526
+ if (offset !== len) {
527
+ if (offset !== 0) {
528
+ arg = arg.slice(offset);
529
+ }
530
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
531
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
532
+ const ret = cachedTextEncoder.encodeInto(arg, view);
533
+
534
+ offset += ret.written;
535
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
536
+ }
537
+
538
+ WASM_VECTOR_LEN = offset;
539
+ return ptr;
540
+ }
541
+
542
+ let stack_pointer = 128;
543
+
544
+ function takeObject(idx) {
545
+ const ret = getObject(idx);
546
+ dropObject(idx);
547
+ return ret;
548
+ }
549
+
550
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
551
+ cachedTextDecoder.decode();
552
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
553
+ let numBytesDecoded = 0;
554
+ function decodeText(ptr, len) {
555
+ numBytesDecoded += len;
556
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
557
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
558
+ cachedTextDecoder.decode();
559
+ numBytesDecoded = len;
560
+ }
561
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
562
+ }
563
+
564
+ const cachedTextEncoder = new TextEncoder();
565
+
566
+ if (!('encodeInto' in cachedTextEncoder)) {
567
+ cachedTextEncoder.encodeInto = function (arg, view) {
568
+ const buf = cachedTextEncoder.encode(arg);
569
+ view.set(buf);
570
+ return {
571
+ read: arg.length,
572
+ written: buf.length
573
+ };
574
+ };
575
+ }
576
+
577
+ let WASM_VECTOR_LEN = 0;
578
+
579
+ let wasm;
580
+ function __wbg_finalize_init(instance, module) {
581
+ wasm = instance.exports;
582
+ cachedDataViewMemory0 = null;
583
+ cachedUint8ArrayMemory0 = null;
584
+ return wasm;
585
+ }
586
+
587
+ async function __wbg_load(module, imports) {
588
+ if (typeof Response === 'function' && module instanceof Response) {
589
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
590
+ try {
591
+ return await WebAssembly.instantiateStreaming(module, imports);
592
+ } catch (e) {
593
+ const validResponse = module.ok && expectedResponseType(module.type);
594
+
595
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
596
+ 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);
597
+
598
+ } else { throw e; }
599
+ }
600
+ }
601
+
602
+ const bytes = await module.arrayBuffer();
603
+ return await WebAssembly.instantiate(bytes, imports);
604
+ } else {
605
+ const instance = await WebAssembly.instantiate(module, imports);
606
+
607
+ if (instance instanceof WebAssembly.Instance) {
608
+ return { instance, module };
609
+ } else {
610
+ return instance;
611
+ }
612
+ }
613
+
614
+ function expectedResponseType(type) {
615
+ switch (type) {
616
+ case 'basic': case 'cors': case 'default': return true;
617
+ }
618
+ return false;
619
+ }
620
+ }
621
+
622
+ function initSync(module) {
623
+ if (wasm !== undefined) return wasm;
624
+
625
+
626
+ if (module !== undefined) {
627
+ if (Object.getPrototypeOf(module) === Object.prototype) {
628
+ ({module} = module);
629
+ } else {
630
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
631
+ }
632
+ }
633
+
634
+ const imports = __wbg_get_imports();
635
+ if (!(module instanceof WebAssembly.Module)) {
636
+ module = new WebAssembly.Module(module);
637
+ }
638
+ const instance = new WebAssembly.Instance(module, imports);
639
+ return __wbg_finalize_init(instance);
640
+ }
641
+
642
+ async function __wbg_init(module_or_path) {
643
+ if (wasm !== undefined) return wasm;
644
+
645
+
646
+ if (module_or_path !== undefined) {
647
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
648
+ ({module_or_path} = module_or_path);
649
+ } else {
650
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead');
651
+ }
652
+ }
653
+
654
+
655
+ const imports = __wbg_get_imports();
656
+
657
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
658
+ module_or_path = fetch(module_or_path);
659
+ }
660
+
661
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
662
+
663
+ return __wbg_finalize_init(instance);
664
+ }
665
+
666
+ const module$1 = new URL("wasm_account_tools.wasm", import.meta.url);
667
+
668
+ await __wbg_init({ module_or_path: module$1 });
669
+
670
+ export { Address, Field, initSync };
671
+ //# sourceMappingURL=aleo_wasm_account_tools.js.map