@baerae/zkap-zkp-react-native 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +24 -3
  2. package/ZkapReactNative.podspec +42 -0
  3. package/android/CMakeLists.txt +81 -0
  4. package/android/build.gradle +111 -14
  5. package/android/cpp-adapter.cpp +43 -0
  6. package/android/libs/arm64-v8a/libzkap_uniffi_bindings.so +0 -0
  7. package/android/libs/x86_64/libzkap_uniffi_bindings.so +0 -0
  8. package/android/proguard-rules.pro +2 -0
  9. package/android/src/main/AndroidManifest.xml +5 -0
  10. package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativeModule.kt +51 -0
  11. package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativePackage.kt +34 -0
  12. package/cpp/baerae-zkap-react-native.cpp +17 -0
  13. package/cpp/baerae-zkap-react-native.h +15 -0
  14. package/cpp/generated/zkap_uniffi_bindings.cpp +2154 -0
  15. package/cpp/generated/zkap_uniffi_bindings.hpp +66 -0
  16. package/ios/ZkapReactNative.h +16 -0
  17. package/ios/ZkapReactNative.mm +412 -0
  18. package/ios/ZkapZkp.xcframework/Info.plist +5 -5
  19. package/ios/ZkapZkp.xcframework/ios-arm64/libzkap_uniffi_bindings.a +0 -0
  20. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/libzkap_uniffi_bindings.a +0 -0
  21. package/package.json +37 -16
  22. package/src/NativeZkapReactNative.ts +11 -0
  23. package/src/generated/zkap_uniffi_bindings-ffi.ts +150 -0
  24. package/src/generated/zkap_uniffi_bindings.ts +1015 -0
  25. package/src/index.ts +250 -47
  26. package/ubrn.config.yaml +13 -0
  27. package/android/libs/armeabi-v7a/libzkap_uniffi_bindings.so +0 -0
  28. package/android/src/main/java/expo/modules/zkap/ZkapSdkModule.kt +0 -153
  29. package/android/src/main/java/uniffi/zkap_uniffi_bindings/zkap_uniffi_bindings.kt +0 -1566
  30. package/expo-module.config.json +0 -9
  31. package/ios/ZkapSdkModule.podspec +0 -35
  32. package/ios/ZkapSdkModule.swift +0 -147
  33. package/ios/uniffi/zkap_uniffi_bindings.swift +0 -1174
  34. package/ios/uniffi/zkap_uniffi_bindingsFFI.h +0 -567
  35. package/ios/uniffi/zkap_uniffi_bindingsFFI.modulemap +0 -7
  36. package/src/artifact-manager.ts +0 -231
