@auditable/privacy-pool-zk-sdk 0.0.2-rc.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,226 +1,37 @@
1
- let wasm;
1
+ /* @ts-self-types="./client_sdk_wasm.d.ts" */
2
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 addHeapObject(obj) {
12
- if (heap_next === heap.length) heap.push(heap.length + 1);
13
- const idx = heap_next;
14
- heap_next = heap[idx];
15
-
16
- heap[idx] = obj;
17
- return idx;
18
- }
19
-
20
- function handleError(f, args) {
21
- try {
22
- return f.apply(this, args);
23
- } catch (e) {
24
- wasm.__wbindgen_export_0(addHeapObject(e));
25
- }
26
- }
27
-
28
- let cachedUint8ArrayMemory0 = null;
29
-
30
- function getUint8ArrayMemory0() {
31
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
32
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
33
- }
34
- return cachedUint8ArrayMemory0;
35
- }
36
-
37
- let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
38
-
39
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
40
-
41
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
42
- let numBytesDecoded = 0;
43
- function decodeText(ptr, len) {
44
- numBytesDecoded += len;
45
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
46
- cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
47
- cachedTextDecoder.decode();
48
- numBytesDecoded = len;
49
- }
50
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
51
- }
52
-
53
- function getStringFromWasm0(ptr, len) {
54
- ptr = ptr >>> 0;
55
- return decodeText(ptr, len);
56
- }
57
-
58
- function dropObject(idx) {
59
- if (idx < 132) return;
60
- heap[idx] = heap_next;
61
- heap_next = idx;
62
- }
63
-
64
- function takeObject(idx) {
65
- const ret = getObject(idx);
66
- dropObject(idx);
67
- return ret;
68
- }
69
-
70
- function isLikeNone(x) {
71
- return x === undefined || x === null;
72
- }
73
-
74
- function debugString(val) {
75
- // primitive types
76
- const type = typeof val;
77
- if (type == 'number' || type == 'boolean' || val == null) {
78
- return `${val}`;
79
- }
80
- if (type == 'string') {
81
- return `"${val}"`;
82
- }
83
- if (type == 'symbol') {
84
- const description = val.description;
85
- if (description == null) {
86
- return 'Symbol';
87
- } else {
88
- return `Symbol(${description})`;
89
- }
90
- }
91
- if (type == 'function') {
92
- const name = val.name;
93
- if (typeof name == 'string' && name.length > 0) {
94
- return `Function(${name})`;
95
- } else {
96
- return 'Function';
97
- }
98
- }
99
- // objects
100
- if (Array.isArray(val)) {
101
- const length = val.length;
102
- let debug = '[';
103
- if (length > 0) {
104
- debug += debugString(val[0]);
105
- }
106
- for(let i = 1; i < length; i++) {
107
- debug += ', ' + debugString(val[i]);
108
- }
109
- debug += ']';
110
- return debug;
111
- }
112
- // Test for built-in
113
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
114
- let className;
115
- if (builtInMatches && builtInMatches.length > 1) {
116
- className = builtInMatches[1];
117
- } else {
118
- // Failed to match the standard '[object ClassName]'
119
- return toString.call(val);
120
- }
121
- if (className == 'Object') {
122
- // we're a user defined class or Object
123
- // JSON.stringify avoids problems with cycles, and is generally much
124
- // easier than looping through ownProperties of `val`.
125
- try {
126
- return 'Object(' + JSON.stringify(val) + ')';
127
- } catch (_) {
128
- return 'Object';
129
- }
130
- }
131
- // errors
132
- if (val instanceof Error) {
133
- return `${val.name}: ${val.message}\n${val.stack}`;
134
- }
135
- // TODO we could test for more things here, like `Set`s and `Map`s.
136
- return className;
137
- }
138
-
139
- let WASM_VECTOR_LEN = 0;
140
-
141
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
142
-
143
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
144
- ? function (arg, view) {
145
- return cachedTextEncoder.encodeInto(arg, view);
146
- }
147
- : function (arg, view) {
148
- const buf = cachedTextEncoder.encode(arg);
149
- view.set(buf);
150
- return {
151
- read: arg.length,
152
- written: buf.length
153
- };
154
- });
155
-
156
- function passStringToWasm0(arg, malloc, realloc) {
157
-
158
- if (realloc === undefined) {
159
- const buf = cachedTextEncoder.encode(arg);
160
- const ptr = malloc(buf.length, 1) >>> 0;
161
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
162
- WASM_VECTOR_LEN = buf.length;
163
- return ptr;
164
- }
165
-
166
- let len = arg.length;
167
- let ptr = malloc(len, 1) >>> 0;
168
-
169
- const mem = getUint8ArrayMemory0();
170
-
171
- let offset = 0;
172
-
173
- for (; offset < len; offset++) {
174
- const code = arg.charCodeAt(offset);
175
- if (code > 0x7F) break;
176
- mem[ptr + offset] = code;
177
- }
178
-
179
- if (offset !== len) {
180
- if (offset !== 0) {
181
- arg = arg.slice(offset);
182
- }
183
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
184
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
185
- const ret = encodeString(arg, view);
186
-
187
- offset += ret.written;
188
- ptr = realloc(ptr, len, offset, 1) >>> 0;
189
- }
190
-
191
- WASM_VECTOR_LEN = offset;
192
- return ptr;
193
- }
194
-
195
- let cachedDataViewMemory0 = null;
196
-
197
- function getDataViewMemory0() {
198
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
199
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
200
- }
201
- return cachedDataViewMemory0;
202
- }
203
3
  /**
204
- * Convert snarkjs public signals JSON to hex bytes for Soroban contract.
205
- * @param {string} public_json
4
+ * Merkle root, path, and coin field strings for the first withdraw leg (JSON → JSON).
5
+ * @param {string} coin_json
6
+ * @param {string} state_json
206
7
  * @returns {string}
207
8
  */
