@breeztech/breez-sdk-spark-react-native 0.3.4 → 0.3.5-rc1

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 (37) hide show
  1. package/cpp/generated/breez_sdk_common.cpp +2351 -79
  2. package/cpp/generated/breez_sdk_common.hpp +92 -0
  3. package/cpp/generated/breez_sdk_spark.cpp +102 -0
  4. package/cpp/generated/breez_sdk_spark.hpp +14 -0
  5. package/lib/commonjs/generated/breez_sdk_common-ffi.js.map +1 -1
  6. package/lib/commonjs/generated/breez_sdk_common.js +1043 -60
  7. package/lib/commonjs/generated/breez_sdk_common.js.map +1 -1
  8. package/lib/commonjs/generated/breez_sdk_spark-ffi.js.map +1 -1
  9. package/lib/commonjs/generated/breez_sdk_spark.js +108 -39
  10. package/lib/commonjs/generated/breez_sdk_spark.js.map +1 -1
  11. package/lib/module/generated/breez_sdk_common-ffi.js.map +1 -1
  12. package/lib/module/generated/breez_sdk_common.js +1041 -59
  13. package/lib/module/generated/breez_sdk_common.js.map +1 -1
  14. package/lib/module/generated/breez_sdk_spark-ffi.js.map +1 -1
  15. package/lib/module/generated/breez_sdk_spark.js +107 -39
  16. package/lib/module/generated/breez_sdk_spark.js.map +1 -1
  17. package/lib/typescript/commonjs/src/generated/breez_sdk_common-ffi.d.ts +47 -0
  18. package/lib/typescript/commonjs/src/generated/breez_sdk_common-ffi.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/src/generated/breez_sdk_common.d.ts +529 -0
  20. package/lib/typescript/commonjs/src/generated/breez_sdk_common.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/src/generated/breez_sdk_spark-ffi.d.ts +4 -0
  22. package/lib/typescript/commonjs/src/generated/breez_sdk_spark-ffi.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/src/generated/breez_sdk_spark.d.ts +79 -24
  24. package/lib/typescript/commonjs/src/generated/breez_sdk_spark.d.ts.map +1 -1
  25. package/lib/typescript/module/src/generated/breez_sdk_common-ffi.d.ts +47 -0
  26. package/lib/typescript/module/src/generated/breez_sdk_common-ffi.d.ts.map +1 -1
  27. package/lib/typescript/module/src/generated/breez_sdk_common.d.ts +529 -0
  28. package/lib/typescript/module/src/generated/breez_sdk_common.d.ts.map +1 -1
  29. package/lib/typescript/module/src/generated/breez_sdk_spark-ffi.d.ts +4 -0
  30. package/lib/typescript/module/src/generated/breez_sdk_spark-ffi.d.ts.map +1 -1
  31. package/lib/typescript/module/src/generated/breez_sdk_spark.d.ts +79 -24
  32. package/lib/typescript/module/src/generated/breez_sdk_spark.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/generated/breez_sdk_common-ffi.ts +134 -0
  35. package/src/generated/breez_sdk_common.ts +1739 -27
  36. package/src/generated/breez_sdk_spark-ffi.ts +10 -0
  37. package/src/generated/breez_sdk_spark.ts +191 -56
@@ -120,6 +120,46 @@ typedef void (*UniffiCallbackInterfaceRestClientMethod2)(
120
120
  uint64_t uniffi_handle, RustBuffer url, RustBuffer headers, RustBuffer body,
121
121
  UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
122
122
  uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
123
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod0)(
124
+ uint64_t uniffi_handle, RustBuffer record,
125
+ UniffiForeignFutureCompleteU64 uniffi_future_callback,
126
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
127
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod1)(
128
+ uint64_t uniffi_handle, RustBuffer record,
129
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
130
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
131
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod2)(
132
+ uint64_t uniffi_handle, uint32_t limit,
133
+ UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
134
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
135
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod3)(
136
+ uint64_t uniffi_handle,
137
+ UniffiForeignFutureCompleteU64 uniffi_future_callback,
138
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
139
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod4)(
140
+ uint64_t uniffi_handle, RustBuffer records,
141
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
142
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
143
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod5)(
144
+ uint64_t uniffi_handle, RustBuffer record,
145
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
146
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
147
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod6)(
148
+ uint64_t uniffi_handle, uint64_t revision,
149
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
150
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
151
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod7)(
152
+ uint64_t uniffi_handle, uint32_t limit,
153
+ UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
154
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
155
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod8)(
156
+ uint64_t uniffi_handle,
157
+ UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
158
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
159
+ typedef void (*UniffiCallbackInterfaceSyncStorageMethod9)(
160
+ uint64_t uniffi_handle, RustBuffer record,
161
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
162
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
123
163
  typedef struct UniffiVTableCallbackInterfaceFiatService {
124
164
  UniffiCallbackInterfaceFiatServiceMethod0 fetch_fiat_currencies;
125
165
  UniffiCallbackInterfaceFiatServiceMethod1 fetch_fiat_rates;
@@ -131,6 +171,19 @@ typedef struct UniffiVTableCallbackInterfaceRestClient {
131
171
  UniffiCallbackInterfaceRestClientMethod2 delete_request;
132
172
  UniffiCallbackInterfaceFree uniffi_free;
133
173
  } UniffiVTableCallbackInterfaceRestClient;
174
+ typedef struct UniffiVTableCallbackInterfaceSyncStorage {
175
+ UniffiCallbackInterfaceSyncStorageMethod0 add_outgoing_change;
176
+ UniffiCallbackInterfaceSyncStorageMethod1 complete_outgoing_sync;
177
+ UniffiCallbackInterfaceSyncStorageMethod2 get_pending_outgoing_changes;
178
+ UniffiCallbackInterfaceSyncStorageMethod3 get_last_revision;
179
+ UniffiCallbackInterfaceSyncStorageMethod4 insert_incoming_records;
180
+ UniffiCallbackInterfaceSyncStorageMethod5 delete_incoming_record;
181
+ UniffiCallbackInterfaceSyncStorageMethod6 rebase_pending_outgoing_records;
182
+ UniffiCallbackInterfaceSyncStorageMethod7 get_incoming_records;
183
+ UniffiCallbackInterfaceSyncStorageMethod8 get_latest_outgoing_change;
184
+ UniffiCallbackInterfaceSyncStorageMethod9 update_record_from_incoming;
185
+ UniffiCallbackInterfaceFree uniffi_free;
186
+ } UniffiVTableCallbackInterfaceSyncStorage;
134
187
  void *
135
188
  uniffi_breez_sdk_common_fn_clone_fiatservice(void *ptr,
136
189
  RustCallStatus *uniffi_out_err);
@@ -155,6 +208,42 @@ void uniffi_breez_sdk_common_fn_init_callback_vtable_restclient(
155
208
  void *ptr, RustBuffer url, RustBuffer headers, RustBuffer body);
156
209
  /*handle*/ uint64_t uniffi_breez_sdk_common_fn_method_restclient_delete_request(
157
210
  void *ptr, RustBuffer url, RustBuffer headers, RustBuffer body);
211
+ void *
212
+ uniffi_breez_sdk_common_fn_clone_syncstorage(void *ptr,
213
+ RustCallStatus *uniffi_out_err);
214
+ void uniffi_breez_sdk_common_fn_free_syncstorage(
215
+ void *ptr, RustCallStatus *uniffi_out_err);
216
+ void uniffi_breez_sdk_common_fn_init_callback_vtable_syncstorage(
217
+ UniffiVTableCallbackInterfaceSyncStorage *vtable);
218
+ /*handle*/ uint64_t
219
+ uniffi_breez_sdk_common_fn_method_syncstorage_add_outgoing_change(
220
+ void *ptr, RustBuffer record);
221
+ /*handle*/ uint64_t
222
+ uniffi_breez_sdk_common_fn_method_syncstorage_complete_outgoing_sync(
223
+ void *ptr, RustBuffer record);
224
+ /*handle*/ uint64_t
225
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_pending_outgoing_changes(
226
+ void *ptr, uint32_t limit);
227
+ /*handle*/ uint64_t
228
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_last_revision(void *ptr);
229
+ /*handle*/ uint64_t
230
+ uniffi_breez_sdk_common_fn_method_syncstorage_insert_incoming_records(
231
+ void *ptr, RustBuffer records);
232
+ /*handle*/ uint64_t
233
+ uniffi_breez_sdk_common_fn_method_syncstorage_delete_incoming_record(
234
+ void *ptr, RustBuffer record);
235
+ /*handle*/ uint64_t
236
+ uniffi_breez_sdk_common_fn_method_syncstorage_rebase_pending_outgoing_records(
237
+ void *ptr, uint64_t revision);
238
+ /*handle*/ uint64_t
239
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_incoming_records(
240
+ void *ptr, uint32_t limit);
241
+ /*handle*/ uint64_t
242
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_latest_outgoing_change(
243
+ void *ptr);
244
+ /*handle*/ uint64_t
245
+ uniffi_breez_sdk_common_fn_method_syncstorage_update_record_from_incoming(
246
+ void *ptr, RustBuffer record);
158
247
  RustBuffer
159
248
  ffi_breez_sdk_common_rustbuffer_alloc(uint64_t size,
160
249
  RustCallStatus *uniffi_out_err);
@@ -289,6 +378,26 @@ uint16_t uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates();
289
378
  uint16_t uniffi_breez_sdk_common_checksum_method_restclient_get_request();
290
379
  uint16_t uniffi_breez_sdk_common_checksum_method_restclient_post_request();
291
380
  uint16_t uniffi_breez_sdk_common_checksum_method_restclient_delete_request();
381
+ uint16_t
382
+ uniffi_breez_sdk_common_checksum_method_syncstorage_add_outgoing_change();
383
+ uint16_t
384
+ uniffi_breez_sdk_common_checksum_method_syncstorage_complete_outgoing_sync();
385
+ uint16_t
386
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_pending_outgoing_changes();
387
+ uint16_t
388
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_last_revision();
389
+ uint16_t
390
+ uniffi_breez_sdk_common_checksum_method_syncstorage_insert_incoming_records();
391
+ uint16_t
392
+ uniffi_breez_sdk_common_checksum_method_syncstorage_delete_incoming_record();
393
+ uint16_t
394
+ uniffi_breez_sdk_common_checksum_method_syncstorage_rebase_pending_outgoing_records();
395
+ uint16_t
396
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_incoming_records();
397
+ uint16_t
398
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_latest_outgoing_change();
399
+ uint16_t
400
+ uniffi_breez_sdk_common_checksum_method_syncstorage_update_record_from_incoming();
292
401
  uint32_t ffi_breez_sdk_common_uniffi_contract_version();
293
402
  }
294
403
 
@@ -980,6 +1089,118 @@ static void cleanup() {
980
1089
  }
981
1090
  } // namespace
982
1091
  // uniffi::breez_sdk_common::st::vtablecallbackinterfacerestclient::vtablecallbackinterfacerestclient::free
1092
+
1093
+ // Callback function:
1094
+ // uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::vtablecallbackinterfacesyncstorage::free::UniffiCallbackInterfaceFree
1095
+ //
1096
+ // We have the following constraints:
1097
+ // - we need to pass a function pointer to Rust.
1098
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
1099
+ // - function pointers can't store state, so we can't use a lamda.
1100
+ //
1101
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
1102
+ // function calls the lambda, which itself calls the `body` which then calls
1103
+ // into JS.
1104
+ //
1105
+ // We then give the `callback` function pointer to Rust which will call the
1106
+ // lambda sometime in the future.
1107
+ namespace uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::
1108
+ vtablecallbackinterfacesyncstorage::free {
1109
+ using namespace facebook;
1110
+
1111
+ // We need to store a lambda in a global so we can call it from
1112
+ // a function pointer. The function pointer is passed to Rust.
1113
+ static std::function<void(uint64_t)> rsLambda = nullptr;
1114
+
1115
+ // This is the main body of the callback. It's called from the lambda,
1116
+ // which itself is called from the callback function which is passed to Rust.
1117
+ static void body(jsi::Runtime &rt,
1118
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
1119
+ std::shared_ptr<jsi::Value> callbackValue,
1120
+ uint64_t rs_handle) {
1121
+
1122
+ // Convert the arguments from Rust, into jsi::Values.
1123
+ // We'll use the Bridging class to do this…
1124
+ auto js_handle =
1125
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
1126
+
1127
+ // Now we are ready to call the callback.
1128
+ // We are already on the JS thread, because this `body` function was
1129
+ // invoked from the CallInvoker.
1130
+ try {
1131
+ // Getting the callback function
1132
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
1133
+ auto uniffiResult = cb.call(rt, js_handle);
1134
+
1135
+ } catch (const jsi::JSError &error) {
1136
+ std::cout << "Error in callback UniffiCallbackInterfaceFree: "
1137
+ << error.what() << std::endl;
1138
+ throw error;
1139
+ }
1140
+ }
1141
+
1142
+ static void callback(uint64_t rs_handle) {
1143
+ // If the runtime has shutdown, then there is no point in trying to
1144
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
1145
+ //
1146
+ // Answer: the module destructor calls into callback `cleanup` method,
1147
+ // which nulls out the rsLamda.
1148
+ //
1149
+ // If rsLamda is null, then there is no runtime to call into.
1150
+ if (rsLambda == nullptr) {
1151
+ // This only occurs when destructors are calling into Rust free/drop,
1152
+ // which causes the JS callback to be dropped.
1153
+ return;
1154
+ }
1155
+
1156
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
1157
+ // are all in the lambda.
1158
+ rsLambda(rs_handle);
1159
+ }
1160
+
1161
+ static UniffiCallbackInterfaceFree
1162
+ makeCallbackFunction( // uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::vtablecallbackinterfacesyncstorage::free
1163
+ jsi::Runtime &rt,
1164
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
1165
+ const jsi::Value &value) {
1166
+ if (rsLambda != nullptr) {
1167
+ // `makeCallbackFunction` is called in two circumstances:
1168
+ //
1169
+ // 1. at startup, when initializing callback interface vtables.
1170
+ // 2. when polling futures. This happens at least once per future that is
1171
+ // exposed to Javascript. We know that this is always the same function,
1172
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
1173
+ //
1174
+ // We can therefore return the callback function without making anything
1175
+ // new if we've been initialized already.
1176
+ return callback;
1177
+ }
1178
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
1179
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
1180
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
1181
+ // We immediately make a lambda which will do the work of transforming the
1182
+ // arguments into JSI values and calling the callback.
1183
+ uniffi_runtime::UniffiCallFunc jsLambda =
1184
+ [callInvoker, callbackValue, rs_handle](jsi::Runtime &rt) mutable {
1185
+ body(rt, callInvoker, callbackValue, rs_handle);
1186
+ };
1187
+ // We'll then call that lambda from the callInvoker which will
1188
+ // look after calling it on the correct thread.
1189
+
1190
+ callInvoker->invokeNonBlocking(rt, jsLambda);
1191
+ };
1192
+ return callback;
1193
+ }
1194
+
1195
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
1196
+ // happens when the jsi::Runtime is being destroyed.
1197
+ static void cleanup() {
1198
+ // The lambda holds a reference to the the Runtime, so when this is nulled
1199
+ // out, then the pointer will no longer be left dangling.
1200
+ rsLambda = nullptr;
1201
+ }
1202
+ } // namespace
1203
+ // uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::vtablecallbackinterfacesyncstorage::free
983
1204
  namespace uniffi::breez_sdk_common {
984
1205
  using namespace facebook;
985
1206
  using CallInvoker = uniffi_runtime::UniffiCallInvoker;
@@ -2606,63 +2827,1462 @@ static void cleanup() {
2606
2827
  rsLambda = nullptr;
2607
2828
  }
2608
2829
  } // namespace uniffi::breez_sdk_common::cb::callbackinterfacerestclientmethod2
