@fedimint/react-native-bindings 0.0.0-om-rn1-d72fdc108a01df2d7d64c2b85c8b1f9fd43927cb

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