208
- export function publicToHex(public_json) {
209
- let deferred2_0;
210
- let deferred2_1;
9
+ export function buildWithdrawMerkleWitness(coin_json, state_json) {
10
+ let deferred4_0;
11
+ let deferred4_1;
211
12
  try {
212
13
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
213
- const ptr0 = passStringToWasm0(public_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
14
+ const ptr0 = passStringToWasm0(coin_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
214
15
  const len0 = WASM_VECTOR_LEN;
215
- wasm.publicToHex(retptr, ptr0, len0);
16
+ const ptr1 = passStringToWasm0(state_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
17
+ const len1 = WASM_VECTOR_LEN;
18
+ wasm.buildWithdrawMerkleWitness(retptr, ptr0, len0, ptr1, len1);
216
19
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
217
20
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
218
- deferred2_0 = r0;
219
- deferred2_1 = r1;
220
- return getStringFromWasm0(r0, r1);
21
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
22
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
23
+ var ptr3 = r0;
24
+ var len3 = r1;
25
+ if (r3) {
26
+ ptr3 = 0; len3 = 0;
27
+ throw takeObject(r2);
28
+ }
29
+ deferred4_0 = ptr3;
30
+ deferred4_1 = len3;
31
+ return getStringFromWasm0(ptr3, len3);
221
32
  } finally {
222
33
  wasm.__wbindgen_add_to_stack_pointer(16);
223
- wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
34
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
224
35
  }
225
36
  }
226
37
 
@@ -235,7 +46,7 @@ export function calculateNullifierHash(nullifier_decimal) {
235
46
  let deferred3_1;
236
47
  try {
237
48
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
238
- const ptr0 = passStringToWasm0(nullifier_decimal, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
49
+ const ptr0 = passStringToWasm0(nullifier_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
239
50
  const len0 = WASM_VECTOR_LEN;
240
51
  wasm.calculateNullifierHash(retptr, ptr0, len0);
241
52
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -253,54 +64,213 @@ export function calculateNullifierHash(nullifier_decimal) {
253
64
  return getStringFromWasm0(ptr2, len2);
254
65
  } finally {
255
66
  wasm.__wbindgen_add_to_stack_pointer(16);
256
- wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
67
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
257
68
  }
258
69
  }
259
70
 
260
71
  /**
261
- * Generate withdrawal SNARK input from coin and state JSON strings.
262
- * Returns JSON string of SnarkInput.
263
- * @param {string} coin_json
264
- * @param {string} state_json
265
- * @returns {string}
72
+ * UTF-8 seed `SHA256` scalar BabyJubJub `BASE8 * r` (circom `ECDHEphemeralKey`).
73
+ * `x` and `y` are lowercase hex (no `0x`). Bech32 / stealth string: TypeScript `encodeStealthAddress`.
74
+ * @param {string} seed
75
+ * @returns {any}
266
76
  */
267
- export function generateWithdrawalInput(coin_json, state_json) {
268
- let deferred4_0;
269
- let deferred4_1;
77
+ export function ecdhEphemeralPublicKey(seed) {
270
78
  try {
271
79
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
- const ptr0 = passStringToWasm0(coin_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
80
+ const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_export, wasm.__wbindgen_export2);
273
81
  const len0 = WASM_VECTOR_LEN;
274
- const ptr1 = passStringToWasm0(state_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
82
+ wasm.ecdhEphemeralPublicKey(retptr, ptr0, len0);
83
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
84
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
85
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
86
+ if (r2) {
87
+ throw takeObject(r1);
88
+ }
89
+ return takeObject(r0);
90
+ } finally {
91
+ wasm.__wbindgen_add_to_stack_pointer(16);
92
+ }
93
+ }
94
+
95
+ /**
96
+ * 32-byte scalar as 64 hex chars (optional `0x`) → `ecdh_ephemeral_public_key` (no UTF-8 seed hash).
97
+ * @param {string} scalar_hex
98
+ * @returns {any}
99
+ */
100
+ export function ecdhEphemeralPublicKeyFromScalarHex(scalar_hex) {
101
+ try {
102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
103
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
104
+ const len0 = WASM_VECTOR_LEN;
105
+ wasm.ecdhEphemeralPublicKeyFromScalarHex(retptr, ptr0, len0);
106
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
107
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
108
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
109
+ if (r2) {
110
+ throw takeObject(r1);
111
+ }
112
+ return takeObject(r0);
113
+ } finally {
114
+ wasm.__wbindgen_add_to_stack_pointer(16);
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Circuit `ECDH`: `priv * (pub_x, pub_y)` → shared key (`key[0], key[1]` hex).
120
+ * @param {string} priv_hex
121
+ * @param {string} pub_x_hex
122
+ * @param {string} pub_y_hex
123
+ * @returns {any}
124
+ */
125
+ export function ecdhSharedKey(priv_hex, pub_x_hex, pub_y_hex) {
126
+ try {
127
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
128
+ const ptr0 = passStringToWasm0(priv_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
129
+ const len0 = WASM_VECTOR_LEN;
130
+ const ptr1 = passStringToWasm0(pub_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
275
131
  const len1 = WASM_VECTOR_LEN;
276
- wasm.generateWithdrawalInput(retptr, ptr0, len0, ptr1, len1);
132
+ const ptr2 = passStringToWasm0(pub_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
133
+ const len2 = WASM_VECTOR_LEN;
134
+ wasm.ecdhSharedKey(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
277
135
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
278
136
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
279
137
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
280
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
281
- var ptr3 = r0;
282
- var len3 = r1;
283
- if (r3) {
284
- ptr3 = 0; len3 = 0;
285
- throw takeObject(r2);
138
+ if (r2) {
139
+ throw takeObject(r1);
286
140
  }
287
- deferred4_0 = ptr3;
288
- deferred4_1 = len3;
289
- return getStringFromWasm0(ptr3, len3);
141
+ return takeObject(r0);
290
142
  } finally {
291
143
  wasm.__wbindgen_add_to_stack_pointer(16);
292
- wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
293
144
  }
294
145
  }
295
146
 
296
147
  /**
297
- * Generate a new coin with random nullifier and secret.
298
- * Returns JSON: { coin: { value, nullifier, secret, commitment }, commitment_hex }
148
+ * Generate a new coin with random nullifier, secret, and shared-secret field elements.
149
+ * `amount` is stroops (u64); JS passes `bigint`.
150
+ * `asset_hi_decimal` / `asset_lo_decimal` are decimal Fr strings for the Stellar asset contract id (two limbs).
151
+ * Returns JSON: { coin: { value, nullifier, secret, commitment, asset_hi, asset_lo }, commitment_hex, precommitement_hex }
152
+ * @param {bigint} amount
153
+ * @param {string} asset_hi_decimal
154
+ * @param {string} asset_lo_decimal
299
155
  * @returns {any}
300
156
  */
301
- export function generateCoin() {
302
- const ret = wasm.generateCoin();
303
- return takeObject(ret);
157
+ export function generateCoin(amount, asset_hi_decimal, asset_lo_decimal) {
158
+ try {
159
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
160
+ const ptr0 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
161
+ const len0 = WASM_VECTOR_LEN;
162
+ const ptr1 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
163
+ const len1 = WASM_VECTOR_LEN;
164
+ wasm.generateCoin(retptr, amount, ptr0, len0, ptr1, len1);
165
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
166
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
167
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
168
+ if (r2) {
169
+ throw takeObject(r1);
170
+ }
171
+ return takeObject(r0);
172
+ } finally {
173
+ wasm.__wbindgen_add_to_stack_pointer(16);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * `Poseidon₁(scalar)` secret + fixed ECDH shared coords (hex), matching an aligned deposit witness.
179
+ * @param {string} scalar_hex
180
+ * @param {string} shared_x_hex
181
+ * @param {string} shared_y_hex
182
+ * @param {bigint} amount
183
+ * @param {string} asset_hi_decimal
184
+ * @param {string} asset_lo_decimal
185
+ * @returns {any}
186
+ */
187
+ export function generateCoinForDepositWithSharedHex(scalar_hex, shared_x_hex, shared_y_hex, amount, asset_hi_decimal, asset_lo_decimal) {
188
+ try {
189
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
190
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
191
+ const len0 = WASM_VECTOR_LEN;
192
+ const ptr1 = passStringToWasm0(shared_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
193
+ const len1 = WASM_VECTOR_LEN;
194
+ const ptr2 = passStringToWasm0(shared_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
195
+ const len2 = WASM_VECTOR_LEN;
196
+ const ptr3 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
197
+ const len3 = WASM_VECTOR_LEN;
198
+ const ptr4 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
199
+ const len4 = WASM_VECTOR_LEN;
200
+ wasm.generateCoinForDepositWithSharedHex(retptr, ptr0, len0, ptr1, len1, ptr2, len2, amount, ptr3, len3, ptr4, len4);
201
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
202
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
203
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
204
+ if (r2) {
205
+ throw takeObject(r1);
206
+ }
207
+ return takeObject(r0);
208
+ } finally {
209
+ wasm.__wbindgen_add_to_stack_pointer(16);
210
+ }
211
+ }
212
+
213
+ /**
214
+ * `secret` in coin = `Poseidon255(1)(scalar)` per `deposit.circom`; scalar is 32-byte hex (64 chars, optional `0x`).
215
+ * @param {string} scalar_hex
216
+ * @param {bigint} amount
217
+ * @param {string} asset_hi_decimal
218
+ * @param {string} asset_lo_decimal
219
+ * @returns {any}
220
+ */
221
+ export function generateCoinFromDepositEphemeralScalarHex(scalar_hex, amount, asset_hi_decimal, asset_lo_decimal) {
222
+ try {
223
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
224
+ const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ const ptr1 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
227
+ const len1 = WASM_VECTOR_LEN;
228
+ const ptr2 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
229
+ const len2 = WASM_VECTOR_LEN;
230
+ wasm.generateCoinFromDepositEphemeralScalarHex(retptr, ptr0, len0, amount, ptr1, len1, ptr2, len2);
231
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
232
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
233
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
234
+ if (r2) {
235
+ throw takeObject(r1);
236
+ }
237
+ return takeObject(r0);
238
+ } finally {
239
+ wasm.__wbindgen_add_to_stack_pointer(16);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Same as `generateCoin`, but commitment uses the given ECDH shared key (64-char hex coords from `ecdhSharedKey`); shared coords are not stored in `coin` JSON.
245
+ * @param {string} shared_x_hex
246
+ * @param {string} shared_y_hex
247
+ * @param {bigint} amount
248
+ * @param {string} asset_hi_decimal
249
+ * @param {string} asset_lo_decimal
250
+ * @returns {any}
251
+ */
252
+ export function generateCoinWithSharedSecretHex(shared_x_hex, shared_y_hex, amount, asset_hi_decimal, asset_lo_decimal) {
253
+ try {
254
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
255
+ const ptr0 = passStringToWasm0(shared_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
256
+ const len0 = WASM_VECTOR_LEN;
257
+ const ptr1 = passStringToWasm0(shared_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
258
+ const len1 = WASM_VECTOR_LEN;
259
+ const ptr2 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
260
+ const len2 = WASM_VECTOR_LEN;
261
+ const ptr3 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
262
+ const len3 = WASM_VECTOR_LEN;
263
+ wasm.generateCoinWithSharedSecretHex(retptr, ptr0, len0, ptr1, len1, amount, ptr2, len2, ptr3, len3);
264
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
265
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
266
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
267
+ if (r2) {
268
+ throw takeObject(r1);
269
+ }
270
+ return takeObject(r0);
271
+ } finally {
272
+ wasm.__wbindgen_add_to_stack_pointer(16);
273
+ }
304
274
  }
305
275
 
306
276
  /**
@@ -313,7 +283,7 @@ export function proofToHex(proof_json) {
313
283
  let deferred2_1;
314
284
  try {
315
285
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
316
- const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
286
+ const ptr0 = passStringToWasm0(proof_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
317
287
  const len0 = WASM_VECTOR_LEN;
318
288
  wasm.proofToHex(retptr, ptr0, len0);
319
289
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -323,202 +293,341 @@ export function proofToHex(proof_json) {
323
293
  return getStringFromWasm0(r0, r1);
324
294
  } finally {
325
295
  wasm.__wbindgen_add_to_stack_pointer(16);
326
- wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
296
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Convert snarkjs public signals JSON to hex bytes for Soroban contract.
302
+ * @param {string} public_json
303
+ * @returns {string}
304
+ */
305
+ export function publicToHex(public_json) {
306
+ let deferred2_0;
307
+ let deferred2_1;
308
+ try {
309
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
310
+ const ptr0 = passStringToWasm0(public_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
311
+ const len0 = WASM_VECTOR_LEN;
312
+ wasm.publicToHex(retptr, ptr0, len0);
313
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
+ deferred2_0 = r0;
316
+ deferred2_1 = r1;
317
+ return getStringFromWasm0(r0, r1);
318
+ } finally {
319
+ wasm.__wbindgen_add_to_stack_pointer(16);
320
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
321
+ }
322
+ }
323
+
324
+ function __wbg_get_imports() {
325
+ const import0 = {
326
+ __proto__: null,
327
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
328
+ const ret = String(getObject(arg1));
329
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
330
+ const len1 = WASM_VECTOR_LEN;
331
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
332
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
333
+ },
334
+ __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
335
+ const ret = typeof(getObject(arg0)) === 'function';
336
+ return ret;
337
+ },
338
+ __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
339
+ const val = getObject(arg0);
340
+ const ret = typeof(val) === 'object' && val !== null;
341
+ return ret;
342
+ },
343
+ __wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
344
+ const ret = typeof(getObject(arg0)) === 'string';
345
+ return ret;
346
+ },
347
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
348
+ const ret = getObject(arg0) === undefined;
349
+ return ret;
350
+ },
351
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
352
+ throw new Error(getStringFromWasm0(arg0, arg1));
353
+ },
354
+ __wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
355
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
356
+ return addHeapObject(ret);
357
+ }, arguments); },
358
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
359
+ const ret = getObject(arg0).crypto;
360
+ return addHeapObject(ret);
361
+ },
362
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
363
+ getObject(arg0).getRandomValues(getObject(arg1));
364
+ }, arguments); },
365
+ __wbg_length_ea16607d7b61445b: function(arg0) {
366
+ const ret = getObject(arg0).length;
367
+ return ret;
368
+ },
369
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
370
+ const ret = getObject(arg0).msCrypto;
371
+ return addHeapObject(ret);
372
+ },
373
+ __wbg_new_ab79df5bd7c26067: function() {
374
+ const ret = new Object();
375
+ return addHeapObject(ret);
376
+ },
377
+ __wbg_new_with_length_825018a1616e9e55: function(arg0) {
378
+ const ret = new Uint8Array(arg0 >>> 0);
379
+ return addHeapObject(ret);
380
+ },
381
+ __wbg_node_84ea875411254db1: function(arg0) {
382
+ const ret = getObject(arg0).node;
383
+ return addHeapObject(ret);
384
+ },
385
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
386
+ const ret = getObject(arg0).process;
387
+ return addHeapObject(ret);
388
+ },
389
+ __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
390
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
391
+ },
392
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
393
+ getObject(arg0).randomFillSync(takeObject(arg1));
394
+ }, arguments); },
395
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
396
+ const ret = module.require;
397
+ return addHeapObject(ret);
398
+ }, arguments); },
399
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
400
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
401
+ },
402
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
403
+ const ret = typeof global === 'undefined' ? null : global;
404
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
405
+ },
406
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
407
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
408
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
409
+ },
410
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
411
+ const ret = typeof self === 'undefined' ? null : self;
412
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
413
+ },
414
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
415
+ const ret = typeof window === 'undefined' ? null : window;
416
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
417
+ },
418
+ __wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
419
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
420
+ return addHeapObject(ret);
421
+ },
422
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
423
+ const ret = getObject(arg0).versions;
424
+ return addHeapObject(ret);
425
+ },
426
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
427
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
428
+ const ret = getArrayU8FromWasm0(arg0, arg1);
429
+ return addHeapObject(ret);
430
+ },
431
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
432
+ // Cast intrinsic for `Ref(String) -> Externref`.
433
+ const ret = getStringFromWasm0(arg0, arg1);
434
+ return addHeapObject(ret);
435
+ },
436
+ __wbindgen_object_clone_ref: function(arg0) {
437
+ const ret = getObject(arg0);
438
+ return addHeapObject(ret);
439
+ },
440
+ __wbindgen_object_drop_ref: function(arg0) {
441
+ takeObject(arg0);
442
+ },
443
+ };
444
+ return {
445
+ __proto__: null,
446
+ "./client_sdk_wasm_bg.js": import0,
447
+ };
448
+ }
449
+
450
+ function addHeapObject(obj) {
451
+ if (heap_next === heap.length) heap.push(heap.length + 1);
452
+ const idx = heap_next;
453
+ heap_next = heap[idx];
454
+
455
+ heap[idx] = obj;
456
+ return idx;
457
+ }
458
+
459
+ function dropObject(idx) {
460
+ if (idx < 1028) return;
461
+ heap[idx] = heap_next;
462
+ heap_next = idx;
463
+ }
464
+
465
+ function getArrayU8FromWasm0(ptr, len) {
466
+ ptr = ptr >>> 0;
467
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
468
+ }
469
+
470
+ let cachedDataViewMemory0 = null;
471
+ function getDataViewMemory0() {
472
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
473
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
474
+ }
475
+ return cachedDataViewMemory0;
476
+ }
477
+
478
+ function getStringFromWasm0(ptr, len) {
479
+ ptr = ptr >>> 0;
480
+ return decodeText(ptr, len);
481
+ }
482
+
483
+ let cachedUint8ArrayMemory0 = null;
484
+ function getUint8ArrayMemory0() {
485
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
486
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
487
+ }
488
+ return cachedUint8ArrayMemory0;
489
+ }
490
+
491
+ function getObject(idx) { return heap[idx]; }
492
+
493
+ function handleError(f, args) {
494
+ try {
495
+ return f.apply(this, args);
496
+ } catch (e) {
497
+ wasm.__wbindgen_export3(addHeapObject(e));
498
+ }
499
+ }
500
+
501
+ let heap = new Array(1024).fill(undefined);
502
+ heap.push(undefined, null, true, false);
503
+
504
+ let heap_next = heap.length;
505
+
506
+ function isLikeNone(x) {
507
+ return x === undefined || x === null;
508
+ }
509
+
510
+ function passStringToWasm0(arg, malloc, realloc) {
511
+ if (realloc === undefined) {
512
+ const buf = cachedTextEncoder.encode(arg);
513
+ const ptr = malloc(buf.length, 1) >>> 0;
514
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
515
+ WASM_VECTOR_LEN = buf.length;
516
+ return ptr;
517
+ }
518
+
519
+ let len = arg.length;
520
+ let ptr = malloc(len, 1) >>> 0;
521
+
522
+ const mem = getUint8ArrayMemory0();
523
+
524
+ let offset = 0;
525
+
526
+ for (; offset < len; offset++) {
527
+ const code = arg.charCodeAt(offset);
528
+ if (code > 0x7F) break;
529
+ mem[ptr + offset] = code;
327
530
  }
531
+ if (offset !== len) {
532
+ if (offset !== 0) {
533
+ arg = arg.slice(offset);
534
+ }
535
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
536
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
537
+ const ret = cachedTextEncoder.encodeInto(arg, view);
538
+
539
+ offset += ret.written;
540
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
541
+ }
542
+
543
+ WASM_VECTOR_LEN = offset;
544
+ return ptr;
328
545
  }