@@ -0,0 +1,2154 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
2
+ // Trust me, you don't want to mess with it!
3
+ #include "zkap_uniffi_bindings.hpp"
4
+
5
+ #include "UniffiJsiTypes.h"
6
+ #include <stdexcept>
7
+ #include <map>
8
+ #include <utility>
9
+ #include <iostream>
10
+ #include <thread>
11
+
12
+ namespace react = facebook::react;
13
+ namespace jsi = facebook::jsi;
14
+
15
+ // Calling into Rust.
16
+ extern "C" {
17
+ typedef void
18
+ (*UniffiRustFutureContinuationCallback)(
19
+ uint64_t data,
20
+ int8_t poll_result
21
+ );
22
+ typedef void
23
+ (*UniffiForeignFutureDroppedCallback)(
24
+ uint64_t handle
25
+ );
26
+ typedef void
27
+ (*UniffiCallbackInterfaceFree)(
28
+ uint64_t handle
29
+ );
30
+ typedef uint64_t
31
+ (*UniffiCallbackInterfaceClone)(
32
+ uint64_t handle
33
+ );typedef struct UniffiForeignFutureDroppedCallbackStruct {
34
+ uint64_t handle;
35
+ UniffiForeignFutureDroppedCallback free;
36
+ } UniffiForeignFutureDroppedCallbackStruct;typedef struct UniffiForeignFutureResultU8 {
37
+ uint8_t return_value;
38
+ RustCallStatus call_status;
39
+ } UniffiForeignFutureResultU8;
40
+ typedef void
41
+ (*UniffiForeignFutureCompleteU8)(
42
+ uint64_t callback_data,
43
+ UniffiForeignFutureResultU8 result
44
+ );typedef struct UniffiForeignFutureResultI8 {
45
+ int8_t return_value;
46
+ RustCallStatus call_status;
47
+ } UniffiForeignFutureResultI8;
48
+ typedef void
49
+ (*UniffiForeignFutureCompleteI8)(
50
+ uint64_t callback_data,
51
+ UniffiForeignFutureResultI8 result
52
+ );typedef struct UniffiForeignFutureResultU16 {
53
+ uint16_t return_value;
54
+ RustCallStatus call_status;
55
+ } UniffiForeignFutureResultU16;
56
+ typedef void
57
+ (*UniffiForeignFutureCompleteU16)(
58
+ uint64_t callback_data,
59
+ UniffiForeignFutureResultU16 result
60
+ );typedef struct UniffiForeignFutureResultI16 {
61
+ int16_t return_value;
62
+ RustCallStatus call_status;
63
+ } UniffiForeignFutureResultI16;
64
+ typedef void
65
+ (*UniffiForeignFutureCompleteI16)(
66
+ uint64_t callback_data,
67
+ UniffiForeignFutureResultI16 result
68
+ );typedef struct UniffiForeignFutureResultU32 {
69
+ uint32_t return_value;
70
+ RustCallStatus call_status;
71
+ } UniffiForeignFutureResultU32;
72
+ typedef void
73
+ (*UniffiForeignFutureCompleteU32)(
74
+ uint64_t callback_data,
75
+ UniffiForeignFutureResultU32 result
76
+ );typedef struct UniffiForeignFutureResultI32 {
77
+ int32_t return_value;
78
+ RustCallStatus call_status;
79
+ } UniffiForeignFutureResultI32;
80
+ typedef void
81
+ (*UniffiForeignFutureCompleteI32)(
82
+ uint64_t callback_data,
83
+ UniffiForeignFutureResultI32 result
84
+ );typedef struct UniffiForeignFutureResultU64 {
85
+ uint64_t return_value;
86
+ RustCallStatus call_status;
87
+ } UniffiForeignFutureResultU64;
88
+ typedef void
89
+ (*UniffiForeignFutureCompleteU64)(
90
+ uint64_t callback_data,
91
+ UniffiForeignFutureResultU64 result
92
+ );typedef struct UniffiForeignFutureResultI64 {
93
+ int64_t return_value;
94
+ RustCallStatus call_status;
95
+ } UniffiForeignFutureResultI64;
96
+ typedef void
97
+ (*UniffiForeignFutureCompleteI64)(
98
+ uint64_t callback_data,
99
+ UniffiForeignFutureResultI64 result
100
+ );typedef struct UniffiForeignFutureResultF32 {
101
+ float return_value;
102
+ RustCallStatus call_status;
103
+ } UniffiForeignFutureResultF32;
104
+ typedef void
105
+ (*UniffiForeignFutureCompleteF32)(
106
+ uint64_t callback_data,
107
+ UniffiForeignFutureResultF32 result
108
+ );typedef struct UniffiForeignFutureResultF64 {
109
+ double return_value;
110
+ RustCallStatus call_status;
111
+ } UniffiForeignFutureResultF64;
112
+ typedef void
113
+ (*UniffiForeignFutureCompleteF64)(
114
+ uint64_t callback_data,
115
+ UniffiForeignFutureResultF64 result
116
+ );typedef struct UniffiForeignFutureResultRustBuffer {
117
+ RustBuffer return_value;
118
+ RustCallStatus call_status;
119
+ } UniffiForeignFutureResultRustBuffer;
120
+ typedef void
121
+ (*UniffiForeignFutureCompleteRustBuffer)(
122
+ uint64_t callback_data,
123
+ UniffiForeignFutureResultRustBuffer result
124
+ );typedef struct UniffiForeignFutureResultVoid {
125
+ RustCallStatus call_status;
126
+ } UniffiForeignFutureResultVoid;
127
+ typedef void
128
+ (*UniffiForeignFutureCompleteVoid)(
129
+ uint64_t callback_data,
130
+ UniffiForeignFutureResultVoid result
131
+ );
132
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(
133
+ RustBuffer config,
134
+ RustBuffer secrets,
135
+ RustCallStatus *uniffi_out_err
136
+ );
137
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(
138
+ RustBuffer config,
139
+ RustBuffer aud_list,
140
+ RustCallStatus *uniffi_out_err
141
+ );
142
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_generate_hash(
143
+ RustBuffer messages,
144
+ RustCallStatus *uniffi_out_err
145
+ );
146
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(
147
+ RustBuffer config,
148
+ RustBuffer iss,
149
+ RustBuffer pk_b64,
150
+ RustCallStatus *uniffi_out_err
151
+ );
152
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs(
153
+ RustBuffer _config,
154
+ RustBuffer request,
155
+ RustCallStatus *uniffi_out_err
156
+ );
157
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_prove(
158
+ RustBuffer _config,
159
+ RustBuffer request,
160
+ RustCallStatus *uniffi_out_err
161
+ );
162
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file(
163
+ RustBuffer _config,
164
+ RustBuffer request,
165
+ RustBuffer witness,
166
+ RustCallStatus *uniffi_out_err
167
+ );
168
+ RustBuffer uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles(
169
+ RustBuffer _config,
170
+ RustBuffer request,
171
+ RustBuffer witness,
172
+ RustCallStatus *uniffi_out_err
173
+ );
174
+ RustBuffer ffi_zkap_uniffi_bindings_rustbuffer_alloc(
175
+ uint64_t size,
176
+ RustCallStatus *uniffi_out_err
177
+ );
178
+ RustBuffer ffi_zkap_uniffi_bindings_rustbuffer_from_bytes(
179
+ ForeignBytes bytes,
180
+ RustCallStatus *uniffi_out_err
181
+ );
182
+ void ffi_zkap_uniffi_bindings_rustbuffer_free(
183
+ RustBuffer buf,
184
+ RustCallStatus *uniffi_out_err
185
+ );
186
+ RustBuffer ffi_zkap_uniffi_bindings_rustbuffer_reserve(
187
+ RustBuffer buf,
188
+ uint64_t additional,
189
+ RustCallStatus *uniffi_out_err
190
+ );
191
+ void ffi_zkap_uniffi_bindings_rust_future_poll_u8(
192
+ /*handle*/ uint64_t handle,
193
+ UniffiRustFutureContinuationCallback callback,
194
+ /*handle*/ uint64_t callback_data
195
+ );
196
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_u8(
197
+ /*handle*/ uint64_t handle
198
+ );
199
+ void ffi_zkap_uniffi_bindings_rust_future_free_u8(
200
+ /*handle*/ uint64_t handle
201
+ );
202
+ uint8_t ffi_zkap_uniffi_bindings_rust_future_complete_u8(
203
+ /*handle*/ uint64_t handle,
204
+ RustCallStatus *uniffi_out_err
205
+ );
206
+ void ffi_zkap_uniffi_bindings_rust_future_poll_i8(
207
+ /*handle*/ uint64_t handle,
208
+ UniffiRustFutureContinuationCallback callback,
209
+ /*handle*/ uint64_t callback_data
210
+ );
211
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_i8(
212
+ /*handle*/ uint64_t handle
213
+ );
214
+ void ffi_zkap_uniffi_bindings_rust_future_free_i8(
215
+ /*handle*/ uint64_t handle
216
+ );
217
+ int8_t ffi_zkap_uniffi_bindings_rust_future_complete_i8(
218
+ /*handle*/ uint64_t handle,
219
+ RustCallStatus *uniffi_out_err
220
+ );
221
+ void ffi_zkap_uniffi_bindings_rust_future_poll_u16(
222
+ /*handle*/ uint64_t handle,
223
+ UniffiRustFutureContinuationCallback callback,
224
+ /*handle*/ uint64_t callback_data
225
+ );
226
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_u16(
227
+ /*handle*/ uint64_t handle
228
+ );
229
+ void ffi_zkap_uniffi_bindings_rust_future_free_u16(
230
+ /*handle*/ uint64_t handle
231
+ );
232
+ uint16_t ffi_zkap_uniffi_bindings_rust_future_complete_u16(
233
+ /*handle*/ uint64_t handle,
234
+ RustCallStatus *uniffi_out_err
235
+ );
236
+ void ffi_zkap_uniffi_bindings_rust_future_poll_i16(
237
+ /*handle*/ uint64_t handle,
238
+ UniffiRustFutureContinuationCallback callback,
239
+ /*handle*/ uint64_t callback_data
240
+ );
241
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_i16(
242
+ /*handle*/ uint64_t handle
243
+ );
244
+ void ffi_zkap_uniffi_bindings_rust_future_free_i16(
245
+ /*handle*/ uint64_t handle
246
+ );
247
+ int16_t ffi_zkap_uniffi_bindings_rust_future_complete_i16(
248
+ /*handle*/ uint64_t handle,
249
+ RustCallStatus *uniffi_out_err
250
+ );
251
+ void ffi_zkap_uniffi_bindings_rust_future_poll_u32(
252
+ /*handle*/ uint64_t handle,
253
+ UniffiRustFutureContinuationCallback callback,
254
+ /*handle*/ uint64_t callback_data
255
+ );
256
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_u32(
257
+ /*handle*/ uint64_t handle
258
+ );
259
+ void ffi_zkap_uniffi_bindings_rust_future_free_u32(
260
+ /*handle*/ uint64_t handle
261
+ );
262
+ uint32_t ffi_zkap_uniffi_bindings_rust_future_complete_u32(
263
+ /*handle*/ uint64_t handle,
264
+ RustCallStatus *uniffi_out_err
265
+ );
266
+ void ffi_zkap_uniffi_bindings_rust_future_poll_i32(
267
+ /*handle*/ uint64_t handle,
268
+ UniffiRustFutureContinuationCallback callback,
269
+ /*handle*/ uint64_t callback_data
270
+ );
271
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_i32(
272
+ /*handle*/ uint64_t handle
273
+ );
274
+ void ffi_zkap_uniffi_bindings_rust_future_free_i32(
275
+ /*handle*/ uint64_t handle
276
+ );
277
+ int32_t ffi_zkap_uniffi_bindings_rust_future_complete_i32(
278
+ /*handle*/ uint64_t handle,
279
+ RustCallStatus *uniffi_out_err
280
+ );
281
+ void ffi_zkap_uniffi_bindings_rust_future_poll_u64(
282
+ /*handle*/ uint64_t handle,
283
+ UniffiRustFutureContinuationCallback callback,
284
+ /*handle*/ uint64_t callback_data
285
+ );
286
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_u64(
287
+ /*handle*/ uint64_t handle
288
+ );
289
+ void ffi_zkap_uniffi_bindings_rust_future_free_u64(
290
+ /*handle*/ uint64_t handle
291
+ );
292
+ uint64_t ffi_zkap_uniffi_bindings_rust_future_complete_u64(
293
+ /*handle*/ uint64_t handle,
294
+ RustCallStatus *uniffi_out_err
295
+ );
296
+ void ffi_zkap_uniffi_bindings_rust_future_poll_i64(
297
+ /*handle*/ uint64_t handle,
298
+ UniffiRustFutureContinuationCallback callback,
299
+ /*handle*/ uint64_t callback_data
300
+ );
301
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_i64(
302
+ /*handle*/ uint64_t handle
303
+ );
304
+ void ffi_zkap_uniffi_bindings_rust_future_free_i64(
305
+ /*handle*/ uint64_t handle
306
+ );
307
+ int64_t ffi_zkap_uniffi_bindings_rust_future_complete_i64(
308
+ /*handle*/ uint64_t handle,
309
+ RustCallStatus *uniffi_out_err
310
+ );
311
+ void ffi_zkap_uniffi_bindings_rust_future_poll_f32(
312
+ /*handle*/ uint64_t handle,
313
+ UniffiRustFutureContinuationCallback callback,
314
+ /*handle*/ uint64_t callback_data
315
+ );
316
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_f32(
317
+ /*handle*/ uint64_t handle
318
+ );
319
+ void ffi_zkap_uniffi_bindings_rust_future_free_f32(
320
+ /*handle*/ uint64_t handle
321
+ );
322
+ float ffi_zkap_uniffi_bindings_rust_future_complete_f32(
323
+ /*handle*/ uint64_t handle,
324
+ RustCallStatus *uniffi_out_err
325
+ );
326
+ void ffi_zkap_uniffi_bindings_rust_future_poll_f64(
327
+ /*handle*/ uint64_t handle,
328
+ UniffiRustFutureContinuationCallback callback,
329
+ /*handle*/ uint64_t callback_data
330
+ );
331
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_f64(
332
+ /*handle*/ uint64_t handle
333
+ );
334
+ void ffi_zkap_uniffi_bindings_rust_future_free_f64(
335
+ /*handle*/ uint64_t handle
336
+ );
337
+ double ffi_zkap_uniffi_bindings_rust_future_complete_f64(
338
+ /*handle*/ uint64_t handle,
339
+ RustCallStatus *uniffi_out_err
340
+ );
341
+ void ffi_zkap_uniffi_bindings_rust_future_poll_rust_buffer(
342
+ /*handle*/ uint64_t handle,
343
+ UniffiRustFutureContinuationCallback callback,
344
+ /*handle*/ uint64_t callback_data
345
+ );
346
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_rust_buffer(
347
+ /*handle*/ uint64_t handle
348
+ );
349
+ void ffi_zkap_uniffi_bindings_rust_future_free_rust_buffer(
350
+ /*handle*/ uint64_t handle
351
+ );
352
+ RustBuffer ffi_zkap_uniffi_bindings_rust_future_complete_rust_buffer(
353
+ /*handle*/ uint64_t handle,
354
+ RustCallStatus *uniffi_out_err
355
+ );
356
+ void ffi_zkap_uniffi_bindings_rust_future_poll_void(
357
+ /*handle*/ uint64_t handle,
358
+ UniffiRustFutureContinuationCallback callback,
359
+ /*handle*/ uint64_t callback_data
360
+ );
361
+ void ffi_zkap_uniffi_bindings_rust_future_cancel_void(
362
+ /*handle*/ uint64_t handle
363
+ );
364
+ void ffi_zkap_uniffi_bindings_rust_future_free_void(
365
+ /*handle*/ uint64_t handle
366
+ );
367
+ void ffi_zkap_uniffi_bindings_rust_future_complete_void(
368
+ /*handle*/ uint64_t handle,
369
+ RustCallStatus *uniffi_out_err
370
+ );
371
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor(
372
+ );
373
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash(
374
+ );
375
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_generate_hash(
376
+ );
377
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash(
378
+ );
379
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs(
380
+ );
381
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_prove(
382
+ );
383
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file(
384
+ );
385
+ uint16_t uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles(
386
+ );
387
+ uint32_t ffi_zkap_uniffi_bindings_uniffi_contract_version(
388
+ );
389
+ }
390
+
391
+
392
+ namespace uniffi::zkap_uniffi_bindings {
393
+ template <typename T> struct Bridging;
394
+
395
+ using namespace facebook;
396
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
397
+
398
+ template <typename T> struct Bridging<ReferenceHolder<T>> {
399
+ static jsi::Value jsNew(jsi::Runtime &rt) {
400
+ auto holder = jsi::Object(rt);
401
+ return holder;
402
+ }
403
+ static T fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
404
+ const jsi::Value &value) {
405
+ auto obj = value.asObject(rt);
406
+ if (obj.hasProperty(rt, "pointee")) {
407
+ auto pointee = obj.getProperty(rt, "pointee");
408
+ return uniffi::zkap_uniffi_bindings::Bridging<T>::fromJs(rt, callInvoker, pointee);
409
+ }
410
+ throw jsi::JSError(
411
+ rt,
412
+ "Expected ReferenceHolder to have a pointee property. This is likely a bug in uniffi-bindgen-react-native"
413
+ );
414
+ }
415
+ };
416
+ } // namespace uniffi::zkap_uniffi_bindings
417
+ namespace uniffi::zkap_uniffi_bindings {
418
+ using namespace facebook;
419
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
420
+
421
+ template <> struct Bridging<RustBuffer> {
422
+ static RustBuffer rustbuffer_alloc(int32_t size) {
423
+ RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
424
+ return ffi_zkap_uniffi_bindings_rustbuffer_alloc(
425
+ size,
426
+ &status
427
+ );
428
+ }
429
+
430
+ static void rustbuffer_free(RustBuffer buf) {
431
+ RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
432
+ ffi_zkap_uniffi_bindings_rustbuffer_free(
433
+ buf,
434
+ &status
435
+ );
436
+ }
437
+
438
+ static RustBuffer rustbuffer_from_bytes(ForeignBytes bytes) {
439
+ RustCallStatus status = { UNIFFI_CALL_STATUS_OK };
440
+ return ffi_zkap_uniffi_bindings_rustbuffer_from_bytes(
441
+ bytes,
442
+ &status
443
+ );
444
+ }
445
+
446
+ static RustBuffer fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
447
+ const jsi::Value &value) {
448
+ try {
449
+ auto buffer = uniffi_jsi::Bridging<jsi::ArrayBuffer>::value_to_arraybuffer(rt, value);
450
+ auto bytes = ForeignBytes{
451
+ .len = static_cast<int32_t>(buffer.length(rt)),
452
+ .data = buffer.data(rt),
453
+ };
454
+
455
+ // This buffer is constructed from foreign bytes. Rust scaffolding copies
456
+ // the bytes, to make the RustBuffer.
457
+ auto buf = rustbuffer_from_bytes(bytes);
458
+ // Once it leaves this function, the buffer is immediately passed back
459
+ // into Rust, where it's used to deserialize into the Rust versions of the
460
+ // arguments. At that point, the copy is destroyed.
461
+ return buf;
462
+ } catch (const std::logic_error &e) {
463
+ throw jsi::JSError(rt, e.what());
464
+ }
465
+ }
466
+
467
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
468
+ RustBuffer buf) {
469
+ // We need to make a copy of the bytes from Rust's memory space into
470
+ // Javascripts memory space. We need to do this because the two languages
471
+ // manages memory very differently: a garbage collector needs to track all
472
+ // the memory at runtime, Rust is doing it all closer to compile time.
473
+ uint8_t *bytes = new uint8_t[buf.len];
474
+ std::memcpy(bytes, buf.data, buf.len);
475
+
476
+ // Construct an ArrayBuffer with copy of the bytes from the RustBuffer.
477
+ auto payload = std::make_shared<uniffi_jsi::CMutableBuffer>(
478
+ uniffi_jsi::CMutableBuffer((uint8_t *)bytes, buf.len));
479
+ auto arrayBuffer = jsi::ArrayBuffer(rt, payload);
480
+
481
+ // Once we have a Javascript version, we no longer need the Rust version, so
482
+ // we can call into Rust to tell it it's okay to free that memory.
483
+ rustbuffer_free(buf);
484
+
485
+ // Finally, return the ArrayBuffer.
486
+ return uniffi_jsi::Bridging<jsi::ArrayBuffer>::arraybuffer_to_value(rt, arrayBuffer);;
487
+ }
488
+ };
489
+
490
+ } // namespace uniffi::zkap_uniffi_bindings
491
+
492
+ namespace uniffi::zkap_uniffi_bindings {
493
+ using namespace facebook;
494
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
495
+
496
+ template <> struct Bridging<RustCallStatus> {
497
+ static jsi::Value jsSuccess(jsi::Runtime &rt) {
498
+ auto statusObject = jsi::Object(rt);
499
+ statusObject.setProperty(rt, "code", jsi::Value(rt, UNIFFI_CALL_STATUS_OK));
500
+ return statusObject;
501
+ }
502
+ static RustCallStatus rustSuccess(jsi::Runtime &rt) {
503
+ return {UNIFFI_CALL_STATUS_OK};
504
+ }
505
+ static void copyIntoJs(jsi::Runtime &rt,
506
+ std::shared_ptr<CallInvoker> callInvoker,
507
+ const RustCallStatus status,
508
+ const jsi::Value &jsStatus) {
509
+ auto statusObject = jsStatus.asObject(rt);
510
+ if (status.error_buf.data != nullptr) {
511
+ auto rbuf = Bridging<RustBuffer>::toJs(rt, callInvoker,
512
+ status.error_buf);
513
+ statusObject.setProperty(rt, "errorBuf", rbuf);
514
+ }
515
+ if (status.code != UNIFFI_CALL_STATUS_OK) {
516
+ auto code =
517
+ uniffi_jsi::Bridging<uint8_t>::toJs(rt, callInvoker, status.code);
518
+ statusObject.setProperty(rt, "code", code);
519
+ }
520
+ }
521
+
522
+ static RustCallStatus fromJs(jsi::Runtime &rt,
523
+ std::shared_ptr<CallInvoker> invoker,
524
+ const jsi::Value &jsStatus) {
525
+ RustCallStatus status;
526
+ auto statusObject = jsStatus.asObject(rt);
527
+ if (statusObject.hasProperty(rt, "errorBuf")) {
528
+ auto rbuf = statusObject.getProperty(rt, "errorBuf");
529
+ status.error_buf =
530
+ Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
531
+ }
532
+ if (statusObject.hasProperty(rt, "code")) {
533
+ auto code = statusObject.getProperty(rt, "code");
534
+ status.code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
535
+ }
536
+ return status;
537
+ }
538
+
539
+ static void copyFromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> invoker,
540
+ const jsi::Value &jsStatus, RustCallStatus *status) {
541
+ auto statusObject = jsStatus.asObject(rt);
542
+ if (statusObject.hasProperty(rt, "errorBuf")) {
543
+ auto rbuf = statusObject.getProperty(rt, "errorBuf");
544
+ status->error_buf =
545
+ Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
546
+ }
547
+ if (statusObject.hasProperty(rt, "code")) {
548
+ auto code = statusObject.getProperty(rt, "code");
549
+ status->code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
550
+ }
551
+ }
552
+ };
553
+
554
+ } // namespace uniffi::zkap_uniffi_bindings
555
+ // In other uniffi bindings, it is assumed that the foreign language holds on
556
+ // to the vtable, which the Rust just gets a pointer to.
557
+ // Here, we need to hold on to them, but also be able to clear them at just the
558
+ // right time so we can support hot-reloading.
559
+ namespace uniffi::zkap_uniffi_bindings::registry {
560
+ template <typename T>
561
+ class VTableHolder {
562
+ public:
563
+ T vtable;
564
+ VTableHolder(T v) : vtable(v) {}
565
+ };
566
+
567
+ // Mutex to bind the storage and setting of vtable together.
568
+ // We declare it here, but the lock is taken by callers of the putTable
569
+ // method who are also sending a pointer to Rust.
570
+ static std::mutex vtableMutex;
571
+
572
+ // Registry to hold all vtables so they persist even when JS objects are GC'd.
573
+ // The only reason this exists is to prevent a dangling pointer in the
574
+ // Rust machinery: i.e. we don't need to access or write to this registry
575
+ // after startup.
576
+ // Registry to hold all vtables so they persist even when JS objects are GC'd.
577
+ // Maps string identifiers to vtable holders using type erasure
578
+ static std::unordered_map<std::string, std::shared_ptr<void>> vtableRegistry;
579
+
580
+ // Add a vtable to the registry with an identifier
581
+ template <typename T>
582
+ static T* putTable(std::string_view identifier, T vtable) {
583
+ auto holder = std::make_shared<VTableHolder<T>>(vtable);
584
+ // Store the raw pointer to the vtable before type erasure
585
+ T* rawPtr = &(holder->vtable);
586
+ // Store the holder using type erasure with the string identifier
587
+ vtableRegistry[std::string(identifier)] = std::shared_ptr<void>(holder);
588
+ return rawPtr;
589
+ }
590
+
591
+ // Clear the registry.
592
+ //
593
+ // Conceptually, this is called after teardown of the module (i.e. after
594
+ // teardown of the jsi::Runtime). However, because Rust is dropping callbacks
595
+ // because the Runtime is being torn down, we must keep the registry intact
596
+ // until after the runtime goes away.
597
+ //
598
+ // Therefore, in practice we should call this when the next runtime is
599
+ // being stood up.
600
+ static void clearRegistry() {
601
+ std::lock_guard<std::mutex> lock(vtableMutex);
602
+ vtableRegistry.clear();
603
+ }
604
+ } // namespace uniffi::zkap_uniffi_bindings::registry
605
+
606
+ // This calls into Rust.
607
+ // Implementation of callback function calling from Rust to JS RustFutureContinuationCallback
608
+
609
+ // Callback function: uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback::UniffiRustFutureContinuationCallback
610
+ //
611
+ // We have the following constraints:
612
+ // - we need to pass a function pointer to Rust.
613
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
614
+ // - function pointers can't store state, so we can't use a lamda.
615
+ //
616
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
617
+ // the lambda, which itself calls the `body` which then calls into JS.
618
+ //
619
+ // We then give the `callback` function pointer to Rust which will call the lambda sometime in the
620
+ // future.
621
+ namespace uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback {
622
+ using namespace facebook;
623
+
624
+ // We need to store a lambda in a global so we can call it from
625
+ // a function pointer. The function pointer is passed to Rust.
626
+ static std::function<void(uint64_t, int8_t)> rsLambda = nullptr;
627
+
628
+ // This is the main body of the callback. It's called from the lambda,
629
+ // which itself is called from the callback function which is passed to Rust.
630
+ static void body(jsi::Runtime &rt,
631
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
632
+ std::shared_ptr<jsi::Value> callbackValue
633
+ ,uint64_t rs_data
634
+ ,int8_t rs_pollResult) {
635
+
636
+ // Convert the arguments from Rust, into jsi::Values.
637
+ // We'll use the Bridging class to do this…
638
+ auto js_data = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_data);
639
+ auto js_pollResult = uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, rs_pollResult);
640
+
641
+ // Now we are ready to call the callback.
642
+ // We are already on the JS thread, because this `body` function was
643
+ // invoked from the CallInvoker.
644
+ try {
645
+ // Getting the callback function
646
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
647
+ auto uniffiResult = cb.call(rt, js_data, js_pollResult
648
+ );
649
+
650
+
651
+
652
+
653
+ } catch (const jsi::JSError &error) {
654
+ std::cout << "Error in callback UniffiRustFutureContinuationCallback: "
655
+ << error.what() << std::endl;
656
+ throw error;
657
+ }
658
+ }
659
+
660
+ static void callback(uint64_t rs_data, int8_t rs_pollResult) {
661
+ // If the runtime has shutdown, then there is no point in trying to
662
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
663
+ //
664
+ // Answer: the module destructor calls into callback `cleanup` method,
665
+ // which nulls out the rsLamda.
666
+ //
667
+ // If rsLamda is null, then there is no runtime to call into.
668
+ if (rsLambda == nullptr) {
669
+ // This only occurs when destructors are calling into Rust free/drop,
670
+ // which causes the JS callback to be dropped.
671
+ return;
672
+ }
673
+
674
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
675
+ // are all in the lambda.
676
+ rsLambda(
677
+ rs_data,
678
+ rs_pollResult);
679
+ }
680
+
681
+ [[maybe_unused]] static UniffiRustFutureContinuationCallback
682
+ makeCallbackFunction( // uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback
683
+ jsi::Runtime &rt,
684
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
685
+ const jsi::Value &value) {
686
+ if (rsLambda != nullptr) {
687
+ // `makeCallbackFunction` is called in two circumstances:
688
+ //
689
+ // 1. at startup, when initializing callback interface vtables.
690
+ // 2. when polling futures. This happens at least once per future that is
691
+ // exposed to Javascript. We know that this is always the same function,
692
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
693
+ //
694
+ // We can therefore return the callback function without making anything
695
+ // new if we've been initialized already.
696
+ return callback;
697
+ }
698
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
699
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
700
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_data, int8_t rs_pollResult) {
701
+ // We immediately make a lambda which will do the work of transforming the
702
+ // arguments into JSI values and calling the callback.
703
+ uniffi_runtime::UniffiCallFunc jsLambda = [
704
+ callInvoker,
705
+ callbackValue
706
+ , rs_data
707
+ , rs_pollResult](jsi::Runtime &rt) mutable {
708
+ body(rt, callInvoker, callbackValue
709
+ , rs_data
710
+ , rs_pollResult);
711
+ };
712
+ // We'll then call that lambda from the callInvoker which will
713
+ // look after calling it on the correct thread.
714
+
715
+ callInvoker->invokeNonBlocking(rt, jsLambda);
716
+ };
717
+ return callback;
718
+ }
719
+
720
+ // This method is called from the destructor of NativeZkapUniffiBindings, which only happens
721
+ // when the jsi::Runtime is being destroyed.
722
+ static void cleanup() {
723
+ // The lambda holds a reference to the the Runtime, so when this is nulled out,
724
+ // then the pointer will no longer be left dangling.
725
+ rsLambda = nullptr;
726
+ }
727
+ } // namespace uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback
728
+ // Implementation of callback function calling from Rust to JS ForeignFutureDroppedCallback
729
+
730
+ // Callback function: uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback::UniffiForeignFutureDroppedCallback
731
+ //
732
+ // We have the following constraints:
733
+ // - we need to pass a function pointer to Rust.
734
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
735
+ // - function pointers can't store state, so we can't use a lamda.
736
+ //
737
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
738
+ // the lambda, which itself calls the `body` which then calls into JS.
739
+ //
740
+ // We then give the `callback` function pointer to Rust which will call the lambda sometime in the
741
+ // future.
742
+ namespace uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback {
743
+ using namespace facebook;
744
+
745
+ // We need to store a lambda in a global so we can call it from
746
+ // a function pointer. The function pointer is passed to Rust.
747
+ static std::function<void(uint64_t)> rsLambda = nullptr;
748
+
749
+ // This is the main body of the callback. It's called from the lambda,
750
+ // which itself is called from the callback function which is passed to Rust.
751
+ static void body(jsi::Runtime &rt,
752
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
753
+ std::shared_ptr<jsi::Value> callbackValue
754
+ ,uint64_t rs_handle) {
755
+
756
+ // Convert the arguments from Rust, into jsi::Values.
757
+ // We'll use the Bridging class to do this…
758
+ auto js_handle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
759
+
760
+ // Now we are ready to call the callback.
761
+ // We are already on the JS thread, because this `body` function was
762
+ // invoked from the CallInvoker.
763
+ try {
764
+ // Getting the callback function
765
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
766
+ auto uniffiResult = cb.call(rt, js_handle
767
+ );
768
+
769
+
770
+
771
+
772
+ } catch (const jsi::JSError &error) {
773
+ std::cout << "Error in callback UniffiForeignFutureDroppedCallback: "
774
+ << error.what() << std::endl;
775
+ throw error;
776
+ }
777
+ }
778
+
779
+ static void callback(uint64_t rs_handle) {
780
+ // If the runtime has shutdown, then there is no point in trying to
781
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
782
+ //
783
+ // Answer: the module destructor calls into callback `cleanup` method,
784
+ // which nulls out the rsLamda.
785
+ //
786
+ // If rsLamda is null, then there is no runtime to call into.
787
+ if (rsLambda == nullptr) {
788
+ // This only occurs when destructors are calling into Rust free/drop,
789
+ // which causes the JS callback to be dropped.
790
+ return;
791
+ }
792
+
793
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
794
+ // are all in the lambda.
795
+ rsLambda(
796
+ rs_handle);
797
+ }
798
+
799
+ [[maybe_unused]] static UniffiForeignFutureDroppedCallback
800
+ makeCallbackFunction( // uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback
801
+ jsi::Runtime &rt,
802
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
803
+ const jsi::Value &value) {
804
+ if (rsLambda != nullptr) {
805
+ // `makeCallbackFunction` is called in two circumstances:
806
+ //
807
+ // 1. at startup, when initializing callback interface vtables.
808
+ // 2. when polling futures. This happens at least once per future that is
809
+ // exposed to Javascript. We know that this is always the same function,
810
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
811
+ //
812
+ // We can therefore return the callback function without making anything
813
+ // new if we've been initialized already.
814
+ return callback;
815
+ }
816
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
817
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
818
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
819
+ // We immediately make a lambda which will do the work of transforming the
820
+ // arguments into JSI values and calling the callback.
821
+ uniffi_runtime::UniffiCallFunc jsLambda = [
822
+ callInvoker,
823
+ callbackValue
824
+ , rs_handle](jsi::Runtime &rt) mutable {
825
+ body(rt, callInvoker, callbackValue
826
+ , rs_handle);
827
+ };
828
+ // We'll then call that lambda from the callInvoker which will
829
+ // look after calling it on the correct thread.
830
+
831
+ callInvoker->invokeNonBlocking(rt, jsLambda);
832
+ };
833
+ return callback;
834
+ }
835
+
836
+ // This method is called from the destructor of NativeZkapUniffiBindings, which only happens
837
+ // when the jsi::Runtime is being destroyed.
838
+ static void cleanup() {
839
+ // The lambda holds a reference to the the Runtime, so when this is nulled out,
840
+ // then the pointer will no longer be left dangling.
841
+ rsLambda = nullptr;
842
+ }
843
+ } // namespace uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback
844
+ // Implementation of free callback function CallbackInterfaceFree
845
+
846
+ namespace uniffi::zkap_uniffi_bindings {
847
+ using namespace facebook;
848
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
849
+
850
+ template <> struct Bridging<UniffiForeignFutureDroppedCallbackStruct> {
851
+ static UniffiForeignFutureDroppedCallbackStruct fromJs(jsi::Runtime &rt,
852
+ std::shared_ptr<CallInvoker> callInvoker,
853
+ const jsi::Value &jsValue
854
+ ) {
855
+ // Check if the input is an object
856
+ if (!jsValue.isObject()) {
857
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureDroppedCallbackStruct");
858
+ }
859
+
860
+ // Get the object from the jsi::Value
861
+ auto jsObject = jsValue.getObject(rt);
862
+
863
+ // Create the vtable struct
864
+ UniffiForeignFutureDroppedCallbackStruct rsObject;
865
+
866
+ // Create the vtable from the js callbacks.
867
+ rsObject.handle = uniffi_jsi::Bridging<uint64_t>::fromJs(
868
+ rt, callInvoker,
869
+ jsObject.getProperty(rt, "handle")
870
+ );
871
+ rsObject.free = uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback::makeCallbackFunction(
872
+ rt, callInvoker, jsObject.getProperty(rt, "free")
873
+ );
874
+
875
+ return rsObject;
876
+ }
877
+ };
878
+
879
+ } // namespace uniffi::zkap_uniffi_bindings
880
+ namespace uniffi::zkap_uniffi_bindings {
881
+ using namespace facebook;
882
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
883
+
884
+ template <> struct Bridging<UniffiForeignFutureResultU8> {
885
+ static UniffiForeignFutureResultU8 fromJs(jsi::Runtime &rt,
886
+ std::shared_ptr<CallInvoker> callInvoker,
887
+ const jsi::Value &jsValue
888
+ ) {
889
+ // Check if the input is an object
890
+ if (!jsValue.isObject()) {
891
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultU8");
892
+ }
893
+
894
+ // Get the object from the jsi::Value
895
+ auto jsObject = jsValue.getObject(rt);
896
+
897
+ // Create the vtable struct
898
+ UniffiForeignFutureResultU8 rsObject;
899
+
900
+ // Create the vtable from the js callbacks.
901
+ rsObject.return_value = uniffi_jsi::Bridging<uint8_t>::fromJs(
902
+ rt, callInvoker,
903
+ jsObject.getProperty(rt, "returnValue")
904
+ );
905
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
906
+ rt, callInvoker,
907
+ jsObject.getProperty(rt, "callStatus")
908
+ );
909
+
910
+ return rsObject;
911
+ }
912
+ };
913
+
914
+ } // namespace uniffi::zkap_uniffi_bindings
915
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU8,
916
+ // passed from Rust to JS as part of async callbacks.
917
+ namespace uniffi::zkap_uniffi_bindings {
918
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
919
+
920
+ template <> struct Bridging<UniffiForeignFutureCompleteU8> {
921
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU8 rsCallback) {
922
+ return jsi::Function::createFromHostFunction(
923
+ rt,
924
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU8"),
925
+ 2,
926
+ [rsCallback, callInvoker](
927
+ jsi::Runtime &rt,
928
+ const jsi::Value &thisValue,
929
+ const jsi::Value *arguments,
930
+ size_t count) -> jsi::Value
931
+ {
932
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
933
+ }
934
+ );
935
+ }
936
+
937
+ static jsi::Value intoRust(
938
+ jsi::Runtime &rt,
939
+ std::shared_ptr<CallInvoker> callInvoker,
940
+ const jsi::Value &thisValue,
941
+ const jsi::Value *args,
942
+ size_t count,
943
+ UniffiForeignFutureCompleteU8 func) {
944
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
945
+ // then call the rs_callback with those arguments.
946
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultU8>::fromJs(rt, callInvoker, args[1])
947
+ );
948
+
949
+
950
+ return jsi::Value::undefined();
951
+ }
952
+ };
953
+ } // namespace uniffi::zkap_uniffi_bindings
954
+ namespace uniffi::zkap_uniffi_bindings {
955
+ using namespace facebook;
956
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
957
+
958
+ template <> struct Bridging<UniffiForeignFutureResultI8> {
959
+ static UniffiForeignFutureResultI8 fromJs(jsi::Runtime &rt,
960
+ std::shared_ptr<CallInvoker> callInvoker,
961
+ const jsi::Value &jsValue
962
+ ) {
963
+ // Check if the input is an object
964
+ if (!jsValue.isObject()) {
965
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultI8");
966
+ }
967
+
968
+ // Get the object from the jsi::Value
969
+ auto jsObject = jsValue.getObject(rt);
970
+
971
+ // Create the vtable struct
972
+ UniffiForeignFutureResultI8 rsObject;
973
+
974
+ // Create the vtable from the js callbacks.
975
+ rsObject.return_value = uniffi_jsi::Bridging<int8_t>::fromJs(
976
+ rt, callInvoker,
977
+ jsObject.getProperty(rt, "returnValue")
978
+ );
979
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
980
+ rt, callInvoker,
981
+ jsObject.getProperty(rt, "callStatus")
982
+ );
983
+
984
+ return rsObject;
985
+ }
986
+ };
987
+
988
+ } // namespace uniffi::zkap_uniffi_bindings
989
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI8,
990
+ // passed from Rust to JS as part of async callbacks.
991
+ namespace uniffi::zkap_uniffi_bindings {
992
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
993
+
994
+ template <> struct Bridging<UniffiForeignFutureCompleteI8> {
995
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI8 rsCallback) {
996
+ return jsi::Function::createFromHostFunction(
997
+ rt,
998
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI8"),
999
+ 2,
1000
+ [rsCallback, callInvoker](
1001
+ jsi::Runtime &rt,
1002
+ const jsi::Value &thisValue,
1003
+ const jsi::Value *arguments,
1004
+ size_t count) -> jsi::Value
1005
+ {
1006
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1007
+ }
1008
+ );
1009
+ }
1010
+
1011
+ static jsi::Value intoRust(
1012
+ jsi::Runtime &rt,
1013
+ std::shared_ptr<CallInvoker> callInvoker,
1014
+ const jsi::Value &thisValue,
1015
+ const jsi::Value *args,
1016
+ size_t count,
1017
+ UniffiForeignFutureCompleteI8 func) {
1018
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1019
+ // then call the rs_callback with those arguments.
1020
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultI8>::fromJs(rt, callInvoker, args[1])
1021
+ );
1022
+
1023
+
1024
+ return jsi::Value::undefined();
1025
+ }
1026
+ };
1027
+ } // namespace uniffi::zkap_uniffi_bindings
1028
+ namespace uniffi::zkap_uniffi_bindings {
1029
+ using namespace facebook;
1030
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1031
+
1032
+ template <> struct Bridging<UniffiForeignFutureResultU16> {
1033
+ static UniffiForeignFutureResultU16 fromJs(jsi::Runtime &rt,
1034
+ std::shared_ptr<CallInvoker> callInvoker,
1035
+ const jsi::Value &jsValue
1036
+ ) {
1037
+ // Check if the input is an object
1038
+ if (!jsValue.isObject()) {
1039
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultU16");
1040
+ }
1041
+
1042
+ // Get the object from the jsi::Value
1043
+ auto jsObject = jsValue.getObject(rt);
1044
+
1045
+ // Create the vtable struct
1046
+ UniffiForeignFutureResultU16 rsObject;
1047
+
1048
+ // Create the vtable from the js callbacks.
1049
+ rsObject.return_value = uniffi_jsi::Bridging<uint16_t>::fromJs(
1050
+ rt, callInvoker,
1051
+ jsObject.getProperty(rt, "returnValue")
1052
+ );
1053
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1054
+ rt, callInvoker,
1055
+ jsObject.getProperty(rt, "callStatus")
1056
+ );
1057
+
1058
+ return rsObject;
1059
+ }
1060
+ };
1061
+
1062
+ } // namespace uniffi::zkap_uniffi_bindings
1063
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU16,
1064
+ // passed from Rust to JS as part of async callbacks.
1065
+ namespace uniffi::zkap_uniffi_bindings {
1066
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1067
+
1068
+ template <> struct Bridging<UniffiForeignFutureCompleteU16> {
1069
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU16 rsCallback) {
1070
+ return jsi::Function::createFromHostFunction(
1071
+ rt,
1072
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU16"),
1073
+ 2,
1074
+ [rsCallback, callInvoker](
1075
+ jsi::Runtime &rt,
1076
+ const jsi::Value &thisValue,
1077
+ const jsi::Value *arguments,
1078
+ size_t count) -> jsi::Value
1079
+ {
1080
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1081
+ }
1082
+ );
1083
+ }
1084
+
1085
+ static jsi::Value intoRust(
1086
+ jsi::Runtime &rt,
1087
+ std::shared_ptr<CallInvoker> callInvoker,
1088
+ const jsi::Value &thisValue,
1089
+ const jsi::Value *args,
1090
+ size_t count,
1091
+ UniffiForeignFutureCompleteU16 func) {
1092
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1093
+ // then call the rs_callback with those arguments.
1094
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultU16>::fromJs(rt, callInvoker, args[1])
1095
+ );
1096
+
1097
+
1098
+ return jsi::Value::undefined();
1099
+ }
1100
+ };
1101
+ } // namespace uniffi::zkap_uniffi_bindings
1102
+ namespace uniffi::zkap_uniffi_bindings {
1103
+ using namespace facebook;
1104
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1105
+
1106
+ template <> struct Bridging<UniffiForeignFutureResultI16> {
1107
+ static UniffiForeignFutureResultI16 fromJs(jsi::Runtime &rt,
1108
+ std::shared_ptr<CallInvoker> callInvoker,
1109
+ const jsi::Value &jsValue
1110
+ ) {
1111
+ // Check if the input is an object
1112
+ if (!jsValue.isObject()) {
1113
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultI16");
1114
+ }
1115
+
1116
+ // Get the object from the jsi::Value
1117
+ auto jsObject = jsValue.getObject(rt);
1118
+
1119
+ // Create the vtable struct
1120
+ UniffiForeignFutureResultI16 rsObject;
1121
+
1122
+ // Create the vtable from the js callbacks.
1123
+ rsObject.return_value = uniffi_jsi::Bridging<int16_t>::fromJs(
1124
+ rt, callInvoker,
1125
+ jsObject.getProperty(rt, "returnValue")
1126
+ );
1127
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1128
+ rt, callInvoker,
1129
+ jsObject.getProperty(rt, "callStatus")
1130
+ );
1131
+
1132
+ return rsObject;
1133
+ }
1134
+ };
1135
+
1136
+ } // namespace uniffi::zkap_uniffi_bindings
1137
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI16,
1138
+ // passed from Rust to JS as part of async callbacks.
1139
+ namespace uniffi::zkap_uniffi_bindings {
1140
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1141
+
1142
+ template <> struct Bridging<UniffiForeignFutureCompleteI16> {
1143
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI16 rsCallback) {
1144
+ return jsi::Function::createFromHostFunction(
1145
+ rt,
1146
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI16"),
1147
+ 2,
1148
+ [rsCallback, callInvoker](
1149
+ jsi::Runtime &rt,
1150
+ const jsi::Value &thisValue,
1151
+ const jsi::Value *arguments,
1152
+ size_t count) -> jsi::Value
1153
+ {
1154
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1155
+ }
1156
+ );
1157
+ }
1158
+
1159
+ static jsi::Value intoRust(
1160
+ jsi::Runtime &rt,
1161
+ std::shared_ptr<CallInvoker> callInvoker,
1162
+ const jsi::Value &thisValue,
1163
+ const jsi::Value *args,
1164
+ size_t count,
1165
+ UniffiForeignFutureCompleteI16 func) {
1166
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1167
+ // then call the rs_callback with those arguments.
1168
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultI16>::fromJs(rt, callInvoker, args[1])
1169
+ );
1170
+
1171
+
1172
+ return jsi::Value::undefined();
1173
+ }
1174
+ };
1175
+ } // namespace uniffi::zkap_uniffi_bindings
1176
+ namespace uniffi::zkap_uniffi_bindings {
1177
+ using namespace facebook;
1178
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1179
+
1180
+ template <> struct Bridging<UniffiForeignFutureResultU32> {
1181
+ static UniffiForeignFutureResultU32 fromJs(jsi::Runtime &rt,
1182
+ std::shared_ptr<CallInvoker> callInvoker,
1183
+ const jsi::Value &jsValue
1184
+ ) {
1185
+ // Check if the input is an object
1186
+ if (!jsValue.isObject()) {
1187
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultU32");
1188
+ }
1189
+
1190
+ // Get the object from the jsi::Value
1191
+ auto jsObject = jsValue.getObject(rt);
1192
+
1193
+ // Create the vtable struct
1194
+ UniffiForeignFutureResultU32 rsObject;
1195
+
1196
+ // Create the vtable from the js callbacks.
1197
+ rsObject.return_value = uniffi_jsi::Bridging<uint32_t>::fromJs(
1198
+ rt, callInvoker,
1199
+ jsObject.getProperty(rt, "returnValue")
1200
+ );
1201
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1202
+ rt, callInvoker,
1203
+ jsObject.getProperty(rt, "callStatus")
1204
+ );
1205
+
1206
+ return rsObject;
1207
+ }
1208
+ };
1209
+
1210
+ } // namespace uniffi::zkap_uniffi_bindings
1211
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU32,
1212
+ // passed from Rust to JS as part of async callbacks.
1213
+ namespace uniffi::zkap_uniffi_bindings {
1214
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1215
+
1216
+ template <> struct Bridging<UniffiForeignFutureCompleteU32> {
1217
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU32 rsCallback) {
1218
+ return jsi::Function::createFromHostFunction(
1219
+ rt,
1220
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU32"),
1221
+ 2,
1222
+ [rsCallback, callInvoker](
1223
+ jsi::Runtime &rt,
1224
+ const jsi::Value &thisValue,
1225
+ const jsi::Value *arguments,
1226
+ size_t count) -> jsi::Value
1227
+ {
1228
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1229
+ }
1230
+ );
1231
+ }
1232
+
1233
+ static jsi::Value intoRust(
1234
+ jsi::Runtime &rt,
1235
+ std::shared_ptr<CallInvoker> callInvoker,
1236
+ const jsi::Value &thisValue,
1237
+ const jsi::Value *args,
1238
+ size_t count,
1239
+ UniffiForeignFutureCompleteU32 func) {
1240
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1241
+ // then call the rs_callback with those arguments.
1242
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultU32>::fromJs(rt, callInvoker, args[1])
1243
+ );
1244
+
1245
+
1246
+ return jsi::Value::undefined();
1247
+ }
1248
+ };
1249
+ } // namespace uniffi::zkap_uniffi_bindings
1250
+ namespace uniffi::zkap_uniffi_bindings {
1251
+ using namespace facebook;
1252
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1253
+
1254
+ template <> struct Bridging<UniffiForeignFutureResultI32> {
1255
+ static UniffiForeignFutureResultI32 fromJs(jsi::Runtime &rt,
1256
+ std::shared_ptr<CallInvoker> callInvoker,
1257
+ const jsi::Value &jsValue
1258
+ ) {
1259
+ // Check if the input is an object
1260
+ if (!jsValue.isObject()) {
1261
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultI32");
1262
+ }
1263
+
1264
+ // Get the object from the jsi::Value
1265
+ auto jsObject = jsValue.getObject(rt);
1266
+
1267
+ // Create the vtable struct
1268
+ UniffiForeignFutureResultI32 rsObject;
1269
+
1270
+ // Create the vtable from the js callbacks.
1271
+ rsObject.return_value = uniffi_jsi::Bridging<int32_t>::fromJs(
1272
+ rt, callInvoker,
1273
+ jsObject.getProperty(rt, "returnValue")
1274
+ );
1275
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1276
+ rt, callInvoker,
1277
+ jsObject.getProperty(rt, "callStatus")
1278
+ );
1279
+
1280
+ return rsObject;
1281
+ }
1282
+ };
1283
+
1284
+ } // namespace uniffi::zkap_uniffi_bindings
1285
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI32,
1286
+ // passed from Rust to JS as part of async callbacks.
1287
+ namespace uniffi::zkap_uniffi_bindings {
1288
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1289
+
1290
+ template <> struct Bridging<UniffiForeignFutureCompleteI32> {
1291
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI32 rsCallback) {
1292
+ return jsi::Function::createFromHostFunction(
1293
+ rt,
1294
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI32"),
1295
+ 2,
1296
+ [rsCallback, callInvoker](
1297
+ jsi::Runtime &rt,
1298
+ const jsi::Value &thisValue,
1299
+ const jsi::Value *arguments,
1300
+ size_t count) -> jsi::Value
1301
+ {
1302
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1303
+ }
1304
+ );
1305
+ }
1306
+
1307
+ static jsi::Value intoRust(
1308
+ jsi::Runtime &rt,
1309
+ std::shared_ptr<CallInvoker> callInvoker,
1310
+ const jsi::Value &thisValue,
1311
+ const jsi::Value *args,
1312
+ size_t count,
1313
+ UniffiForeignFutureCompleteI32 func) {
1314
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1315
+ // then call the rs_callback with those arguments.
1316
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultI32>::fromJs(rt, callInvoker, args[1])
1317
+ );
1318
+
1319
+
1320
+ return jsi::Value::undefined();
1321
+ }
1322
+ };
1323
+ } // namespace uniffi::zkap_uniffi_bindings
1324
+ namespace uniffi::zkap_uniffi_bindings {
1325
+ using namespace facebook;
1326
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1327
+
1328
+ template <> struct Bridging<UniffiForeignFutureResultU64> {
1329
+ static UniffiForeignFutureResultU64 fromJs(jsi::Runtime &rt,
1330
+ std::shared_ptr<CallInvoker> callInvoker,
1331
+ const jsi::Value &jsValue
1332
+ ) {
1333
+ // Check if the input is an object
1334
+ if (!jsValue.isObject()) {
1335
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultU64");
1336
+ }
1337
+
1338
+ // Get the object from the jsi::Value
1339
+ auto jsObject = jsValue.getObject(rt);
1340
+
1341
+ // Create the vtable struct
1342
+ UniffiForeignFutureResultU64 rsObject;
1343
+
1344
+ // Create the vtable from the js callbacks.
1345
+ rsObject.return_value = uniffi_jsi::Bridging<uint64_t>::fromJs(
1346
+ rt, callInvoker,
1347
+ jsObject.getProperty(rt, "returnValue")
1348
+ );
1349
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1350
+ rt, callInvoker,
1351
+ jsObject.getProperty(rt, "callStatus")
1352
+ );
1353
+
1354
+ return rsObject;
1355
+ }
1356
+ };
1357
+
1358
+ } // namespace uniffi::zkap_uniffi_bindings
1359
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU64,
1360
+ // passed from Rust to JS as part of async callbacks.
1361
+ namespace uniffi::zkap_uniffi_bindings {
1362
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1363
+
1364
+ template <> struct Bridging<UniffiForeignFutureCompleteU64> {
1365
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteU64 rsCallback) {
1366
+ return jsi::Function::createFromHostFunction(
1367
+ rt,
1368
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU64"),
1369
+ 2,
1370
+ [rsCallback, callInvoker](
1371
+ jsi::Runtime &rt,
1372
+ const jsi::Value &thisValue,
1373
+ const jsi::Value *arguments,
1374
+ size_t count) -> jsi::Value
1375
+ {
1376
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1377
+ }
1378
+ );
1379
+ }
1380
+
1381
+ static jsi::Value intoRust(
1382
+ jsi::Runtime &rt,
1383
+ std::shared_ptr<CallInvoker> callInvoker,
1384
+ const jsi::Value &thisValue,
1385
+ const jsi::Value *args,
1386
+ size_t count,
1387
+ UniffiForeignFutureCompleteU64 func) {
1388
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1389
+ // then call the rs_callback with those arguments.
1390
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultU64>::fromJs(rt, callInvoker, args[1])
1391
+ );
1392
+
1393
+
1394
+ return jsi::Value::undefined();
1395
+ }
1396
+ };
1397
+ } // namespace uniffi::zkap_uniffi_bindings
1398
+ namespace uniffi::zkap_uniffi_bindings {
1399
+ using namespace facebook;
1400
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1401
+
1402
+ template <> struct Bridging<UniffiForeignFutureResultI64> {
1403
+ static UniffiForeignFutureResultI64 fromJs(jsi::Runtime &rt,
1404
+ std::shared_ptr<CallInvoker> callInvoker,
1405
+ const jsi::Value &jsValue
1406
+ ) {
1407
+ // Check if the input is an object
1408
+ if (!jsValue.isObject()) {
1409
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultI64");
1410
+ }
1411
+
1412
+ // Get the object from the jsi::Value
1413
+ auto jsObject = jsValue.getObject(rt);
1414
+
1415
+ // Create the vtable struct
1416
+ UniffiForeignFutureResultI64 rsObject;
1417
+
1418
+ // Create the vtable from the js callbacks.
1419
+ rsObject.return_value = uniffi_jsi::Bridging<int64_t>::fromJs(
1420
+ rt, callInvoker,
1421
+ jsObject.getProperty(rt, "returnValue")
1422
+ );
1423
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1424
+ rt, callInvoker,
1425
+ jsObject.getProperty(rt, "callStatus")
1426
+ );
1427
+
1428
+ return rsObject;
1429
+ }
1430
+ };
1431
+
1432
+ } // namespace uniffi::zkap_uniffi_bindings
1433
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI64,
1434
+ // passed from Rust to JS as part of async callbacks.
1435
+ namespace uniffi::zkap_uniffi_bindings {
1436
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1437
+
1438
+ template <> struct Bridging<UniffiForeignFutureCompleteI64> {
1439
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteI64 rsCallback) {
1440
+ return jsi::Function::createFromHostFunction(
1441
+ rt,
1442
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI64"),
1443
+ 2,
1444
+ [rsCallback, callInvoker](
1445
+ jsi::Runtime &rt,
1446
+ const jsi::Value &thisValue,
1447
+ const jsi::Value *arguments,
1448
+ size_t count) -> jsi::Value
1449
+ {
1450
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1451
+ }
1452
+ );
1453
+ }
1454
+
1455
+ static jsi::Value intoRust(
1456
+ jsi::Runtime &rt,
1457
+ std::shared_ptr<CallInvoker> callInvoker,
1458
+ const jsi::Value &thisValue,
1459
+ const jsi::Value *args,
1460
+ size_t count,
1461
+ UniffiForeignFutureCompleteI64 func) {
1462
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1463
+ // then call the rs_callback with those arguments.
1464
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultI64>::fromJs(rt, callInvoker, args[1])
1465
+ );
1466
+
1467
+
1468
+ return jsi::Value::undefined();
1469
+ }
1470
+ };
1471
+ } // namespace uniffi::zkap_uniffi_bindings
1472
+ namespace uniffi::zkap_uniffi_bindings {
1473
+ using namespace facebook;
1474
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1475
+
1476
+ template <> struct Bridging<UniffiForeignFutureResultF32> {
1477
+ static UniffiForeignFutureResultF32 fromJs(jsi::Runtime &rt,
1478
+ std::shared_ptr<CallInvoker> callInvoker,
1479
+ const jsi::Value &jsValue
1480
+ ) {
1481
+ // Check if the input is an object
1482
+ if (!jsValue.isObject()) {
1483
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultF32");
1484
+ }
1485
+
1486
+ // Get the object from the jsi::Value
1487
+ auto jsObject = jsValue.getObject(rt);
1488
+
1489
+ // Create the vtable struct
1490
+ UniffiForeignFutureResultF32 rsObject;
1491
+
1492
+ // Create the vtable from the js callbacks.
1493
+ rsObject.return_value = uniffi_jsi::Bridging<float>::fromJs(
1494
+ rt, callInvoker,
1495
+ jsObject.getProperty(rt, "returnValue")
1496
+ );
1497
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1498
+ rt, callInvoker,
1499
+ jsObject.getProperty(rt, "callStatus")
1500
+ );
1501
+
1502
+ return rsObject;
1503
+ }
1504
+ };
1505
+
1506
+ } // namespace uniffi::zkap_uniffi_bindings
1507
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteF32,
1508
+ // passed from Rust to JS as part of async callbacks.
1509
+ namespace uniffi::zkap_uniffi_bindings {
1510
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1511
+
1512
+ template <> struct Bridging<UniffiForeignFutureCompleteF32> {
1513
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteF32 rsCallback) {
1514
+ return jsi::Function::createFromHostFunction(
1515
+ rt,
1516
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF32"),
1517
+ 2,
1518
+ [rsCallback, callInvoker](
1519
+ jsi::Runtime &rt,
1520
+ const jsi::Value &thisValue,
1521
+ const jsi::Value *arguments,
1522
+ size_t count) -> jsi::Value
1523
+ {
1524
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1525
+ }
1526
+ );
1527
+ }
1528
+
1529
+ static jsi::Value intoRust(
1530
+ jsi::Runtime &rt,
1531
+ std::shared_ptr<CallInvoker> callInvoker,
1532
+ const jsi::Value &thisValue,
1533
+ const jsi::Value *args,
1534
+ size_t count,
1535
+ UniffiForeignFutureCompleteF32 func) {
1536
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1537
+ // then call the rs_callback with those arguments.
1538
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultF32>::fromJs(rt, callInvoker, args[1])
1539
+ );
1540
+
1541
+
1542
+ return jsi::Value::undefined();
1543
+ }
1544
+ };
1545
+ } // namespace uniffi::zkap_uniffi_bindings
1546
+ namespace uniffi::zkap_uniffi_bindings {
1547
+ using namespace facebook;
1548
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1549
+
1550
+ template <> struct Bridging<UniffiForeignFutureResultF64> {
1551
+ static UniffiForeignFutureResultF64 fromJs(jsi::Runtime &rt,
1552
+ std::shared_ptr<CallInvoker> callInvoker,
1553
+ const jsi::Value &jsValue
1554
+ ) {
1555
+ // Check if the input is an object
1556
+ if (!jsValue.isObject()) {
1557
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultF64");
1558
+ }
1559
+
1560
+ // Get the object from the jsi::Value
1561
+ auto jsObject = jsValue.getObject(rt);
1562
+
1563
+ // Create the vtable struct
1564
+ UniffiForeignFutureResultF64 rsObject;
1565
+
1566
+ // Create the vtable from the js callbacks.
1567
+ rsObject.return_value = uniffi_jsi::Bridging<double>::fromJs(
1568
+ rt, callInvoker,
1569
+ jsObject.getProperty(rt, "returnValue")
1570
+ );
1571
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1572
+ rt, callInvoker,
1573
+ jsObject.getProperty(rt, "callStatus")
1574
+ );
1575
+
1576
+ return rsObject;
1577
+ }
1578
+ };
1579
+
1580
+ } // namespace uniffi::zkap_uniffi_bindings
1581
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteF64,
1582
+ // passed from Rust to JS as part of async callbacks.
1583
+ namespace uniffi::zkap_uniffi_bindings {
1584
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1585
+
1586
+ template <> struct Bridging<UniffiForeignFutureCompleteF64> {
1587
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteF64 rsCallback) {
1588
+ return jsi::Function::createFromHostFunction(
1589
+ rt,
1590
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF64"),
1591
+ 2,
1592
+ [rsCallback, callInvoker](
1593
+ jsi::Runtime &rt,
1594
+ const jsi::Value &thisValue,
1595
+ const jsi::Value *arguments,
1596
+ size_t count) -> jsi::Value
1597
+ {
1598
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1599
+ }
1600
+ );
1601
+ }
1602
+
1603
+ static jsi::Value intoRust(
1604
+ jsi::Runtime &rt,
1605
+ std::shared_ptr<CallInvoker> callInvoker,
1606
+ const jsi::Value &thisValue,
1607
+ const jsi::Value *args,
1608
+ size_t count,
1609
+ UniffiForeignFutureCompleteF64 func) {
1610
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1611
+ // then call the rs_callback with those arguments.
1612
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultF64>::fromJs(rt, callInvoker, args[1])
1613
+ );
1614
+
1615
+
1616
+ return jsi::Value::undefined();
1617
+ }
1618
+ };
1619
+ } // namespace uniffi::zkap_uniffi_bindings
1620
+ namespace uniffi::zkap_uniffi_bindings {
1621
+ using namespace facebook;
1622
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1623
+
1624
+ template <> struct Bridging<UniffiForeignFutureResultRustBuffer> {
1625
+ static UniffiForeignFutureResultRustBuffer fromJs(jsi::Runtime &rt,
1626
+ std::shared_ptr<CallInvoker> callInvoker,
1627
+ const jsi::Value &jsValue
1628
+ ) {
1629
+ // Check if the input is an object
1630
+ if (!jsValue.isObject()) {
1631
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultRustBuffer");
1632
+ }
1633
+
1634
+ // Get the object from the jsi::Value
1635
+ auto jsObject = jsValue.getObject(rt);
1636
+
1637
+ // Create the vtable struct
1638
+ UniffiForeignFutureResultRustBuffer rsObject;
1639
+
1640
+ // Create the vtable from the js callbacks.
1641
+ rsObject.return_value = uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(
1642
+ rt, callInvoker,
1643
+ jsObject.getProperty(rt, "returnValue")
1644
+ );
1645
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1646
+ rt, callInvoker,
1647
+ jsObject.getProperty(rt, "callStatus")
1648
+ );
1649
+
1650
+ return rsObject;
1651
+ }
1652
+ };
1653
+
1654
+ } // namespace uniffi::zkap_uniffi_bindings
1655
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteRustBuffer,
1656
+ // passed from Rust to JS as part of async callbacks.
1657
+ namespace uniffi::zkap_uniffi_bindings {
1658
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1659
+
1660
+ template <> struct Bridging<UniffiForeignFutureCompleteRustBuffer> {
1661
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteRustBuffer rsCallback) {
1662
+ return jsi::Function::createFromHostFunction(
1663
+ rt,
1664
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteRustBuffer"),
1665
+ 2,
1666
+ [rsCallback, callInvoker](
1667
+ jsi::Runtime &rt,
1668
+ const jsi::Value &thisValue,
1669
+ const jsi::Value *arguments,
1670
+ size_t count) -> jsi::Value
1671
+ {
1672
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1673
+ }
1674
+ );
1675
+ }
1676
+
1677
+ static jsi::Value intoRust(
1678
+ jsi::Runtime &rt,
1679
+ std::shared_ptr<CallInvoker> callInvoker,
1680
+ const jsi::Value &thisValue,
1681
+ const jsi::Value *args,
1682
+ size_t count,
1683
+ UniffiForeignFutureCompleteRustBuffer func) {
1684
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1685
+ // then call the rs_callback with those arguments.
1686
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultRustBuffer>::fromJs(rt, callInvoker, args[1])
1687
+ );
1688
+
1689
+
1690
+ return jsi::Value::undefined();
1691
+ }
1692
+ };
1693
+ } // namespace uniffi::zkap_uniffi_bindings
1694
+ namespace uniffi::zkap_uniffi_bindings {
1695
+ using namespace facebook;
1696
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1697
+
1698
+ template <> struct Bridging<UniffiForeignFutureResultVoid> {
1699
+ static UniffiForeignFutureResultVoid fromJs(jsi::Runtime &rt,
1700
+ std::shared_ptr<CallInvoker> callInvoker,
1701
+ const jsi::Value &jsValue
1702
+ ) {
1703
+ // Check if the input is an object
1704
+ if (!jsValue.isObject()) {
1705
+ throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureResultVoid");
1706
+ }
1707
+
1708
+ // Get the object from the jsi::Value
1709
+ auto jsObject = jsValue.getObject(rt);
1710
+
1711
+ // Create the vtable struct
1712
+ UniffiForeignFutureResultVoid rsObject;
1713
+
1714
+ // Create the vtable from the js callbacks.
1715
+ rsObject.call_status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::fromJs(
1716
+ rt, callInvoker,
1717
+ jsObject.getProperty(rt, "callStatus")
1718
+ );
1719
+
1720
+ return rsObject;
1721
+ }
1722
+ };
1723
+
1724
+ } // namespace uniffi::zkap_uniffi_bindings
1725
+ // Implementation of callback function calling from JS to Rust ForeignFutureCompleteVoid,
1726
+ // passed from Rust to JS as part of async callbacks.
1727
+ namespace uniffi::zkap_uniffi_bindings {
1728
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1729
+
1730
+ template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
1731
+ static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker, UniffiForeignFutureCompleteVoid rsCallback) {
1732
+ return jsi::Function::createFromHostFunction(
1733
+ rt,
1734
+ jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"),
1735
+ 2,
1736
+ [rsCallback, callInvoker](
1737
+ jsi::Runtime &rt,
1738
+ const jsi::Value &thisValue,
1739
+ const jsi::Value *arguments,
1740
+ size_t count) -> jsi::Value
1741
+ {
1742
+ return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback);
1743
+ }
1744
+ );
1745
+ }
1746
+
1747
+ static jsi::Value intoRust(
1748
+ jsi::Runtime &rt,
1749
+ std::shared_ptr<CallInvoker> callInvoker,
1750
+ const jsi::Value &thisValue,
1751
+ const jsi::Value *args,
1752
+ size_t count,
1753
+ UniffiForeignFutureCompleteVoid func) {
1754
+ // Convert the arguments into the Rust, with Bridging<T>::fromJs,
1755
+ // then call the rs_callback with those arguments.
1756
+ func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<UniffiForeignFutureResultVoid>::fromJs(rt, callInvoker, args[1])
1757
+ );
1758
+
1759
+
1760
+ return jsi::Value::undefined();
1761
+ }
1762
+ };
1763
+ } // namespace uniffi::zkap_uniffi_bindings
1764
+
1765
+
1766
+ namespace uniffi::zkap_uniffi_bindings {
1767
+ using namespace facebook;
1768
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
1769
+
1770
+ template <> struct Bridging<UniffiRustFutureContinuationCallback> {
1771
+ static UniffiRustFutureContinuationCallback fromJs(
1772
+ jsi::Runtime &rt,
1773
+ std::shared_ptr<CallInvoker> callInvoker,
1774
+ const jsi::Value &value
1775
+ ) {
1776
+ try {
1777
+ return uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback::makeCallbackFunction(
1778
+ rt,
1779
+ callInvoker,
1780
+ value
1781
+ );
1782
+ } catch (const std::logic_error &e) {
1783
+ throw jsi::JSError(rt, e.what());
1784
+ }
1785
+ }
1786
+ };
1787
+
1788
+ } // namespace uniffi::zkap_uniffi_bindings
1789
+
1790
+ NativeZkapUniffiBindings::NativeZkapUniffiBindings(
1791
+ jsi::Runtime &rt,
1792
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> invoker
1793
+ ) : callInvoker(invoker), props() {
1794
+ // Map from Javascript names to the cpp names
1795
+ props["ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"] = jsi::Function::createFromHostFunction(
1796
+ rt,
1797
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"),
1798
+ 1,
1799
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1800
+ return this->cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(rt, thisVal, args, count);
1801
+ }
1802
+ );
1803
+ props["ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"] = jsi::Function::createFromHostFunction(
1804
+ rt,
1805
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"),
1806
+ 1,
1807
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1808
+ return this->cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(rt, thisVal, args, count);
1809
+ }
1810
+ );
1811
+ props["ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"] = jsi::Function::createFromHostFunction(
1812
+ rt,
1813
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"),
1814
+ 1,
1815
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1816
+ return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(rt, thisVal, args, count);
1817
+ }
1818
+ );
1819
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_anchor"] = jsi::Function::createFromHostFunction(
1820
+ rt,
1821
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_anchor"),
1822
+ 2,
1823
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1824
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(rt, thisVal, args, count);
1825
+ }
1826
+ );
1827
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash"] = jsi::Function::createFromHostFunction(
1828
+ rt,
1829
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash"),
1830
+ 2,
1831
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1832
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(rt, thisVal, args, count);
1833
+ }
1834
+ );
1835
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_hash"] = jsi::Function::createFromHostFunction(
1836
+ rt,
1837
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_hash"),
1838
+ 1,
1839
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1840
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_hash(rt, thisVal, args, count);
1841
+ }
1842
+ );
1843
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash"] = jsi::Function::createFromHostFunction(
1844
+ rt,
1845
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash"),
1846
+ 3,
1847
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1848
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(rt, thisVal, args, count);
1849
+ }
1850
+ );
1851
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs"] = jsi::Function::createFromHostFunction(
1852
+ rt,
1853
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs"),
1854
+ 2,
1855
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1856
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs(rt, thisVal, args, count);
1857
+ }
1858
+ );
1859
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove"] = jsi::Function::createFromHostFunction(
1860
+ rt,
1861
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove"),
1862
+ 2,
1863
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1864
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_prove(rt, thisVal, args, count);
1865
+ }
1866
+ );
1867
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file"] = jsi::Function::createFromHostFunction(
1868
+ rt,
1869
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file"),
1870
+ 3,
1871
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1872
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file(rt, thisVal, args, count);
1873
+ }
1874
+ );
1875
+ props["ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles"] = jsi::Function::createFromHostFunction(
1876
+ rt,
1877
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles"),
1878
+ 3,
1879
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1880
+ return this->cpp_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles(rt, thisVal, args, count);
1881
+ }
1882
+ );
1883
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor"] = jsi::Function::createFromHostFunction(
1884
+ rt,
1885
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor"),
1886
+ 0,
1887
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1888
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor(rt, thisVal, args, count);
1889
+ }
1890
+ );
1891
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash"] = jsi::Function::createFromHostFunction(
1892
+ rt,
1893
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash"),
1894
+ 0,
1895
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1896
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash(rt, thisVal, args, count);
1897
+ }
1898
+ );
1899
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_hash"] = jsi::Function::createFromHostFunction(
1900
+ rt,
1901
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_hash"),
1902
+ 0,
1903
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1904
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_hash(rt, thisVal, args, count);
1905
+ }
1906
+ );
1907
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash"] = jsi::Function::createFromHostFunction(
1908
+ rt,
1909
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash"),
1910
+ 0,
1911
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1912
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash(rt, thisVal, args, count);
1913
+ }
1914
+ );
1915
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs"] = jsi::Function::createFromHostFunction(
1916
+ rt,
1917
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs"),
1918
+ 0,
1919
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1920
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs(rt, thisVal, args, count);
1921
+ }
1922
+ );
1923
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove"] = jsi::Function::createFromHostFunction(
1924
+ rt,
1925
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove"),
1926
+ 0,
1927
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1928
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove(rt, thisVal, args, count);
1929
+ }
1930
+ );
1931
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file"] = jsi::Function::createFromHostFunction(
1932
+ rt,
1933
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file"),
1934
+ 0,
1935
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1936
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file(rt, thisVal, args, count);
1937
+ }
1938
+ );
1939
+ props["ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles"] = jsi::Function::createFromHostFunction(
1940
+ rt,
1941
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles"),
1942
+ 0,
1943
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1944
+ return this->cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles(rt, thisVal, args, count);
1945
+ }
1946
+ );
1947
+ props["ubrn_ffi_zkap_uniffi_bindings_uniffi_contract_version"] = jsi::Function::createFromHostFunction(
1948
+ rt,
1949
+ jsi::PropNameID::forAscii(rt, "ubrn_ffi_zkap_uniffi_bindings_uniffi_contract_version"),
1950
+ 0,
1951
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
1952
+ return this->cpp_ffi_zkap_uniffi_bindings_uniffi_contract_version(rt, thisVal, args, count);
1953
+ }
1954
+ );
1955
+ }
1956
+
1957
+ void NativeZkapUniffiBindings::registerModule(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker) {
1958
+ auto invoker = std::make_shared<uniffi_runtime::UniffiCallInvoker>(callInvoker);
1959
+ auto tm = std::make_shared<NativeZkapUniffiBindings>(rt, invoker);
1960
+ auto obj = rt.global().createFromHostObject(rt, tm);
1961
+ rt.global().setProperty(rt, "NativeZkapUniffiBindings", obj);
1962
+ }
1963
+
1964
+ void NativeZkapUniffiBindings::unregisterModule(jsi::Runtime &rt) {
1965
+ uniffi::zkap_uniffi_bindings::registry::clearRegistry();
1966
+ }
1967
+
1968
+ jsi::Value NativeZkapUniffiBindings::get(jsi::Runtime& rt, const jsi::PropNameID& name) {
1969
+ try {
1970
+ return jsi::Value(rt, props.at(name.utf8(rt)));
1971
+ }
1972
+ catch (std::out_of_range &e) {
1973
+ return jsi::Value::undefined();
1974
+ }
1975
+ }
1976
+
1977
+ std::vector<jsi::PropNameID> NativeZkapUniffiBindings::getPropertyNames(jsi::Runtime& rt) {
1978
+ std::vector<jsi::PropNameID> rval;
1979
+ for (auto& [key, value] : props) {
1980
+ rval.push_back(jsi::PropNameID::forUtf8(rt, key));
1981
+ }
1982
+ return rval;
1983
+ }
1984
+
1985
+ void NativeZkapUniffiBindings::set(jsi::Runtime& rt, const jsi::PropNameID& name, const jsi::Value& value) {
1986
+ props.insert_or_assign(name.utf8(rt), &value);
1987
+ }
1988
+
1989
+ NativeZkapUniffiBindings::~NativeZkapUniffiBindings() {
1990
+ // Cleanup for callback function RustFutureContinuationCallback
1991
+ uniffi::zkap_uniffi_bindings::cb::rustfuturecontinuationcallback::cleanup();
1992
+ // Cleanup for callback function ForeignFutureDroppedCallback
1993
+ uniffi::zkap_uniffi_bindings::cb::foreignfuturedroppedcallback::cleanup();
1994
+ // Cleanup for "free" callback function CallbackInterfaceFree
1995
+
1996
+ }
1997
+
1998
+ // Utility functions for serialization/deserialization of strings.
1999
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2000
+ return uniffi_jsi::Bridging<std::string>::string_to_bytelength(rt, args[0]);
2001
+ }
2002
+
2003
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2004
+ return uniffi_jsi::Bridging<std::string>::string_to_arraybuffer(rt, args[0]);
2005
+ }
2006
+
2007
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2008
+ return uniffi_jsi::Bridging<std::string>::arraybuffer_to_string(rt, args[0]);
2009
+ }
2010
+
2011
+ // Methods calling directly into the uniffi generated C API of the Rust crate.
2012
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2013
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2014
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2015
+ &status
2016
+ );
2017
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2018
+
2019
+
2020
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2021
+ }
2022
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2023
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2024
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2025
+ &status
2026
+ );
2027
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2028
+
2029
+
2030
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2031
+ }
2032
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2033
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2034
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_generate_hash(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]),
2035
+ &status
2036
+ );
2037
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2038
+
2039
+
2040
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2041
+ }
2042
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2043
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2044
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]),
2045
+ &status
2046
+ );
2047
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2048
+
2049
+
2050
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2051
+ }
2052
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2053
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2054
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2055
+ &status
2056
+ );
2057
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2058
+
2059
+
2060
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2061
+ }
2062
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_prove(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2063
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2064
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_prove(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2065
+ &status
2066
+ );
2067
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2068
+
2069
+
2070
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2071
+ }
2072
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2073
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2074
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]),
2075
+ &status
2076
+ );
2077
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2078
+
2079
+
2080
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2081
+ }
2082
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2083
+ RustCallStatus status = uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::rustSuccess(rt);
2084
+ auto value = uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles(uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]),
2085
+ &status
2086
+ );
2087
+ uniffi::zkap_uniffi_bindings::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2088
+
2089
+
2090
+ return uniffi::zkap_uniffi_bindings::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2091
+ }
2092
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2093
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor(
2094
+ );
2095
+
2096
+
2097
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2098
+ }
2099
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2100
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash(
2101
+ );
2102
+
2103
+
2104
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2105
+ }
2106
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2107
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_generate_hash(
2108
+ );
2109
+
2110
+
2111
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2112
+ }
2113
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2114
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash(
2115
+ );
2116
+
2117
+
2118
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2119
+ }
2120
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2121
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs(
2122
+ );
2123
+
2124
+
2125
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2126
+ }
2127
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2128
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_prove(
2129
+ );
2130
+
2131
+
2132
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2133
+ }
2134
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2135
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file(
2136
+ );
2137
+
2138
+
2139
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2140
+ }
2141
+ jsi::Value NativeZkapUniffiBindings::cpp_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2142
+ auto value = uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles(
2143
+ );
2144
+
2145
+
2146
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2147
+ }
2148
+ jsi::Value NativeZkapUniffiBindings::cpp_ffi_zkap_uniffi_bindings_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2149
+ auto value = ffi_zkap_uniffi_bindings_uniffi_contract_version(
2150
+ );
2151
+
2152
+
2153
+ return uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, value);
2154
+ }