2609
- namespace uniffi::breez_sdk_common {
2830
+ // Implementation of callback function calling from Rust to JS
2831
+ // CallbackInterfaceSyncStorageMethod0
2832
+
2833
+ // Callback function:
2834
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod0::UniffiCallbackInterfaceSyncStorageMethod0
2835
+ //
2836
+ // We have the following constraints:
2837
+ // - we need to pass a function pointer to Rust.
2838
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
2839
+ // - function pointers can't store state, so we can't use a lamda.
2840
+ //
2841
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
2842
+ // function calls the lambda, which itself calls the `body` which then calls
2843
+ // into JS.
2844
+ //
2845
+ // We then give the `callback` function pointer to Rust which will call the
2846
+ // lambda sometime in the future.
2847
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod0 {
2610
2848
  using namespace facebook;
2611
- using CallInvoker = uniffi_runtime::UniffiCallInvoker;
2612
2849
 
2613
- template <> struct Bridging<UniffiVTableCallbackInterfaceFiatService> {
2614
- static UniffiVTableCallbackInterfaceFiatService
2615
- fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
2616
- const jsi::Value &jsValue) {
2617
- // Check if the input is an object
2618
- if (!jsValue.isObject()) {
2619
- throw jsi::JSError(
2620
- rt,
2621
- "Expected an object for UniffiVTableCallbackInterfaceFiatService");
2622
- }
2850
+ // We need to store a lambda in a global so we can call it from
2851
+ // a function pointer. The function pointer is passed to Rust.
2852
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteU64,
2853
+ uint64_t, UniffiForeignFuture *)>
2854
+ rsLambda = nullptr;
2623
2855
 
2624
- // Get the object from the jsi::Value
2625
- auto jsObject = jsValue.getObject(rt);
2856
+ // This is the main body of the callback. It's called from the lambda,
2857
+ // which itself is called from the callback function which is passed to Rust.
2858
+ static void body(jsi::Runtime &rt,
2859
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2860
+ std::shared_ptr<jsi::Value> callbackValue,
2861
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
2862
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
2863
+ uint64_t rs_uniffiCallbackData,
2864
+ UniffiForeignFuture *rs_uniffiOutReturn) {
2626
2865
 
2627
- // Create the vtable struct
2628
- UniffiVTableCallbackInterfaceFiatService rsObject;
2866
+ // Convert the arguments from Rust, into jsi::Values.
2867
+ // We'll use the Bridging class to do this…
2868
+ auto js_uniffiHandle =
2869
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
2870
+ auto js_record = uniffi::breez_sdk_common::Bridging<RustBuffer>::toJs(
2871
+ rt, callInvoker, rs_record);
2872
+ auto js_uniffiFutureCallback =
2873
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteU64>::toJs(
2874
+ rt, callInvoker, rs_uniffiFutureCallback);
2875
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
2876
+ rt, callInvoker, rs_uniffiCallbackData);
2629
2877
 
2630
- // Create the vtable from the js callbacks.
2631
- rsObject.fetch_fiat_currencies = uniffi::breez_sdk_common::cb::
2632
- callbackinterfacefiatservicemethod0::makeCallbackFunction(
2633
- rt, callInvoker, jsObject.getProperty(rt, "fetchFiatCurrencies"));
2634
- rsObject.fetch_fiat_rates = uniffi::breez_sdk_common::cb::
2635
- callbackinterfacefiatservicemethod1::makeCallbackFunction(
2636
- rt, callInvoker, jsObject.getProperty(rt, "fetchFiatRates"));
2637
- rsObject.uniffi_free =
2638
- uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::
2639
- vtablecallbackinterfacefiatservice::free::makeCallbackFunction(
2640
- rt, callInvoker, jsObject.getProperty(rt, "uniffiFree"));
2878
+ // Now we are ready to call the callback.
2879
+ // We are already on the JS thread, because this `body` function was
2880
+ // invoked from the CallInvoker.
2881
+ try {
2882
+ // Getting the callback function
2883
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
2884
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_record,
2885
+ js_uniffiFutureCallback, js_uniffiCallbackData);
2641
2886
 
2642
- return rsObject;
2887
+ // Finally, we need to copy the return value back into the Rust pointer.
2888
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
2889
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
2890
+ uniffiResult);
2891
+ } catch (const jsi::JSError &error) {
2892
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod0: "
2893
+ << error.what() << std::endl;
2894
+ throw error;
2643
2895
  }
2644
- };
2645
-
2646
- } // namespace uniffi::breez_sdk_common
2647
- namespace uniffi::breez_sdk_common {
2648
- using namespace facebook;
2649
- using CallInvoker = uniffi_runtime::UniffiCallInvoker;
2896
+ }
2650
2897
 
