diff --git a/cli/src/commands.rs b/cli/src/commands.rs index 0d22a58..9760c9b 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -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?; diff --git a/lib/bindings/langs/flutter/breez_liquid_sdk/include/breez_liquid_sdk.h b/lib/bindings/langs/flutter/breez_liquid_sdk/include/breez_liquid_sdk.h index 80e0544..c3a61dd 100644 --- a/lib/bindings/langs/flutter/breez_liquid_sdk/include/breez_liquid_sdk.h +++ b/lib/bindings/langs/flutter/breez_liquid_sdk/include/breez_liquid_sdk.h @@ -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); diff --git a/lib/bindings/src/breez_liquid_sdk.udl b/lib/bindings/src/breez_liquid_sdk.udl index 0b61002..ca5603a 100644 --- a/lib/bindings/src/breez_liquid_sdk.udl +++ b/lib/bindings/src/breez_liquid_sdk.udl @@ -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); diff --git a/lib/bindings/src/lib.rs b/lib/bindings/src/lib.rs index 3e8bfcd..6821ebc 100644 --- a/lib/bindings/src/lib.rs +++ b/lib/bindings/src/lib.rs @@ -79,8 +79,8 @@ impl BindingLiquidSdk { rt().block_on(self.sdk.remove_event_listener(id)) } - pub fn get_info(&self, req: GetInfoRequest) -> Result { - rt().block_on(self.sdk.get_info(req)).map_err(Into::into) + pub fn get_info(&self) -> Result { + rt().block_on(self.sdk.get_info()).map_err(Into::into) } pub fn prepare_send_payment( diff --git a/lib/bindings/tests/bindings/test_breez_liquid_sdk.kts b/lib/bindings/tests/bindings/test_breez_liquid_sdk.kts index 88a8b21..904f148 100644 --- a/lib/bindings/tests/bindings/test_breez_liquid_sdk.kts +++ b/lib/bindings/tests/bindings/test_breez_liquid_sdk.kts @@ -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) diff --git a/lib/bindings/tests/bindings/test_breez_liquid_sdk.py b/lib/bindings/tests/bindings/test_breez_liquid_sdk.py index 9ae2034..3442172 100644 --- a/lib/bindings/tests/bindings/test_breez_liquid_sdk.py +++ b/lib/bindings/tests/bindings/test_breez_liquid_sdk.py @@ -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) diff --git a/lib/bindings/tests/bindings/test_breez_liquid_sdk.swift b/lib/bindings/tests/bindings/test_breez_liquid_sdk.swift index de1df65..cdcca42 100644 --- a/lib/bindings/tests/bindings/test_breez_liquid_sdk.swift +++ b/lib/bindings/tests/bindings/test_breez_liquid_sdk.swift @@ -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); diff --git a/lib/core/src/bindings.rs b/lib/core/src/bindings.rs index 0bcb2c4..956dc64 100644 --- a/lib/core/src/bindings.rs +++ b/lib/core/src/bindings.rs @@ -74,8 +74,8 @@ pub struct BindingLiquidSdk { } impl BindingLiquidSdk { - pub async fn get_info(&self, req: GetInfoRequest) -> Result { - self.sdk.get_info(req).await.map_err(Into::into) + pub async fn get_info(&self) -> Result { + self.sdk.get_info().await.map_err(Into::into) } pub async fn add_event_listener( diff --git a/lib/core/src/frb_generated.io.rs b/lib/core/src/frb_generated.io.rs index ec7519d..2ec5de2 100644 --- a/lib/core/src/frb_generated.io.rs +++ b/lib/core/src/frb_generated.io.rs @@ -118,13 +118,6 @@ impl CstDecode for *mut wire_cst_connect_request { CstDecode::::cst_decode(*wrap).into() } } -impl CstDecode 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::::cst_decode(*wrap).into() - } -} impl CstDecode 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 for wire_cst_connect_request { } } } -impl CstDecode 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 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, diff --git a/lib/core/src/frb_generated.rs b/lib/core/src/frb_generated.rs index e1cd8b2..6f9f032 100644 --- a/lib/core/src/frb_generated.rs +++ b/lib/core/src/frb_generated.rs @@ -208,7 +208,6 @@ fn wire__crate__bindings__BindingLiquidSdk_get_info_impl( that: impl CstDecode< RustOpaqueNom>, >, - req: impl CstDecode, ) { FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( 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 for bool { - // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> bool { - self - } -} impl CstDecode 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 = ::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 } } // 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 - 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) { - ::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; diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index eff1a3d..e37381b 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -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`. diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 374fab5..16a71ac 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -417,15 +417,12 @@ impl LiquidSdk { Ok(()) } - pub async fn get_info(&self, req: GetInfoRequest) -> Result { + pub async fn get_info(&self) -> Result { 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; diff --git a/packages/dart/lib/src/bindings.dart b/packages/dart/lib/src/bindings.dart index cffe3b2..ae626dd 100644 --- a/packages/dart/lib/src/bindings.dart +++ b/packages/dart/lib/src/bindings.dart @@ -33,7 +33,7 @@ abstract class BindingLiquidSdk implements RustOpaqueInterface { void emptyWalletCache(); - Future getInfo({required GetInfoRequest req}); + Future getInfo(); Future> listPayments(); diff --git a/packages/dart/lib/src/frb_generated.dart b/packages/dart/lib/src/frb_generated.dart index 3d1f0d7..c89939f 100644 --- a/packages/dart/lib/src/frb_generated.dart +++ b/packages/dart/lib/src/frb_generated.dart @@ -72,8 +72,7 @@ abstract class RustLibApi extends BaseApi { void crateBindingsBindingLiquidSdkEmptyWalletCache({required BindingLiquidSdk that}); - Future crateBindingsBindingLiquidSdkGetInfo( - {required BindingLiquidSdk that, required GetInfoRequest req}); + Future crateBindingsBindingLiquidSdkGetInfo({required BindingLiquidSdk that}); Future> crateBindingsBindingLiquidSdkListPayments({required BindingLiquidSdk that}); @@ -220,29 +219,27 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ); @override - Future crateBindingsBindingLiquidSdkGetInfo( - {required BindingLiquidSdk that, required GetInfoRequest req}) { + Future 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; - 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 getInfo({required GetInfoRequest req}) => - RustLib.instance.api.crateBindingsBindingLiquidSdkGetInfo(that: this, req: req); + Future getInfo() => RustLib.instance.api.crateBindingsBindingLiquidSdkGetInfo( + that: this, + ); Future> listPayments() => RustLib.instance.api.crateBindingsBindingLiquidSdkListPayments( that: this, diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index d53001d..25fad4e 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -55,9 +55,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @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 { @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 { @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 { @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 { @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 { @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 { @protected BigInt sse_decode_usize(SseDeserializer deserializer); + @protected + bool sse_decode_bool(SseDeserializer deserializer); + @protected ffi.Pointer 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 { return ptr; } - @protected - ffi.Pointer 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 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 { 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 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 wireObj) { @@ -649,11 +620,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { 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 { 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 { @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 { @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 { @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 { @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 req, ) { return _wire__crate__bindings__BindingLiquidSdk_get_info( port_, that, - req, ); } - late final _wire__crate__bindings__BindingLiquidSdk_get_infoPtr = _lookup< - ffi - .NativeFunction)>>( - 'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info'); + late final _wire__crate__bindings__BindingLiquidSdk_get_infoPtr = + _lookup>( + 'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info'); late final _wire__crate__bindings__BindingLiquidSdk_get_info = - _wire__crate__bindings__BindingLiquidSdk_get_infoPtr - .asFunction)>(); + _wire__crate__bindings__BindingLiquidSdk_get_infoPtr.asFunction(); 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 Function()>(); - ffi.Pointer 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 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 Function()>(); - ffi.Pointer 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 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; diff --git a/packages/dart/lib/src/model.dart b/packages/dart/lib/src/model.dart index ce6a4bf..7266f40 100644 --- a/packages/dart/lib/src/model.dart +++ b/packages/dart/lib/src/model.dart @@ -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; diff --git a/packages/dart/test/breez_liquid_dart_test.dart b/packages/dart/test/breez_liquid_dart_test.dart index 42cc61d..ffc00cb 100644 --- a/packages/dart/test/breez_liquid_dart_test.dart +++ b/packages/dart/test/breez_liquid_dart_test.dart @@ -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"); diff --git a/packages/flutter/example/lib/routes/home/home_page.dart b/packages/flutter/example/lib/routes/home/home_page.dart index e3527ac..8fc29d7 100644 --- a/packages/flutter/example/lib/routes/home/home_page.dart +++ b/packages/flutter/example/lib/routes/home/home_page.dart @@ -22,11 +22,10 @@ class HomePage extends StatefulWidget { class _HomePageState extends State { Stream 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"); } } diff --git a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart index a9006b2..cc752ba 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -110,22 +110,19 @@ class FlutterBreezLiquidBindings { void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info( int port_, int that, - ffi.Pointer 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)>>( - 'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info'); + late final _frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_infoPtr = + _lookup>( + '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)>(); + .asFunction(); 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 Function()>(); - ffi.Pointer 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 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 Function()>(); - ffi.Pointer 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 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; diff --git a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt index 1dfb18a..5b9afa9 100644 --- a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt +++ b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt @@ -117,38 +117,6 @@ fun asConnectRequestList(arr: ReadableArray): List { 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 { - val list = ArrayList() - 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, diff --git a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKModule.kt b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKModule.kt index a82d11b..f69d27f 100644 --- a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKModule.kt +++ b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKModule.kt @@ -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) diff --git a/packages/react-native/example/App.js b/packages/react-native/example/App.js index 6a16467..97891f9 100644 --- a/packages/react-native/example/App.js +++ b/packages/react-native/example/App.js @@ -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()) diff --git a/packages/react-native/ios/BreezLiquidSDKMapper.swift b/packages/react-native/ios/BreezLiquidSDKMapper.swift index 5002d62..d594331 100644 --- a/packages/react-native/ios/BreezLiquidSDKMapper.swift +++ b/packages/react-native/ios/BreezLiquidSDKMapper.swift @@ -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")) diff --git a/packages/react-native/ios/RNBreezLiquidSDK.m b/packages/react-native/ios/RNBreezLiquidSDK.m index 2f20e42..4531ab0 100644 --- a/packages/react-native/ios/RNBreezLiquidSDK.m +++ b/packages/react-native/ios/RNBreezLiquidSDK.m @@ -38,8 +38,7 @@ RCT_EXTERN_METHOD( ) RCT_EXTERN_METHOD( - getInfo: (NSDictionary*)req - resolve: (RCTPromiseResolveBlock)resolve + getInfo: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject ) diff --git a/packages/react-native/ios/RNBreezLiquidSDK.swift b/packages/react-native/ios/RNBreezLiquidSDK.swift index 6cb821c..c2a7c23 100644 --- a/packages/react-native/ios/RNBreezLiquidSDK.swift +++ b/packages/react-native/ios/RNBreezLiquidSDK.swift @@ -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) diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts index a343475..e087fb8 100644 --- a/packages/react-native/src/index.ts +++ b/packages/react-native/src/index.ts @@ -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 => { await BreezLiquidSDK.removeEventListener(id) } -export const getInfo = async (req: GetInfoRequest): Promise => { - const response = await BreezLiquidSDK.getInfo(req) +export const getInfo = async (): Promise => { + const response = await BreezLiquidSDK.getInfo() return response }