@breeztech/breez-sdk-spark-react-native 0.1.9-dev1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/generated/breez_sdk_common.cpp +675 -25
- package/cpp/generated/breez_sdk_common.hpp +27 -0
- package/cpp/generated/breez_sdk_spark.cpp +196 -3
- package/cpp/generated/breez_sdk_spark.hpp +27 -0
- package/lib/commonjs/generated/breez_sdk_common-ffi.js.map +1 -1
- package/lib/commonjs/generated/breez_sdk_common.js +185 -1
- package/lib/commonjs/generated/breez_sdk_common.js.map +1 -1
- package/lib/commonjs/generated/breez_sdk_spark-ffi.js.map +1 -1
- package/lib/commonjs/generated/breez_sdk_spark.js +427 -17
- package/lib/commonjs/generated/breez_sdk_spark.js.map +1 -1
- package/lib/module/generated/breez_sdk_common-ffi.js.map +1 -1
- package/lib/module/generated/breez_sdk_common.js +183 -0
- package/lib/module/generated/breez_sdk_common.js.map +1 -1
- package/lib/module/generated/breez_sdk_spark-ffi.js.map +1 -1
- package/lib/module/generated/breez_sdk_spark.js +427 -17
- package/lib/module/generated/breez_sdk_spark.js.map +1 -1
- package/lib/typescript/commonjs/src/generated/breez_sdk_common-ffi.d.ts +15 -0
- package/lib/typescript/commonjs/src/generated/breez_sdk_common-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/generated/breez_sdk_common.d.ts +44 -0
- package/lib/typescript/commonjs/src/generated/breez_sdk_common.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/generated/breez_sdk_spark-ffi.d.ts +10 -2
- package/lib/typescript/commonjs/src/generated/breez_sdk_spark-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/generated/breez_sdk_spark.d.ts +306 -12
- package/lib/typescript/commonjs/src/generated/breez_sdk_spark.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/breez_sdk_common-ffi.d.ts +15 -0
- package/lib/typescript/module/src/generated/breez_sdk_common-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/breez_sdk_common.d.ts +44 -0
- package/lib/typescript/module/src/generated/breez_sdk_common.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/breez_sdk_spark-ffi.d.ts +10 -2
- package/lib/typescript/module/src/generated/breez_sdk_spark-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/breez_sdk_spark.d.ts +306 -12
- package/lib/typescript/module/src/generated/breez_sdk_spark.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/generated/breez_sdk_common-ffi.ts +38 -0
- package/src/generated/breez_sdk_common.ts +334 -0
- package/src/generated/breez_sdk_spark-ffi.ts +22 -2
- package/src/generated/breez_sdk_spark.ts +657 -20
|
@@ -100,6 +100,14 @@ typedef struct UniffiForeignFutureStructVoid {
|
|
|
100
100
|
} UniffiForeignFutureStructVoid;
|
|
101
101
|
typedef void (*UniffiForeignFutureCompleteVoid)(
|
|
102
102
|
uint64_t callback_data, UniffiForeignFutureStructVoid result);
|
|
103
|
+
typedef void (*UniffiCallbackInterfaceFiatServiceMethod0)(
|
|
104
|
+
uint64_t uniffi_handle,
|
|
105
|
+
UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
|
|
106
|
+
uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
|
|
107
|
+
typedef void (*UniffiCallbackInterfaceFiatServiceMethod1)(
|
|
108
|
+
uint64_t uniffi_handle,
|
|
109
|
+
UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
|
|
110
|
+
uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
|
|
103
111
|
typedef void (*UniffiCallbackInterfaceRestClientMethod0)(
|
|
104
112
|
uint64_t uniffi_handle, RustBuffer url, RustBuffer headers,
|
|
105
113
|
UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
|
|
@@ -112,6 +120,11 @@ typedef void (*UniffiCallbackInterfaceRestClientMethod2)(
|
|
|
112
120
|
uint64_t uniffi_handle, RustBuffer url, RustBuffer headers, RustBuffer body,
|
|
113
121
|
UniffiForeignFutureCompleteRustBuffer uniffi_future_callback,
|
|
114
122
|
uint64_t uniffi_callback_data, UniffiForeignFuture *uniffi_out_return);
|
|
123
|
+
typedef struct UniffiVTableCallbackInterfaceFiatService {
|
|
124
|
+
UniffiCallbackInterfaceFiatServiceMethod0 fetch_fiat_currencies;
|
|
125
|
+
UniffiCallbackInterfaceFiatServiceMethod1 fetch_fiat_rates;
|
|
126
|
+
UniffiCallbackInterfaceFree uniffi_free;
|
|
127
|
+
} UniffiVTableCallbackInterfaceFiatService;
|
|
115
128
|
typedef struct UniffiVTableCallbackInterfaceRestClient {
|
|
116
129
|
UniffiCallbackInterfaceRestClientMethod0 get_request;
|
|
117
130
|
UniffiCallbackInterfaceRestClientMethod1 post_request;
|
|
@@ -119,6 +132,17 @@ typedef struct UniffiVTableCallbackInterfaceRestClient {
|
|
|
119
132
|
UniffiCallbackInterfaceFree uniffi_free;
|
|
120
133
|
} UniffiVTableCallbackInterfaceRestClient;
|
|
121
134
|
void *
|
|
135
|
+
uniffi_breez_sdk_common_fn_clone_fiatservice(void *ptr,
|
|
136
|
+
RustCallStatus *uniffi_out_err);
|
|
137
|
+
void uniffi_breez_sdk_common_fn_free_fiatservice(
|
|
138
|
+
void *ptr, RustCallStatus *uniffi_out_err);
|
|
139
|
+
void uniffi_breez_sdk_common_fn_init_callback_vtable_fiatservice(
|
|
140
|
+
UniffiVTableCallbackInterfaceFiatService *vtable);
|
|
141
|
+
/*handle*/ uint64_t
|
|
142
|
+
uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_currencies(void *ptr);
|
|
143
|
+
/*handle*/ uint64_t
|
|
144
|
+
uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_rates(void *ptr);
|
|
145
|
+
void *
|
|
122
146
|
uniffi_breez_sdk_common_fn_clone_restclient(void *ptr,
|
|
123
147
|
RustCallStatus *uniffi_out_err);
|
|
124
148
|
void uniffi_breez_sdk_common_fn_free_restclient(void *ptr,
|
|
@@ -259,6 +283,9 @@ void ffi_breez_sdk_common_rust_future_free_void(
|
|
|
259
283
|
/*handle*/ uint64_t handle);
|
|
260
284
|
void ffi_breez_sdk_common_rust_future_complete_void(
|
|
261
285
|
/*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
|
|
286
|
+
uint16_t
|
|
287
|
+
uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies();
|
|
288
|
+
uint16_t uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates();
|
|
262
289
|
uint16_t uniffi_breez_sdk_common_checksum_method_restclient_get_request();
|
|
263
290
|
uint16_t uniffi_breez_sdk_common_checksum_method_restclient_post_request();
|
|
264
291
|
uint16_t uniffi_breez_sdk_common_checksum_method_restclient_delete_request();
|
|
@@ -730,6 +757,118 @@ static void cleanup() {
|
|
|
730
757
|
}
|
|
731
758
|
} // namespace uniffi::breez_sdk_common::st::foreignfuture::foreignfuture::free
|
|
732
759
|
|
|
760
|
+
// Callback function:
|
|
761
|
+
// uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::vtablecallbackinterfacefiatservice::free::UniffiCallbackInterfaceFree
|
|
762
|
+
//
|
|
763
|
+
// We have the following constraints:
|
|
764
|
+
// - we need to pass a function pointer to Rust.
|
|
765
|
+
// - we need a jsi::Runtime and jsi::Function to call into JS.
|
|
766
|
+
// - function pointers can't store state, so we can't use a lamda.
|
|
767
|
+
//
|
|
768
|
+
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
|
|
769
|
+
// function calls the lambda, which itself calls the `body` which then calls
|
|
770
|
+
// into JS.
|
|
771
|
+
//
|
|
772
|
+
// We then give the `callback` function pointer to Rust which will call the
|
|
773
|
+
// lambda sometime in the future.
|
|
774
|
+
namespace uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::
|
|
775
|
+
vtablecallbackinterfacefiatservice::free {
|
|
776
|
+
using namespace facebook;
|
|
777
|
+
|
|
778
|
+
// We need to store a lambda in a global so we can call it from
|
|
779
|
+
// a function pointer. The function pointer is passed to Rust.
|
|
780
|
+
static std::function<void(uint64_t)> rsLambda = nullptr;
|
|
781
|
+
|
|
782
|
+
// This is the main body of the callback. It's called from the lambda,
|
|
783
|
+
// which itself is called from the callback function which is passed to Rust.
|
|
784
|
+
static void body(jsi::Runtime &rt,
|
|
785
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
786
|
+
std::shared_ptr<jsi::Value> callbackValue,
|
|
787
|
+
uint64_t rs_handle) {
|
|
788
|
+
|
|
789
|
+
// Convert the arguments from Rust, into jsi::Values.
|
|
790
|
+
// We'll use the Bridging class to do this…
|
|
791
|
+
auto js_handle =
|
|
792
|
+
uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
|
|
793
|
+
|
|
794
|
+
// Now we are ready to call the callback.
|
|
795
|
+
// We are already on the JS thread, because this `body` function was
|
|
796
|
+
// invoked from the CallInvoker.
|
|
797
|
+
try {
|
|
798
|
+
// Getting the callback function
|
|
799
|
+
auto cb = callbackValue->asObject(rt).asFunction(rt);
|
|
800
|
+
auto uniffiResult = cb.call(rt, js_handle);
|
|
801
|
+
|
|
802
|
+
} catch (const jsi::JSError &error) {
|
|
803
|
+
std::cout << "Error in callback UniffiCallbackInterfaceFree: "
|
|
804
|
+
<< error.what() << std::endl;
|
|
805
|
+
throw error;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
static void callback(uint64_t rs_handle) {
|
|
810
|
+
// If the runtime has shutdown, then there is no point in trying to
|
|
811
|
+
// call into Javascript. BUT how do we tell if the runtime has shutdown?
|
|
812
|
+
//
|
|
813
|
+
// Answer: the module destructor calls into callback `cleanup` method,
|
|
814
|
+
// which nulls out the rsLamda.
|
|
815
|
+
//
|
|
816
|
+
// If rsLamda is null, then there is no runtime to call into.
|
|
817
|
+
if (rsLambda == nullptr) {
|
|
818
|
+
// This only occurs when destructors are calling into Rust free/drop,
|
|
819
|
+
// which causes the JS callback to be dropped.
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// The runtime, the actual callback jsi::funtion, and the callInvoker
|
|
824
|
+
// are all in the lambda.
|
|
825
|
+
rsLambda(rs_handle);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
static UniffiCallbackInterfaceFree
|
|
829
|
+
makeCallbackFunction( // uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::vtablecallbackinterfacefiatservice::free
|
|
830
|
+
jsi::Runtime &rt,
|
|
831
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
832
|
+
const jsi::Value &value) {
|
|
833
|
+
if (rsLambda != nullptr) {
|
|
834
|
+
// `makeCallbackFunction` is called in two circumstances:
|
|
835
|
+
//
|
|
836
|
+
// 1. at startup, when initializing callback interface vtables.
|
|
837
|
+
// 2. when polling futures. This happens at least once per future that is
|
|
838
|
+
// exposed to Javascript. We know that this is always the same function,
|
|
839
|
+
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
|
|
840
|
+
//
|
|
841
|
+
// We can therefore return the callback function without making anything
|
|
842
|
+
// new if we've been initialized already.
|
|
843
|
+
return callback;
|
|
844
|
+
}
|
|
845
|
+
auto callbackFunction = value.asObject(rt).asFunction(rt);
|
|
846
|
+
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
|
|
847
|
+
rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
|
|
848
|
+
// We immediately make a lambda which will do the work of transforming the
|
|
849
|
+
// arguments into JSI values and calling the callback.
|
|
850
|
+
uniffi_runtime::UniffiCallFunc jsLambda =
|
|
851
|
+
[callInvoker, callbackValue, rs_handle](jsi::Runtime &rt) mutable {
|
|
852
|
+
body(rt, callInvoker, callbackValue, rs_handle);
|
|
853
|
+
};
|
|
854
|
+
// We'll then call that lambda from the callInvoker which will
|
|
855
|
+
// look after calling it on the correct thread.
|
|
856
|
+
|
|
857
|
+
callInvoker->invokeNonBlocking(rt, jsLambda);
|
|
858
|
+
};
|
|
859
|
+
return callback;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// This method is called from the destructor of NativeBreezSdkCommon, which only
|
|
863
|
+
// happens when the jsi::Runtime is being destroyed.
|
|
864
|
+
static void cleanup() {
|
|
865
|
+
// The lambda holds a reference to the the Runtime, so when this is nulled
|
|
866
|
+
// out, then the pointer will no longer be left dangling.
|
|
867
|
+
rsLambda = nullptr;
|
|
868
|
+
}
|
|
869
|
+
} // namespace
|
|
870
|
+
// uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::vtablecallbackinterfacefiatservice::free
|
|
871
|
+
|
|
733
872
|
// Callback function:
|
|
734
873
|
// uniffi::breez_sdk_common::st::vtablecallbackinterfacerestclient::vtablecallbackinterfacerestclient::free::UniffiCallbackInterfaceFree
|
|
735
874
|
//
|
|
@@ -1716,35 +1855,311 @@ template <> struct Bridging<UniffiForeignFutureStructVoid> {
|
|
|
1716
1855
|
namespace uniffi::breez_sdk_common {
|
|
1717
1856
|
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
|
|
1718
1857
|
|
|
1719
|
-
template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
|
|
1720
|
-
static jsi::Value toJs(jsi::Runtime &rt,
|
|
1721
|
-
std::shared_ptr<CallInvoker> callInvoker,
|
|
1722
|
-
UniffiForeignFutureCompleteVoid rsCallback) {
|
|
1723
|
-
return jsi::Function::createFromHostFunction(
|
|
1724
|
-
rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"), 2,
|
|
1725
|
-
[rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
|
|
1726
|
-
const jsi::Value *arguments,
|
|
1727
|
-
size_t count) -> jsi::Value {
|
|
1728
|
-
return intoRust(rt, callInvoker, thisValue, arguments, count,
|
|
1729
|
-
rsCallback);
|
|
1730
|
-
});
|
|
1858
|
+
template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
|
|
1859
|
+
static jsi::Value toJs(jsi::Runtime &rt,
|
|
1860
|
+
std::shared_ptr<CallInvoker> callInvoker,
|
|
1861
|
+
UniffiForeignFutureCompleteVoid rsCallback) {
|
|
1862
|
+
return jsi::Function::createFromHostFunction(
|
|
1863
|
+
rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"), 2,
|
|
1864
|
+
[rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
|
|
1865
|
+
const jsi::Value *arguments,
|
|
1866
|
+
size_t count) -> jsi::Value {
|
|
1867
|
+
return intoRust(rt, callInvoker, thisValue, arguments, count,
|
|
1868
|
+
rsCallback);
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
static jsi::Value intoRust(jsi::Runtime &rt,
|
|
1873
|
+
std::shared_ptr<CallInvoker> callInvoker,
|
|
1874
|
+
const jsi::Value &thisValue,
|
|
1875
|
+
const jsi::Value *args, size_t count,
|
|
1876
|
+
UniffiForeignFutureCompleteVoid func) {
|
|
1877
|
+
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
|
|
1878
|
+
// then call the rs_callback with those arguments.
|
|
1879
|
+
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
|
|
1880
|
+
uniffi::breez_sdk_common::Bridging<
|
|
1881
|
+
UniffiForeignFutureStructVoid>::fromJs(rt, callInvoker, args[1]));
|
|
1882
|
+
|
|
1883
|
+
return jsi::Value::undefined();
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
} // namespace uniffi::breez_sdk_common
|
|
1887
|
+
// Implementation of callback function calling from Rust to JS
|
|
1888
|
+
// CallbackInterfaceFiatServiceMethod0
|
|
1889
|
+
|
|
1890
|
+
// Callback function:
|
|
1891
|
+
// uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0::UniffiCallbackInterfaceFiatServiceMethod0
|
|
1892
|
+
//
|
|
1893
|
+
// We have the following constraints:
|
|
1894
|
+
// - we need to pass a function pointer to Rust.
|
|
1895
|
+
// - we need a jsi::Runtime and jsi::Function to call into JS.
|
|
1896
|
+
// - function pointers can't store state, so we can't use a lamda.
|
|
1897
|
+
//
|
|
1898
|
+
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
|
|
1899
|
+
// function calls the lambda, which itself calls the `body` which then calls
|
|
1900
|
+
// into JS.
|
|
1901
|
+
//
|
|
1902
|
+
// We then give the `callback` function pointer to Rust which will call the
|
|
1903
|
+
// lambda sometime in the future.
|
|
1904
|
+
namespace uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0 {
|
|
1905
|
+
using namespace facebook;
|
|
1906
|
+
|
|
1907
|
+
// We need to store a lambda in a global so we can call it from
|
|
1908
|
+
// a function pointer. The function pointer is passed to Rust.
|
|
1909
|
+
static std::function<void(uint64_t, UniffiForeignFutureCompleteRustBuffer,
|
|
1910
|
+
uint64_t, UniffiForeignFuture *)>
|
|
1911
|
+
rsLambda = nullptr;
|
|
1912
|
+
|
|
1913
|
+
// This is the main body of the callback. It's called from the lambda,
|
|
1914
|
+
// which itself is called from the callback function which is passed to Rust.
|
|
1915
|
+
static void body(jsi::Runtime &rt,
|
|
1916
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
1917
|
+
std::shared_ptr<jsi::Value> callbackValue,
|
|
1918
|
+
uint64_t rs_uniffiHandle,
|
|
1919
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
1920
|
+
uint64_t rs_uniffiCallbackData,
|
|
1921
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
1922
|
+
|
|
1923
|
+
// Convert the arguments from Rust, into jsi::Values.
|
|
1924
|
+
// We'll use the Bridging class to do this…
|
|
1925
|
+
auto js_uniffiHandle =
|
|
1926
|
+
uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
|
|
1927
|
+
auto js_uniffiFutureCallback = uniffi::breez_sdk_common::Bridging<
|
|
1928
|
+
UniffiForeignFutureCompleteRustBuffer>::toJs(rt, callInvoker,
|
|
1929
|
+
rs_uniffiFutureCallback);
|
|
1930
|
+
auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
|
|
1931
|
+
rt, callInvoker, rs_uniffiCallbackData);
|
|
1932
|
+
|
|
1933
|
+
// Now we are ready to call the callback.
|
|
1934
|
+
// We are already on the JS thread, because this `body` function was
|
|
1935
|
+
// invoked from the CallInvoker.
|
|
1936
|
+
try {
|
|
1937
|
+
// Getting the callback function
|
|
1938
|
+
auto cb = callbackValue->asObject(rt).asFunction(rt);
|
|
1939
|
+
auto uniffiResult = cb.call(rt, js_uniffiHandle, js_uniffiFutureCallback,
|
|
1940
|
+
js_uniffiCallbackData);
|
|
1941
|
+
|
|
1942
|
+
// Finally, we need to copy the return value back into the Rust pointer.
|
|
1943
|
+
*rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
|
|
1944
|
+
ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
|
|
1945
|
+
uniffiResult);
|
|
1946
|
+
} catch (const jsi::JSError &error) {
|
|
1947
|
+
std::cout << "Error in callback UniffiCallbackInterfaceFiatServiceMethod0: "
|
|
1948
|
+
<< error.what() << std::endl;
|
|
1949
|
+
throw error;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
static void
|
|
1954
|
+
callback(uint64_t rs_uniffiHandle,
|
|
1955
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
1956
|
+
uint64_t rs_uniffiCallbackData,
|
|
1957
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
1958
|
+
// If the runtime has shutdown, then there is no point in trying to
|
|
1959
|
+
// call into Javascript. BUT how do we tell if the runtime has shutdown?
|
|
1960
|
+
//
|
|
1961
|
+
// Answer: the module destructor calls into callback `cleanup` method,
|
|
1962
|
+
// which nulls out the rsLamda.
|
|
1963
|
+
//
|
|
1964
|
+
// If rsLamda is null, then there is no runtime to call into.
|
|
1965
|
+
if (rsLambda == nullptr) {
|
|
1966
|
+
// This only occurs when destructors are calling into Rust free/drop,
|
|
1967
|
+
// which causes the JS callback to be dropped.
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// The runtime, the actual callback jsi::funtion, and the callInvoker
|
|
1972
|
+
// are all in the lambda.
|
|
1973
|
+
rsLambda(rs_uniffiHandle, rs_uniffiFutureCallback, rs_uniffiCallbackData,
|
|
1974
|
+
rs_uniffiOutReturn);
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
static UniffiCallbackInterfaceFiatServiceMethod0
|
|
1978
|
+
makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0
|
|
1979
|
+
jsi::Runtime &rt,
|
|
1980
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
1981
|
+
const jsi::Value &value) {
|
|
1982
|
+
if (rsLambda != nullptr) {
|
|
1983
|
+
// `makeCallbackFunction` is called in two circumstances:
|
|
1984
|
+
//
|
|
1985
|
+
// 1. at startup, when initializing callback interface vtables.
|
|
1986
|
+
// 2. when polling futures. This happens at least once per future that is
|
|
1987
|
+
// exposed to Javascript. We know that this is always the same function,
|
|
1988
|
+
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
|
|
1989
|
+
//
|
|
1990
|
+
// We can therefore return the callback function without making anything
|
|
1991
|
+
// new if we've been initialized already.
|
|
1992
|
+
return callback;
|
|
1993
|
+
}
|
|
1994
|
+
auto callbackFunction = value.asObject(rt).asFunction(rt);
|
|
1995
|
+
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
|
|
1996
|
+
rsLambda = [&rt, callInvoker, callbackValue](
|
|
1997
|
+
uint64_t rs_uniffiHandle,
|
|
1998
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
1999
|
+
uint64_t rs_uniffiCallbackData,
|
|
2000
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
2001
|
+
// We immediately make a lambda which will do the work of transforming the
|
|
2002
|
+
// arguments into JSI values and calling the callback.
|
|
2003
|
+
uniffi_runtime::UniffiCallFunc jsLambda =
|
|
2004
|
+
[callInvoker, callbackValue, rs_uniffiHandle, rs_uniffiFutureCallback,
|
|
2005
|
+
rs_uniffiCallbackData, rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
|
|
2006
|
+
body(rt, callInvoker, callbackValue, rs_uniffiHandle,
|
|
2007
|
+
rs_uniffiFutureCallback, rs_uniffiCallbackData,
|
|
2008
|
+
rs_uniffiOutReturn);
|
|
2009
|
+
};
|
|
2010
|
+
// We'll then call that lambda from the callInvoker which will
|
|
2011
|
+
// look after calling it on the correct thread.
|
|
2012
|
+
callInvoker->invokeBlocking(rt, jsLambda);
|
|
2013
|
+
};
|
|
2014
|
+
return callback;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
// This method is called from the destructor of NativeBreezSdkCommon, which only
|
|
2018
|
+
// happens when the jsi::Runtime is being destroyed.
|
|
2019
|
+
static void cleanup() {
|
|
2020
|
+
// The lambda holds a reference to the the Runtime, so when this is nulled
|
|
2021
|
+
// out, then the pointer will no longer be left dangling.
|
|
2022
|
+
rsLambda = nullptr;
|
|
2023
|
+
}
|
|
2024
|
+
} // namespace uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0
|
|
2025
|
+
// Implementation of callback function calling from Rust to JS
|
|
2026
|
+
// CallbackInterfaceFiatServiceMethod1
|
|
2027
|
+
|
|
2028
|
+
// Callback function:
|
|
2029
|
+
// uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod1::UniffiCallbackInterfaceFiatServiceMethod1
|
|
2030
|
+
//
|
|
2031
|
+
// We have the following constraints:
|
|
2032
|
+
// - we need to pass a function pointer to Rust.
|
|
2033
|
+
// - we need a jsi::Runtime and jsi::Function to call into JS.
|
|
2034
|
+
// - function pointers can't store state, so we can't use a lamda.
|
|
2035
|
+
//
|
|
2036
|
+
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
|
|
2037
|
+
// function calls the lambda, which itself calls the `body` which then calls
|
|
2038
|
+
// into JS.
|
|
2039
|
+
//
|
|
2040
|
+
// We then give the `callback` function pointer to Rust which will call the
|
|
2041
|
+
// lambda sometime in the future.
|
|
2042
|
+
namespace uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod1 {
|
|
2043
|
+
using namespace facebook;
|
|
2044
|
+
|
|
2045
|
+
// We need to store a lambda in a global so we can call it from
|
|
2046
|
+
// a function pointer. The function pointer is passed to Rust.
|
|
2047
|
+
static std::function<void(uint64_t, UniffiForeignFutureCompleteRustBuffer,
|
|
2048
|
+
uint64_t, UniffiForeignFuture *)>
|
|
2049
|
+
rsLambda = nullptr;
|
|
2050
|
+
|
|
2051
|
+
// This is the main body of the callback. It's called from the lambda,
|
|
2052
|
+
// which itself is called from the callback function which is passed to Rust.
|
|
2053
|
+
static void body(jsi::Runtime &rt,
|
|
2054
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
2055
|
+
std::shared_ptr<jsi::Value> callbackValue,
|
|
2056
|
+
uint64_t rs_uniffiHandle,
|
|
2057
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
2058
|
+
uint64_t rs_uniffiCallbackData,
|
|
2059
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
2060
|
+
|
|
2061
|
+
// Convert the arguments from Rust, into jsi::Values.
|
|
2062
|
+
// We'll use the Bridging class to do this…
|
|
2063
|
+
auto js_uniffiHandle =
|
|
2064
|
+
uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
|
|
2065
|
+
auto js_uniffiFutureCallback = uniffi::breez_sdk_common::Bridging<
|
|
2066
|
+
UniffiForeignFutureCompleteRustBuffer>::toJs(rt, callInvoker,
|
|
2067
|
+
rs_uniffiFutureCallback);
|
|
2068
|
+
auto js_uniffiCallbackData = uniffi_jsi::Bridging<uint64_t>::toJs(
|
|
2069
|
+
rt, callInvoker, rs_uniffiCallbackData);
|
|
2070
|
+
|
|
2071
|
+
// Now we are ready to call the callback.
|
|
2072
|
+
// We are already on the JS thread, because this `body` function was
|
|
2073
|
+
// invoked from the CallInvoker.
|
|
2074
|
+
try {
|
|
2075
|
+
// Getting the callback function
|
|
2076
|
+
auto cb = callbackValue->asObject(rt).asFunction(rt);
|
|
2077
|
+
auto uniffiResult = cb.call(rt, js_uniffiHandle, js_uniffiFutureCallback,
|
|
2078
|
+
js_uniffiCallbackData);
|
|
2079
|
+
|
|
2080
|
+
// Finally, we need to copy the return value back into the Rust pointer.
|
|
2081
|
+
*rs_uniffiOutReturn = uniffi::breez_sdk_common::Bridging<
|
|
2082
|
+
ReferenceHolder<UniffiForeignFuture>>::fromJs(rt, callInvoker,
|
|
2083
|
+
uniffiResult);
|
|
2084
|
+
} catch (const jsi::JSError &error) {
|
|
2085
|
+
std::cout << "Error in callback UniffiCallbackInterfaceFiatServiceMethod1: "
|
|
2086
|
+
<< error.what() << std::endl;
|
|
2087
|
+
throw error;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
static void
|
|
2092
|
+
callback(uint64_t rs_uniffiHandle,
|
|
2093
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
2094
|
+
uint64_t rs_uniffiCallbackData,
|
|
2095
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
2096
|
+
// If the runtime has shutdown, then there is no point in trying to
|
|
2097
|
+
// call into Javascript. BUT how do we tell if the runtime has shutdown?
|
|
2098
|
+
//
|
|
2099
|
+
// Answer: the module destructor calls into callback `cleanup` method,
|
|
2100
|
+
// which nulls out the rsLamda.
|
|
2101
|
+
//
|
|
2102
|
+
// If rsLamda is null, then there is no runtime to call into.
|
|
2103
|
+
if (rsLambda == nullptr) {
|
|
2104
|
+
// This only occurs when destructors are calling into Rust free/drop,
|
|
2105
|
+
// which causes the JS callback to be dropped.
|
|
2106
|
+
return;
|
|
1731
2107
|
}
|
|
1732
2108
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
// Convert the arguments into the Rust, with Bridging<T>::fromJs,
|
|
1739
|
-
// then call the rs_callback with those arguments.
|
|
1740
|
-
func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
|
|
1741
|
-
uniffi::breez_sdk_common::Bridging<
|
|
1742
|
-
UniffiForeignFutureStructVoid>::fromJs(rt, callInvoker, args[1]));
|
|
2109
|
+
// The runtime, the actual callback jsi::funtion, and the callInvoker
|
|
2110
|
+
// are all in the lambda.
|
|
2111
|
+
rsLambda(rs_uniffiHandle, rs_uniffiFutureCallback, rs_uniffiCallbackData,
|
|
2112
|
+
rs_uniffiOutReturn);
|
|
2113
|
+
}
|
|
1743
2114
|
|
|
1744
|
-
|
|
2115
|
+
static UniffiCallbackInterfaceFiatServiceMethod1
|
|
2116
|
+
makeCallbackFunction( // uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod1
|
|
2117
|
+
jsi::Runtime &rt,
|
|
2118
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
|
|
2119
|
+
const jsi::Value &value) {
|
|
2120
|
+
if (rsLambda != nullptr) {
|
|
2121
|
+
// `makeCallbackFunction` is called in two circumstances:
|
|
2122
|
+
//
|
|
2123
|
+
// 1. at startup, when initializing callback interface vtables.
|
|
2124
|
+
// 2. when polling futures. This happens at least once per future that is
|
|
2125
|
+
// exposed to Javascript. We know that this is always the same function,
|
|
2126
|
+
// `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
|
|
2127
|
+
//
|
|
2128
|
+
// We can therefore return the callback function without making anything
|
|
2129
|
+
// new if we've been initialized already.
|
|
2130
|
+
return callback;
|
|
1745
2131
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
2132
|
+
auto callbackFunction = value.asObject(rt).asFunction(rt);
|
|
2133
|
+
auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
|
|
2134
|
+
rsLambda = [&rt, callInvoker, callbackValue](
|
|
2135
|
+
uint64_t rs_uniffiHandle,
|
|
2136
|
+
UniffiForeignFutureCompleteRustBuffer rs_uniffiFutureCallback,
|
|
2137
|
+
uint64_t rs_uniffiCallbackData,
|
|
2138
|
+
UniffiForeignFuture *rs_uniffiOutReturn) {
|
|
2139
|
+
// We immediately make a lambda which will do the work of transforming the
|
|
2140
|
+
// arguments into JSI values and calling the callback.
|
|
2141
|
+
uniffi_runtime::UniffiCallFunc jsLambda =
|
|
2142
|
+
[callInvoker, callbackValue, rs_uniffiHandle, rs_uniffiFutureCallback,
|
|
2143
|
+
rs_uniffiCallbackData, rs_uniffiOutReturn](jsi::Runtime &rt) mutable {
|
|
2144
|
+
body(rt, callInvoker, callbackValue, rs_uniffiHandle,
|
|
2145
|
+
rs_uniffiFutureCallback, rs_uniffiCallbackData,
|
|
2146
|
+
rs_uniffiOutReturn);
|
|
2147
|
+
};
|
|
2148
|
+
// We'll then call that lambda from the callInvoker which will
|
|
2149
|
+
// look after calling it on the correct thread.
|
|
2150
|
+
callInvoker->invokeBlocking(rt, jsLambda);
|
|
2151
|
+
};
|
|
2152
|
+
return callback;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
// This method is called from the destructor of NativeBreezSdkCommon, which only
|
|
2156
|
+
// happens when the jsi::Runtime is being destroyed.
|
|
2157
|
+
static void cleanup() {
|
|
2158
|
+
// The lambda holds a reference to the the Runtime, so when this is nulled
|
|
2159
|
+
// out, then the pointer will no longer be left dangling.
|
|
2160
|
+
rsLambda = nullptr;
|
|
2161
|
+
}
|
|
2162
|
+
} // namespace uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod1
|
|
1748
2163
|
// Implementation of callback function calling from Rust to JS
|
|
1749
2164
|
// CallbackInterfaceRestClientMethod0
|
|
1750
2165
|
|
|
@@ -2195,6 +2610,44 @@ namespace uniffi::breez_sdk_common {
|
|
|
2195
2610
|
using namespace facebook;
|
|
2196
2611
|
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
|
|
2197
2612
|
|
|
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
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// Get the object from the jsi::Value
|
|
2625
|
+
auto jsObject = jsValue.getObject(rt);
|
|
2626
|
+
|
|
2627
|
+
// Create the vtable struct
|
|
2628
|
+
UniffiVTableCallbackInterfaceFiatService rsObject;
|
|
2629
|
+
|
|
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"));
|
|
2641
|
+
|
|
2642
|
+
return rsObject;
|
|
2643
|
+
}
|
|
2644
|
+
};
|
|
2645
|
+
|
|
2646
|
+
} // namespace uniffi::breez_sdk_common
|
|
2647
|
+
namespace uniffi::breez_sdk_common {
|
|
2648
|
+
using namespace facebook;
|
|
2649
|
+
using CallInvoker = uniffi_runtime::UniffiCallInvoker;
|
|
2650
|
+
|
|
2198
2651
|
template <> struct Bridging<UniffiVTableCallbackInterfaceRestClient> {
|
|
2199
2652
|
static UniffiVTableCallbackInterfaceRestClient
|
|
2200
2653
|
fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
|
|
@@ -2289,6 +2742,52 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
|
|
|
2289
2742
|
return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
|
|
2290
2743
|
rt, thisVal, args, count);
|
|
2291
2744
|
});
|
|
2745
|
+
props["ubrn_uniffi_breez_sdk_common_fn_clone_fiatservice"] =
|
|
2746
|
+
jsi::Function::createFromHostFunction(
|
|
2747
|
+
rt,
|
|
2748
|
+
jsi::PropNameID::forAscii(
|
|
2749
|
+
rt, "ubrn_uniffi_breez_sdk_common_fn_clone_fiatservice"),
|
|
2750
|
+
1,
|
|
2751
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2752
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2753
|
+
return this->cpp_uniffi_breez_sdk_common_fn_clone_fiatservice(
|
|
2754
|
+
rt, thisVal, args, count);
|
|
2755
|
+
});
|
|
2756
|
+
props["ubrn_uniffi_breez_sdk_common_fn_free_fiatservice"] =
|
|
2757
|
+
jsi::Function::createFromHostFunction(
|
|
2758
|
+
rt,
|
|
2759
|
+
jsi::PropNameID::forAscii(
|
|
2760
|
+
rt, "ubrn_uniffi_breez_sdk_common_fn_free_fiatservice"),
|
|
2761
|
+
1,
|
|
2762
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2763
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2764
|
+
return this->cpp_uniffi_breez_sdk_common_fn_free_fiatservice(
|
|
2765
|
+
rt, thisVal, args, count);
|
|
2766
|
+
});
|
|
2767
|
+
props["ubrn_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_"
|
|
2768
|
+
"currencies"] = jsi::Function::createFromHostFunction(
|
|
2769
|
+
rt,
|
|
2770
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_method_"
|
|
2771
|
+
"fiatservice_fetch_fiat_currencies"),
|
|
2772
|
+
1,
|
|
2773
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2774
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2775
|
+
return this
|
|
2776
|
+
->cpp_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_currencies(
|
|
2777
|
+
rt, thisVal, args, count);
|
|
2778
|
+
});
|
|
2779
|
+
props["ubrn_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_rates"] =
|
|
2780
|
+
jsi::Function::createFromHostFunction(
|
|
2781
|
+
rt,
|
|
2782
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_"
|
|
2783
|
+
"method_fiatservice_fetch_fiat_rates"),
|
|
2784
|
+
1,
|
|
2785
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2786
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2787
|
+
return this
|
|
2788
|
+
->cpp_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_rates(
|
|
2789
|
+
rt, thisVal, args, count);
|
|
2790
|
+
});
|
|
2292
2791
|
props["ubrn_uniffi_breez_sdk_common_fn_clone_restclient"] =
|
|
2293
2792
|
jsi::Function::createFromHostFunction(
|
|
2294
2793
|
rt,
|
|
@@ -2923,6 +3422,30 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
|
|
|
2923
3422
|
return this->cpp_ffi_breez_sdk_common_rust_future_complete_void(
|
|
2924
3423
|
rt, thisVal, args, count);
|
|
2925
3424
|
});
|
|
3425
|
+
props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
|
|
3426
|
+
"currencies"] = jsi::Function::createFromHostFunction(
|
|
3427
|
+
rt,
|
|
3428
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
|
|
3429
|
+
"method_fiatservice_fetch_fiat_currencies"),
|
|
3430
|
+
0,
|
|
3431
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3432
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3433
|
+
return this
|
|
3434
|
+
->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies(
|
|
3435
|
+
rt, thisVal, args, count);
|
|
3436
|
+
});
|
|
3437
|
+
props["ubrn_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_"
|
|
3438
|
+
"rates"] = jsi::Function::createFromHostFunction(
|
|
3439
|
+
rt,
|
|
3440
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_checksum_"
|
|
3441
|
+
"method_fiatservice_fetch_fiat_rates"),
|
|
3442
|
+
0,
|
|
3443
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3444
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3445
|
+
return this
|
|
3446
|
+
->cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates(
|
|
3447
|
+
rt, thisVal, args, count);
|
|
3448
|
+
});
|
|
2926
3449
|
props["ubrn_uniffi_breez_sdk_common_checksum_method_restclient_get_request"] =
|
|
2927
3450
|
jsi::Function::createFromHostFunction(
|
|
2928
3451
|
rt,
|
|
@@ -2970,6 +3493,18 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
|
|
|
2970
3493
|
return this->cpp_ffi_breez_sdk_common_uniffi_contract_version(
|
|
2971
3494
|
rt, thisVal, args, count);
|
|
2972
3495
|
});
|
|
3496
|
+
props["ubrn_uniffi_breez_sdk_common_fn_init_callback_vtable_fiatservice"] =
|
|
3497
|
+
jsi::Function::createFromHostFunction(
|
|
3498
|
+
rt,
|
|
3499
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_breez_sdk_common_fn_init_"
|
|
3500
|
+
"callback_vtable_fiatservice"),
|
|
3501
|
+
1,
|
|
3502
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3503
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3504
|
+
return this
|
|
3505
|
+
->cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_fiatservice(
|
|
3506
|
+
rt, thisVal, args, count);
|
|
3507
|
+
});
|
|
2973
3508
|
props["ubrn_uniffi_breez_sdk_common_fn_init_callback_vtable_restclient"] =
|
|
2974
3509
|
jsi::Function::createFromHostFunction(
|
|
2975
3510
|
rt,
|
|
@@ -2982,6 +3517,19 @@ NativeBreezSdkCommon::NativeBreezSdkCommon(
|
|
|
2982
3517
|
->cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_restclient(
|
|
2983
3518
|
rt, thisVal, args, count);
|
|
2984
3519
|
});
|
|
3520
|
+
props["ubrn_uniffi_internal_fn_method_fiatservice_ffi__bless_pointer"] =
|
|
3521
|
+
jsi::Function::createFromHostFunction(
|
|
3522
|
+
rt,
|
|
3523
|
+
jsi::PropNameID::forAscii(
|
|
3524
|
+
rt,
|
|
3525
|
+
"ubrn_uniffi_internal_fn_method_fiatservice_ffi__bless_pointer"),
|
|
3526
|
+
1,
|
|
3527
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3528
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3529
|
+
return this
|
|
3530
|
+
->cpp_uniffi_internal_fn_method_fiatservice_ffi__bless_pointer(
|
|
3531
|
+
rt, thisVal, args, count);
|
|
3532
|
+
});
|
|
2985
3533
|
props["ubrn_uniffi_internal_fn_method_restclient_ffi__bless_pointer"] =
|
|
2986
3534
|
jsi::Function::createFromHostFunction(
|
|
2987
3535
|
rt,
|
|
@@ -3038,8 +3586,14 @@ NativeBreezSdkCommon::~NativeBreezSdkCommon() {
|
|
|
3038
3586
|
uniffi::breez_sdk_common::cb::rustfuturecontinuationcallback::cleanup();
|
|
3039
3587
|
// Cleanup for "free" callback function CallbackInterfaceFree
|
|
3040
3588
|
uniffi::breez_sdk_common::st::foreignfuture::foreignfuture::free::cleanup();
|
|
3589
|
+
uniffi::breez_sdk_common::st::vtablecallbackinterfacefiatservice::
|
|
3590
|
+
vtablecallbackinterfacefiatservice::free::cleanup();
|
|
3041
3591
|
uniffi::breez_sdk_common::st::vtablecallbackinterfacerestclient::
|
|
3042
3592
|
vtablecallbackinterfacerestclient::free::cleanup();
|
|
3593
|
+
// Cleanup for callback function CallbackInterfaceFiatServiceMethod0
|
|
3594
|
+
uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod0::cleanup();
|
|
3595
|
+
// Cleanup for callback function CallbackInterfaceFiatServiceMethod1
|
|
3596
|
+
uniffi::breez_sdk_common::cb::callbackinterfacefiatservicemethod1::cleanup();
|
|
3043
3597
|
// Cleanup for callback function CallbackInterfaceRestClientMethod0
|
|
3044
3598
|
uniffi::breez_sdk_common::cb::callbackinterfacerestclientmethod0::cleanup();
|
|
3045
3599
|
// Cleanup for callback function CallbackInterfaceRestClientMethod1
|
|
@@ -3069,6 +3623,22 @@ NativeBreezSdkCommon::cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
|
|
|
3069
3623
|
size_t count) {
|
|
3070
3624
|
return uniffi_jsi::Bridging<std::string>::arraybuffer_to_string(rt, args[0]);
|
|
3071
3625
|
}
|
|
3626
|
+
jsi::Value NativeBreezSdkCommon::
|
|
3627
|
+
cpp_uniffi_internal_fn_method_fiatservice_ffi__bless_pointer(
|
|
3628
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3629
|
+
size_t count) {
|
|
3630
|
+
auto pointer =
|
|
3631
|
+
uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
|
|
3632
|
+
auto static destructor = [](uint64_t p) {
|
|
3633
|
+
auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
|
|
3634
|
+
RustCallStatus status = {0};
|
|
3635
|
+
uniffi_breez_sdk_common_fn_free_fiatservice(pointer, &status);
|
|
3636
|
+
};
|
|
3637
|
+
auto ptrObj =
|
|
3638
|
+
std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
|
|
3639
|
+
auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
|
|
3640
|
+
return jsi::Value(rt, obj);
|
|
3641
|
+
}
|
|
3072
3642
|
jsi::Value NativeBreezSdkCommon::
|
|
3073
3643
|
cpp_uniffi_internal_fn_method_restclient_ffi__bless_pointer(
|
|
3074
3644
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
@@ -3088,6 +3658,53 @@ jsi::Value NativeBreezSdkCommon::
|
|
|
3088
3658
|
|
|
3089
3659
|
// Methods calling directly into the uniffi generated C API of the Rust crate.
|
|
3090
3660
|
jsi::Value
|
|
3661
|
+
NativeBreezSdkCommon::cpp_uniffi_breez_sdk_common_fn_clone_fiatservice(
|
|
3662
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3663
|
+
size_t count) {
|
|
3664
|
+
RustCallStatus status =
|
|
3665
|
+
uniffi::breez_sdk_common::Bridging<RustCallStatus>::rustSuccess(rt);
|
|
3666
|
+
auto value = uniffi_breez_sdk_common_fn_clone_fiatservice(
|
|
3667
|
+
uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
|
|
3668
|
+
uniffi::breez_sdk_common::Bridging<RustCallStatus>::copyIntoJs(
|
|
3669
|
+
rt, callInvoker, status, args[count - 1]);
|
|
3670
|
+
|
|
3671
|
+
return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
|
|
3672
|
+
}
|
|
3673
|
+
jsi::Value
|
|
3674
|
+
NativeBreezSdkCommon::cpp_uniffi_breez_sdk_common_fn_free_fiatservice(
|
|
3675
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3676
|
+
size_t count) {
|
|
3677
|
+
RustCallStatus status =
|
|
3678
|
+
uniffi::breez_sdk_common::Bridging<RustCallStatus>::rustSuccess(rt);
|
|
3679
|
+
uniffi_breez_sdk_common_fn_free_fiatservice(
|
|
3680
|
+
uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
|
|
3681
|
+
uniffi::breez_sdk_common::Bridging<RustCallStatus>::copyIntoJs(
|
|
3682
|
+
rt, callInvoker, status, args[count - 1]);
|
|
3683
|
+
|
|
3684
|
+
return jsi::Value::undefined();
|
|
3685
|
+
}
|
|
3686
|
+
jsi::Value NativeBreezSdkCommon::
|
|
3687
|
+
cpp_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_currencies(
|
|
3688
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3689
|
+
size_t count) {
|
|
3690
|
+
auto value =
|
|
3691
|
+
uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_currencies(
|
|
3692
|
+
uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]));
|
|
3693
|
+
|
|
3694
|
+
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
3695
|
+
value);
|
|
3696
|
+
}
|
|
3697
|
+
jsi::Value NativeBreezSdkCommon::
|
|
3698
|
+
cpp_uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_rates(
|
|
3699
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3700
|
+
size_t count) {
|
|
3701
|
+
auto value = uniffi_breez_sdk_common_fn_method_fiatservice_fetch_fiat_rates(
|
|
3702
|
+
uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]));
|
|
3703
|
+
|
|
3704
|
+
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
3705
|
+
value);
|
|
3706
|
+
}
|
|
3707
|
+
jsi::Value
|
|
3091
3708
|
NativeBreezSdkCommon::cpp_uniffi_breez_sdk_common_fn_clone_restclient(
|
|
3092
3709
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
3093
3710
|
size_t count) {
|
|
@@ -3785,6 +4402,24 @@ NativeBreezSdkCommon::cpp_ffi_breez_sdk_common_rust_future_complete_void(
|
|
|
3785
4402
|
|
|
3786
4403
|
return jsi::Value::undefined();
|
|
3787
4404
|
}
|
|
4405
|
+
jsi::Value NativeBreezSdkCommon::
|
|
4406
|
+
cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies(
|
|
4407
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
4408
|
+
size_t count) {
|
|
4409
|
+
auto value =
|
|
4410
|
+
uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_currencies();
|
|
4411
|
+
|
|
4412
|
+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
4413
|
+
}
|
|
4414
|
+
jsi::Value NativeBreezSdkCommon::
|
|
4415
|
+
cpp_uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates(
|
|
4416
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
4417
|
+
size_t count) {
|
|
4418
|
+
auto value =
|
|
4419
|
+
uniffi_breez_sdk_common_checksum_method_fiatservice_fetch_fiat_rates();
|
|
4420
|
+
|
|
4421
|
+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
4422
|
+
}
|
|
3788
4423
|
jsi::Value NativeBreezSdkCommon::
|
|
3789
4424
|
cpp_uniffi_breez_sdk_common_checksum_method_restclient_get_request(
|
|
3790
4425
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
@@ -3819,6 +4454,21 @@ NativeBreezSdkCommon::cpp_ffi_breez_sdk_common_uniffi_contract_version(
|
|
|
3819
4454
|
|
|
3820
4455
|
return uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, value);
|
|
3821
4456
|
}
|
|
4457
|
+
jsi::Value NativeBreezSdkCommon::
|
|
4458
|
+
cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_fiatservice(
|
|
4459
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
4460
|
+
size_t count) {
|
|
4461
|
+
auto vtableInstance = uniffi::breez_sdk_common::Bridging<
|
|
4462
|
+
UniffiVTableCallbackInterfaceFiatService>::fromJs(rt, callInvoker,
|
|
4463
|
+
args[0]);
|
|
4464
|
+
|
|
4465
|
+
std::lock_guard<std::mutex> lock(
|
|
4466
|
+
uniffi::breez_sdk_common::registry::vtableMutex);
|
|
4467
|
+
uniffi_breez_sdk_common_fn_init_callback_vtable_fiatservice(
|
|
4468
|
+
uniffi::breez_sdk_common::registry::putTable(
|
|
4469
|
+
"UniffiVTableCallbackInterfaceFiatService", vtableInstance));
|
|
4470
|
+
return jsi::Value::undefined();
|
|
4471
|
+
}
|
|
3822
4472
|
jsi::Value NativeBreezSdkCommon::
|
|
3823
4473
|
cpp_uniffi_breez_sdk_common_fn_init_callback_vtable_restclient(
|
|
3824
4474
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|