2651
- template <> struct Bridging<UniffiVTableCallbackInterfaceRestClient> {
2652
- static UniffiVTableCallbackInterfaceRestClient
2653
- fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
2654
- const jsi::Value &jsValue) {
2655
- // Check if the input is an object
2656
- if (!jsValue.isObject()) {
2657
- throw jsi::JSError(
2658
- rt, "Expected an object for UniffiVTableCallbackInterfaceRestClient");
2659
- }
2898
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_record,
2899
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
2900
+ uint64_t rs_uniffiCallbackData,
2901
+ UniffiForeignFuture *rs_uniffiOutReturn) {
2902
+ // If the runtime has shutdown, then there is no point in trying to
2903
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
2904
+ //
2905
+ // Answer: the module destructor calls into callback `cleanup` method,
2906
+ // which nulls out the rsLamda.
2907
+ //
2908
+ // If rsLamda is null, then there is no runtime to call into.
2909
+ if (rsLambda == nullptr) {
2910
+ // This only occurs when destructors are calling into Rust free/drop,
2911
+ // which causes the JS callback to be dropped.
2912
+ return;
2913
+ }
2660
2914
 
2661
- // Get the object from the jsi::Value
2662
- auto jsObject = jsValue.getObject(rt);
2915
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
2916
+ // are all in the lambda.
2917
+ rsLambda(rs_uniffiHandle, rs_record, rs_uniffiFutureCallback,
2918
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
2919
+ }
2663
2920
 
2664
- // Create the vtable struct
2665
- UniffiVTableCallbackInterfaceRestClient rsObject;
2921
+ static UniffiCallbackInterfaceSyncStorageMethod0
2922
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod0
2923
+ jsi::Runtime &rt,
2924
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2925
+ const jsi::Value &value) {
2926
+ if (rsLambda != nullptr) {
2927
+ // `makeCallbackFunction` is called in two circumstances:
2928
+ //
2929
+ // 1. at startup, when initializing callback interface vtables.
2930
+ // 2. when polling futures. This happens at least once per future that is
2931
+ // exposed to Javascript. We know that this is always the same function,
2932
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
2933
+ //
2934
+ // We can therefore return the callback function without making anything
2935
+ // new if we've been initialized already.
2936
+ return callback;
2937
+ }
2938
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
2939
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
2940
+ rsLambda = [&rt, callInvoker, callbackValue](
2941
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
2942
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
2943
+ uint64_t rs_uniffiCallbackData,
2944
+ UniffiForeignFuture *rs_uniffiOutReturn) {
2945
+ // We immediately make a lambda which will do the work of transforming the
2946
+ // arguments into JSI values and calling the callback.
2947
+ uniffi_runtime::UniffiCallFunc jsLambda =
2948
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_record,
2949
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
2950
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
2951
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_record,
2952
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
2953
+ rs_uniffiOutReturn);
2954
+ };
2955
+ // We'll then call that lambda from the callInvoker which will
2956
+ // look after calling it on the correct thread.
2957
+ callInvoker->invokeBlocking(rt, jsLambda);
2958
+ };
2959
+ return callback;
2960
+ }
2961
+
2962
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
2963
+ // happens when the jsi::Runtime is being destroyed.
2964
+ static void cleanup() {
2965
+ // The lambda holds a reference to the the Runtime, so when this is nulled
2966
+ // out, then the pointer will no longer be left dangling.
2967
+ rsLambda = nullptr;
2968
+ }
2969
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod0
2970
+ // Implementation of callback function calling from Rust to JS
2971
+ // CallbackInterfaceSyncStorageMethod1
2972
+
2973
+ // Callback function:
2974
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod1::UniffiCallbackInterfaceSyncStorageMethod1
2975
+ //
2976
+ // We have the following constraints:
2977
+ // - we need to pass a function pointer to Rust.
2978
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
2979
+ // - function pointers can't store state, so we can't use a lamda.
2980
+ //
2981
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
2982
+ // function calls the lambda, which itself calls the `body` which then calls
2983
+ // into JS.
2984
+ //
2985
+ // We then give the `callback` function pointer to Rust which will call the
2986
+ // lambda sometime in the future.
2987
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod1 {
2988
+ using namespace facebook;
2989
+
2990
+ // We need to store a lambda in a global so we can call it from
2991
+ // a function pointer. The function pointer is passed to Rust.
2992
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid,
2993
+ uint64_t, UniffiForeignFuture *)>
2994
+ rsLambda = nullptr;
2995
+
2996
+ // This is the main body of the callback. It's called from the lambda,
2997
+ // which itself is called from the callback function which is passed to Rust.
2998
+ static void body(jsi::Runtime &rt,
2999
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3000
+ std::shared_ptr<jsi::Value> callbackValue,
3001
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
3002
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3003
+ uint64_t rs_uniffiCallbackData,
3004
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3005
+
3006
+ // Convert the arguments from Rust, into jsi::Values.
3007
+ // We'll use the Bridging class to do this…
3008
+ auto js_uniffiHandle =
3009
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3010
+ auto js_record = uniffi::breez_sdk_common::Bridging<RustBuffer>::toJs(
3011
+ rt, callInvoker, rs_record);
3012
+ auto js_uniffiFutureCallback =
3013
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
3014
+ rt, callInvoker, rs_uniffiFutureCallback);
3015
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3016
+ rt, callInvoker, rs_uniffiCallbackData);
3017
+
3018
+ // Now we are ready to call the callback.
3019
+ // We are already on the JS thread, because this `body` function was
3020
+ // invoked from the CallInvoker.
3021
+ try {
3022
+ // Getting the callback function
3023
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3024
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_record,
3025
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3026
+
3027
+ // Finally, we need to copy the return value back into the Rust pointer.
3028
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3029
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3030
+ uniffiResult);
3031
+ } catch (const jsi::JSError &error) {
3032
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod1: "
3033
+ << error.what() << std::endl;
3034
+ throw error;
3035
+ }
3036
+ }
3037
+
3038
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_record,
3039
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3040
+ uint64_t rs_uniffiCallbackData,
3041
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3042
+ // If the runtime has shutdown, then there is no point in trying to
3043
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3044
+ //
3045
+ // Answer: the module destructor calls into callback `cleanup` method,
3046
+ // which nulls out the rsLamda.
3047
+ //
3048
+ // If rsLamda is null, then there is no runtime to call into.
3049
+ if (rsLambda == nullptr) {
3050
+ // This only occurs when destructors are calling into Rust free/drop,
3051
+ // which causes the JS callback to be dropped.
3052
+ return;
3053
+ }
3054
+
3055
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3056
+ // are all in the lambda.
3057
+ rsLambda(rs_uniffiHandle, rs_record, rs_uniffiFutureCallback,
3058
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3059
+ }
3060
+
3061
+ static UniffiCallbackInterfaceSyncStorageMethod1
3062
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod1
3063
+ jsi::Runtime &rt,
3064
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3065
+ const jsi::Value &value) {
3066
+ if (rsLambda != nullptr) {
3067
+ // `makeCallbackFunction` is called in two circumstances:
3068
+ //
3069
+ // 1. at startup, when initializing callback interface vtables.
3070
+ // 2. when polling futures. This happens at least once per future that is
3071
+ // exposed to Javascript. We know that this is always the same function,
3072
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3073
+ //
3074
+ // We can therefore return the callback function without making anything
3075
+ // new if we've been initialized already.
3076
+ return callback;
3077
+ }
3078
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3079
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3080
+ rsLambda = [&rt, callInvoker, callbackValue](
3081
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
3082
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3083
+ uint64_t rs_uniffiCallbackData,
3084
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3085
+ // We immediately make a lambda which will do the work of transforming the
3086
+ // arguments into JSI values and calling the callback.
3087
+ uniffi_runtime::UniffiCallFunc jsLambda =
3088
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_record,
3089
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3090
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3091
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_record,
3092
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3093
+ rs_uniffiOutReturn);
3094
+ };
3095
+ // We'll then call that lambda from the callInvoker which will
3096
+ // look after calling it on the correct thread.
3097
+ callInvoker->invokeBlocking(rt, jsLambda);
3098
+ };
3099
+ return callback;
3100
+ }
3101
+
3102
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3103
+ // happens when the jsi::Runtime is being destroyed.
3104
+ static void cleanup() {
3105
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3106
+ // out, then the pointer will no longer be left dangling.
3107
+ rsLambda = nullptr;
3108
+ }
3109
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod1
3110
+ // Implementation of callback function calling from Rust to JS
3111
+ // CallbackInterfaceSyncStorageMethod2
3112
+
3113
+ // Callback function:
3114
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod2::UniffiCallbackInterfaceSyncStorageMethod2
3115
+ //
3116
+ // We have the following constraints:
3117
+ // - we need to pass a function pointer to Rust.
3118
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3119
+ // - function pointers can't store state, so we can't use a lamda.
3120
+ //
3121
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3122
+ // function calls the lambda, which itself calls the `body` which then calls
3123
+ // into JS.
3124
+ //
3125
+ // We then give the `callback` function pointer to Rust which will call the
3126
+ // lambda sometime in the future.
3127
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod2 {
3128
+ using namespace facebook;
3129
+
3130
+ // We need to store a lambda in a global so we can call it from
3131
+ // a function pointer. The function pointer is passed to Rust.
3132
+ static std::function<void(uint64_t, uint32_t,
3133
+ UniffiForeignFutureCompleteRustBuffer, uint64_t,
3134
+ UniffiForeignFuture *)>
3135
+ rsLambda = nullptr;
3136
+
3137
+ // This is the main body of the callback. It's called from the lambda,
3138
+ // which itself is called from the callback function which is passed to Rust.
3139
+ static void body(jsi::Runtime &rt,
3140
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3141
+ std::shared_ptr<jsi::Value> callbackValue,
3142
+ uint64_t rs_uniffiHandle, uint32_t rs_limit,
3143
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3144
+ uint64_t rs_uniffiCallbackData,
3145
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3146
+
3147
+ // Convert the arguments from Rust, into jsi::Values.
3148
+ // We'll use the Bridging class to do this…
3149
+ auto js_uniffiHandle =
3150
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3151
+ auto js_limit =
3152
+ uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, rs_limit);
3153
+ auto js_uniffiFutureCallback = uniffi::breez_sdk_common::Bridging<
3154
+ UniffiForeignFutureCompleteRustBuffer>::toJs(rt, callInvoker,
3155
+ rs_uniffiFutureCallback);
3156
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3157
+ rt, callInvoker, rs_uniffiCallbackData);
3158
+
3159
+ // Now we are ready to call the callback.
3160
+ // We are already on the JS thread, because this `body` function was
3161
+ // invoked from the CallInvoker.
3162
+ try {
3163
+ // Getting the callback function
3164
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3165
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_limit,
3166
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3167
+
3168
+ // Finally, we need to copy the return value back into the Rust pointer.
3169
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3170
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3171
+ uniffiResult);
3172
+ } catch (const jsi::JSError &error) {
3173
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod2: "
3174
+ << error.what() << std::endl;
3175
+ throw error;
3176
+ }
3177
+ }
3178
+
3179
+ static void
3180
+ callback(uint64_t rs_uniffiHandle, uint32_t rs_limit,
3181
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3182
+ uint64_t rs_uniffiCallbackData,
3183
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3184
+ // If the runtime has shutdown, then there is no point in trying to
3185
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3186
+ //
3187
+ // Answer: the module destructor calls into callback `cleanup` method,
3188
+ // which nulls out the rsLamda.
3189
+ //
3190
+ // If rsLamda is null, then there is no runtime to call into.
3191
+ if (rsLambda == nullptr) {
3192
+ // This only occurs when destructors are calling into Rust free/drop,
3193
+ // which causes the JS callback to be dropped.
3194
+ return;
3195
+ }
3196
+
3197
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3198
+ // are all in the lambda.
3199
+ rsLambda(rs_uniffiHandle, rs_limit, rs_uniffiFutureCallback,
3200
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3201
+ }
3202
+
3203
+ static UniffiCallbackInterfaceSyncStorageMethod2
3204
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod2
3205
+ jsi::Runtime &rt,
3206
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3207
+ const jsi::Value &value) {
3208
+ if (rsLambda != nullptr) {
3209
+ // `makeCallbackFunction` is called in two circumstances:
3210
+ //
3211
+ // 1. at startup, when initializing callback interface vtables.
3212
+ // 2. when polling futures. This happens at least once per future that is
3213
+ // exposed to Javascript. We know that this is always the same function,
3214
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3215
+ //
3216
+ // We can therefore return the callback function without making anything
3217
+ // new if we've been initialized already.
3218
+ return callback;
3219
+ }
3220
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3221
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3222
+ rsLambda = [&rt, callInvoker, callbackValue](
3223
+ uint64_t rs_uniffiHandle, uint32_t rs_limit,
3224
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3225
+ uint64_t rs_uniffiCallbackData,
3226
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3227
+ // We immediately make a lambda which will do the work of transforming the
3228
+ // arguments into JSI values and calling the callback.
3229
+ uniffi_runtime::UniffiCallFunc jsLambda =
3230
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_limit,
3231
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3232
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3233
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_limit,
3234
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3235
+ rs_uniffiOutReturn);
3236
+ };
3237
+ // We'll then call that lambda from the callInvoker which will
3238
+ // look after calling it on the correct thread.
3239
+ callInvoker->invokeBlocking(rt, jsLambda);
3240
+ };
3241
+ return callback;
3242
+ }
3243
+
3244
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3245
+ // happens when the jsi::Runtime is being destroyed.
3246
+ static void cleanup() {
3247
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3248
+ // out, then the pointer will no longer be left dangling.
3249
+ rsLambda = nullptr;
3250
+ }
3251
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod2
3252
+ // Implementation of callback function calling from Rust to JS
3253
+ // CallbackInterfaceSyncStorageMethod3
3254
+
3255
+ // Callback function:
3256
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod3::UniffiCallbackInterfaceSyncStorageMethod3
3257
+ //
3258
+ // We have the following constraints:
3259
+ // - we need to pass a function pointer to Rust.
3260
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3261
+ // - function pointers can't store state, so we can't use a lamda.
3262
+ //
3263
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3264
+ // function calls the lambda, which itself calls the `body` which then calls
3265
+ // into JS.
3266
+ //
3267
+ // We then give the `callback` function pointer to Rust which will call the
3268
+ // lambda sometime in the future.
3269
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod3 {
3270
+ using namespace facebook;
3271
+
3272
+ // We need to store a lambda in a global so we can call it from
3273
+ // a function pointer. The function pointer is passed to Rust.
3274
+ static std::function<void(uint64_t, UniffiForeignFutureCompleteU64, uint64_t,
3275
+ UniffiForeignFuture *)>
3276
+ rsLambda = nullptr;
3277
+
3278
+ // This is the main body of the callback. It's called from the lambda,
3279
+ // which itself is called from the callback function which is passed to Rust.
3280
+ static void body(jsi::Runtime &rt,
3281
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3282
+ std::shared_ptr<jsi::Value> callbackValue,
3283
+ uint64_t rs_uniffiHandle,
3284
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
3285
+ uint64_t rs_uniffiCallbackData,
3286
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3287
+
3288
+ // Convert the arguments from Rust, into jsi::Values.
3289
+ // We'll use the Bridging class to do this…
3290
+ auto js_uniffiHandle =
3291
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3292
+ auto js_uniffiFutureCallback =
3293
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteU64>::toJs(
3294
+ rt, callInvoker, rs_uniffiFutureCallback);
3295
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3296
+ rt, callInvoker, rs_uniffiCallbackData);
3297
+
3298
+ // Now we are ready to call the callback.
3299
+ // We are already on the JS thread, because this `body` function was
3300
+ // invoked from the CallInvoker.
3301
+ try {
3302
+ // Getting the callback function
3303
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3304
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_uniffiFutureCallback,
3305
+ js_uniffiCallbackData);
3306
+
3307
+ // Finally, we need to copy the return value back into the Rust pointer.
3308
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3309
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3310
+ uniffiResult);
3311
+ } catch (const jsi::JSError &error) {
3312
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod3: "
3313
+ << error.what() << std::endl;
3314
+ throw error;
3315
+ }
3316
+ }
3317
+
3318
+ static void callback(uint64_t rs_uniffiHandle,
3319
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
3320
+ uint64_t rs_uniffiCallbackData,
3321
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3322
+ // If the runtime has shutdown, then there is no point in trying to
3323
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3324
+ //
3325
+ // Answer: the module destructor calls into callback `cleanup` method,
3326
+ // which nulls out the rsLamda.
3327
+ //
3328
+ // If rsLamda is null, then there is no runtime to call into.
3329
+ if (rsLambda == nullptr) {
3330
+ // This only occurs when destructors are calling into Rust free/drop,
3331
+ // which causes the JS callback to be dropped.
3332
+ return;
3333
+ }
3334
+
3335
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3336
+ // are all in the lambda.
3337
+ rsLambda(rs_uniffiHandle, rs_uniffiFutureCallback, rs_uniffiCallbackData,
3338
+ rs_uniffiOutReturn);
3339
+ }
3340
+
3341
+ static UniffiCallbackInterfaceSyncStorageMethod3
3342
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod3
3343
+ jsi::Runtime &rt,
3344
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3345
+ const jsi::Value &value) {
3346
+ if (rsLambda != nullptr) {
3347
+ // `makeCallbackFunction` is called in two circumstances:
3348
+ //
3349
+ // 1. at startup, when initializing callback interface vtables.
3350
+ // 2. when polling futures. This happens at least once per future that is
3351
+ // exposed to Javascript. We know that this is always the same function,
3352
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3353
+ //
3354
+ // We can therefore return the callback function without making anything
3355
+ // new if we've been initialized already.
3356
+ return callback;
3357
+ }
3358
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3359
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3360
+ rsLambda = [&rt, callInvoker, callbackValue](
3361
+ uint64_t rs_uniffiHandle,
3362
+ UniffiForeignFutureCompleteU64 rs_uniffiFutureCallback,
3363
+ uint64_t rs_uniffiCallbackData,
3364
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3365
+ // We immediately make a lambda which will do the work of transforming the
3366
+ // arguments into JSI values and calling the callback.
3367
+ uniffi_runtime::UniffiCallFunc jsLambda =
3368
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_uniffiFutureCallback,
3369
+ rs_uniffiCallbackData, rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3370
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle,
3371
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3372
+ rs_uniffiOutReturn);
3373
+ };
3374
+ // We'll then call that lambda from the callInvoker which will
3375
+ // look after calling it on the correct thread.
3376
+ callInvoker->invokeBlocking(rt, jsLambda);
3377
+ };
3378
+ return callback;
3379
+ }
3380
+
3381
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3382
+ // happens when the jsi::Runtime is being destroyed.
3383
+ static void cleanup() {
3384
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3385
+ // out, then the pointer will no longer be left dangling.
3386
+ rsLambda = nullptr;
3387
+ }
3388
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod3
3389
+ // Implementation of callback function calling from Rust to JS
3390
+ // CallbackInterfaceSyncStorageMethod4
3391
+
3392
+ // Callback function:
3393
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod4::UniffiCallbackInterfaceSyncStorageMethod4
3394
+ //
3395
+ // We have the following constraints:
3396
+ // - we need to pass a function pointer to Rust.
3397
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3398
+ // - function pointers can't store state, so we can't use a lamda.
3399
+ //
3400
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3401
+ // function calls the lambda, which itself calls the `body` which then calls
3402
+ // into JS.
3403
+ //
3404
+ // We then give the `callback` function pointer to Rust which will call the
3405
+ // lambda sometime in the future.
3406
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod4 {
3407
+ using namespace facebook;
3408
+
3409
+ // We need to store a lambda in a global so we can call it from
3410
+ // a function pointer. The function pointer is passed to Rust.
3411
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid,
3412
+ uint64_t, UniffiForeignFuture *)>
3413
+ rsLambda = nullptr;
3414
+
3415
+ // This is the main body of the callback. It's called from the lambda,
3416
+ // which itself is called from the callback function which is passed to Rust.
3417
+ static void body(jsi::Runtime &rt,
3418
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3419
+ std::shared_ptr<jsi::Value> callbackValue,
3420
+ uint64_t rs_uniffiHandle, RustBuffer rs_records,
3421
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3422
+ uint64_t rs_uniffiCallbackData,
3423
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3424
+
3425
+ // Convert the arguments from Rust, into jsi::Values.
3426
+ // We'll use the Bridging class to do this…
3427
+ auto js_uniffiHandle =
3428
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3429
+ auto js_records = uniffi::breez_sdk_common::Bridging<RustBuffer>::toJs(
3430
+ rt, callInvoker, rs_records);
3431
+ auto js_uniffiFutureCallback =
3432
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
3433
+ rt, callInvoker, rs_uniffiFutureCallback);
3434
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3435
+ rt, callInvoker, rs_uniffiCallbackData);
3436
+
3437
+ // Now we are ready to call the callback.
3438
+ // We are already on the JS thread, because this `body` function was
3439
+ // invoked from the CallInvoker.
3440
+ try {
3441
+ // Getting the callback function
3442
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3443
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_records,
3444
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3445
+
3446
+ // Finally, we need to copy the return value back into the Rust pointer.
3447
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3448
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3449
+ uniffiResult);
3450
+ } catch (const jsi::JSError &error) {
3451
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod4: "
3452
+ << error.what() << std::endl;
3453
+ throw error;
3454
+ }
3455
+ }
3456
+
3457
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_records,
3458
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3459
+ uint64_t rs_uniffiCallbackData,
3460
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3461
+ // If the runtime has shutdown, then there is no point in trying to
3462
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3463
+ //
3464
+ // Answer: the module destructor calls into callback `cleanup` method,
3465
+ // which nulls out the rsLamda.
3466
+ //
3467
+ // If rsLamda is null, then there is no runtime to call into.
3468
+ if (rsLambda == nullptr) {
3469
+ // This only occurs when destructors are calling into Rust free/drop,
3470
+ // which causes the JS callback to be dropped.
3471
+ return;
3472
+ }
3473
+
3474
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3475
+ // are all in the lambda.
3476
+ rsLambda(rs_uniffiHandle, rs_records, rs_uniffiFutureCallback,
3477
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3478
+ }
3479
+
3480
+ static UniffiCallbackInterfaceSyncStorageMethod4
3481
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod4
3482
+ jsi::Runtime &rt,
3483
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3484
+ const jsi::Value &value) {
3485
+ if (rsLambda != nullptr) {
3486
+ // `makeCallbackFunction` is called in two circumstances:
3487
+ //
3488
+ // 1. at startup, when initializing callback interface vtables.
3489
+ // 2. when polling futures. This happens at least once per future that is
3490
+ // exposed to Javascript. We know that this is always the same function,
3491
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3492
+ //
3493
+ // We can therefore return the callback function without making anything
3494
+ // new if we've been initialized already.
3495
+ return callback;
3496
+ }
3497
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3498
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3499
+ rsLambda = [&rt, callInvoker, callbackValue](
3500
+ uint64_t rs_uniffiHandle, RustBuffer rs_records,
3501
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3502
+ uint64_t rs_uniffiCallbackData,
3503
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3504
+ // We immediately make a lambda which will do the work of transforming the
3505
+ // arguments into JSI values and calling the callback.
3506
+ uniffi_runtime::UniffiCallFunc jsLambda =
3507
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_records,
3508
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3509
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3510
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_records,
3511
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3512
+ rs_uniffiOutReturn);
3513
+ };
3514
+ // We'll then call that lambda from the callInvoker which will
3515
+ // look after calling it on the correct thread.
3516
+ callInvoker->invokeBlocking(rt, jsLambda);
3517
+ };
3518
+ return callback;
3519
+ }
3520
+
3521
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3522
+ // happens when the jsi::Runtime is being destroyed.
3523
+ static void cleanup() {
3524
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3525
+ // out, then the pointer will no longer be left dangling.
3526
+ rsLambda = nullptr;
3527
+ }
3528
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod4
3529
+ // Implementation of callback function calling from Rust to JS
3530
+ // CallbackInterfaceSyncStorageMethod5
3531
+
3532
+ // Callback function:
3533
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod5::UniffiCallbackInterfaceSyncStorageMethod5
3534
+ //
3535
+ // We have the following constraints:
3536
+ // - we need to pass a function pointer to Rust.
3537
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3538
+ // - function pointers can't store state, so we can't use a lamda.
3539
+ //
3540
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3541
+ // function calls the lambda, which itself calls the `body` which then calls
3542
+ // into JS.
3543
+ //
3544
+ // We then give the `callback` function pointer to Rust which will call the
3545
+ // lambda sometime in the future.
3546
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod5 {
3547
+ using namespace facebook;
3548
+
3549
+ // We need to store a lambda in a global so we can call it from
3550
+ // a function pointer. The function pointer is passed to Rust.
3551
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid,
3552
+ uint64_t, UniffiForeignFuture *)>
3553
+ rsLambda = nullptr;
3554
+
3555
+ // This is the main body of the callback. It's called from the lambda,
3556
+ // which itself is called from the callback function which is passed to Rust.
3557
+ static void body(jsi::Runtime &rt,
3558
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3559
+ std::shared_ptr<jsi::Value> callbackValue,
3560
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
3561
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3562
+ uint64_t rs_uniffiCallbackData,
3563
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3564
+
3565
+ // Convert the arguments from Rust, into jsi::Values.
3566
+ // We'll use the Bridging class to do this…
3567
+ auto js_uniffiHandle =
3568
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3569
+ auto js_record = uniffi::breez_sdk_common::Bridging<RustBuffer>::toJs(
3570
+ rt, callInvoker, rs_record);
3571
+ auto js_uniffiFutureCallback =
3572
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
3573
+ rt, callInvoker, rs_uniffiFutureCallback);
3574
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3575
+ rt, callInvoker, rs_uniffiCallbackData);
3576
+
3577
+ // Now we are ready to call the callback.
3578
+ // We are already on the JS thread, because this `body` function was
3579
+ // invoked from the CallInvoker.
3580
+ try {
3581
+ // Getting the callback function
3582
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3583
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_record,
3584
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3585
+
3586
+ // Finally, we need to copy the return value back into the Rust pointer.
3587
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3588
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3589
+ uniffiResult);
3590
+ } catch (const jsi::JSError &error) {
3591
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod5: "
3592
+ << error.what() << std::endl;
3593
+ throw error;
3594
+ }
3595
+ }
3596
+
3597
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_record,
3598
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3599
+ uint64_t rs_uniffiCallbackData,
3600
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3601
+ // If the runtime has shutdown, then there is no point in trying to
3602
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3603
+ //
3604
+ // Answer: the module destructor calls into callback `cleanup` method,
3605
+ // which nulls out the rsLamda.
3606
+ //
3607
+ // If rsLamda is null, then there is no runtime to call into.
3608
+ if (rsLambda == nullptr) {
3609
+ // This only occurs when destructors are calling into Rust free/drop,
3610
+ // which causes the JS callback to be dropped.
3611
+ return;
3612
+ }
3613
+
3614
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3615
+ // are all in the lambda.
3616
+ rsLambda(rs_uniffiHandle, rs_record, rs_uniffiFutureCallback,
3617
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3618
+ }
3619
+
3620
+ static UniffiCallbackInterfaceSyncStorageMethod5
3621
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod5
3622
+ jsi::Runtime &rt,
3623
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3624
+ const jsi::Value &value) {
3625
+ if (rsLambda != nullptr) {
3626
+ // `makeCallbackFunction` is called in two circumstances:
3627
+ //
3628
+ // 1. at startup, when initializing callback interface vtables.
3629
+ // 2. when polling futures. This happens at least once per future that is
3630
+ // exposed to Javascript. We know that this is always the same function,
3631
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3632
+ //
3633
+ // We can therefore return the callback function without making anything
3634
+ // new if we've been initialized already.
3635
+ return callback;
3636
+ }
3637
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3638
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3639
+ rsLambda = [&rt, callInvoker, callbackValue](
3640
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
3641
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3642
+ uint64_t rs_uniffiCallbackData,
3643
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3644
+ // We immediately make a lambda which will do the work of transforming the
3645
+ // arguments into JSI values and calling the callback.
3646
+ uniffi_runtime::UniffiCallFunc jsLambda =
3647
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_record,
3648
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3649
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3650
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_record,
3651
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3652
+ rs_uniffiOutReturn);
3653
+ };
3654
+ // We'll then call that lambda from the callInvoker which will
3655
+ // look after calling it on the correct thread.
3656
+ callInvoker->invokeBlocking(rt, jsLambda);
3657
+ };
3658
+ return callback;
3659
+ }
3660
+
3661
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3662
+ // happens when the jsi::Runtime is being destroyed.
3663
+ static void cleanup() {
3664
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3665
+ // out, then the pointer will no longer be left dangling.
3666
+ rsLambda = nullptr;
3667
+ }
3668
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod5
3669
+ // Implementation of callback function calling from Rust to JS
3670
+ // CallbackInterfaceSyncStorageMethod6
3671
+
3672
+ // Callback function:
3673
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod6::UniffiCallbackInterfaceSyncStorageMethod6
3674
+ //
3675
+ // We have the following constraints:
3676
+ // - we need to pass a function pointer to Rust.
3677
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3678
+ // - function pointers can't store state, so we can't use a lamda.
3679
+ //
3680
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3681
+ // function calls the lambda, which itself calls the `body` which then calls
3682
+ // into JS.
3683
+ //
3684
+ // We then give the `callback` function pointer to Rust which will call the
3685
+ // lambda sometime in the future.
3686
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod6 {
3687
+ using namespace facebook;
3688
+
3689
+ // We need to store a lambda in a global so we can call it from
3690
+ // a function pointer. The function pointer is passed to Rust.
3691
+ static std::function<void(uint64_t, uint64_t, UniffiForeignFutureCompleteVoid,
3692
+ uint64_t, UniffiForeignFuture *)>
3693
+ rsLambda = nullptr;
3694
+
3695
+ // This is the main body of the callback. It's called from the lambda,
3696
+ // which itself is called from the callback function which is passed to Rust.
3697
+ static void body(jsi::Runtime &rt,
3698
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3699
+ std::shared_ptr<jsi::Value> callbackValue,
3700
+ uint64_t rs_uniffiHandle, uint64_t rs_revision,
3701
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3702
+ uint64_t rs_uniffiCallbackData,
3703
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3704
+
3705
+ // Convert the arguments from Rust, into jsi::Values.
3706
+ // We'll use the Bridging class to do this…
3707
+ auto js_uniffiHandle =
3708
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3709
+ auto js_revision =
3710
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_revision);
3711
+ auto js_uniffiFutureCallback =
3712
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
3713
+ rt, callInvoker, rs_uniffiFutureCallback);
3714
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3715
+ rt, callInvoker, rs_uniffiCallbackData);
3716
+
3717
+ // Now we are ready to call the callback.
3718
+ // We are already on the JS thread, because this `body` function was
3719
+ // invoked from the CallInvoker.
3720
+ try {
3721
+ // Getting the callback function
3722
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3723
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_revision,
3724
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3725
+
3726
+ // Finally, we need to copy the return value back into the Rust pointer.
3727
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3728
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3729
+ uniffiResult);
3730
+ } catch (const jsi::JSError &error) {
3731
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod6: "
3732
+ << error.what() << std::endl;
3733
+ throw error;
3734
+ }
3735
+ }
3736
+
3737
+ static void callback(uint64_t rs_uniffiHandle, uint64_t rs_revision,
3738
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3739
+ uint64_t rs_uniffiCallbackData,
3740
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3741
+ // If the runtime has shutdown, then there is no point in trying to
3742
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3743
+ //
3744
+ // Answer: the module destructor calls into callback `cleanup` method,
3745
+ // which nulls out the rsLamda.
3746
+ //
3747
+ // If rsLamda is null, then there is no runtime to call into.
3748
+ if (rsLambda == nullptr) {
3749
+ // This only occurs when destructors are calling into Rust free/drop,
3750
+ // which causes the JS callback to be dropped.
3751
+ return;
3752
+ }
3753
+
3754
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3755
+ // are all in the lambda.
3756
+ rsLambda(rs_uniffiHandle, rs_revision, rs_uniffiFutureCallback,
3757
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3758
+ }
3759
+
3760
+ static UniffiCallbackInterfaceSyncStorageMethod6
3761
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod6
3762
+ jsi::Runtime &rt,
3763
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3764
+ const jsi::Value &value) {
3765
+ if (rsLambda != nullptr) {
3766
+ // `makeCallbackFunction` is called in two circumstances:
3767
+ //
3768
+ // 1. at startup, when initializing callback interface vtables.
3769
+ // 2. when polling futures. This happens at least once per future that is
3770
+ // exposed to Javascript. We know that this is always the same function,
3771
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3772
+ //
3773
+ // We can therefore return the callback function without making anything
3774
+ // new if we've been initialized already.
3775
+ return callback;
3776
+ }
3777
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3778
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3779
+ rsLambda = [&rt, callInvoker, callbackValue](
3780
+ uint64_t rs_uniffiHandle, uint64_t rs_revision,
3781
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
3782
+ uint64_t rs_uniffiCallbackData,
3783
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3784
+ // We immediately make a lambda which will do the work of transforming the
3785
+ // arguments into JSI values and calling the callback.
3786
+ uniffi_runtime::UniffiCallFunc jsLambda =
3787
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_revision,
3788
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3789
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3790
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_revision,
3791
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3792
+ rs_uniffiOutReturn);
3793
+ };
3794
+ // We'll then call that lambda from the callInvoker which will
3795
+ // look after calling it on the correct thread.
3796
+ callInvoker->invokeBlocking(rt, jsLambda);
3797
+ };
3798
+ return callback;
3799
+ }
3800
+
3801
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3802
+ // happens when the jsi::Runtime is being destroyed.
3803
+ static void cleanup() {
3804
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3805
+ // out, then the pointer will no longer be left dangling.
3806
+ rsLambda = nullptr;
3807
+ }
3808
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod6
3809
+ // Implementation of callback function calling from Rust to JS
3810
+ // CallbackInterfaceSyncStorageMethod7
3811
+
3812
+ // Callback function:
3813
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod7::UniffiCallbackInterfaceSyncStorageMethod7
3814
+ //
3815
+ // We have the following constraints:
3816
+ // - we need to pass a function pointer to Rust.
3817
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3818
+ // - function pointers can't store state, so we can't use a lamda.
3819
+ //
3820
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3821
+ // function calls the lambda, which itself calls the `body` which then calls
3822
+ // into JS.
3823
+ //
3824
+ // We then give the `callback` function pointer to Rust which will call the
3825
+ // lambda sometime in the future.
3826
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod7 {
3827
+ using namespace facebook;
3828
+
3829
+ // We need to store a lambda in a global so we can call it from
3830
+ // a function pointer. The function pointer is passed to Rust.
3831
+ static std::function<void(uint64_t, uint32_t,
3832
+ UniffiForeignFutureCompleteRustBuffer, uint64_t,
3833
+ UniffiForeignFuture *)>
3834
+ rsLambda = nullptr;
3835
+
3836
+ // This is the main body of the callback. It's called from the lambda,
3837
+ // which itself is called from the callback function which is passed to Rust.
3838
+ static void body(jsi::Runtime &rt,
3839
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3840
+ std::shared_ptr<jsi::Value> callbackValue,
3841
+ uint64_t rs_uniffiHandle, uint32_t rs_limit,
3842
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3843
+ uint64_t rs_uniffiCallbackData,
3844
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3845
+
3846
+ // Convert the arguments from Rust, into jsi::Values.
3847
+ // We'll use the Bridging class to do this…
3848
+ auto js_uniffiHandle =
3849
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3850
+ auto js_limit =
3851
+ uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, rs_limit);
3852
+ auto js_uniffiFutureCallback = uniffi::breez_sdk_common::Bridging<
3853
+ UniffiForeignFutureCompleteRustBuffer>::toJs(rt, callInvoker,
3854
+ rs_uniffiFutureCallback);
3855
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3856
+ rt, callInvoker, rs_uniffiCallbackData);
3857
+
3858
+ // Now we are ready to call the callback.
3859
+ // We are already on the JS thread, because this `body` function was
3860
+ // invoked from the CallInvoker.
3861
+ try {
3862
+ // Getting the callback function
3863
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
3864
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_limit,
3865
+ js_uniffiFutureCallback, js_uniffiCallbackData);
3866
+
3867
+ // Finally, we need to copy the return value back into the Rust pointer.
3868
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
3869
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
3870
+ uniffiResult);
3871
+ } catch (const jsi::JSError &error) {
3872
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod7: "
3873
+ << error.what() << std::endl;
3874
+ throw error;
3875
+ }
3876
+ }
3877
+
3878
+ static void
3879
+ callback(uint64_t rs_uniffiHandle, uint32_t rs_limit,
3880
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3881
+ uint64_t rs_uniffiCallbackData,
3882
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3883
+ // If the runtime has shutdown, then there is no point in trying to
3884
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
3885
+ //
3886
+ // Answer: the module destructor calls into callback `cleanup` method,
3887
+ // which nulls out the rsLamda.
3888
+ //
3889
+ // If rsLamda is null, then there is no runtime to call into.
3890
+ if (rsLambda == nullptr) {
3891
+ // This only occurs when destructors are calling into Rust free/drop,
3892
+ // which causes the JS callback to be dropped.
3893
+ return;
3894
+ }
3895
+
3896
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
3897
+ // are all in the lambda.
3898
+ rsLambda(rs_uniffiHandle, rs_limit, rs_uniffiFutureCallback,
3899
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
3900
+ }
3901
+
3902
+ static UniffiCallbackInterfaceSyncStorageMethod7
3903
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod7
3904
+ jsi::Runtime &rt,
3905
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3906
+ const jsi::Value &value) {
3907
+ if (rsLambda != nullptr) {
3908
+ // `makeCallbackFunction` is called in two circumstances:
3909
+ //
3910
+ // 1. at startup, when initializing callback interface vtables.
3911
+ // 2. when polling futures. This happens at least once per future that is
3912
+ // exposed to Javascript. We know that this is always the same function,
3913
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
3914
+ //
3915
+ // We can therefore return the callback function without making anything
3916
+ // new if we've been initialized already.
3917
+ return callback;
3918
+ }
3919
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
3920
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
3921
+ rsLambda = [&rt, callInvoker, callbackValue](
3922
+ uint64_t rs_uniffiHandle, uint32_t rs_limit,
3923
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3924
+ uint64_t rs_uniffiCallbackData,
3925
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3926
+ // We immediately make a lambda which will do the work of transforming the
3927
+ // arguments into JSI values and calling the callback.
3928
+ uniffi_runtime::UniffiCallFunc jsLambda =
3929
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_limit,
3930
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3931
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
3932
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_limit,
3933
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
3934
+ rs_uniffiOutReturn);
3935
+ };
3936
+ // We'll then call that lambda from the callInvoker which will
3937
+ // look after calling it on the correct thread.
3938
+ callInvoker->invokeBlocking(rt, jsLambda);
3939
+ };
3940
+ return callback;
3941
+ }
3942
+
3943
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
3944
+ // happens when the jsi::Runtime is being destroyed.
3945
+ static void cleanup() {
3946
+ // The lambda holds a reference to the the Runtime, so when this is nulled
3947
+ // out, then the pointer will no longer be left dangling.
3948
+ rsLambda = nullptr;
3949
+ }
3950
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod7
3951
+ // Implementation of callback function calling from Rust to JS
3952
+ // CallbackInterfaceSyncStorageMethod8
3953
+
3954
+ // Callback function:
3955
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod8::UniffiCallbackInterfaceSyncStorageMethod8
3956
+ //
3957
+ // We have the following constraints:
3958
+ // - we need to pass a function pointer to Rust.
3959
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
3960
+ // - function pointers can't store state, so we can't use a lamda.
3961
+ //
3962
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
3963
+ // function calls the lambda, which itself calls the `body` which then calls
3964
+ // into JS.
3965
+ //
3966
+ // We then give the `callback` function pointer to Rust which will call the
3967
+ // lambda sometime in the future.
3968
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod8 {
3969
+ using namespace facebook;
3970
+
3971
+ // We need to store a lambda in a global so we can call it from
3972
+ // a function pointer. The function pointer is passed to Rust.
3973
+ static std::function<void(uint64_t, UniffiForeignFutureCompleteRustBuffer,
3974
+ uint64_t, UniffiForeignFuture *)>
3975
+ rsLambda = nullptr;
3976
+
3977
+ // This is the main body of the callback. It's called from the lambda,
3978
+ // which itself is called from the callback function which is passed to Rust.
3979
+ static void body(jsi::Runtime &rt,
3980
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
3981
+ std::shared_ptr<jsi::Value> callbackValue,
3982
+ uint64_t rs_uniffiHandle,
3983
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
3984
+ uint64_t rs_uniffiCallbackData,
3985
+ UniffiForeignFuture *rs_uniffiOutReturn) {
3986
+
3987
+ // Convert the arguments from Rust, into jsi::Values.
3988
+ // We'll use the Bridging class to do this…
3989
+ auto js_uniffiHandle =
3990
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
3991
+ auto js_uniffiFutureCallback = uniffi::breez_sdk_common::Bridging<
3992
+ UniffiForeignFutureCompleteRustBuffer>::toJs(rt, callInvoker,
3993
+ rs_uniffiFutureCallback);
3994
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
3995
+ rt, callInvoker, rs_uniffiCallbackData);
3996
+
3997
+ // Now we are ready to call the callback.
3998
+ // We are already on the JS thread, because this `body` function was
3999
+ // invoked from the CallInvoker.
4000
+ try {
4001
+ // Getting the callback function
4002
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
4003
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_uniffiFutureCallback,
4004
+ js_uniffiCallbackData);
4005
+
4006
+ // Finally, we need to copy the return value back into the Rust pointer.
4007
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
4008
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
4009
+ uniffiResult);
4010
+ } catch (const jsi::JSError &error) {
4011
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod8: "
4012
+ << error.what() << std::endl;
4013
+ throw error;
4014
+ }
4015
+ }
4016
+
4017
+ static void
4018
+ callback(uint64_t rs_uniffiHandle,
4019
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
4020
+ uint64_t rs_uniffiCallbackData,
4021
+ UniffiForeignFuture *rs_uniffiOutReturn) {
4022
+ // If the runtime has shutdown, then there is no point in trying to
4023
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
4024
+ //
4025
+ // Answer: the module destructor calls into callback `cleanup` method,
4026
+ // which nulls out the rsLamda.
4027
+ //
4028
+ // If rsLamda is null, then there is no runtime to call into.
4029
+ if (rsLambda == nullptr) {
4030
+ // This only occurs when destructors are calling into Rust free/drop,
4031
+ // which causes the JS callback to be dropped.
4032
+ return;
4033
+ }
4034
+
4035
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
4036
+ // are all in the lambda.
4037
+ rsLambda(rs_uniffiHandle, rs_uniffiFutureCallback, rs_uniffiCallbackData,
4038
+ rs_uniffiOutReturn);
4039
+ }
4040
+
4041
+ static UniffiCallbackInterfaceSyncStorageMethod8
4042
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod8
4043
+ jsi::Runtime &rt,
4044
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
4045
+ const jsi::Value &value) {
4046
+ if (rsLambda != nullptr) {
4047
+ // `makeCallbackFunction` is called in two circumstances:
4048
+ //
4049
+ // 1. at startup, when initializing callback interface vtables.
4050
+ // 2. when polling futures. This happens at least once per future that is
4051
+ // exposed to Javascript. We know that this is always the same function,
4052
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
4053
+ //
4054
+ // We can therefore return the callback function without making anything
4055
+ // new if we've been initialized already.
4056
+ return callback;
4057
+ }
4058
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
4059
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
4060
+ rsLambda = [&rt, callInvoker, callbackValue](
4061
+ uint64_t rs_uniffiHandle,
4062
+ UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
4063
+ uint64_t rs_uniffiCallbackData,
4064
+ UniffiForeignFuture *rs_uniffiOutReturn) {
4065
+ // We immediately make a lambda which will do the work of transforming the
4066
+ // arguments into JSI values and calling the callback.
4067
+ uniffi_runtime::UniffiCallFunc jsLambda =
4068
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_uniffiFutureCallback,
4069
+ rs_uniffiCallbackData, rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
4070
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle,
4071
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
4072
+ rs_uniffiOutReturn);
4073
+ };
4074
+ // We'll then call that lambda from the callInvoker which will
4075
+ // look after calling it on the correct thread.
4076
+ callInvoker->invokeBlocking(rt, jsLambda);
4077
+ };
4078
+ return callback;
4079
+ }
4080
+
4081
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
4082
+ // happens when the jsi::Runtime is being destroyed.
4083
+ static void cleanup() {
4084
+ // The lambda holds a reference to the the Runtime, so when this is nulled
4085
+ // out, then the pointer will no longer be left dangling.
4086
+ rsLambda = nullptr;
4087
+ }
4088
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod8
4089
+ // Implementation of callback function calling from Rust to JS
4090
+ // CallbackInterfaceSyncStorageMethod9
4091
+
4092
+ // Callback function:
4093
+ // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod9::UniffiCallbackInterfaceSyncStorageMethod9
4094
+ //
4095
+ // We have the following constraints:
4096
+ // - we need to pass a function pointer to Rust.
4097
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
4098
+ // - function pointers can't store state, so we can't use a lamda.
4099
+ //
4100
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
4101
+ // function calls the lambda, which itself calls the `body` which then calls
4102
+ // into JS.
4103
+ //
4104
+ // We then give the `callback` function pointer to Rust which will call the
4105
+ // lambda sometime in the future.
4106
+ namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod9 {
4107
+ using namespace facebook;
4108
+
4109
+ // We need to store a lambda in a global so we can call it from
4110
+ // a function pointer. The function pointer is passed to Rust.
4111
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid,
4112
+ uint64_t, UniffiForeignFuture *)>
4113
+ rsLambda = nullptr;
4114
+
4115
+ // This is the main body of the callback. It's called from the lambda,
4116
+ // which itself is called from the callback function which is passed to Rust.
4117
+ static void body(jsi::Runtime &rt,
4118
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
4119
+ std::shared_ptr<jsi::Value> callbackValue,
4120
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
4121
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
4122
+ uint64_t rs_uniffiCallbackData,
4123
+ UniffiForeignFuture *rs_uniffiOutReturn) {
4124
+
4125
+ // Convert the arguments from Rust, into jsi::Values.
4126
+ // We'll use the Bridging class to do this…
4127
+ auto js_uniffiHandle =
4128
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
4129
+ auto js_record = uniffi::breez_sdk_common::Bridging<RustBuffer>::toJs(
4130
+ rt, callInvoker, rs_record);
4131
+ auto js_uniffiFutureCallback =
4132
+ uniffi::breez_sdk_common::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
4133
+ rt, callInvoker, rs_uniffiFutureCallback);
4134
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
4135
+ rt, callInvoker, rs_uniffiCallbackData);
4136
+
4137
+ // Now we are ready to call the callback.
4138
+ // We are already on the JS thread, because this `body` function was
4139
+ // invoked from the CallInvoker.
4140
+ try {
4141
+ // Getting the callback function
4142
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
4143
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_record,
4144
+ js_uniffiFutureCallback, js_uniffiCallbackData);
4145
+
4146
+ // Finally, we need to copy the return value back into the Rust pointer.
4147
+ *rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
4148
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
4149
+ uniffiResult);
4150
+ } catch (const jsi::JSError &error) {
4151
+ std::cout << "Error in callback UniffiCallbackInterfaceSyncStorageMethod9: "
4152
+ << error.what() << std::endl;
4153
+ throw error;
4154
+ }
4155
+ }
4156
+
4157
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_record,
4158
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
4159
+ uint64_t rs_uniffiCallbackData,
4160
+ UniffiForeignFuture *rs_uniffiOutReturn) {
4161
+ // If the runtime has shutdown, then there is no point in trying to
4162
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
4163
+ //
4164
+ // Answer: the module destructor calls into callback `cleanup` method,
4165
+ // which nulls out the rsLamda.
4166
+ //
4167
+ // If rsLamda is null, then there is no runtime to call into.
4168
+ if (rsLambda == nullptr) {
4169
+ // This only occurs when destructors are calling into Rust free/drop,
4170
+ // which causes the JS callback to be dropped.
4171
+ return;
4172
+ }
4173
+
4174
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
4175
+ // are all in the lambda.
4176
+ rsLambda(rs_uniffiHandle, rs_record, rs_uniffiFutureCallback,
4177
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
4178
+ }
4179
+
4180
+ static UniffiCallbackInterfaceSyncStorageMethod9
4181
+ makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod9
4182
+ jsi::Runtime &rt,
4183
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
4184
+ const jsi::Value &value) {
4185
+ if (rsLambda != nullptr) {
4186
+ // `makeCallbackFunction` is called in two circumstances:
4187
+ //
4188
+ // 1. at startup, when initializing callback interface vtables.
4189
+ // 2. when polling futures. This happens at least once per future that is
4190
+ // exposed to Javascript. We know that this is always the same function,
4191
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
4192
+ //
4193
+ // We can therefore return the callback function without making anything
4194
+ // new if we've been initialized already.
4195
+ return callback;
4196
+ }
4197
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
4198
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
4199
+ rsLambda = [&rt, callInvoker, callbackValue](
4200
+ uint64_t rs_uniffiHandle, RustBuffer rs_record,
4201
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
4202
+ uint64_t rs_uniffiCallbackData,
4203
+ UniffiForeignFuture *rs_uniffiOutReturn) {
4204
+ // We immediately make a lambda which will do the work of transforming the
4205
+ // arguments into JSI values and calling the callback.
4206
+ uniffi_runtime::UniffiCallFunc jsLambda =
4207
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_record,
4208
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
4209
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
4210
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_record,
4211
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
4212
+ rs_uniffiOutReturn);
4213
+ };
4214
+ // We'll then call that lambda from the callInvoker which will
4215
+ // look after calling it on the correct thread.
4216
+ callInvoker->invokeBlocking(rt, jsLambda);
4217
+ };
4218
+ return callback;
4219
+ }
4220
+
4221
+ // This method is called from the destructor of NativeBreezSdkCommon, which only
4222
+ // happens when the jsi::Runtime is being destroyed.
4223
+ static void cleanup() {
4224
+ // The lambda holds a reference to the the Runtime, so when this is nulled
4225
+ // out, then the pointer will no longer be left dangling.
4226
+ rsLambda = nullptr;
4227
+ }
4228
+ } // namespace uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod9
4229
+ namespace uniffi::breez_sdk_common {
4230
+ using namespace facebook;
4231
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
4232
+
4233
+ template <> struct Bridging<UniffiVTableCallbackInterfaceFiatService> {
4234
+ static UniffiVTableCallbackInterfaceFiatService
4235
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
4236
+ const jsi::Value &jsValue) {
4237
+ // Check if the input is an object
4238
+ if (!jsValue.isObject()) {
4239
+ throw jsi::JSError(
4240
+ rt,
4241
+ "Expected an object for UniffiVTableCallbackInterfaceFiatService");
4242
+ }
4243
+
4244
+ // Get the object from the jsi::Value
4245
+ auto jsObject = jsValue.getObject(rt);
4246
+
4247
+ // Create the vtable struct
4248
+ UniffiVTableCallbackInterfaceFiatService rsObject;
4249
+
4250
+ // Create the vtable from the js callbacks.
4251
+ rsObject.fetch_fiat_currencies = uniffi::breez_sdk_common::cb::
4252
+ callbackinterfacefiatservicemethod0::makeCallbackFunction(
4253
+ rt, callInvoker, jsObject.getProperty(rt, "fetchFiatCurrencies"));
4254
+ rsObject.fetch_fiat_rates = uniffi::breez_sdk_common::cb::
4255
+ callbackinterfacefiatservicemethod1::makeCallbackFunction(
4256
+ rt, callInvoker, jsObject.getProperty(rt, "fetchFiatRates"));
4257
+ rsObject.uniffi_free =
4258
+ uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::
4259
+ vtablecallbackinterfacefiatservice::free::makeCallbackFunction(
4260
+ rt, callInvoker, jsObject.getProperty(rt, "uniffiFree"));
4261
+
4262
+ return rsObject;
4263
+ }
4264
+ };
4265
+
4266
+ } // namespace uniffi::breez_sdk_common
4267
+ namespace uniffi::breez_sdk_common {
4268
+ using namespace facebook;
4269
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
4270
+
4271
+ template <> struct Bridging<UniffiVTableCallbackInterfaceRestClient> {
4272
+ static UniffiVTableCallbackInterfaceRestClient
4273
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
4274
+ const jsi::Value &jsValue) {
4275
+ // Check if the input is an object
4276
+ if (!jsValue.isObject()) {
4277
+ throw jsi::JSError(
4278
+ rt, "Expected an object for UniffiVTableCallbackInterfaceRestClient");
4279
+ }
4280
+
4281
+ // Get the object from the jsi::Value
4282
+ auto jsObject = jsValue.getObject(rt);
4283
+
4284
+ // Create the vtable struct
4285
+ UniffiVTableCallbackInterfaceRestClient rsObject;
2666
4286
 
2667
4287
  // Create the vtable from the js callbacks.
2668
4288
  rsObject.get_request = uniffi::breez_sdk_common::cb::
@@ -2683,6 +4303,72 @@ template <> struct Bridging<UniffiVTableCallbackInterfaceRestClient> {
2683
4303
  }
2684
4304
  };
2685
4305
 
4306
+ } // namespace uniffi::breez_sdk_common
4307
+ namespace uniffi::breez_sdk_common {
4308
+ using namespace facebook;
4309
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
4310
+
4311
+ template <> struct Bridging<UniffiVTableCallbackInterfaceSyncStorage> {
4312
+ static UniffiVTableCallbackInterfaceSyncStorage
4313
+ fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
4314
+ const jsi::Value &jsValue) {
4315
+ // Check if the input is an object
4316
+ if (!jsValue.isObject()) {
4317
+ throw jsi::JSError(
4318
+ rt,
4319
+ "Expected an object for UniffiVTableCallbackInterfaceSyncStorage");
4320
+ }
4321
+
4322
+ // Get the object from the jsi::Value
4323
+ auto jsObject = jsValue.getObject(rt);
4324
+
4325
+ // Create the vtable struct
4326
+ UniffiVTableCallbackInterfaceSyncStorage rsObject;
4327
+
4328
+ // Create the vtable from the js callbacks.
4329
+ rsObject.add_outgoing_change = uniffi::breez_sdk_common::cb::
4330
+ callbackinterfacesyncstoragemethod0::makeCallbackFunction(
4331
+ rt, callInvoker, jsObject.getProperty(rt, "addOutgoingChange"));
4332
+ rsObject.complete_outgoing_sync = uniffi::breez_sdk_common::cb::
4333
+ callbackinterfacesyncstoragemethod1::makeCallbackFunction(
4334
+ rt, callInvoker, jsObject.getProperty(rt, "completeOutgoingSync"));
4335
+ rsObject.get_pending_outgoing_changes = uniffi::breez_sdk_common::cb::
4336
+ callbackinterfacesyncstoragemethod2::makeCallbackFunction(
4337
+ rt, callInvoker,
4338
+ jsObject.getProperty(rt, "getPendingOutgoingChanges"));
4339
+ rsObject.get_last_revision = uniffi::breez_sdk_common::cb::
4340
+ callbackinterfacesyncstoragemethod3::makeCallbackFunction(
4341
+ rt, callInvoker, jsObject.getProperty(rt, "getLastRevision"));
4342
+ rsObject.insert_incoming_records = uniffi::breez_sdk_common::cb::
4343
+ callbackinterfacesyncstoragemethod4::makeCallbackFunction(
4344
+ rt, callInvoker, jsObject.getProperty(rt, "insertIncomingRecords"));
4345
+ rsObject.delete_incoming_record = uniffi::breez_sdk_common::cb::
4346
+ callbackinterfacesyncstoragemethod5::makeCallbackFunction(
4347
+ rt, callInvoker, jsObject.getProperty(rt, "deleteIncomingRecord"));
4348
+ rsObject.rebase_pending_outgoing_records = uniffi::breez_sdk_common::cb::
4349
+ callbackinterfacesyncstoragemethod6::makeCallbackFunction(
4350
+ rt, callInvoker,
4351
+ jsObject.getProperty(rt, "rebasePendingOutgoingRecords"));
4352
+ rsObject.get_incoming_records = uniffi::breez_sdk_common::cb::
4353
+ callbackinterfacesyncstoragemethod7::makeCallbackFunction(
4354
+ rt, callInvoker, jsObject.getProperty(rt, "getIncomingRecords"));
4355
+ rsObject.get_latest_outgoing_change = uniffi::breez_sdk_common::cb::
4356
+ callbackinterfacesyncstoragemethod8::makeCallbackFunction(
4357
+ rt, callInvoker,
4358
+ jsObject.getProperty(rt, "getLatestOutgoingChange"));
4359
+ rsObject.update_record_from_incoming = uniffi::breez_sdk_common::cb::
4360
+ callbackinterfacesyncstoragemethod9::makeCallbackFunction(
4361
+ rt, callInvoker,
4362
+ jsObject.getProperty(rt, "updateRecordFromIncoming"));
4363
+ rsObject.uniffi_free =
4364
+ uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::
4365
+ vtablecallbackinterfacesyncstorage::free::makeCallbackFunction(
4366
+ rt, callInvoker, jsObject.getProperty(rt, "uniffiFree"));
4367
+
4368
+ return rsObject;
4369
+ }
4370
+ };
4371
+
2686
4372
  } // namespace uniffi::breez_sdk_common