329
546
 
330
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
547
+ function takeObject(idx) {
548
+ const ret = getObject(idx);
549
+ dropObject(idx);
550
+ return ret;
551
+ }
552
+
553
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
554
+ cachedTextDecoder.decode();
555
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
556
+ let numBytesDecoded = 0;
557
+ function decodeText(ptr, len) {
558
+ numBytesDecoded += len;
559
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
560
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
561
+ cachedTextDecoder.decode();
562
+ numBytesDecoded = len;
563
+ }
564
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
565
+ }
566
+
567
+ const cachedTextEncoder = new TextEncoder();
568
+
569
+ if (!('encodeInto' in cachedTextEncoder)) {
570
+ cachedTextEncoder.encodeInto = function (arg, view) {
571
+ const buf = cachedTextEncoder.encode(arg);
572
+ view.set(buf);
573
+ return {
574
+ read: arg.length,
575
+ written: buf.length
576
+ };
577
+ };
578
+ }
579
+
580
+ let WASM_VECTOR_LEN = 0;
581
+
582
+ let wasmModule, wasm;
583
+ function __wbg_finalize_init(instance, module) {
584
+ wasm = instance.exports;
585
+ wasmModule = module;
586
+ cachedDataViewMemory0 = null;
587
+ cachedUint8ArrayMemory0 = null;
588
+ return wasm;
589
+ }
331
590
 
