mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-17 22:14:24 +01:00
get_info: remove with_scan argument (#306)
* get_info: remove with_scan argument * Fix binding tests * Update dart test and kotlin example app * Update RN example app
This commit is contained in:
@@ -151,7 +151,7 @@ pub(crate) async fn handle_command(
|
||||
}
|
||||
}
|
||||
Command::GetInfo => {
|
||||
command_result!(sdk.get_info(GetInfoRequest { with_scan: true }).await?)
|
||||
command_result!(sdk.get_info().await?)
|
||||
}
|
||||
Command::ListPayments => {
|
||||
let payments = sdk.list_payments().await?;
|
||||
|
||||
@@ -29,10 +29,6 @@ typedef struct wire_cst_backup_request {
|
||||
struct wire_cst_list_prim_u_8_strict *backup_path;
|
||||
} wire_cst_backup_request;
|
||||
|
||||
typedef struct wire_cst_get_info_request {
|
||||
bool with_scan;
|
||||
} wire_cst_get_info_request;
|
||||
|
||||
typedef struct wire_cst_prepare_receive_request {
|
||||
uint64_t payer_amount_sat;
|
||||
} wire_cst_prepare_receive_request;
|
||||
@@ -258,8 +254,7 @@ void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_disconnect(int6
|
||||
WireSyncRust2DartDco frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache(uintptr_t that);
|
||||
|
||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(int64_t port_,
|
||||
uintptr_t that,
|
||||
struct wire_cst_get_info_request *req);
|
||||
uintptr_t that);
|
||||
|
||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments(int64_t port_,
|
||||
uintptr_t that);
|
||||
@@ -310,8 +305,6 @@ struct wire_cst_binding_event_listener *frbgen_breez_liquid_cst_new_box_autoadd_
|
||||
|
||||
struct wire_cst_connect_request *frbgen_breez_liquid_cst_new_box_autoadd_connect_request(void);
|
||||
|
||||
struct wire_cst_get_info_request *frbgen_breez_liquid_cst_new_box_autoadd_get_info_request(void);
|
||||
|
||||
struct wire_cst_liquid_sdk_event *frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event(void);
|
||||
|
||||
struct wire_cst_payment *frbgen_breez_liquid_cst_new_box_autoadd_payment(void);
|
||||
@@ -340,7 +333,6 @@ static int64_t dummy_method_to_enforce_bundling(void) {
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_backup_request);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_binding_event_listener);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_connect_request);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_get_info_request);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_payment);
|
||||
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_prepare_receive_request);
|
||||
|
||||
@@ -45,10 +45,6 @@ dictionary ConnectRequest {
|
||||
string mnemonic;
|
||||
};
|
||||
|
||||
dictionary GetInfoRequest {
|
||||
boolean with_scan;
|
||||
};
|
||||
|
||||
dictionary GetInfoResponse {
|
||||
u64 balance_sat;
|
||||
u64 pending_send_sat;
|
||||
@@ -191,7 +187,7 @@ interface BindingLiquidSdk {
|
||||
void remove_event_listener(string id);
|
||||
|
||||
[Throws=LiquidSdkError]
|
||||
GetInfoResponse get_info(GetInfoRequest req);
|
||||
GetInfoResponse get_info();
|
||||
|
||||
[Throws=PaymentError]
|
||||
PrepareSendResponse prepare_send_payment(PrepareSendRequest req);
|
||||
|
||||
@@ -79,8 +79,8 @@ impl BindingLiquidSdk {
|
||||
rt().block_on(self.sdk.remove_event_listener(id))
|
||||
}
|
||||
|
||||
pub fn get_info(&self, req: GetInfoRequest) -> Result<GetInfoResponse, LiquidSdkError> {
|
||||
rt().block_on(self.sdk.get_info(req)).map_err(Into::into)
|
||||
pub fn get_info(&self) -> Result<GetInfoResponse, LiquidSdkError> {
|
||||
rt().block_on(self.sdk.get_info()).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn prepare_send_payment(
|
||||
|
||||
@@ -13,8 +13,7 @@ try {
|
||||
|
||||
var listenerId = sdk.addEventListener(SDKListener())
|
||||
|
||||
var getInfoReq = breez_liquid_sdk.GetInfoRequest(false)
|
||||
var nodeInfo = sdk.getInfo(getInfoReq)
|
||||
var nodeInfo = sdk.getInfo()
|
||||
|
||||
sdk.removeEventListener(listenerId)
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ def test():
|
||||
|
||||
listener_id = sdk.add_event_listener(SDKListener())
|
||||
|
||||
get_info_req = breez_liquid_sdk.GetInfoRequest(with_scan=False)
|
||||
node_info = sdk.get_info(get_info_req)
|
||||
node_info = sdk.get_info()
|
||||
|
||||
sdk.remove_event_listener(listener_id)
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ let sdk = try breez_liquid_sdk.connect(req: connectRequest);
|
||||
|
||||
let listenerId = try sdk.addEventListener(listener: SDKListener());
|
||||
|
||||
let getInfoReq = breez_liquid_sdk.GetInfoRequest(withScan: false);
|
||||
let nodeInfo = try sdk.getInfo(req: getInfoReq);
|
||||
let nodeInfo = try sdk.getInfo();
|
||||
|
||||
try sdk.removeEventListener(id: listenerId);
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ pub struct BindingLiquidSdk {
|
||||
}
|
||||
|
||||
impl BindingLiquidSdk {
|
||||
pub async fn get_info(&self, req: GetInfoRequest) -> Result<GetInfoResponse, LiquidSdkError> {
|
||||
self.sdk.get_info(req).await.map_err(Into::into)
|
||||
pub async fn get_info(&self) -> Result<GetInfoResponse, LiquidSdkError> {
|
||||
self.sdk.get_info().await.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub async fn add_event_listener(
|
||||
|
||||
@@ -118,13 +118,6 @@ impl CstDecode<crate::model::ConnectRequest> for *mut wire_cst_connect_request {
|
||||
CstDecode::<crate::model::ConnectRequest>::cst_decode(*wrap).into()
|
||||
}
|
||||
}
|
||||
impl CstDecode<crate::model::GetInfoRequest> for *mut wire_cst_get_info_request {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> crate::model::GetInfoRequest {
|
||||
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
|
||||
CstDecode::<crate::model::GetInfoRequest>::cst_decode(*wrap).into()
|
||||
}
|
||||
}
|
||||
impl CstDecode<crate::model::LiquidSdkEvent> for *mut wire_cst_liquid_sdk_event {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> crate::model::LiquidSdkEvent {
|
||||
@@ -201,14 +194,6 @@ impl CstDecode<crate::model::ConnectRequest> for wire_cst_connect_request {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl CstDecode<crate::model::GetInfoRequest> for wire_cst_get_info_request {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> crate::model::GetInfoRequest {
|
||||
crate::model::GetInfoRequest {
|
||||
with_scan: self.with_scan.cst_decode(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl CstDecode<crate::model::GetInfoResponse> for wire_cst_get_info_response {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> crate::model::GetInfoResponse {
|
||||
@@ -561,18 +546,6 @@ impl Default for wire_cst_connect_request {
|
||||
Self::new_with_null_ptr()
|
||||
}
|
||||
}
|
||||
impl NewWithNullPtr for wire_cst_get_info_request {
|
||||
fn new_with_null_ptr() -> Self {
|
||||
Self {
|
||||
with_scan: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Default for wire_cst_get_info_request {
|
||||
fn default() -> Self {
|
||||
Self::new_with_null_ptr()
|
||||
}
|
||||
}
|
||||
impl NewWithNullPtr for wire_cst_get_info_response {
|
||||
fn new_with_null_ptr() -> Self {
|
||||
Self {
|
||||
@@ -838,9 +811,8 @@ pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_em
|
||||
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(
|
||||
port_: i64,
|
||||
that: usize,
|
||||
req: *mut wire_cst_get_info_request,
|
||||
) {
|
||||
wire__crate__bindings__BindingLiquidSdk_get_info_impl(port_, that, req)
|
||||
wire__crate__bindings__BindingLiquidSdk_get_info_impl(port_, that)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -984,14 +956,6 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_connect_request(
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_get_info_request(
|
||||
) -> *mut wire_cst_get_info_request {
|
||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(
|
||||
wire_cst_get_info_request::new_with_null_ptr(),
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event(
|
||||
) -> *mut wire_cst_liquid_sdk_event {
|
||||
@@ -1128,11 +1092,6 @@ pub struct wire_cst_connect_request {
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct wire_cst_get_info_request {
|
||||
with_scan: bool,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct wire_cst_get_info_response {
|
||||
balance_sat: u64,
|
||||
pending_send_sat: u64,
|
||||
|
||||
@@ -208,7 +208,6 @@ fn wire__crate__bindings__BindingLiquidSdk_get_info_impl(
|
||||
that: impl CstDecode<
|
||||
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
|
||||
>,
|
||||
req: impl CstDecode<crate::model::GetInfoRequest>,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
@@ -218,7 +217,6 @@ fn wire__crate__bindings__BindingLiquidSdk_get_info_impl(
|
||||
},
|
||||
move || {
|
||||
let api_that = that.cst_decode();
|
||||
let api_req = req.cst_decode();
|
||||
move |context| async move {
|
||||
transform_result_dco(
|
||||
(move || async move {
|
||||
@@ -239,7 +237,7 @@ fn wire__crate__bindings__BindingLiquidSdk_get_info_impl(
|
||||
}
|
||||
}
|
||||
let api_that = &*api_that_decoded.unwrap();
|
||||
crate::bindings::BindingLiquidSdk::get_info(api_that, api_req).await
|
||||
crate::bindings::BindingLiquidSdk::get_info(api_that).await
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
@@ -635,12 +633,6 @@ fn wire__crate__bindings__parse_invoice_impl(
|
||||
|
||||
// Section: dart2rust
|
||||
|
||||
impl CstDecode<bool> for bool {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> bool {
|
||||
self
|
||||
}
|
||||
}
|
||||
impl CstDecode<i32> for i32 {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> i32 {
|
||||
@@ -781,13 +773,6 @@ impl SseDecode for crate::bindings::BindingEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for bool {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
deserializer.cursor.read_u8().unwrap() != 0
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for crate::model::Config {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@@ -818,16 +803,6 @@ impl SseDecode for crate::model::ConnectRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for crate::model::GetInfoRequest {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
let mut var_withScan = <bool>::sse_decode(deserializer);
|
||||
return crate::model::GetInfoRequest {
|
||||
with_scan: var_withScan,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for crate::model::GetInfoResponse {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@@ -1321,6 +1296,13 @@ impl SseDecode for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for bool {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
deserializer.cursor.read_u8().unwrap() != 0
|
||||
}
|
||||
}
|
||||
|
||||
fn pde_ffi_dispatcher_primary_impl(
|
||||
func_id: i32,
|
||||
port: flutter_rust_bridge::for_generated::MessagePort,
|
||||
@@ -1432,20 +1414,6 @@ impl flutter_rust_bridge::IntoIntoDart<crate::model::ConnectRequest>
|
||||
}
|
||||
}
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
impl flutter_rust_bridge::IntoDart for crate::model::GetInfoRequest {
|
||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||
[self.with_scan.into_into_dart().into_dart()].into_dart()
|
||||
}
|
||||
}
|
||||
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::GetInfoRequest {}
|
||||
impl flutter_rust_bridge::IntoIntoDart<crate::model::GetInfoRequest>
|
||||
for crate::model::GetInfoRequest
|
||||
{
|
||||
fn into_into_dart(self) -> crate::model::GetInfoRequest {
|
||||
self
|
||||
}
|
||||
}
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
impl flutter_rust_bridge::IntoDart for crate::model::GetInfoResponse {
|
||||
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
|
||||
[
|
||||
@@ -1923,13 +1891,6 @@ impl SseEncode for crate::bindings::BindingEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for bool {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
serializer.cursor.write_u8(self as _).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for crate::model::Config {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
@@ -1949,13 +1910,6 @@ impl SseEncode for crate::model::ConnectRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for crate::model::GetInfoRequest {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<bool>::sse_encode(self.with_scan, serializer);
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for crate::model::GetInfoResponse {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
@@ -2366,6 +2320,13 @@ impl SseEncode for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for bool {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
serializer.cursor.write_u8(self as _).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[path = "frb_generated.io.rs"]
|
||||
mod io;
|
||||
|
||||
@@ -157,11 +157,6 @@ pub struct SendPaymentResponse {
|
||||
pub payment: Payment,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct GetInfoRequest {
|
||||
pub with_scan: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct GetInfoResponse {
|
||||
/// Usable balance. This is the confirmed onchain balance minus `pending_send_sat`.
|
||||
|
||||
@@ -417,15 +417,12 @@ impl LiquidSdk {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_info(&self, req: GetInfoRequest) -> Result<GetInfoResponse> {
|
||||
pub async fn get_info(&self) -> Result<GetInfoResponse> {
|
||||
self.ensure_is_started().await?;
|
||||
debug!(
|
||||
"next_unused_address: {}",
|
||||
self.onchain_wallet.next_unused_address().await?
|
||||
);
|
||||
if req.with_scan {
|
||||
self.sync().await?;
|
||||
}
|
||||
|
||||
let mut pending_send_sat = 0;
|
||||
let mut pending_receive_sat = 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface {
|
||||
|
||||
void emptyWalletCache();
|
||||
|
||||
Future<GetInfoResponse> getInfo({required GetInfoRequest req});
|
||||
Future<GetInfoResponse> getInfo();
|
||||
|
||||
Future<List<Payment>> listPayments();
|
||||
|
||||
|
||||
@@ -72,8 +72,7 @@ abstract class RustLibApi extends BaseApi {
|
||||
|
||||
void crateBindingsBindingLiquidSdkEmptyWalletCache({required BindingLiquidSdk that});
|
||||
|
||||
Future<GetInfoResponse> crateBindingsBindingLiquidSdkGetInfo(
|
||||
{required BindingLiquidSdk that, required GetInfoRequest req});
|
||||
Future<GetInfoResponse> crateBindingsBindingLiquidSdkGetInfo({required BindingLiquidSdk that});
|
||||
|
||||
Future<List<Payment>> crateBindingsBindingLiquidSdkListPayments({required BindingLiquidSdk that});
|
||||
|
||||
@@ -220,29 +219,27 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
|
||||
@override
|
||||
Future<GetInfoResponse> crateBindingsBindingLiquidSdkGetInfo(
|
||||
{required BindingLiquidSdk that, required GetInfoRequest req}) {
|
||||
Future<GetInfoResponse> crateBindingsBindingLiquidSdkGetInfo({required BindingLiquidSdk that}) {
|
||||
return handler.executeNormal(NormalTask(
|
||||
callFfi: (port_) {
|
||||
var arg0 =
|
||||
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
that);
|
||||
var arg1 = cst_encode_box_autoadd_get_info_request(req);
|
||||
return wire.wire__crate__bindings__BindingLiquidSdk_get_info(port_, arg0, arg1);
|
||||
return wire.wire__crate__bindings__BindingLiquidSdk_get_info(port_, arg0);
|
||||
},
|
||||
codec: DcoCodec(
|
||||
decodeSuccessData: dco_decode_get_info_response,
|
||||
decodeErrorData: dco_decode_liquid_sdk_error,
|
||||
),
|
||||
constMeta: kCrateBindingsBindingLiquidSdkGetInfoConstMeta,
|
||||
argValues: [that, req],
|
||||
argValues: [that],
|
||||
apiImpl: this,
|
||||
));
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateBindingsBindingLiquidSdkGetInfoConstMeta => const TaskConstMeta(
|
||||
debugName: "BindingLiquidSdk_get_info",
|
||||
argNames: ["that", "req"],
|
||||
argNames: ["that"],
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -610,12 +607,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
bool dco_decode_bool(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
return raw as bool;
|
||||
}
|
||||
|
||||
@protected
|
||||
BackupRequest dco_decode_box_autoadd_backup_request(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
@@ -634,12 +625,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return dco_decode_connect_request(raw);
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoRequest dco_decode_box_autoadd_get_info_request(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
return dco_decode_get_info_request(raw);
|
||||
}
|
||||
|
||||
@protected
|
||||
LiquidSdkEvent dco_decode_box_autoadd_liquid_sdk_event(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
@@ -713,16 +698,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoRequest dco_decode_get_info_request(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
|
||||
return GetInfoRequest(
|
||||
withScan: dco_decode_bool(arr[0]),
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoResponse dco_decode_get_info_response(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
@@ -1154,12 +1129,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return BindingEventListener(stream: var_stream);
|
||||
}
|
||||
|
||||
@protected
|
||||
bool sse_decode_bool(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
return deserializer.buffer.getUint8() != 0;
|
||||
}
|
||||
|
||||
@protected
|
||||
BackupRequest sse_decode_box_autoadd_backup_request(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -1178,12 +1147,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return (sse_decode_connect_request(deserializer));
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoRequest sse_decode_box_autoadd_get_info_request(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
return (sse_decode_get_info_request(deserializer));
|
||||
}
|
||||
|
||||
@protected
|
||||
LiquidSdkEvent sse_decode_box_autoadd_liquid_sdk_event(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -1256,13 +1219,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return ConnectRequest(mnemonic: var_mnemonic, config: var_config);
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoRequest sse_decode_get_info_request(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
var var_withScan = sse_decode_bool(deserializer);
|
||||
return GetInfoRequest(withScan: var_withScan);
|
||||
}
|
||||
|
||||
@protected
|
||||
GetInfoResponse sse_decode_get_info_response(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -1645,6 +1601,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return deserializer.buffer.getBigUint64();
|
||||
}
|
||||
|
||||
@protected
|
||||
bool sse_decode_bool(SseDeserializer deserializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
return deserializer.buffer.getUint8() != 0;
|
||||
}
|
||||
|
||||
@protected
|
||||
int cst_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
BindingLiquidSdk raw) {
|
||||
@@ -1669,12 +1631,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
return (raw as BindingLiquidSdkImpl).frbInternalCstEncode();
|
||||
}
|
||||
|
||||
@protected
|
||||
bool cst_encode_bool(bool raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
return raw;
|
||||
}
|
||||
|
||||
@protected
|
||||
int cst_encode_i_32(int raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
@@ -1781,12 +1737,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_StreamSink_liquid_sdk_event_Dco(self.stream, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_bool(bool self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
serializer.buffer.putUint8(self ? 1 : 0);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_backup_request(BackupRequest self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -1805,12 +1755,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_connect_request(self, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_get_info_request(GetInfoRequest self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_get_info_request(self, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_liquid_sdk_event(LiquidSdkEvent self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -1877,12 +1821,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_config(self.config, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_get_info_request(GetInfoRequest self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
sse_encode_bool(self.withScan, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_get_info_response(GetInfoResponse self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
@@ -2198,6 +2136,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
serializer.buffer.putBigUint64(self);
|
||||
}
|
||||
|
||||
@protected
|
||||
void sse_encode_bool(bool self, SseSerializer serializer) {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
serializer.buffer.putUint8(self ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@sealed
|
||||
@@ -2232,8 +2176,9 @@ class BindingLiquidSdkImpl extends RustOpaque implements BindingLiquidSdk {
|
||||
that: this,
|
||||
);
|
||||
|
||||
Future<GetInfoResponse> getInfo({required GetInfoRequest req}) =>
|
||||
RustLib.instance.api.crateBindingsBindingLiquidSdkGetInfo(that: this, req: req);
|
||||
Future<GetInfoResponse> getInfo() => RustLib.instance.api.crateBindingsBindingLiquidSdkGetInfo(
|
||||
that: this,
|
||||
);
|
||||
|
||||
Future<List<Payment>> listPayments() => RustLib.instance.api.crateBindingsBindingLiquidSdkListPayments(
|
||||
that: this,
|
||||
|
||||
@@ -55,9 +55,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
BindingEventListener dco_decode_binding_event_listener(dynamic raw);
|
||||
|
||||
@protected
|
||||
bool dco_decode_bool(dynamic raw);
|
||||
|
||||
@protected
|
||||
BackupRequest dco_decode_box_autoadd_backup_request(dynamic raw);
|
||||
|
||||
@@ -67,9 +64,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
ConnectRequest dco_decode_box_autoadd_connect_request(dynamic raw);
|
||||
|
||||
@protected
|
||||
GetInfoRequest dco_decode_box_autoadd_get_info_request(dynamic raw);
|
||||
|
||||
@protected
|
||||
LiquidSdkEvent dco_decode_box_autoadd_liquid_sdk_event(dynamic raw);
|
||||
|
||||
@@ -100,9 +94,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
ConnectRequest dco_decode_connect_request(dynamic raw);
|
||||
|
||||
@protected
|
||||
GetInfoRequest dco_decode_get_info_request(dynamic raw);
|
||||
|
||||
@protected
|
||||
GetInfoResponse dco_decode_get_info_response(dynamic raw);
|
||||
|
||||
@@ -228,9 +219,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
BindingEventListener sse_decode_binding_event_listener(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
bool sse_decode_bool(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
BackupRequest sse_decode_box_autoadd_backup_request(SseDeserializer deserializer);
|
||||
|
||||
@@ -240,9 +228,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
ConnectRequest sse_decode_box_autoadd_connect_request(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
GetInfoRequest sse_decode_box_autoadd_get_info_request(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
LiquidSdkEvent sse_decode_box_autoadd_liquid_sdk_event(SseDeserializer deserializer);
|
||||
|
||||
@@ -273,9 +258,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
ConnectRequest sse_decode_connect_request(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
GetInfoRequest sse_decode_get_info_request(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
GetInfoResponse sse_decode_get_info_response(SseDeserializer deserializer);
|
||||
|
||||
@@ -369,6 +351,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
BigInt sse_decode_usize(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
bool sse_decode_bool(SseDeserializer deserializer);
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_AnyhowException(AnyhowException raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
@@ -422,14 +407,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_get_info_request> cst_encode_box_autoadd_get_info_request(GetInfoRequest raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
final ptr = wire.cst_new_box_autoadd_get_info_request();
|
||||
cst_api_fill_to_wire_get_info_request(raw, ptr.ref);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@protected
|
||||
ffi.Pointer<wire_cst_liquid_sdk_event> cst_encode_box_autoadd_liquid_sdk_event(LiquidSdkEvent raw) {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
@@ -587,12 +564,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
cst_api_fill_to_wire_connect_request(apiObj, wireObj.ref);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_box_autoadd_get_info_request(
|
||||
GetInfoRequest apiObj, ffi.Pointer<wire_cst_get_info_request> wireObj) {
|
||||
cst_api_fill_to_wire_get_info_request(apiObj, wireObj.ref);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_box_autoadd_liquid_sdk_event(
|
||||
LiquidSdkEvent apiObj, ffi.Pointer<wire_cst_liquid_sdk_event> wireObj) {
|
||||
@@ -649,11 +620,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
cst_api_fill_to_wire_config(apiObj.config, wireObj.config);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_get_info_request(GetInfoRequest apiObj, wire_cst_get_info_request wireObj) {
|
||||
wireObj.with_scan = cst_encode_bool(apiObj.withScan);
|
||||
}
|
||||
|
||||
@protected
|
||||
void cst_api_fill_to_wire_get_info_response(GetInfoResponse apiObj, wire_cst_get_info_response wireObj) {
|
||||
wireObj.balance_sat = cst_encode_u_64(apiObj.balanceSat);
|
||||
@@ -924,9 +890,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
int cst_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerBindingLiquidSdk(
|
||||
BindingLiquidSdk raw);
|
||||
|
||||
@protected
|
||||
bool cst_encode_bool(bool raw);
|
||||
|
||||
@protected
|
||||
int cst_encode_i_32(int raw);
|
||||
|
||||
@@ -979,9 +942,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
void sse_encode_binding_event_listener(BindingEventListener self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_bool(bool self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_backup_request(BackupRequest self, SseSerializer serializer);
|
||||
|
||||
@@ -991,9 +951,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
void sse_encode_box_autoadd_connect_request(ConnectRequest self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_get_info_request(GetInfoRequest self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_box_autoadd_liquid_sdk_event(LiquidSdkEvent self, SseSerializer serializer);
|
||||
|
||||
@@ -1024,9 +981,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
@protected
|
||||
void sse_encode_connect_request(ConnectRequest self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_get_info_request(GetInfoRequest self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_get_info_response(GetInfoResponse self, SseSerializer serializer);
|
||||
|
||||
@@ -1119,6 +1073,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
||||
|
||||
@protected
|
||||
void sse_encode_usize(BigInt self, SseSerializer serializer);
|
||||
|
||||
@protected
|
||||
void sse_encode_bool(bool self, SseSerializer serializer);
|
||||
}
|
||||
|
||||
// Section: wire_class
|
||||
@@ -1228,22 +1185,18 @@ class RustLibWire implements BaseWire {
|
||||
void wire__crate__bindings__BindingLiquidSdk_get_info(
|
||||
int port_,
|
||||
int that,
|
||||
ffi.Pointer<wire_cst_get_info_request> req,
|
||||
) {
|
||||
return _wire__crate__bindings__BindingLiquidSdk_get_info(
|
||||
port_,
|
||||
that,
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
late final _wire__crate__bindings__BindingLiquidSdk_get_infoPtr = _lookup<
|
||||
ffi
|
||||
.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_get_info_request>)>>(
|
||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info');
|
||||
late final _wire__crate__bindings__BindingLiquidSdk_get_infoPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
|
||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info');
|
||||
late final _wire__crate__bindings__BindingLiquidSdk_get_info =
|
||||
_wire__crate__bindings__BindingLiquidSdk_get_infoPtr
|
||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_get_info_request>)>();
|
||||
_wire__crate__bindings__BindingLiquidSdk_get_infoPtr.asFunction<void Function(int, int)>();
|
||||
|
||||
void wire__crate__bindings__BindingLiquidSdk_list_payments(
|
||||
int port_,
|
||||
@@ -1519,16 +1472,6 @@ class RustLibWire implements BaseWire {
|
||||
late final _cst_new_box_autoadd_connect_request =
|
||||
_cst_new_box_autoadd_connect_requestPtr.asFunction<ffi.Pointer<wire_cst_connect_request> Function()>();
|
||||
|
||||
ffi.Pointer<wire_cst_get_info_request> cst_new_box_autoadd_get_info_request() {
|
||||
return _cst_new_box_autoadd_get_info_request();
|
||||
}
|
||||
|
||||
late final _cst_new_box_autoadd_get_info_requestPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_get_info_request> Function()>>(
|
||||
'frbgen_breez_liquid_cst_new_box_autoadd_get_info_request');
|
||||
late final _cst_new_box_autoadd_get_info_request = _cst_new_box_autoadd_get_info_requestPtr
|
||||
.asFunction<ffi.Pointer<wire_cst_get_info_request> Function()>();
|
||||
|
||||
ffi.Pointer<wire_cst_liquid_sdk_event> cst_new_box_autoadd_liquid_sdk_event() {
|
||||
return _cst_new_box_autoadd_liquid_sdk_event();
|
||||
}
|
||||
@@ -1697,11 +1640,6 @@ final class wire_cst_backup_request extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> backup_path;
|
||||
}
|
||||
|
||||
final class wire_cst_get_info_request extends ffi.Struct {
|
||||
@ffi.Bool()
|
||||
external bool with_scan;
|
||||
}
|
||||
|
||||
final class wire_cst_prepare_receive_request extends ffi.Struct {
|
||||
@ffi.Uint64()
|
||||
external int payer_amount_sat;
|
||||
|
||||
@@ -91,22 +91,6 @@ class ConnectRequest {
|
||||
config == other.config;
|
||||
}
|
||||
|
||||
class GetInfoRequest {
|
||||
final bool withScan;
|
||||
|
||||
const GetInfoRequest({
|
||||
required this.withScan,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => withScan.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is GetInfoRequest && runtimeType == other.runtimeType && withScan == other.withScan;
|
||||
}
|
||||
|
||||
class GetInfoResponse {
|
||||
/// Usable balance. This is the confirmed onchain balance minus `pending_send_sat`.
|
||||
final BigInt balanceSat;
|
||||
|
||||
@@ -14,9 +14,8 @@ void main() {
|
||||
});
|
||||
|
||||
test("after setting up, getInfo should throw exception with 'Not initialized' message", () async {
|
||||
GetInfoRequest getInfoRequest = GetInfoRequest(withScan: true);
|
||||
try {
|
||||
await sdk.getInfo(req: getInfoRequest);
|
||||
await sdk.getInfo();
|
||||
} catch (e) {
|
||||
if (e is AnyhowException) {
|
||||
expect(e.message, "Not initialized");
|
||||
|
||||
@@ -22,11 +22,10 @@ class HomePage extends StatefulWidget {
|
||||
class _HomePageState extends State<HomePage> {
|
||||
Stream<GetInfoResponse> walletInfoStream() async* {
|
||||
debugPrint("Initialized walletInfoStream");
|
||||
GetInfoRequest req = const GetInfoRequest(withScan: false);
|
||||
yield await widget.liquidSDK.getInfo(req: req);
|
||||
yield await widget.liquidSDK.getInfo();
|
||||
while (true) {
|
||||
await Future.delayed(const Duration(seconds: 10));
|
||||
yield await widget.liquidSDK.getInfo(req: req);
|
||||
yield await widget.liquidSDK.getInfo();
|
||||
debugPrint("Refreshed wallet info");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,22 +110,19 @@ class FlutterBreezLiquidBindings {
|
||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(
|
||||
int port_,
|
||||
int that,
|
||||
ffi.Pointer<wire_cst_get_info_request> req,
|
||||
) {
|
||||
return _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(
|
||||
port_,
|
||||
that,
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_infoPtr = _lookup<
|
||||
ffi
|
||||
.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Pointer<wire_cst_get_info_request>)>>(
|
||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info');
|
||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_infoPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
|
||||
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info');
|
||||
late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info =
|
||||
_frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_infoPtr
|
||||
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_get_info_request>)>();
|
||||
.asFunction<void Function(int, int)>();
|
||||
|
||||
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments(
|
||||
int port_,
|
||||
@@ -412,17 +409,6 @@ class FlutterBreezLiquidBindings {
|
||||
_frbgen_breez_liquid_cst_new_box_autoadd_connect_requestPtr
|
||||
.asFunction<ffi.Pointer<wire_cst_connect_request> Function()>();
|
||||
|
||||
ffi.Pointer<wire_cst_get_info_request> frbgen_breez_liquid_cst_new_box_autoadd_get_info_request() {
|
||||
return _frbgen_breez_liquid_cst_new_box_autoadd_get_info_request();
|
||||
}
|
||||
|
||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_get_info_requestPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Pointer<wire_cst_get_info_request> Function()>>(
|
||||
'frbgen_breez_liquid_cst_new_box_autoadd_get_info_request');
|
||||
late final _frbgen_breez_liquid_cst_new_box_autoadd_get_info_request =
|
||||
_frbgen_breez_liquid_cst_new_box_autoadd_get_info_requestPtr
|
||||
.asFunction<ffi.Pointer<wire_cst_get_info_request> Function()>();
|
||||
|
||||
ffi.Pointer<wire_cst_liquid_sdk_event> frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event() {
|
||||
return _frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event();
|
||||
}
|
||||
@@ -614,11 +600,6 @@ final class wire_cst_backup_request extends ffi.Struct {
|
||||
external ffi.Pointer<wire_cst_list_prim_u_8_strict> backup_path;
|
||||
}
|
||||
|
||||
final class wire_cst_get_info_request extends ffi.Struct {
|
||||
@ffi.Bool()
|
||||
external bool with_scan;
|
||||
}
|
||||
|
||||
final class wire_cst_prepare_receive_request extends ffi.Struct {
|
||||
@ffi.Uint64()
|
||||
external int payer_amount_sat;
|
||||
|
||||
@@ -117,38 +117,6 @@ fun asConnectRequestList(arr: ReadableArray): List<ConnectRequest> {
|
||||
return list
|
||||
}
|
||||
|
||||
fun asGetInfoRequest(getInfoRequest: ReadableMap): GetInfoRequest? {
|
||||
if (!validateMandatoryFields(
|
||||
getInfoRequest,
|
||||
arrayOf(
|
||||
"withScan",
|
||||
),
|
||||
)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
val withScan = getInfoRequest.getBoolean("withScan")
|
||||
return GetInfoRequest(
|
||||
withScan,
|
||||
)
|
||||
}
|
||||
|
||||
fun readableMapOf(getInfoRequest: GetInfoRequest): ReadableMap =
|
||||
readableMapOf(
|
||||
"withScan" to getInfoRequest.withScan,
|
||||
)
|
||||
|
||||
fun asGetInfoRequestList(arr: ReadableArray): List<GetInfoRequest> {
|
||||
val list = ArrayList<GetInfoRequest>()
|
||||
for (value in arr.toArrayList()) {
|
||||
when (value) {
|
||||
is ReadableMap -> list.add(asGetInfoRequest(value)!!)
|
||||
else -> throw LiquidSdkException.Generic(errUnexpectedType("${value::class.java.name}"))
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
fun asGetInfoResponse(getInfoResponse: ReadableMap): GetInfoResponse? {
|
||||
if (!validateMandatoryFields(
|
||||
getInfoResponse,
|
||||
|
||||
@@ -160,15 +160,10 @@ class BreezLiquidSDKModule(
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun getInfo(
|
||||
req: ReadableMap,
|
||||
promise: Promise,
|
||||
) {
|
||||
fun getInfo(promise: Promise) {
|
||||
executor.execute {
|
||||
try {
|
||||
val getInfoRequest =
|
||||
asGetInfoRequest(req) ?: run { throw LiquidSdkException.Generic(errMissingMandatoryField("req", "GetInfoRequest")) }
|
||||
val res = getBindingLiquidSdk().getInfo(getInfoRequest)
|
||||
val res = getBindingLiquidSdk().getInfo()
|
||||
promise.resolve(readableMapOf(res))
|
||||
} catch (e: Exception) {
|
||||
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
|
||||
|
||||
2
packages/react-native/example/App.js
vendored
2
packages/react-native/example/App.js
vendored
@@ -58,7 +58,7 @@ const App = () => {
|
||||
listenerId = await addEventListener(eventHandler)
|
||||
addLine("addEventListener", listenerId)
|
||||
|
||||
let walletInfo = await getInfo({ withScan: false })
|
||||
let walletInfo = await getInfo()
|
||||
addLine("getInfo", JSON.stringify(walletInfo))
|
||||
} catch (e) {
|
||||
addLine("error", e.toString())
|
||||
|
||||
@@ -133,38 +133,6 @@ enum BreezLiquidSDKMapper {
|
||||
return connectRequestList.map { v -> [String: Any?] in dictionaryOf(connectRequest: v) }
|
||||
}
|
||||
|
||||
static func asGetInfoRequest(getInfoRequest: [String: Any?]) throws -> GetInfoRequest {
|
||||
guard let withScan = getInfoRequest["withScan"] as? Bool else {
|
||||
throw LiquidSdkError.Generic(message: errMissingMandatoryField(fieldName: "withScan", typeName: "GetInfoRequest"))
|
||||
}
|
||||
|
||||
return GetInfoRequest(
|
||||
withScan: withScan)
|
||||
}
|
||||
|
||||
static func dictionaryOf(getInfoRequest: GetInfoRequest) -> [String: Any?] {
|
||||
return [
|
||||
"withScan": getInfoRequest.withScan,
|
||||
]
|
||||
}
|
||||
|
||||
static func asGetInfoRequestList(arr: [Any]) throws -> [GetInfoRequest] {
|
||||
var list = [GetInfoRequest]()
|
||||
for value in arr {
|
||||
if let val = value as? [String: Any?] {
|
||||
var getInfoRequest = try asGetInfoRequest(getInfoRequest: val)
|
||||
list.append(getInfoRequest)
|
||||
} else {
|
||||
throw LiquidSdkError.Generic(message: errUnexpectedType(typeName: "GetInfoRequest"))
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
static func arrayOf(getInfoRequestList: [GetInfoRequest]) -> [Any] {
|
||||
return getInfoRequestList.map { v -> [String: Any?] in dictionaryOf(getInfoRequest: v) }
|
||||
}
|
||||
|
||||
static func asGetInfoResponse(getInfoResponse: [String: Any?]) throws -> GetInfoResponse {
|
||||
guard let balanceSat = getInfoResponse["balanceSat"] as? UInt64 else {
|
||||
throw LiquidSdkError.Generic(message: errMissingMandatoryField(fieldName: "balanceSat", typeName: "GetInfoResponse"))
|
||||
|
||||
@@ -38,8 +38,7 @@ RCT_EXTERN_METHOD(
|
||||
)
|
||||
|
||||
RCT_EXTERN_METHOD(
|
||||
getInfo: (NSDictionary*)req
|
||||
resolve: (RCTPromiseResolveBlock)resolve
|
||||
getInfo: (RCTPromiseResolveBlock)resolve
|
||||
reject: (RCTPromiseRejectBlock)reject
|
||||
)
|
||||
|
||||
|
||||
@@ -144,11 +144,10 @@ class RNBreezLiquidSDK: RCTEventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
@objc(getInfo:resolve:reject:)
|
||||
func getInfo(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
@objc(getInfo:reject:)
|
||||
func getInfo(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
||||
do {
|
||||
let getInfoRequest = try BreezLiquidSDKMapper.asGetInfoRequest(getInfoRequest: req)
|
||||
var res = try getBindingLiquidSdk().getInfo(req: getInfoRequest)
|
||||
var res = try getBindingLiquidSdk().getInfo()
|
||||
resolve(BreezLiquidSDKMapper.dictionaryOf(getInfoResponse: res))
|
||||
} catch let err {
|
||||
rejectErr(err: err, reject: reject)
|
||||
|
||||
@@ -36,10 +36,6 @@ export interface ConnectRequest {
|
||||
mnemonic: string
|
||||
}
|
||||
|
||||
export interface GetInfoRequest {
|
||||
withScan: boolean
|
||||
}
|
||||
|
||||
export interface GetInfoResponse {
|
||||
balanceSat: number
|
||||
pendingSendSat: number
|
||||
@@ -216,8 +212,8 @@ export const removeEventListener = async (id: string): Promise<void> => {
|
||||
await BreezLiquidSDK.removeEventListener(id)
|
||||
}
|
||||
|
||||
export const getInfo = async (req: GetInfoRequest): Promise<GetInfoResponse> => {
|
||||
const response = await BreezLiquidSDK.getInfo(req)
|
||||
export const getInfo = async (): Promise<GetInfoResponse> => {
|
||||
const response = await BreezLiquidSDK.getInfo()
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user