2687
4373
 
2688
4374
  namespace uniffi::breez_sdk_common {
@@ -2848,6 +4534,149 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
2848
4534
  ->cpp_uniffi_breez_sdk_common_fn_method_restclient_delete_request(
2849
4535
  rt, thisVal, args, count);
2850
4536
  });
4537
+ props["ubrn_uniffi_breez_sdk_common_fn_clone_syncstorage"] =
4538
+ jsi::Function::createFromHostFunction(
4539
+ rt,
4540
+ jsi::PropNameID::forAscii(
4541
+ rt, "ubrn_uniffi_breez_sdk_common_fn_clone_syncstorage"),
4542
+ 1,
4543
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4544
+ const jsi::Value *args, size_t count) -> jsi::Value {
4545
+ return this->cpp_uniffi_breez_sdk_common_fn_clone_syncstorage(
4546
+ rt, thisVal, args, count);
4547
+ });
4548
+ props["ubrn_uniffi_breez_sdk_common_fn_free_syncstorage"] =
4549
+ jsi::Function::createFromHostFunction(
4550
+ rt,
4551
+ jsi::PropNameID::forAscii(
4552
+ rt, "ubrn_uniffi_breez_sdk_common_fn_free_syncstorage"),
4553
+ 1,
4554
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4555
+ const jsi::Value *args, size_t count) -> jsi::Value {
4556
+ return this->cpp_uniffi_breez_sdk_common_fn_free_syncstorage(
4557
+ rt, thisVal, args, count);
4558
+ });
4559
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_add_outgoing_"
4560
+ "change"] = jsi::Function::createFromHostFunction(
4561
+ rt,
4562
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4563
+ "syncstorage_add_outgoing_change"),
4564
+ 2,
4565
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4566
+ const jsi::Value *args, size_t count) -> jsi::Value {
4567
+ return this
4568
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_add_outgoing_change(
4569
+ rt, thisVal, args, count);
4570
+ });
4571
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_complete_outgoing_"
4572
+ "sync"] = jsi::Function::createFromHostFunction(
4573
+ rt,
4574
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4575
+ "syncstorage_complete_outgoing_sync"),
4576
+ 2,
4577
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4578
+ const jsi::Value *args, size_t count) -> jsi::Value {
4579
+ return this
4580
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_complete_outgoing_sync(
4581
+ rt, thisVal, args, count);
4582
+ });
4583
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_get_pending_"
4584
+ "outgoing_changes"] = jsi::Function::createFromHostFunction(
4585
+ rt,
4586
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4587
+ "syncstorage_get_pending_outgoing_changes"),
4588
+ 2,
4589
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4590
+ const jsi::Value *args, size_t count) -> jsi::Value {
4591
+ return this
4592
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_pending_outgoing_changes(
4593
+ rt, thisVal, args, count);
4594
+ });
4595
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_get_last_"
4596
+ "revision"] = jsi::Function::createFromHostFunction(
4597
+ rt,
4598
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4599
+ "syncstorage_get_last_revision"),
4600
+ 1,
4601
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4602
+ const jsi::Value *args, size_t count) -> jsi::Value {
4603
+ return this
4604
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_last_revision(
4605
+ rt, thisVal, args, count);
4606
+ });
4607
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_insert_incoming_"
4608
+ "records"] = jsi::Function::createFromHostFunction(
4609
+ rt,
4610
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4611
+ "syncstorage_insert_incoming_records"),
4612
+ 2,
4613
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4614
+ const jsi::Value *args, size_t count) -> jsi::Value {
4615
+ return this
4616
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_insert_incoming_records(
4617
+ rt, thisVal, args, count);
4618
+ });
4619
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_delete_incoming_"
4620
+ "record"] = jsi::Function::createFromHostFunction(
4621
+ rt,
4622
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4623
+ "syncstorage_delete_incoming_record"),
4624
+ 2,
4625
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4626
+ const jsi::Value *args, size_t count) -> jsi::Value {
4627
+ return this
4628
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_delete_incoming_record(
4629
+ rt, thisVal, args, count);
4630
+ });
4631
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_rebase_pending_"
4632
+ "outgoing_records"] = jsi::Function::createFromHostFunction(
4633
+ rt,
4634
+ jsi::PropNameID::forAscii(rt,
4635
+ "ubrn_uniffi_breez_sdk_common_fn_method_"
4636
+ "syncstorage_rebase_pending_outgoing_records"),
4637
+ 2,
4638
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4639
+ const jsi::Value *args, size_t count) -> jsi::Value {
4640
+ return this
4641
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_rebase_pending_outgoing_records(
4642
+ rt, thisVal, args, count);
4643
+ });
4644
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_get_incoming_"
4645
+ "records"] = jsi::Function::createFromHostFunction(
4646
+ rt,
4647
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4648
+ "syncstorage_get_incoming_records"),
4649
+ 2,
4650
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4651
+ const jsi::Value *args, size_t count) -> jsi::Value {
4652
+ return this
4653
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_incoming_records(
4654
+ rt, thisVal, args, count);
4655
+ });
4656
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_get_latest_"
4657
+ "outgoing_change"] = jsi::Function::createFromHostFunction(
4658
+ rt,
4659
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4660
+ "syncstorage_get_latest_outgoing_change"),
4661
+ 1,
4662
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4663
+ const jsi::Value *args, size_t count) -> jsi::Value {
4664
+ return this
4665
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_latest_outgoing_change(
4666
+ rt, thisVal, args, count);
4667
+ });
4668
+ props["ubrn_uniffi_breez_sdk_common_fn_method_syncstorage_update_record_from_"
4669
+ "incoming"] = jsi::Function::createFromHostFunction(
4670
+ rt,
4671
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
4672
+ "syncstorage_update_record_from_incoming"),
4673
+ 2,
4674
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4675
+ const jsi::Value *args, size_t count) -> jsi::Value {
4676
+ return this
4677
+ ->cpp_uniffi_breez_sdk_common_fn_method_syncstorage_update_record_from_incoming(
4678
+ rt, thisVal, args, count);
4679
+ });
2851
4680
  props["ubrn_ffi_breez_sdk_common_rust_future_poll_u8"] =