332
591
  async function __wbg_load(module, imports) {
333
592
  if (typeof Response === 'function' && module instanceof Response) {
334
593
  if (typeof WebAssembly.instantiateStreaming === 'function') {
335
594
  try {
336
595
  return await WebAssembly.instantiateStreaming(module, imports);
337
-
338
596
  } catch (e) {
339
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
597
+ const validResponse = module.ok && expectedResponseType(module.type);
340
598
 
341
599
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
342
600
  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);
343
601
 
344
- } else {
345
- throw e;
346
- }
602
+ } else { throw e; }
347
603
  }
348
604
  }
349
605
 
350
606
  const bytes = await module.arrayBuffer();
351
607
  return await WebAssembly.instantiate(bytes, imports);
352
-
353
608
  } else {
354
609
  const instance = await WebAssembly.instantiate(module, imports);
355
610
 
356
611
  if (instance instanceof WebAssembly.Instance) {
357
612
  return { instance, module };
358
-
359
613
  } else {
360
614
  return instance;
361
615
  }
362
616
  }
363
- }
364
-
365
- function __wbg_get_imports() {
366
- const imports = {};
367
- imports.wbg = {};
368
- imports.wbg.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
369
- const ret = getObject(arg0).buffer;
370
- return addHeapObject(ret);
371
- };
372
- imports.wbg.__wbg_call_f2db6205e5c51dc8 = function() { return handleError(function (arg0, arg1, arg2) {
373
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
374
- return addHeapObject(ret);
375
- }, arguments) };
376
- imports.wbg.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
377
- const ret = getObject(arg0).call(getObject(arg1));
378
- return addHeapObject(ret);
379
- }, arguments) };
380
- imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
381
- const ret = getObject(arg0).crypto;
382
- return addHeapObject(ret);
383
- };
384
- imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
385
- getObject(arg0).getRandomValues(getObject(arg1));
386
- }, arguments) };
387
- imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
388
- const ret = getObject(arg0).msCrypto;
389
- return addHeapObject(ret);
390
- };
391
- imports.wbg.__wbg_new_07b483f72211fd66 = function() {
392
- const ret = new Object();
393
- return addHeapObject(ret);
394
- };
395
- imports.wbg.__wbg_new_e52b3efaaa774f96 = function(arg0) {
396
- const ret = new Uint8Array(getObject(arg0));
397
- return addHeapObject(ret);
398
- };
399
- imports.wbg.__wbg_newnoargs_ff528e72d35de39a = function(arg0, arg1) {
400
- const ret = new Function(getStringFromWasm0(arg0, arg1));
401
- return addHeapObject(ret);
402
- };
403
- imports.wbg.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8 = function(arg0, arg1, arg2) {
404
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
405
- return addHeapObject(ret);
406
- };
407
- imports.wbg.__wbg_newwithlength_08f872dc1e3ada2e = function(arg0) {
408
- const ret = new Uint8Array(arg0 >>> 0);
409
- return addHeapObject(ret);
410
- };
411
- imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
412
- const ret = getObject(arg0).node;
413
- return addHeapObject(ret);
414
- };
415
- imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
416
- const ret = getObject(arg0).process;
417
- return addHeapObject(ret);
418
- };
419
- imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
420
- getObject(arg0).randomFillSync(takeObject(arg1));
421
- }, arguments) };
422
- imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
423
- const ret = module.require;
424
- return addHeapObject(ret);
425
- }, arguments) };
426
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
427
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
428
- };
429
- imports.wbg.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
430
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
431
- };
432
- imports.wbg.__wbg_static_accessor_GLOBAL_487c52c58d65314d = function() {
433
- const ret = typeof global === 'undefined' ? null : global;
434
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
435
- };
436
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291 = function() {
437
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
438
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
439
- };
440
- imports.wbg.__wbg_static_accessor_SELF_78c9e3071b912620 = function() {
441
- const ret = typeof self === 'undefined' ? null : self;
442
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
443
- };
444
- imports.wbg.__wbg_static_accessor_WINDOW_a093d21393777366 = function() {
445
- const ret = typeof window === 'undefined' ? null : window;
446
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
447
- };
448
- imports.wbg.__wbg_subarray_dd4ade7d53bd8e26 = function(arg0, arg1, arg2) {
449
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
450
- return addHeapObject(ret);
451
- };
452
- imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
453
- const ret = getObject(arg0).versions;
454
- return addHeapObject(ret);
455
- };
456
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
457
- const ret = debugString(getObject(arg1));
458
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
459
- const len1 = WASM_VECTOR_LEN;
460
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
461
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
462
- };
463
- imports.wbg.__wbindgen_is_function = function(arg0) {
464
- const ret = typeof(getObject(arg0)) === 'function';
465
- return ret;
466
- };
467
- imports.wbg.__wbindgen_is_object = function(arg0) {
468
- const val = getObject(arg0);
469
- const ret = typeof(val) === 'object' && val !== null;
470
- return ret;
471
- };
472
- imports.wbg.__wbindgen_is_string = function(arg0) {
473
- const ret = typeof(getObject(arg0)) === 'string';
474
- return ret;
475
- };
476
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
477
- const ret = getObject(arg0) === undefined;
478
- return ret;
479
- };
480
- imports.wbg.__wbindgen_memory = function() {
481
- const ret = wasm.memory;
482
- return addHeapObject(ret);
483
- };
484
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
485
- const ret = getObject(arg0);
486
- return addHeapObject(ret);
487
- };
488
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
489
- takeObject(arg0);
490
- };
491
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
492
- const ret = getStringFromWasm0(arg0, arg1);
493
- return addHeapObject(ret);
494
- };
495
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
496
- throw new Error(getStringFromWasm0(arg0, arg1));
497
- };
498
-
499
- return imports;
500
- }
501
-
502
- function __wbg_init_memory(imports, memory) {
503
617
 
504
- }
505
-
506
- function __wbg_finalize_init(instance, module) {
507
- wasm = instance.exports;
508
- __wbg_init.__wbindgen_wasm_module = module;
509
- cachedDataViewMemory0 = null;
510
- cachedUint8ArrayMemory0 = null;
511
-
512
-
513
-
514
- return wasm;
618
+ function expectedResponseType(type) {
619
+ switch (type) {
620
+ case 'basic': case 'cors': case 'default': return true;
621
+ }
622
+ return false;
623
+ }
515
624
  }
