@breeztech/breez-sdk-spark-react-native 0.5.0 → 0.5.2

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.
@@ -200,6 +200,10 @@ typedef void (*UniffiCallbackInterfaceStorageMethod11)(
200
200
  uint64_t uniffi_handle, RustBuffer txid, uint32_t vout, RustBuffer payload,
201
201
  UniffiForeignFutureCompleteVoid uniffi_future_callback,
202
202
  uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
203
+ typedef void (*UniffiCallbackInterfaceStorageMethod12)(
204
+ uint64_t uniffi_handle, RustBuffer metadata,
205
+ UniffiForeignFutureCompleteVoid uniffi_future_callback,
206
+ uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
203
207
  typedef void (*UniffiCallbackInterfaceSyncStorageMethod0)(
204
208
  uint64_t uniffi_handle, RustBuffer record,
205
209
  UniffiForeignFutureCompleteU64 uniffi_future_callback,
@@ -284,6 +288,7 @@ typedef struct UniffiVTableCallbackInterfaceStorage {
284
288
  UniffiCallbackInterfaceStorageMethod9 delete_deposit;
285
289
  UniffiCallbackInterfaceStorageMethod10 list_deposits;
286
290
  UniffiCallbackInterfaceStorageMethod11 update_deposit;
291
+ UniffiCallbackInterfaceStorageMethod12 set_lnurl_metadata;
287
292
  UniffiCallbackInterfaceFree uniffi_free;
288
293
  } UniffiVTableCallbackInterfaceStorage;
289
294
  typedef struct UniffiVTableCallbackInterfaceSyncStorage {
@@ -515,6 +520,8 @@ uniffi_breez_sdk_spark_fn_method_storage_get_payment_by_invoice(
515
520
  uniffi_breez_sdk_spark_fn_method_storage_list_deposits(void *ptr);
516
521
  /*handle*/ uint64_t uniffi_breez_sdk_spark_fn_method_storage_update_deposit(
517
522
  void *ptr, RustBuffer txid, uint32_t vout, RustBuffer payload);
523
+ /*handle*/ uint64_t uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata(
524
+ void *ptr, RustBuffer metadata);
518
525
  void *
519
526
  uniffi_breez_sdk_spark_fn_clone_syncstorage(void *ptr,
520
527
  RustCallStatus *uniffi_out_err);
@@ -799,6 +806,7 @@ uint16_t uniffi_breez_sdk_spark_checksum_method_storage_add_deposit();
799
806
  uint16_t uniffi_breez_sdk_spark_checksum_method_storage_delete_deposit();
800
807
  uint16_t uniffi_breez_sdk_spark_checksum_method_storage_list_deposits();
801
808
  uint16_t uniffi_breez_sdk_spark_checksum_method_storage_update_deposit();
809
+ uint16_t uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_metadata();
802
810
  uint16_t
803
811
  uniffi_breez_sdk_spark_checksum_method_syncstorage_add_outgoing_change();
804
812
  uint16_t
@@ -6680,6 +6688,146 @@ static void cleanup() {
6680
6688
  rsLambda = nullptr;
6681
6689
  }
6682
6690
  } // namespace uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod11
6691
+ // Implementation of callback function calling from Rust to JS
6692
+ // CallbackInterfaceStorageMethod12
6693
+
6694
+ // Callback function:
6695
+ // uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod12::UniffiCallbackInterfaceStorageMethod12
6696
+ //
6697
+ // We have the following constraints:
6698
+ // - we need to pass a function pointer to Rust.
6699
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
6700
+ // - function pointers can't store state, so we can't use a lamda.
6701
+ //
6702
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback`
6703
+ // function calls the lambda, which itself calls the `body` which then calls
6704
+ // into JS.
6705
+ //
6706
+ // We then give the `callback` function pointer to Rust which will call the
6707
+ // lambda sometime in the future.
6708
+ namespace uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod12 {
6709
+ using namespace facebook;
6710
+
6711
+ // We need to store a lambda in a global so we can call it from
6712
+ // a function pointer. The function pointer is passed to Rust.
6713
+ static std::function<void(uint64_t, RustBuffer, UniffiForeignFutureCompleteVoid,
6714
+ uint64_t, UniffiForeignFuture *)>
6715
+ rsLambda = nullptr;
6716
+
6717
+ // This is the main body of the callback. It's called from the lambda,
6718
+ // which itself is called from the callback function which is passed to Rust.
6719
+ static void body(jsi::Runtime &rt,
6720
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
6721
+ std::shared_ptr<jsi::Value> callbackValue,
6722
+ uint64_t rs_uniffiHandle, RustBuffer rs_metadata,
6723
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
6724
+ uint64_t rs_uniffiCallbackData,
6725
+ UniffiForeignFuture *rs_uniffiOutReturn) {
6726
+
6727
+ // Convert the arguments from Rust, into jsi::Values.
6728
+ // We'll use the Bridging class to do this…
6729
+ auto js_uniffiHandle =
6730
+ uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
6731
+ auto js_metadata = uniffi::breez_sdk_spark::Bridging<RustBuffer>::toJs(
6732
+ rt, callInvoker, rs_metadata);
6733
+ auto js_uniffiFutureCallback =
6734
+ uniffi::breez_sdk_spark::Bridging<UniffiForeignFutureCompleteVoid>::toJs(
6735
+ rt, callInvoker, rs_uniffiFutureCallback);
6736
+ auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
6737
+ rt, callInvoker, rs_uniffiCallbackData);
6738
+
6739
+ // Now we are ready to call the callback.
6740
+ // We are already on the JS thread, because this `body` function was
6741
+ // invoked from the CallInvoker.
6742
+ try {
6743
+ // Getting the callback function
6744
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
6745
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_metadata,
6746
+ js_uniffiFutureCallback, js_uniffiCallbackData);
6747
+
6748
+ // Finally, we need to copy the return value back into the Rust pointer.
6749
+ *rs_uniffiOutReturn = uniffi::breez_sdk_spark::Bridging<
6750
+ ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
6751
+ uniffiResult);
6752
+ } catch (const jsi::JSError &error) {
6753
+ std::cout << "Error in callback UniffiCallbackInterfaceStorageMethod12: "
6754
+ << error.what() << std::endl;
6755
+ throw error;
6756
+ }
6757
+ }
6758
+
6759
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_metadata,
6760
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
6761
+ uint64_t rs_uniffiCallbackData,
6762
+ UniffiForeignFuture *rs_uniffiOutReturn) {
6763
+ // If the runtime has shutdown, then there is no point in trying to
6764
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
6765
+ //
6766
+ // Answer: the module destructor calls into callback `cleanup` method,
6767
+ // which nulls out the rsLamda.
6768
+ //
6769
+ // If rsLamda is null, then there is no runtime to call into.
6770
+ if (rsLambda == nullptr) {
6771
+ // This only occurs when destructors are calling into Rust free/drop,
6772
+ // which causes the JS callback to be dropped.
6773
+ return;
6774
+ }
6775
+
6776
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
6777
+ // are all in the lambda.
6778
+ rsLambda(rs_uniffiHandle, rs_metadata, rs_uniffiFutureCallback,
6779
+ rs_uniffiCallbackData, rs_uniffiOutReturn);
6780
+ }
6781
+
6782
+ static UniffiCallbackInterfaceStorageMethod12
6783
+ makeCallbackFunction( // uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod12
6784
+ jsi::Runtime &rt,
6785
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
6786
+ const jsi::Value &value) {
6787
+ if (rsLambda != nullptr) {
6788
+ // `makeCallbackFunction` is called in two circumstances:
6789
+ //
6790
+ // 1. at startup, when initializing callback interface vtables.
6791
+ // 2. when polling futures. This happens at least once per future that is
6792
+ // exposed to Javascript. We know that this is always the same function,
6793
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
6794
+ //
6795
+ // We can therefore return the callback function without making anything
6796
+ // new if we've been initialized already.
6797
+ return callback;
6798
+ }
6799
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
6800
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
6801
+ rsLambda = [&rt, callInvoker, callbackValue](
6802
+ uint64_t rs_uniffiHandle, RustBuffer rs_metadata,
6803
+ UniffiForeignFutureCompleteVoid rs_uniffiFutureCallback,
6804
+ uint64_t rs_uniffiCallbackData,
6805
+ UniffiForeignFuture *rs_uniffiOutReturn) {
6806
+ // We immediately make a lambda which will do the work of transforming the
6807
+ // arguments into JSI values and calling the callback.
6808
+ uniffi_runtime::UniffiCallFunc jsLambda =
6809
+ [callInvoker, callbackValue, rs_uniffiHandle, rs_metadata,
6810
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
6811
+ rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
6812
+ body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_metadata,
6813
+ rs_uniffiFutureCallback, rs_uniffiCallbackData,
6814
+ rs_uniffiOutReturn);
6815
+ };
6816
+ // We'll then call that lambda from the callInvoker which will
6817
+ // look after calling it on the correct thread.
6818
+ callInvoker->invokeBlocking(rt, jsLambda);
6819
+ };
6820
+ return callback;
6821
+ }
6822
+
6823
+ // This method is called from the destructor of NativeBreezSdkSpark, which only
6824
+ // happens when the jsi::Runtime is being destroyed.
6825
+ static void cleanup() {
6826
+ // The lambda holds a reference to the the Runtime, so when this is nulled
6827
+ // out, then the pointer will no longer be left dangling.
6828
+ rsLambda = nullptr;
6829
+ }
6830
+ } // namespace uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod12
6683
6831
  // Implementation of callback function calling from Rust to JS
6684
6832
  // CallbackInterfaceSyncStorageMethod0
6685
6833
 
@@ -8364,6 +8512,9 @@ template <> struct Bridging<UniffiVTableCallbackInterfaceStorage> {
8364
8512
  rsObject.update_deposit = uniffi::breez_sdk_spark::cb::
8365
8513
  callbackinterfacestoragemethod11::makeCallbackFunction(
8366
8514
  rt, callInvoker, jsObject.getProperty(rt, "updateDeposit"));
8515
+ rsObject.set_lnurl_metadata = uniffi::breez_sdk_spark::cb::
8516
+ callbackinterfacestoragemethod12::makeCallbackFunction(
8517
+ rt, callInvoker, jsObject.getProperty(rt, "setLnurlMetadata"));
8367
8518
  rsObject.uniffi_free =
8368
8519
  uniffi::breez_sdk_spark::st::vtablecallbackinterfacestorage::
8369
8520
  vtablecallbackinterfacestorage::free::makeCallbackFunction(
@@ -9453,6 +9604,18 @@ NativeBreezSdkSpark::NativeBreezSdkSpark(
9453
9604
  ->cpp_uniffi_breez_sdk_spark_fn_method_storage_update_deposit(
9454
9605
  rt, thisVal, args, count);
9455
9606
  });
9607
+ props["ubrn_uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata"] =
9608
+ jsi::Function::createFromHostFunction(
9609
+ rt,
9610
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_spark_fn_method_"
9611
+ "storage_set_lnurl_metadata"),
9612
+ 2,
9613
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
9614
+ const jsi::Value *args, size_t count) -> jsi::Value {
9615
+ return this
9616
+ ->cpp_uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata(
9617
+ rt, thisVal, args, count);
9618
+ });
9456
9619
  props["ubrn_uniffi_breez_sdk_spark_fn_clone_syncstorage"] =
9457
9620
  jsi::Function::createFromHostFunction(
9458
9621
  rt,
@@ -11122,6 +11285,18 @@ NativeBreezSdkSpark::NativeBreezSdkSpark(
11122
11285
  ->cpp_uniffi_breez_sdk_spark_checksum_method_storage_update_deposit(
11123
11286
  rt, thisVal, args, count);
11124
11287
  });
11288
+ props["ubrn_uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_"
11289
+ "metadata"] = jsi::Function::createFromHostFunction(
11290
+ rt,
11291
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_spark_checksum_"
11292
+ "method_storage_set_lnurl_metadata"),
11293
+ 0,
11294
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
11295
+ const jsi::Value *args, size_t count) -> jsi::Value {
11296
+ return this
11297
+ ->cpp_uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_metadata(
11298
+ rt, thisVal, args, count);
11299
+ });
11125
11300
  props["ubrn_uniffi_breez_sdk_spark_checksum_method_syncstorage_add_outgoing_"
11126
11301
  "change"] = jsi::Function::createFromHostFunction(
11127
11302
  rt,
@@ -11707,6 +11882,8 @@ NativeBreezSdkSpark::~NativeBreezSdkSpark() {
11707
11882
  uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod10::cleanup();
11708
11883
  // Cleanup for callback function CallbackInterfaceStorageMethod11
11709
11884
  uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod11::cleanup();
11885
+ // Cleanup for callback function CallbackInterfaceStorageMethod12
11886
+ uniffi::breez_sdk_spark::cb::callbackinterfacestoragemethod12::cleanup();
11710
11887
  // Cleanup for callback function CallbackInterfaceSyncStorageMethod0
11711
11888
  uniffi::breez_sdk_spark::cb::callbackinterfacesyncstoragemethod0::cleanup();
11712
11889
  // Cleanup for callback function CallbackInterfaceSyncStorageMethod1
@@ -12863,6 +13040,18 @@ jsi::Value NativeBreezSdkSpark::
12863
13040
  return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
12864
13041
  value);
12865
13042
  }
13043
+ jsi::Value NativeBreezSdkSpark::
13044
+ cpp_uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata(
13045
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
13046
+ size_t count) {
13047
+ auto value = uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata(
13048
+ uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
13049
+ uniffi::breez_sdk_spark::Bridging<RustBuffer>::fromJs(rt, callInvoker,
13050
+ args[1]));
13051
+
13052
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
13053
+ value);
13054
+ }
12866
13055
  jsi::Value NativeBreezSdkSpark::cpp_uniffi_breez_sdk_spark_fn_clone_syncstorage(
12867
13056
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
12868
13057
  size_t count) {
@@ -14349,6 +14538,15 @@ jsi::Value NativeBreezSdkSpark::
14349
14538
 
14350
14539
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
14351
14540
  }
14541
+ jsi::Value NativeBreezSdkSpark::
14542
+ cpp_uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_metadata(
14543
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
14544
+ size_t count) {
14545
+ auto value =
14546
+ uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_metadata();
14547
+
14548
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
14549
+ }
14352
14550
  jsi::Value NativeBreezSdkSpark::
14353
14551
  cpp_uniffi_breez_sdk_spark_checksum_method_syncstorage_add_outgoing_change(
14354
14552
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
@@ -282,6 +282,9 @@ protected:
282
282
  jsi::Value cpp_uniffi_breez_sdk_spark_fn_method_storage_update_deposit(
283
283
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
284
284
  size_t count);
285
+ jsi::Value cpp_uniffi_breez_sdk_spark_fn_method_storage_set_lnurl_metadata(
286
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
287
+ size_t count);
285
288
  jsi::Value cpp_uniffi_breez_sdk_spark_fn_clone_syncstorage(
286
289
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
287
290
  size_t count);
@@ -764,6 +767,10 @@ protected:
764
767
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
765
768
  size_t count);
766
769
  jsi::Value
770
+ cpp_uniffi_breez_sdk_spark_checksum_method_storage_set_lnurl_metadata(
771
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
772
+ size_t count);
773
+ jsi::Value
767
774
  cpp_uniffi_breez_sdk_spark_checksum_method_syncstorage_add_outgoing_change(
768
775
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
769
776
  size_t count);
@@ -1 +1 @@
1
- {"version":3,"names":["getter","globalThis","NativeBreezSdkSpark","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../../src","sources":["generated/breez_sdk_spark-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAutBA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAmC,GAAGA,CAAA,KACzCC,UAAU,CAASC,mBAAmB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAC3BL,MAAM,EAErB;AAoYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,8CAGL,GAAG,IAAI;AACR,MAAMC,mCAGL,GAAG,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["getter","globalThis","NativeBreezSdkSpark","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../../src","sources":["generated/breez_sdk_spark-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AA4tBA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAmC,GAAGA,CAAA,KACzCC,UAAU,CAASC,mBAAmB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAC3BL,MAAM,EAErB;AA2YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,8CAGL,GAAG,IAAI;AACR,MAAMC,mCAGL,GAAG,IAAI","ignoreList":[]}