2852
4681
  jsi::Function::createFromHostFunction(
2853
4682
  rt,
@@ -3421,65 +5250,192 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
3421
5250
  const jsi::Value *args, size_t count) -> jsi::Value {
3422
5251
  return this->cpp_ffi_breez_sdk_common_rust_future_complete_void(
3423
5252
  rt, thisVal, args, count);
3424
- });
3425
- props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
3426
- "currencies"] = jsi::Function::createFromHostFunction(
5253
+ });
5254
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
5255
+ "currencies"] = jsi::Function::createFromHostFunction(
5256
+ rt,
5257
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5258
+ "method_fiatservice_fetch_fiat_currencies"),
5259
+ 0,
5260
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5261
+ const jsi::Value *args, size_t count) -> jsi::Value {
5262
+ return this
5263
+ ->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies(
5264
+ rt, thisVal, args, count);
5265
+ });
5266
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
5267
+ "rates"] = jsi::Function::createFromHostFunction(
5268
+ rt,
5269
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5270
+ "method_fiatservice_fetch_fiat_rates"),
5271
+ 0,
5272
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5273
+ const jsi::Value *args, size_t count) -> jsi::Value {
5274
+ return this
5275
+ ->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates(
5276
+ rt, thisVal, args, count);
5277
+ });
5278
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_get_request"] =
5279
+ jsi::Function::createFromHostFunction(
5280
+ rt,
5281
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5282
+ "method_restclient_get_request"),
5283
+ 0,
5284
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5285
+ const jsi::Value *args, size_t count) -> jsi::Value {
5286
+ return this
5287
+ ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_get_request(
5288
+ rt, thisVal, args, count);
5289
+ });
5290
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_post_"
5291
+ "request"] = jsi::Function::createFromHostFunction(
5292
+ rt,
5293
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5294
+ "method_restclient_post_request"),
5295
+ 0,
5296
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5297
+ const jsi::Value *args, size_t count) -> jsi::Value {
5298
+ return this
5299
+ ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_post_request(
5300
+ rt, thisVal, args, count);
5301
+ });
5302
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_delete_"
5303
+ "request"] = jsi::Function::createFromHostFunction(
5304
+ rt,
5305
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5306
+ "method_restclient_delete_request"),
5307
+ 0,
5308
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5309
+ const jsi::Value *args, size_t count) -> jsi::Value {
5310
+ return this
5311
+ ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_delete_request(
5312
+ rt, thisVal, args, count);
5313
+ });
5314
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_add_outgoing_"
5315
+ "change"] = jsi::Function::createFromHostFunction(
5316
+ rt,
5317
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5318
+ "method_syncstorage_add_outgoing_change"),
5319
+ 0,
5320
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5321
+ const jsi::Value *args, size_t count) -> jsi::Value {
5322
+ return this
5323
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_add_outgoing_change(
5324
+ rt, thisVal, args, count);
5325
+ });
5326
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_complete_"
5327
+ "outgoing_sync"] = jsi::Function::createFromHostFunction(
5328
+ rt,
5329
+ jsi::PropNameID::forAscii(rt,
5330
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5331
+ "syncstorage_complete_outgoing_sync"),
5332
+ 0,
5333
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5334
+ const jsi::Value *args, size_t count) -> jsi::Value {
5335
+ return this
5336
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_complete_outgoing_sync(
5337
+ rt, thisVal, args, count);
5338
+ });
5339
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_get_pending_"
5340
+ "outgoing_changes"] = jsi::Function::createFromHostFunction(
5341
+ rt,
5342
+ jsi::PropNameID::forAscii(rt,
5343
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5344
+ "syncstorage_get_pending_outgoing_changes"),
5345
+ 0,
5346
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5347
+ const jsi::Value *args, size_t count) -> jsi::Value {
5348
+ return this
5349
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_pending_outgoing_changes(
5350
+ rt, thisVal, args, count);
5351
+ });
5352
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_get_last_"
5353
+ "revision"] = jsi::Function::createFromHostFunction(
5354
+ rt,
5355
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
5356
+ "method_syncstorage_get_last_revision"),
5357
+ 0,
5358
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5359
+ const jsi::Value *args, size_t count) -> jsi::Value {
5360
+ return this
5361
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_last_revision(
5362
+ rt, thisVal, args, count);
5363
+ });
5364
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_insert_"
5365
+ "incoming_records"] = jsi::Function::createFromHostFunction(
5366
+ rt,
5367
+ jsi::PropNameID::forAscii(rt,
5368
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5369
+ "syncstorage_insert_incoming_records"),
5370
+ 0,
5371
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5372
+ const jsi::Value *args, size_t count) -> jsi::Value {
5373
+ return this
5374
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_insert_incoming_records(
5375
+ rt, thisVal, args, count);
5376
+ });
5377
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_delete_"
5378
+ "incoming_record"] = jsi::Function::createFromHostFunction(
5379
+ rt,
5380
+ jsi::PropNameID::forAscii(rt,
5381
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5382
+ "syncstorage_delete_incoming_record"),
5383
+ 0,
5384
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5385
+ const jsi::Value *args, size_t count) -> jsi::Value {
5386
+ return this
5387
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_delete_incoming_record(
5388
+ rt, thisVal, args, count);
5389
+ });
5390
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_rebase_"
5391
+ "pending_outgoing_records"] = jsi::Function::createFromHostFunction(
3427
5392
  rt,
3428
- jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
3429
- "method_fiatservice_fetch_fiat_currencies"),
5393
+ jsi::PropNameID::forAscii(rt,
5394
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5395
+ "syncstorage_rebase_pending_outgoing_records"),
3430
5396
  0,