516
625
 
517
626
  function initSync(module) {
518
627
  if (wasm !== undefined) return wasm;
519
628
 
520
629
 
521
- if (typeof module !== 'undefined') {
630
+ if (module !== undefined) {
522
631
  if (Object.getPrototypeOf(module) === Object.prototype) {
523
632
  ({module} = module)
524
633
  } else {
@@ -527,15 +636,10 @@ function initSync(module) {
527
636
  }
528
637
 
529
638
  const imports = __wbg_get_imports();
530
-
531
- __wbg_init_memory(imports);
532
-
533
639
  if (!(module instanceof WebAssembly.Module)) {
534
640
  module = new WebAssembly.Module(module);
535
641
  }
536
-
537
642
  const instance = new WebAssembly.Instance(module, imports);
538
-
539
643
  return __wbg_finalize_init(instance, module);
540
644
  }
541
645
 
@@ -543,7 +647,7 @@ async function __wbg_init(module_or_path) {
543
647
  if (wasm !== undefined) return wasm;
544
648
 
545
649
 
546
- if (typeof module_or_path !== 'undefined') {
650
+ if (module_or_path !== undefined) {
547
651
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
548
652
  ({module_or_path} = module_or_path)
549
653
  } else {
@@ -551,7 +655,7 @@ async function __wbg_init(module_or_path) {
551
655
  }
552
656
  }
553
657
 
554
- if (typeof module_or_path === 'undefined') {
658
+ if (module_or_path === undefined) {
555
659
  module_or_path = new URL('client_sdk_wasm_bg.wasm', import.meta.url);
556
660
  }
557
661
  const imports = __wbg_get_imports();
@@ -560,12 +664,9 @@ async function __wbg_init(module_or_path) {
560
664
  module_or_path = fetch(module_or_path);
561
665
  }
562
666
 
563
- __wbg_init_memory(imports);
564
-
565
667
  const { instance, module } = await __wbg_load(await module_or_path, imports);
566
668
 
567
669
  return __wbg_finalize_init(instance, module);
568
670
  }
569
671
 
570
- export { initSync };
571
- export default __wbg_init;
672
+ export { initSync, __wbg_init as default };