3431
5397
  [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3432
5398
  const jsi::Value *args, size_t count) -> jsi::Value {
3433
5399
  return this
3434
- ->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies(
5400
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_rebase_pending_outgoing_records(
3435
5401
  rt, thisVal, args, count);
3436
5402
  });
3437
- props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
3438
- "rates"] = jsi::Function::createFromHostFunction(
5403
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_get_incoming_"
5404
+ "records"] = jsi::Function::createFromHostFunction(
3439
5405
  rt,
3440
5406
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
3441
- "method_fiatservice_fetch_fiat_rates"),
5407
+ "method_syncstorage_get_incoming_records"),
3442
5408
  0,
3443
5409
  [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3444
5410
  const jsi::Value *args, size_t count) -> jsi::Value {
3445
5411
  return this
3446
- ->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates(
5412
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_incoming_records(
3447
5413
  rt, thisVal, args, count);
3448
5414
  });
3449
- props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_get_request"] =
3450
- jsi::Function::createFromHostFunction(
3451
- rt,
3452
- jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
3453
- "method_restclient_get_request"),
3454
- 0,
3455
- [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3456
- const jsi::Value *args, size_t count) -> jsi::Value {
3457
- return this
3458
- ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_get_request(
3459
- rt, thisVal, args, count);
3460
- });
3461
- props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_post_"
3462
- "request"] = jsi::Function::createFromHostFunction(
5415
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_get_latest_"
5416
+ "outgoing_change"] = jsi::Function::createFromHostFunction(
3463
5417
  rt,
3464
- jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
3465
- "method_restclient_post_request"),
5418
+ jsi::PropNameID::forAscii(rt,
5419
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5420
+ "syncstorage_get_latest_outgoing_change"),
3466
5421
  0,
3467
5422
  [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3468
5423
  const jsi::Value *args, size_t count) -> jsi::Value {
3469
5424
  return this
3470
- ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_post_request(
5425
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_latest_outgoing_change(
3471
5426
  rt, thisVal, args, count);
3472
5427
  });
3473
- props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_delete_"
3474
- "request"] = jsi::Function::createFromHostFunction(
5428
+ props["ubrn_uniffi_breez_sdk_common_checksum_method_syncstorage_update_"
5429
+ "record_from_incoming"] = jsi::Function::createFromHostFunction(
3475
5430
  rt,
3476
- jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
3477
- "method_restclient_delete_request"),
5431
+ jsi::PropNameID::forAscii(rt,
5432
+ "ubrn_uniffi_breez_sdk_common_checksum_method_"
5433
+ "syncstorage_update_record_from_incoming"),
3478
5434
  0,
3479
5435
  [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3480
5436
  const jsi::Value *args, size_t count) -> jsi::Value {
3481
5437
  return this
3482
- ->cpp_uniffi_breez_sdk_common_checksum_method_restclient_delete_request(
5438
+ ->cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_update_record_from_incoming(
3483
5439
  rt, thisVal, args, count);
3484
5440
  });
3485
5441
  props["ubrn_ffi_breez_sdk_common_uniffi_contract_version"] =
@@ -3517,6 +5473,18 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
3517
5473
  ->cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_restclient(
3518
5474
  rt, thisVal, args, count);
3519
5475
  });
5476
+ props["ubrn_uniffi_breez_sdk_common_fn_init_callback_vtable_syncstorage"] =
5477
+ jsi::Function::createFromHostFunction(
5478
+ rt,
5479
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_init_"
5480
+ "callback_vtable_syncstorage"),
5481
+ 1,
5482
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5483
+ const jsi::Value *args, size_t count) -> jsi::Value {
5484
+ return this
5485
+ ->cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_syncstorage(
5486
+ rt, thisVal, args, count);
5487
+ });
3520
5488
  props["ubrn_uniffi_internal_fn_method_fiatservice_ffi__bless_pointer"] =
3521
5489
  jsi::Function::createFromHostFunction(
3522
5490
  rt,
@@ -3543,6 +5511,19 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
3543
5511
  ->cpp_uniffi_internal_fn_method_restclient_ffi__bless_pointer(
3544
5512
  rt, thisVal, args, count);
3545
5513
  });
5514
+ props["ubrn_uniffi_internal_fn_method_syncstorage_ffi__bless_pointer"] =
5515
+ jsi::Function::createFromHostFunction(
5516
+ rt,
5517
+ jsi::PropNameID::forAscii(
5518
+ rt,
5519
+ "ubrn_uniffi_internal_fn_method_syncstorage_ffi__bless_pointer"),
5520
+ 1,
5521
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
5522
+ const jsi::Value *args, size_t count) -> jsi::Value {
5523
+ return this
5524
+ ->cpp_uniffi_internal_fn_method_syncstorage_ffi__bless_pointer(
5525
+ rt, thisVal, args, count);
5526
+ });
3546
5527
  }
3547
5528
 
3548
5529
  void NativeBreezSdkCommon::registerModule(
@@ -3590,6 +5571,8 @@ NativeBreezSdkCommon::~NativeBreezSdkCommon() {
3590
5571
  vtablecallbackinterfacefiatservice::free::cleanup();
3591
5572
  uniffi::breez_sdk_common::st::vtablecallbackinterfacerestclient::
3592
5573
  vtablecallbackinterfacerestclient::free::cleanup();
5574
+ uniffi::breez_sdk_common::st::vtablecallbackinterfacesyncstorage::
5575
+ vtablecallbackinterfacesyncstorage::free::cleanup();
3593
5576
  // Cleanup for callback function CallbackInterfaceFiatServiceMethod0
3594
5577
  uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0::cleanup();
3595
5578
  // Cleanup for callback function CallbackInterfaceFiatServiceMethod1
@@ -3600,6 +5583,26 @@ NativeBreezSdkCommon::~NativeBreezSdkCommon() {
3600
5583
  uniffi::breez_sdk_common::cb::callbackinterfacerestclientmethod1::cleanup();
3601
5584
  // Cleanup for callback function CallbackInterfaceRestClientMethod2
3602
5585
  uniffi::breez_sdk_common::cb::callbackinterfacerestclientmethod2::cleanup();
5586
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod0
5587
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod0::cleanup();
5588
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod1
5589
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod1::cleanup();
5590
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod2
5591
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod2::cleanup();
5592
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod3
5593
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod3::cleanup();
5594
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod4
5595
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod4::cleanup();
5596
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod5
5597
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod5::cleanup();
5598
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod6
5599
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod6::cleanup();
5600
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod7
5601
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod7::cleanup();
5602
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod8
5603
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod8::cleanup();
5604
+ // Cleanup for callback function CallbackInterfaceSyncStorageMethod9
5605
+ uniffi::breez_sdk_common::cb::callbackinterfacesyncstoragemethod9::cleanup();
3603
5606
  }
3604
5607
 
3605
5608
  // Utility functions for serialization/deserialization of strings.
@@ -3655,6 +5658,22 @@ jsi::Value NativeBreezSdkCommon::
3655
5658
  auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
3656
5659
  return jsi::Value(rt, obj);
3657
5660
  }
5661
+ jsi::Value NativeBreezSdkCommon::
5662
+ cpp_uniffi_internal_fn_method_syncstorage_ffi__bless_pointer(
5663
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5664
+ size_t count) {
5665
+ auto pointer =
5666
+ uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
5667
+ auto static destructor = [](uint64_t p) {
5668
+ auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
5669
+ RustCallStatus status = {0};
5670
+ uniffi_breez_sdk_common_fn_free_syncstorage(pointer, &status);
5671
+ };
5672
+ auto ptrObj =
5673
+ std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
5674
+ auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
5675
+ return jsi::Value(rt, obj);
5676
+ }
3658
5677
 
3659
5678
  // Methods calling directly into the uniffi generated C API of the Rust crate.
3660
5679
  jsi::Value
@@ -3775,6 +5794,154 @@ jsi::Value NativeBreezSdkCommon::
3775
5794
  return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
3776
5795
  value);
3777
5796
  }
5797
+ jsi::Value
5798
+ NativeBreezSdkCommon::cpp_uniffi_breez_sdk_common_fn_clone_syncstorage(
5799
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5800
+ size_t count) {
5801
+ RustCallStatus status =
5802
+ uniffi::breez_sdk_common::Bridging<RustCallStatus>::rustSuccess(rt);
5803
+ auto value = uniffi_breez_sdk_common_fn_clone_syncstorage(
5804
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
5805
+ uniffi::breez_sdk_common::Bridging<RustCallStatus>::copyIntoJs(
5806
+ rt, callInvoker, status, args[count - 1]);
5807
+
5808
+ return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
5809
+ }
5810
+ jsi::Value
5811
+ NativeBreezSdkCommon::cpp_uniffi_breez_sdk_common_fn_free_syncstorage(
5812
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5813
+ size_t count) {
5814
+ RustCallStatus status =
5815
+ uniffi::breez_sdk_common::Bridging<RustCallStatus>::rustSuccess(rt);
5816
+ uniffi_breez_sdk_common_fn_free_syncstorage(
5817
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
5818
+ uniffi::breez_sdk_common::Bridging<RustCallStatus>::copyIntoJs(
5819
+ rt, callInvoker, status, args[count - 1]);
5820
+
5821
+ return jsi::Value::undefined();
5822
+ }
5823
+ jsi::Value NativeBreezSdkCommon::
5824
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_add_outgoing_change(
5825
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5826
+ size_t count) {
5827
+ auto value =
5828
+ uniffi_breez_sdk_common_fn_method_syncstorage_add_outgoing_change(
5829
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5830
+ uniffi::breez_sdk_common::Bridging<RustBuffer>::fromJs(
5831
+ rt, callInvoker, args[1]));
5832
+
5833
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5834
+ value);
5835
+ }
5836
+ jsi::Value NativeBreezSdkCommon::
5837
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_complete_outgoing_sync(
5838
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5839
+ size_t count) {
5840
+ auto value =
5841
+ uniffi_breez_sdk_common_fn_method_syncstorage_complete_outgoing_sync(
5842
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5843
+ uniffi::breez_sdk_common::Bridging<RustBuffer>::fromJs(
5844
+ rt, callInvoker, args[1]));
5845
+
5846
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5847
+ value);
5848
+ }
5849
+ jsi::Value NativeBreezSdkCommon::
5850
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_pending_outgoing_changes(
5851
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5852
+ size_t count) {
5853
+ auto value =
5854
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_pending_outgoing_changes(
5855
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5856
+ uniffi_jsi::Bridging<uint32_t>::fromJs(rt, callInvoker, args[1]));
5857
+
5858
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5859
+ value);
5860
+ }
5861
+ jsi::Value NativeBreezSdkCommon::
5862
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_last_revision(
5863
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5864
+ size_t count) {
5865
+ auto value = uniffi_breez_sdk_common_fn_method_syncstorage_get_last_revision(
5866
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]));
5867
+
5868
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5869
+ value);
5870
+ }
5871
+ jsi::Value NativeBreezSdkCommon::
5872
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_insert_incoming_records(
5873
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5874
+ size_t count) {
5875
+ auto value =
5876
+ uniffi_breez_sdk_common_fn_method_syncstorage_insert_incoming_records(
5877
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5878
+ uniffi::breez_sdk_common::Bridging<RustBuffer>::fromJs(
5879
+ rt, callInvoker, args[1]));
5880
+
5881
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5882
+ value);
5883
+ }
5884
+ jsi::Value NativeBreezSdkCommon::
5885
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_delete_incoming_record(
5886
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5887
+ size_t count) {
5888
+ auto value =
5889
+ uniffi_breez_sdk_common_fn_method_syncstorage_delete_incoming_record(
5890
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5891
+ uniffi::breez_sdk_common::Bridging<RustBuffer>::fromJs(
5892
+ rt, callInvoker, args[1]));
5893
+
5894
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5895
+ value);
5896
+ }
5897
+ jsi::Value NativeBreezSdkCommon::
5898
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_rebase_pending_outgoing_records(
5899
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5900
+ size_t count) {
5901
+ auto value =
5902
+ uniffi_breez_sdk_common_fn_method_syncstorage_rebase_pending_outgoing_records(
5903
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5904
+ uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[1]));
5905
+
5906
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5907
+ value);
5908
+ }
5909
+ jsi::Value NativeBreezSdkCommon::
5910
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_incoming_records(
5911
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5912
+ size_t count) {
5913
+ auto value =
5914
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_incoming_records(
5915
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5916
+ uniffi_jsi::Bridging<uint32_t>::fromJs(rt, callInvoker, args[1]));
5917
+
5918
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5919
+ value);
5920
+ }
5921
+ jsi::Value NativeBreezSdkCommon::
5922
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_get_latest_outgoing_change(
5923
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5924
+ size_t count) {
5925
+ auto value =
5926
+ uniffi_breez_sdk_common_fn_method_syncstorage_get_latest_outgoing_change(
5927
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]));
5928
+
5929
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5930
+ value);
5931
+ }
5932
+ jsi::Value NativeBreezSdkCommon::
5933
+ cpp_uniffi_breez_sdk_common_fn_method_syncstorage_update_record_from_incoming(
5934
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5935
+ size_t count) {
5936
+ auto value =
5937
+ uniffi_breez_sdk_common_fn_method_syncstorage_update_record_from_incoming(
5938
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
5939
+ uniffi::breez_sdk_common::Bridging<RustBuffer>::fromJs(
5940
+ rt, callInvoker, args[1]));
5941
+
5942
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
5943
+ value);
5944
+ }
3778
5945
  jsi::Value NativeBreezSdkCommon::cpp_ffi_breez_sdk_common_rust_future_poll_u8(
3779
5946
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
3780
5947
  size_t count) {
@@ -4446,6 +6613,96 @@ jsi::Value NativeBreezSdkCommon::
4446
6613
 
4447
6614
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
4448
6615
  }
6616
+ jsi::Value NativeBreezSdkCommon::
6617
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_add_outgoing_change(
6618
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6619
+ size_t count) {
6620
+ auto value =
6621
+ uniffi_breez_sdk_common_checksum_method_syncstorage_add_outgoing_change();
6622
+
6623
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6624
+ }
6625
+ jsi::Value NativeBreezSdkCommon::
6626
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_complete_outgoing_sync(
6627
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6628
+ size_t count) {
6629
+ auto value =
6630
+ uniffi_breez_sdk_common_checksum_method_syncstorage_complete_outgoing_sync();
6631
+
6632
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6633
+ }
6634
+ jsi::Value NativeBreezSdkCommon::
6635
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_pending_outgoing_changes(
6636
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6637
+ size_t count) {
6638
+ auto value =
6639
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_pending_outgoing_changes();
6640
+
6641
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6642
+ }
6643
+ jsi::Value NativeBreezSdkCommon::
6644
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_last_revision(
6645
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6646
+ size_t count) {
6647
+ auto value =
6648
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_last_revision();
6649
+
6650
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6651
+ }
6652
+ jsi::Value NativeBreezSdkCommon::
6653
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_insert_incoming_records(
6654
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6655
+ size_t count) {
6656
+ auto value =
6657
+ uniffi_breez_sdk_common_checksum_method_syncstorage_insert_incoming_records();
6658
+
6659
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6660
+ }
6661
+ jsi::Value NativeBreezSdkCommon::
6662
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_delete_incoming_record(
6663
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6664
+ size_t count) {
6665
+ auto value =
6666
+ uniffi_breez_sdk_common_checksum_method_syncstorage_delete_incoming_record();
6667
+
6668
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6669
+ }
6670
+ jsi::Value NativeBreezSdkCommon::
6671
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_rebase_pending_outgoing_records(
6672
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6673
+ size_t count) {
6674
+ auto value =
6675
+ uniffi_breez_sdk_common_checksum_method_syncstorage_rebase_pending_outgoing_records();
6676
+
6677
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6678
+ }
6679
+ jsi::Value NativeBreezSdkCommon::
6680
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_incoming_records(
6681
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6682
+ size_t count) {
6683
+ auto value =
6684
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_incoming_records();
6685
+
6686
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6687
+ }
6688
+ jsi::Value NativeBreezSdkCommon::
6689
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_get_latest_outgoing_change(
6690
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6691
+ size_t count) {
6692
+ auto value =
6693
+ uniffi_breez_sdk_common_checksum_method_syncstorage_get_latest_outgoing_change();
6694
+
6695
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6696
+ }
6697
+ jsi::Value NativeBreezSdkCommon::
6698
+ cpp_uniffi_breez_sdk_common_checksum_method_syncstorage_update_record_from_incoming(
6699
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6700
+ size_t count) {
6701
+ auto value =
6702
+ uniffi_breez_sdk_common_checksum_method_syncstorage_update_record_from_incoming();
6703
+
6704
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6705
+ }
4449
6706
  jsi::Value
4450
6707
  NativeBreezSdkCommon::cpp_ffi_breez_sdk_common_uniffi_contract_version(
4451
6708
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
@@ -4483,4 +6740,19 @@ jsi::Value NativeBreezSdkCommon::
4483
6740
  uniffi::breez_sdk_common::registry::putTable(
4484
6741
  "UniffiVTableCallbackInterfaceRestClient", vtableInstance));
4485
6742
  return jsi::Value::undefined();
6743
+ }
6744
+ jsi::Value NativeBreezSdkCommon::
6745
+ cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_syncstorage(
6746
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6747
+ size_t count) {
6748
+ auto vtableInstance = uniffi::breez_sdk_common::Bridging<
6749
+ UniffiVTableCallbackInterfaceSyncStorage>::fromJs(rt, callInvoker,
6750
+ args[0]);
6751
+
6752
+ std::lock_guard<std::mutex> lock(
6753
+ uniffi::breez_sdk_common::registry::vtableMutex);
6754
+ uniffi_breez_sdk_common_fn_init_callback_vtable_syncstorage(
6755
+ uniffi::breez_sdk_common::registry::putTable(
6756
+ "UniffiVTableCallbackInterfaceSyncStorage", vtableInstance));
6757
+ return jsi::Value::undefined();
4486
6758
  }