From e367277f17aec798e5104ba63ebf4c3fa73cfe5f Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Mon, 11 Nov 2024 21:23:37 +0100 Subject: [PATCH] Rename PayOnchainAmount to PayAmount --- cli/src/commands.rs | 8 +- .../include/breez_sdk_liquid.h | 24 ++--- lib/bindings/src/breez_sdk_liquid.udl | 6 +- lib/core/src/frb_generated.rs | 85 ++++++++-------- lib/core/src/model.rs | 6 +- lib/core/src/sdk.rs | 22 ++--- packages/dart/lib/src/frb_generated.dart | 54 +++++------ packages/dart/lib/src/frb_generated.io.dart | 73 +++++++------- packages/dart/lib/src/model.dart | 14 +-- packages/dart/lib/src/model.freezed.dart | 96 +++++++++---------- ...utter_breez_liquid_bindings_generated.dart | 30 +++--- .../breezsdkliquid/BreezSDKLiquidMapper.kt | 39 +++----- .../ios/BreezSDKLiquidMapper.swift | 42 ++++---- packages/react-native/src/index.ts | 12 +-- 14 files changed, 246 insertions(+), 265 deletions(-) diff --git a/cli/src/commands.rs b/cli/src/commands.rs index 8d058e079..766feb5dd 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -332,8 +332,8 @@ pub(crate) async fn handle_command( } }; let amount = match (amount_sat, drain.unwrap_or(false)) { - (Some(amount_sat), _) => Some(PayOnchainAmount::Receiver { amount_sat }), - (_, true) => Some(PayOnchainAmount::Drain), + (Some(amount_sat), _) => Some(PayAmount::Receiver { amount_sat }), + (_, true) => Some(PayAmount::Drain), (_, _) => None, }; @@ -376,8 +376,8 @@ pub(crate) async fn handle_command( fee_rate_sat_per_vbyte, } => { let amount = match drain.unwrap_or(false) { - true => PayOnchainAmount::Drain, - false => PayOnchainAmount::Receiver { + true => PayAmount::Drain, + false => PayAmount::Receiver { amount_sat: receiver_amount_sat.ok_or(anyhow::anyhow!( "Must specify `receiver_amount_sat` if not draining" ))?, diff --git a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h index 2acd0933b..e887ca4fb 100644 --- a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h +++ b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h @@ -279,21 +279,21 @@ typedef struct wire_cst_prepare_ln_url_pay_request { bool *validate_success_action_url; } wire_cst_prepare_ln_url_pay_request; -typedef struct wire_cst_PayOnchainAmount_Receiver { +typedef struct wire_cst_PayAmount_Receiver { uint64_t amount_sat; -} wire_cst_PayOnchainAmount_Receiver; +} wire_cst_PayAmount_Receiver; -typedef union PayOnchainAmountKind { - struct wire_cst_PayOnchainAmount_Receiver Receiver; -} PayOnchainAmountKind; +typedef union PayAmountKind { + struct wire_cst_PayAmount_Receiver Receiver; +} PayAmountKind; -typedef struct wire_cst_pay_onchain_amount { +typedef struct wire_cst_pay_amount { int32_t tag; - union PayOnchainAmountKind kind; -} wire_cst_pay_onchain_amount; + union PayAmountKind kind; +} wire_cst_pay_amount; typedef struct wire_cst_prepare_pay_onchain_request { - struct wire_cst_pay_onchain_amount amount; + struct wire_cst_pay_amount amount; uint32_t *fee_rate_sat_per_vbyte; } wire_cst_prepare_pay_onchain_request; @@ -310,7 +310,7 @@ typedef struct wire_cst_prepare_refund_request { typedef struct wire_cst_prepare_send_request { struct wire_cst_list_prim_u_8_strict *destination; - struct wire_cst_pay_onchain_amount *amount; + struct wire_cst_pay_amount *amount; } wire_cst_prepare_send_request; typedef struct wire_cst_prepare_receive_response { @@ -1166,7 +1166,7 @@ struct wire_cst_ln_url_withdraw_success_data *frbgen_breez_liquid_cst_new_box_au struct wire_cst_message_success_action_data *frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data(void); -struct wire_cst_pay_onchain_amount *frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount(void); +struct wire_cst_pay_amount *frbgen_breez_liquid_cst_new_box_autoadd_pay_amount(void); struct wire_cst_pay_onchain_request *frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request(void); @@ -1255,7 +1255,7 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_request_data); dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_url_withdraw_success_data); dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_data); - dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount); + dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_pay_amount); dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request); 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_buy_bitcoin_request); diff --git a/lib/bindings/src/breez_sdk_liquid.udl b/lib/bindings/src/breez_sdk_liquid.udl index 26190c44b..e994e7d2f 100644 --- a/lib/bindings/src/breez_sdk_liquid.udl +++ b/lib/bindings/src/breez_sdk_liquid.udl @@ -373,7 +373,7 @@ dictionary LnUrlPayRequest { dictionary PrepareSendRequest { string destination; - PayOnchainAmount? amount = null; + PayAmount? amount = null; }; [Enum] @@ -439,13 +439,13 @@ dictionary OnchainPaymentLimitsResponse { }; [Enum] -interface PayOnchainAmount { +interface PayAmount { Receiver(u64 amount_sat); Drain(); }; dictionary PreparePayOnchainRequest { - PayOnchainAmount amount; + PayAmount amount; u32? fee_rate_sat_per_vbyte = null; }; diff --git a/lib/core/src/frb_generated.rs b/lib/core/src/frb_generated.rs index e456ade1d..9e25cab2d 100644 --- a/lib/core/src/frb_generated.rs +++ b/lib/core/src/frb_generated.rs @@ -3180,11 +3180,11 @@ impl SseDecode for Option { } } -impl SseDecode for Option { +impl SseDecode for Option { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { if (::sse_decode(deserializer)) { - return Some(::sse_decode(deserializer)); + return Some(::sse_decode(deserializer)); } else { return None; } @@ -3270,19 +3270,19 @@ impl SseDecode for Option> { } } -impl SseDecode for crate::model::PayOnchainAmount { +impl SseDecode for crate::model::PayAmount { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { let mut tag_ = ::sse_decode(deserializer); match tag_ { 0 => { let mut var_amountSat = ::sse_decode(deserializer); - return crate::model::PayOnchainAmount::Receiver { + return crate::model::PayAmount::Receiver { amount_sat: var_amountSat, }; } 1 => { - return crate::model::PayOnchainAmount::Drain; + return crate::model::PayAmount::Drain; } _ => { unimplemented!(""); @@ -3569,7 +3569,7 @@ impl SseDecode for crate::model::PrepareLnUrlPayResponse { impl SseDecode for crate::model::PreparePayOnchainRequest { // 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_amount = ::sse_decode(deserializer); + let mut var_amount = ::sse_decode(deserializer); let mut var_feeRateSatPerVbyte = >::sse_decode(deserializer); return crate::model::PreparePayOnchainRequest { amount: var_amount, @@ -3650,7 +3650,7 @@ impl SseDecode for crate::model::PrepareSendRequest { // 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_destination = ::sse_decode(deserializer); - let mut var_amount = >::sse_decode(deserializer); + let mut var_amount = >::sse_decode(deserializer); return crate::model::PrepareSendRequest { destination: var_destination, amount: var_amount, @@ -5180,27 +5180,22 @@ impl flutter_rust_bridge::IntoIntoDart flutter_rust_bridge::for_generated::DartAbi { match self { - crate::model::PayOnchainAmount::Receiver { amount_sat } => { + crate::model::PayAmount::Receiver { amount_sat } => { [0.into_dart(), amount_sat.into_into_dart().into_dart()].into_dart() } - crate::model::PayOnchainAmount::Drain => [1.into_dart()].into_dart(), + crate::model::PayAmount::Drain => [1.into_dart()].into_dart(), _ => { unimplemented!(""); } } } } -impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive - for crate::model::PayOnchainAmount -{ -} -impl flutter_rust_bridge::IntoIntoDart - for crate::model::PayOnchainAmount -{ - fn into_into_dart(self) -> crate::model::PayOnchainAmount { +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::model::PayAmount {} +impl flutter_rust_bridge::IntoIntoDart for crate::model::PayAmount { + fn into_into_dart(self) -> crate::model::PayAmount { self } } @@ -6990,12 +6985,12 @@ impl SseEncode for Option { } } -impl SseEncode for Option { +impl SseEncode for Option { // 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.is_some(), serializer); if let Some(value) = self { - ::sse_encode(value, serializer); + ::sse_encode(value, serializer); } } } @@ -7070,15 +7065,15 @@ impl SseEncode for Option> { } } -impl SseEncode for crate::model::PayOnchainAmount { +impl SseEncode for crate::model::PayAmount { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { match self { - crate::model::PayOnchainAmount::Receiver { amount_sat } => { + crate::model::PayAmount::Receiver { amount_sat } => { ::sse_encode(0, serializer); ::sse_encode(amount_sat, serializer); } - crate::model::PayOnchainAmount::Drain => { + crate::model::PayAmount::Drain => { ::sse_encode(1, serializer); } _ => { @@ -7337,7 +7332,7 @@ impl SseEncode for crate::model::PrepareLnUrlPayResponse { impl SseEncode for crate::model::PreparePayOnchainRequest { // 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.amount, serializer); + ::sse_encode(self.amount, serializer); >::sse_encode(self.fee_rate_sat_per_vbyte, serializer); } } @@ -7390,7 +7385,7 @@ impl SseEncode for crate::model::PrepareSendRequest { // 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.destination, serializer); - >::sse_encode(self.amount, serializer); + >::sse_encode(self.amount, serializer); } } @@ -8057,11 +8052,11 @@ mod io { CstDecode::::cst_decode(*wrap).into() } } - impl CstDecode for *mut wire_cst_pay_onchain_amount { + impl CstDecode for *mut wire_cst_pay_amount { // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::model::PayOnchainAmount { + fn cst_decode(self) -> crate::model::PayAmount { let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }; - CstDecode::::cst_decode(*wrap).into() + CstDecode::::cst_decode(*wrap).into() } } impl CstDecode for *mut wire_cst_pay_onchain_request { @@ -8912,17 +8907,17 @@ mod io { } } } - impl CstDecode for wire_cst_pay_onchain_amount { + impl CstDecode for wire_cst_pay_amount { // Codec=Cst (C-struct based), see doc to use other codecs - fn cst_decode(self) -> crate::model::PayOnchainAmount { + fn cst_decode(self) -> crate::model::PayAmount { match self.tag { 0 => { let ans = unsafe { self.kind.Receiver }; - crate::model::PayOnchainAmount::Receiver { + crate::model::PayAmount::Receiver { amount_sat: ans.amount_sat.cst_decode(), } } - 1 => crate::model::PayOnchainAmount::Drain, + 1 => crate::model::PayAmount::Drain, _ => unreachable!(), } } @@ -10064,15 +10059,15 @@ mod io { Self::new_with_null_ptr() } } - impl NewWithNullPtr for wire_cst_pay_onchain_amount { + impl NewWithNullPtr for wire_cst_pay_amount { fn new_with_null_ptr() -> Self { Self { tag: -1, - kind: PayOnchainAmountKind { nil__: () }, + kind: PayAmountKind { nil__: () }, } } } - impl Default for wire_cst_pay_onchain_amount { + impl Default for wire_cst_pay_amount { fn default() -> Self { Self::new_with_null_ptr() } @@ -11137,10 +11132,10 @@ mod io { } #[no_mangle] - pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount( - ) -> *mut wire_cst_pay_onchain_amount { + pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_pay_amount( + ) -> *mut wire_cst_pay_amount { flutter_rust_bridge::for_generated::new_leak_box_ptr( - wire_cst_pay_onchain_amount::new_with_null_ptr(), + wire_cst_pay_amount::new_with_null_ptr(), ) } @@ -12078,19 +12073,19 @@ mod io { } #[repr(C)] #[derive(Clone, Copy)] - pub struct wire_cst_pay_onchain_amount { + pub struct wire_cst_pay_amount { tag: i32, - kind: PayOnchainAmountKind, + kind: PayAmountKind, } #[repr(C)] #[derive(Clone, Copy)] - pub union PayOnchainAmountKind { - Receiver: wire_cst_PayOnchainAmount_Receiver, + pub union PayAmountKind { + Receiver: wire_cst_PayAmount_Receiver, nil__: (), } #[repr(C)] #[derive(Clone, Copy)] - pub struct wire_cst_PayOnchainAmount_Receiver { + pub struct wire_cst_PayAmount_Receiver { amount_sat: u64, } #[repr(C)] @@ -12253,7 +12248,7 @@ mod io { #[repr(C)] #[derive(Clone, Copy)] pub struct wire_cst_prepare_pay_onchain_request { - amount: wire_cst_pay_onchain_amount, + amount: wire_cst_pay_amount, fee_rate_sat_per_vbyte: *mut u32, } #[repr(C)] @@ -12294,7 +12289,7 @@ mod io { #[derive(Clone, Copy)] pub struct wire_cst_prepare_send_request { destination: *mut wire_cst_list_prim_u_8_strict, - amount: *mut wire_cst_pay_onchain_amount, + amount: *mut wire_cst_pay_amount, } #[repr(C)] #[derive(Clone, Copy)] diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index 258950bb6..136dd7508 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -350,7 +350,7 @@ pub struct PrepareSendRequest { /// Should only be set when paying directly onchain or to a BIP21 URI /// where no amount is specified, or when the caller wishes to drain - pub amount: Option, + pub amount: Option, } /// Specifies the supported destinations which can be payed by the SDK @@ -384,7 +384,7 @@ pub struct SendPaymentResponse { } #[derive(Debug, Serialize, Clone)] -pub enum PayOnchainAmount { +pub enum PayAmount { /// The amount in satoshi that will be received Receiver { amount_sat: u64 }, /// Indicates that all available funds should be sent @@ -394,7 +394,7 @@ pub enum PayOnchainAmount { /// An argument when calling [crate::sdk::LiquidSdk::prepare_pay_onchain]. #[derive(Debug, Serialize, Clone)] pub struct PreparePayOnchainRequest { - pub amount: PayOnchainAmount, + pub amount: PayAmount, /// The optional fee rate of the Bitcoin claim transaction in sat/vB. Defaults to the swapper estimated claim fee. pub fee_rate_sat_per_vbyte: Option, } diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 9027c2b54..81d7638d9 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -725,10 +725,10 @@ impl LiquidSdk { /// /// * `req` - the [PrepareSendRequest] containing: /// * `destination` - Either a Liquid BIP21 URI/address or a BOLT11 invoice - /// * `amount` - The optional amount of type [PayOnchainAmount]. Should only be specified + /// * `amount` - The optional amount of type [PayAmount]. Should only be specified /// when paying directly onchain or via amount-less BIP21. - /// - [PayOnchainAmount::Drain] which uses all funds - /// - [PayOnchainAmount::Receiver] which sets the amount the receiver should receive + /// - [PayAmount::Drain] which uses all funds + /// - [PayAmount::Receiver] which sets the amount the receiver should receive /// /// # Returns /// Returns a [PrepareSendResponse] containing: @@ -755,7 +755,7 @@ impl LiquidSdk { err: "Amount must be set when paying to a Liquid address".to_string(), }); } - (Some(bip21_amount_sat), None) => PayOnchainAmount::Receiver { + (Some(bip21_amount_sat), None) => PayAmount::Receiver { amount_sat: bip21_amount_sat, }, (_, Some(amount)) => amount, @@ -773,7 +773,7 @@ impl LiquidSdk { ); (receiver_amount_sat, fees_sat) = match amount { - PayOnchainAmount::Drain => { + PayAmount::Drain => { ensure_sdk!( get_info_res.pending_receive_sat == 0 && get_info_res.pending_send_sat == 0, @@ -788,7 +788,7 @@ impl LiquidSdk { info!("Drain amount: {drain_amount_sat} sat"); (drain_amount_sat, drain_fees_sat) } - PayOnchainAmount::Receiver { amount_sat } => { + PayAmount::Receiver { amount_sat } => { let fees_sat = self .estimate_onchain_tx_or_drain_tx_fee( amount_sat, @@ -812,7 +812,7 @@ impl LiquidSdk { err: "Expected invoice with an amount".to_string(), })? / 1000; - if let Some(PayOnchainAmount::Receiver { amount_sat }) = req.amount { + if let Some(PayAmount::Receiver { amount_sat }) = req.amount { ensure_sdk!( receiver_amount_sat == amount_sat, PaymentError::Generic { @@ -1198,8 +1198,8 @@ impl LiquidSdk { /// # Arguments /// /// * `req` - the [PreparePayOnchainRequest] containing: - /// * `amount` - which can be of two types: [PayOnchainAmount::Drain], which uses all funds, - /// and [PayOnchainAmount::Receiver], which sets the amount the receiver should receive + /// * `amount` - which can be of two types: [PayAmount::Drain], which uses all funds, + /// and [PayAmount::Receiver], which sets the amount the receiver should receive /// * `fee_rate_sat_per_vbyte` - the optional fee rate of the Bitcoin claim transaction. Defaults to the swapper estimated claim fee pub async fn prepare_pay_onchain( &self, @@ -1217,7 +1217,7 @@ impl LiquidSdk { info!("Preparing for onchain payment of kind: {:?}", req.amount); let (payer_amount_sat, receiver_amount_sat, total_fees_sat) = match req.amount { - PayOnchainAmount::Receiver { amount_sat } => { + PayAmount::Receiver { amount_sat } => { let receiver_amount_sat = amount_sat; let user_lockup_amount_sat_without_service_fee = @@ -1241,7 +1241,7 @@ impl LiquidSdk { (payer_amount_sat, receiver_amount_sat, total_fees_sat) } - PayOnchainAmount::Drain => { + PayAmount::Drain => { ensure_sdk!( get_info_res.pending_receive_sat == 0 && get_info_res.pending_send_sat == 0, PaymentError::Generic { diff --git a/packages/dart/lib/src/frb_generated.dart b/packages/dart/lib/src/frb_generated.dart index 1b9f26967..27733df60 100644 --- a/packages/dart/lib/src/frb_generated.dart +++ b/packages/dart/lib/src/frb_generated.dart @@ -1484,9 +1484,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount dco_decode_box_autoadd_pay_onchain_amount(dynamic raw) { + PayAmount dco_decode_box_autoadd_pay_amount(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs - return dco_decode_pay_onchain_amount(raw); + return dco_decode_pay_amount(raw); } @protected @@ -2312,9 +2312,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount? dco_decode_opt_box_autoadd_pay_onchain_amount(dynamic raw) { + PayAmount? dco_decode_opt_box_autoadd_pay_amount(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs - return raw == null ? null : dco_decode_box_autoadd_pay_onchain_amount(raw); + return raw == null ? null : dco_decode_box_autoadd_pay_amount(raw); } @protected @@ -2360,15 +2360,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount dco_decode_pay_onchain_amount(dynamic raw) { + PayAmount dco_decode_pay_amount(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs switch (raw[0]) { case 0: - return PayOnchainAmount_Receiver( + return PayAmount_Receiver( amountSat: dco_decode_u_64(raw[1]), ); case 1: - return PayOnchainAmount_Drain(); + return PayAmount_Drain(); default: throw Exception("unreachable"); } @@ -2577,7 +2577,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { final arr = raw as List; if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return PreparePayOnchainRequest( - amount: dco_decode_pay_onchain_amount(arr[0]), + amount: dco_decode_pay_amount(arr[0]), feeRateSatPerVbyte: dco_decode_opt_box_autoadd_u_32(arr[1]), ); } @@ -2648,7 +2648,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return PrepareSendRequest( destination: dco_decode_String(arr[0]), - amount: dco_decode_opt_box_autoadd_pay_onchain_amount(arr[1]), + amount: dco_decode_opt_box_autoadd_pay_amount(arr[1]), ); } @@ -3277,9 +3277,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount sse_decode_box_autoadd_pay_onchain_amount(SseDeserializer deserializer) { + PayAmount sse_decode_box_autoadd_pay_amount(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - return (sse_decode_pay_onchain_amount(deserializer)); + return (sse_decode_pay_amount(deserializer)); } @protected @@ -4140,11 +4140,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount? sse_decode_opt_box_autoadd_pay_onchain_amount(SseDeserializer deserializer) { + PayAmount? sse_decode_opt_box_autoadd_pay_amount(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs if (sse_decode_bool(deserializer)) { - return (sse_decode_box_autoadd_pay_onchain_amount(deserializer)); + return (sse_decode_box_autoadd_pay_amount(deserializer)); } else { return null; } @@ -4228,16 +4228,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - PayOnchainAmount sse_decode_pay_onchain_amount(SseDeserializer deserializer) { + PayAmount sse_decode_pay_amount(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs var tag_ = sse_decode_i_32(deserializer); switch (tag_) { case 0: var var_amountSat = sse_decode_u_64(deserializer); - return PayOnchainAmount_Receiver(amountSat: var_amountSat); + return PayAmount_Receiver(amountSat: var_amountSat); case 1: - return PayOnchainAmount_Drain(); + return PayAmount_Drain(); default: throw UnimplementedError(''); } @@ -4443,7 +4443,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected PreparePayOnchainRequest sse_decode_prepare_pay_onchain_request(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - var var_amount = sse_decode_pay_onchain_amount(deserializer); + var var_amount = sse_decode_pay_amount(deserializer); var var_feeRateSatPerVbyte = sse_decode_opt_box_autoadd_u_32(deserializer); return PreparePayOnchainRequest(amount: var_amount, feeRateSatPerVbyte: var_feeRateSatPerVbyte); } @@ -4503,7 +4503,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { PrepareSendRequest sse_decode_prepare_send_request(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs var var_destination = sse_decode_String(deserializer); - var var_amount = sse_decode_opt_box_autoadd_pay_onchain_amount(deserializer); + var var_amount = sse_decode_opt_box_autoadd_pay_amount(deserializer); return PrepareSendRequest(destination: var_destination, amount: var_amount); } @@ -5192,9 +5192,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - void sse_encode_box_autoadd_pay_onchain_amount(PayOnchainAmount self, SseSerializer serializer) { + void sse_encode_box_autoadd_pay_amount(PayAmount self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_pay_onchain_amount(self, serializer); + sse_encode_pay_amount(self, serializer); } @protected @@ -5923,12 +5923,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - void sse_encode_opt_box_autoadd_pay_onchain_amount(PayOnchainAmount? self, SseSerializer serializer) { + void sse_encode_opt_box_autoadd_pay_amount(PayAmount? self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_bool(self != null, serializer); if (self != null) { - sse_encode_box_autoadd_pay_onchain_amount(self, serializer); + sse_encode_box_autoadd_pay_amount(self, serializer); } } @@ -6004,13 +6004,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - void sse_encode_pay_onchain_amount(PayOnchainAmount self, SseSerializer serializer) { + void sse_encode_pay_amount(PayAmount self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs switch (self) { - case PayOnchainAmount_Receiver(amountSat: final amountSat): + case PayAmount_Receiver(amountSat: final amountSat): sse_encode_i_32(0, serializer); sse_encode_u_64(amountSat, serializer); - case PayOnchainAmount_Drain(): + case PayAmount_Drain(): sse_encode_i_32(1, serializer); default: throw UnimplementedError(''); @@ -6193,7 +6193,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @protected void sse_encode_prepare_pay_onchain_request(PreparePayOnchainRequest self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - sse_encode_pay_onchain_amount(self.amount, serializer); + sse_encode_pay_amount(self.amount, serializer); sse_encode_opt_box_autoadd_u_32(self.feeRateSatPerVbyte, serializer); } @@ -6240,7 +6240,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { void sse_encode_prepare_send_request(PrepareSendRequest self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_String(self.destination, serializer); - sse_encode_opt_box_autoadd_pay_onchain_amount(self.amount, serializer); + sse_encode_opt_box_autoadd_pay_amount(self.amount, serializer); } @protected diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index 0275c2461..41fc0c08d 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -150,7 +150,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { MessageSuccessActionData dco_decode_box_autoadd_message_success_action_data(dynamic raw); @protected - PayOnchainAmount dco_decode_box_autoadd_pay_onchain_amount(dynamic raw); + PayAmount dco_decode_box_autoadd_pay_amount(dynamic raw); @protected PayOnchainRequest dco_decode_box_autoadd_pay_onchain_request(dynamic raw); @@ -381,7 +381,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { ListPaymentDetails? dco_decode_opt_box_autoadd_list_payment_details(dynamic raw); @protected - PayOnchainAmount? dco_decode_opt_box_autoadd_pay_onchain_amount(dynamic raw); + PayAmount? dco_decode_opt_box_autoadd_pay_amount(dynamic raw); @protected Payment? dco_decode_opt_box_autoadd_payment(dynamic raw); @@ -405,7 +405,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { List? dco_decode_opt_list_payment_type(dynamic raw); @protected - PayOnchainAmount dco_decode_pay_onchain_amount(dynamic raw); + PayAmount dco_decode_pay_amount(dynamic raw); @protected PayOnchainRequest dco_decode_pay_onchain_request(dynamic raw); @@ -673,7 +673,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { MessageSuccessActionData sse_decode_box_autoadd_message_success_action_data(SseDeserializer deserializer); @protected - PayOnchainAmount sse_decode_box_autoadd_pay_onchain_amount(SseDeserializer deserializer); + PayAmount sse_decode_box_autoadd_pay_amount(SseDeserializer deserializer); @protected PayOnchainRequest sse_decode_box_autoadd_pay_onchain_request(SseDeserializer deserializer); @@ -904,7 +904,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { ListPaymentDetails? sse_decode_opt_box_autoadd_list_payment_details(SseDeserializer deserializer); @protected - PayOnchainAmount? sse_decode_opt_box_autoadd_pay_onchain_amount(SseDeserializer deserializer); + PayAmount? sse_decode_opt_box_autoadd_pay_amount(SseDeserializer deserializer); @protected Payment? sse_decode_opt_box_autoadd_payment(SseDeserializer deserializer); @@ -928,7 +928,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { List? sse_decode_opt_list_payment_type(SseDeserializer deserializer); @protected - PayOnchainAmount sse_decode_pay_onchain_amount(SseDeserializer deserializer); + PayAmount sse_decode_pay_amount(SseDeserializer deserializer); @protected PayOnchainRequest sse_decode_pay_onchain_request(SseDeserializer deserializer); @@ -1326,10 +1326,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } @protected - ffi.Pointer cst_encode_box_autoadd_pay_onchain_amount(PayOnchainAmount raw) { + ffi.Pointer cst_encode_box_autoadd_pay_amount(PayAmount raw) { // Codec=Cst (C-struct based), see doc to use other codecs - final ptr = wire.cst_new_box_autoadd_pay_onchain_amount(); - cst_api_fill_to_wire_pay_onchain_amount(raw, ptr.ref); + final ptr = wire.cst_new_box_autoadd_pay_amount(); + cst_api_fill_to_wire_pay_amount(raw, ptr.ref); return ptr; } @@ -1631,10 +1631,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } @protected - ffi.Pointer cst_encode_opt_box_autoadd_pay_onchain_amount( - PayOnchainAmount? raw) { + ffi.Pointer cst_encode_opt_box_autoadd_pay_amount(PayAmount? raw) { // Codec=Cst (C-struct based), see doc to use other codecs - return raw == null ? ffi.nullptr : cst_encode_box_autoadd_pay_onchain_amount(raw); + return raw == null ? ffi.nullptr : cst_encode_box_autoadd_pay_amount(raw); } @protected @@ -1890,9 +1889,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } @protected - void cst_api_fill_to_wire_box_autoadd_pay_onchain_amount( - PayOnchainAmount apiObj, ffi.Pointer wireObj) { - cst_api_fill_to_wire_pay_onchain_amount(apiObj, wireObj.ref); + void cst_api_fill_to_wire_box_autoadd_pay_amount( + PayAmount apiObj, ffi.Pointer wireObj) { + cst_api_fill_to_wire_pay_amount(apiObj, wireObj.ref); } @protected @@ -2505,14 +2504,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } @protected - void cst_api_fill_to_wire_pay_onchain_amount(PayOnchainAmount apiObj, wire_cst_pay_onchain_amount wireObj) { - if (apiObj is PayOnchainAmount_Receiver) { + void cst_api_fill_to_wire_pay_amount(PayAmount apiObj, wire_cst_pay_amount wireObj) { + if (apiObj is PayAmount_Receiver) { var pre_amount_sat = cst_encode_u_64(apiObj.amountSat); wireObj.tag = 0; wireObj.kind.Receiver.amount_sat = pre_amount_sat; return; } - if (apiObj is PayOnchainAmount_Drain) { + if (apiObj is PayAmount_Drain) { wireObj.tag = 1; return; } @@ -2724,7 +2723,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void cst_api_fill_to_wire_prepare_pay_onchain_request( PreparePayOnchainRequest apiObj, wire_cst_prepare_pay_onchain_request wireObj) { - cst_api_fill_to_wire_pay_onchain_amount(apiObj.amount, wireObj.amount); + cst_api_fill_to_wire_pay_amount(apiObj.amount, wireObj.amount); wireObj.fee_rate_sat_per_vbyte = cst_encode_opt_box_autoadd_u_32(apiObj.feeRateSatPerVbyte); } @@ -2771,7 +2770,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void cst_api_fill_to_wire_prepare_send_request( PrepareSendRequest apiObj, wire_cst_prepare_send_request wireObj) { wireObj.destination = cst_encode_String(apiObj.destination); - wireObj.amount = cst_encode_opt_box_autoadd_pay_onchain_amount(apiObj.amount); + wireObj.amount = cst_encode_opt_box_autoadd_pay_amount(apiObj.amount); } @protected @@ -3200,7 +3199,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { MessageSuccessActionData self, SseSerializer serializer); @protected - void sse_encode_box_autoadd_pay_onchain_amount(PayOnchainAmount self, SseSerializer serializer); + void sse_encode_box_autoadd_pay_amount(PayAmount self, SseSerializer serializer); @protected void sse_encode_box_autoadd_pay_onchain_request(PayOnchainRequest self, SseSerializer serializer); @@ -3436,7 +3435,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_opt_box_autoadd_list_payment_details(ListPaymentDetails? self, SseSerializer serializer); @protected - void sse_encode_opt_box_autoadd_pay_onchain_amount(PayOnchainAmount? self, SseSerializer serializer); + void sse_encode_opt_box_autoadd_pay_amount(PayAmount? self, SseSerializer serializer); @protected void sse_encode_opt_box_autoadd_payment(Payment? self, SseSerializer serializer); @@ -3461,7 +3460,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_opt_list_payment_type(List? self, SseSerializer serializer); @protected - void sse_encode_pay_onchain_amount(PayOnchainAmount self, SseSerializer serializer); + void sse_encode_pay_amount(PayAmount self, SseSerializer serializer); @protected void sse_encode_pay_onchain_request(PayOnchainRequest self, SseSerializer serializer); @@ -4668,15 +4667,15 @@ class RustLibWire implements BaseWire { _cst_new_box_autoadd_message_success_action_dataPtr .asFunction Function()>(); - ffi.Pointer cst_new_box_autoadd_pay_onchain_amount() { - return _cst_new_box_autoadd_pay_onchain_amount(); + ffi.Pointer cst_new_box_autoadd_pay_amount() { + return _cst_new_box_autoadd_pay_amount(); } - late final _cst_new_box_autoadd_pay_onchain_amountPtr = - _lookup Function()>>( - 'frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount'); - late final _cst_new_box_autoadd_pay_onchain_amount = _cst_new_box_autoadd_pay_onchain_amountPtr - .asFunction Function()>(); + late final _cst_new_box_autoadd_pay_amountPtr = + _lookup Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_pay_amount'); + late final _cst_new_box_autoadd_pay_amount = + _cst_new_box_autoadd_pay_amountPtr.asFunction Function()>(); ffi.Pointer cst_new_box_autoadd_pay_onchain_request() { return _cst_new_box_autoadd_pay_onchain_request(); @@ -5396,24 +5395,24 @@ final class wire_cst_prepare_ln_url_pay_request extends ffi.Struct { external ffi.Pointer validate_success_action_url; } -final class wire_cst_PayOnchainAmount_Receiver extends ffi.Struct { +final class wire_cst_PayAmount_Receiver extends ffi.Struct { @ffi.Uint64() external int amount_sat; } -final class PayOnchainAmountKind extends ffi.Union { - external wire_cst_PayOnchainAmount_Receiver Receiver; +final class PayAmountKind extends ffi.Union { + external wire_cst_PayAmount_Receiver Receiver; } -final class wire_cst_pay_onchain_amount extends ffi.Struct { +final class wire_cst_pay_amount extends ffi.Struct { @ffi.Int32() external int tag; - external PayOnchainAmountKind kind; + external PayAmountKind kind; } final class wire_cst_prepare_pay_onchain_request extends ffi.Struct { - external wire_cst_pay_onchain_amount amount; + external wire_cst_pay_amount amount; external ffi.Pointer fee_rate_sat_per_vbyte; } @@ -5437,7 +5436,7 @@ final class wire_cst_prepare_refund_request extends ffi.Struct { final class wire_cst_prepare_send_request extends ffi.Struct { external ffi.Pointer destination; - external ffi.Pointer amount; + external ffi.Pointer amount; } final class wire_cst_prepare_receive_response extends ffi.Struct { diff --git a/packages/dart/lib/src/model.dart b/packages/dart/lib/src/model.dart index 9b171aba2..04ad60e84 100644 --- a/packages/dart/lib/src/model.dart +++ b/packages/dart/lib/src/model.dart @@ -476,16 +476,16 @@ class OnchainPaymentLimitsResponse { } @freezed -sealed class PayOnchainAmount with _$PayOnchainAmount { - const PayOnchainAmount._(); +sealed class PayAmount with _$PayAmount { + const PayAmount._(); /// The amount in satoshi that will be received - const factory PayOnchainAmount.receiver({ + const factory PayAmount.receiver({ required BigInt amountSat, - }) = PayOnchainAmount_Receiver; + }) = PayAmount_Receiver; /// Indicates that all available funds should be sent - const factory PayOnchainAmount.drain() = PayOnchainAmount_Drain; + const factory PayAmount.drain() = PayAmount_Drain; } /// An argument when calling [crate::sdk::LiquidSdk::pay_onchain]. @@ -849,7 +849,7 @@ class PrepareLnUrlPayResponse { /// An argument when calling [crate::sdk::LiquidSdk::prepare_pay_onchain]. class PreparePayOnchainRequest { - final PayOnchainAmount amount; + final PayAmount amount; /// The optional fee rate of the Bitcoin claim transaction in sat/vB. Defaults to the swapper estimated claim fee. final int? feeRateSatPerVbyte; @@ -1006,7 +1006,7 @@ class PrepareSendRequest { /// Should only be set when paying directly onchain or to a BIP21 URI /// where no amount is specified, or when the caller wishes to drain - final PayOnchainAmount? amount; + final PayAmount? amount; const PrepareSendRequest({ required this.destination, diff --git a/packages/dart/lib/src/model.freezed.dart b/packages/dart/lib/src/model.freezed.dart index 067875218..37d19aaf8 100644 --- a/packages/dart/lib/src/model.freezed.dart +++ b/packages/dart/lib/src/model.freezed.dart @@ -594,53 +594,52 @@ abstract class LnUrlPayResult_PayError extends LnUrlPayResult { } /// @nodoc -mixin _$PayOnchainAmount {} +mixin _$PayAmount {} /// @nodoc -abstract class $PayOnchainAmountCopyWith<$Res> { - factory $PayOnchainAmountCopyWith(PayOnchainAmount value, $Res Function(PayOnchainAmount) then) = - _$PayOnchainAmountCopyWithImpl<$Res, PayOnchainAmount>; +abstract class $PayAmountCopyWith<$Res> { + factory $PayAmountCopyWith(PayAmount value, $Res Function(PayAmount) then) = + _$PayAmountCopyWithImpl<$Res, PayAmount>; } /// @nodoc -class _$PayOnchainAmountCopyWithImpl<$Res, $Val extends PayOnchainAmount> - implements $PayOnchainAmountCopyWith<$Res> { - _$PayOnchainAmountCopyWithImpl(this._value, this._then); +class _$PayAmountCopyWithImpl<$Res, $Val extends PayAmount> implements $PayAmountCopyWith<$Res> { + _$PayAmountCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; // ignore: unused_field final $Res Function($Val) _then; - /// Create a copy of PayOnchainAmount + /// Create a copy of PayAmount /// with the given fields replaced by the non-null parameter values. } /// @nodoc -abstract class _$$PayOnchainAmount_ReceiverImplCopyWith<$Res> { - factory _$$PayOnchainAmount_ReceiverImplCopyWith( - _$PayOnchainAmount_ReceiverImpl value, $Res Function(_$PayOnchainAmount_ReceiverImpl) then) = - __$$PayOnchainAmount_ReceiverImplCopyWithImpl<$Res>; +abstract class _$$PayAmount_ReceiverImplCopyWith<$Res> { + factory _$$PayAmount_ReceiverImplCopyWith( + _$PayAmount_ReceiverImpl value, $Res Function(_$PayAmount_ReceiverImpl) then) = + __$$PayAmount_ReceiverImplCopyWithImpl<$Res>; @useResult $Res call({BigInt amountSat}); } /// @nodoc -class __$$PayOnchainAmount_ReceiverImplCopyWithImpl<$Res> - extends _$PayOnchainAmountCopyWithImpl<$Res, _$PayOnchainAmount_ReceiverImpl> - implements _$$PayOnchainAmount_ReceiverImplCopyWith<$Res> { - __$$PayOnchainAmount_ReceiverImplCopyWithImpl( - _$PayOnchainAmount_ReceiverImpl _value, $Res Function(_$PayOnchainAmount_ReceiverImpl) _then) +class __$$PayAmount_ReceiverImplCopyWithImpl<$Res> + extends _$PayAmountCopyWithImpl<$Res, _$PayAmount_ReceiverImpl> + implements _$$PayAmount_ReceiverImplCopyWith<$Res> { + __$$PayAmount_ReceiverImplCopyWithImpl( + _$PayAmount_ReceiverImpl _value, $Res Function(_$PayAmount_ReceiverImpl) _then) : super(_value, _then); - /// Create a copy of PayOnchainAmount + /// Create a copy of PayAmount /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ Object? amountSat = null, }) { - return _then(_$PayOnchainAmount_ReceiverImpl( + return _then(_$PayAmount_ReceiverImpl( amountSat: null == amountSat ? _value.amountSat : amountSat // ignore: cast_nullable_to_non_nullable @@ -651,93 +650,90 @@ class __$$PayOnchainAmount_ReceiverImplCopyWithImpl<$Res> /// @nodoc -class _$PayOnchainAmount_ReceiverImpl extends PayOnchainAmount_Receiver { - const _$PayOnchainAmount_ReceiverImpl({required this.amountSat}) : super._(); +class _$PayAmount_ReceiverImpl extends PayAmount_Receiver { + const _$PayAmount_ReceiverImpl({required this.amountSat}) : super._(); @override final BigInt amountSat; @override String toString() { - return 'PayOnchainAmount.receiver(amountSat: $amountSat)'; + return 'PayAmount.receiver(amountSat: $amountSat)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$PayOnchainAmount_ReceiverImpl && + other is _$PayAmount_ReceiverImpl && (identical(other.amountSat, amountSat) || other.amountSat == amountSat)); } @override int get hashCode => Object.hash(runtimeType, amountSat); - /// Create a copy of PayOnchainAmount + /// Create a copy of PayAmount /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') - _$$PayOnchainAmount_ReceiverImplCopyWith<_$PayOnchainAmount_ReceiverImpl> get copyWith => - __$$PayOnchainAmount_ReceiverImplCopyWithImpl<_$PayOnchainAmount_ReceiverImpl>(this, _$identity); + _$$PayAmount_ReceiverImplCopyWith<_$PayAmount_ReceiverImpl> get copyWith => + __$$PayAmount_ReceiverImplCopyWithImpl<_$PayAmount_ReceiverImpl>(this, _$identity); } -abstract class PayOnchainAmount_Receiver extends PayOnchainAmount { - const factory PayOnchainAmount_Receiver({required final BigInt amountSat}) = - _$PayOnchainAmount_ReceiverImpl; - const PayOnchainAmount_Receiver._() : super._(); +abstract class PayAmount_Receiver extends PayAmount { + const factory PayAmount_Receiver({required final BigInt amountSat}) = _$PayAmount_ReceiverImpl; + const PayAmount_Receiver._() : super._(); BigInt get amountSat; - /// Create a copy of PayOnchainAmount + /// Create a copy of PayAmount /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) - _$$PayOnchainAmount_ReceiverImplCopyWith<_$PayOnchainAmount_ReceiverImpl> get copyWith => + _$$PayAmount_ReceiverImplCopyWith<_$PayAmount_ReceiverImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$PayOnchainAmount_DrainImplCopyWith<$Res> { - factory _$$PayOnchainAmount_DrainImplCopyWith( - _$PayOnchainAmount_DrainImpl value, $Res Function(_$PayOnchainAmount_DrainImpl) then) = - __$$PayOnchainAmount_DrainImplCopyWithImpl<$Res>; +abstract class _$$PayAmount_DrainImplCopyWith<$Res> { + factory _$$PayAmount_DrainImplCopyWith( + _$PayAmount_DrainImpl value, $Res Function(_$PayAmount_DrainImpl) then) = + __$$PayAmount_DrainImplCopyWithImpl<$Res>; } /// @nodoc -class __$$PayOnchainAmount_DrainImplCopyWithImpl<$Res> - extends _$PayOnchainAmountCopyWithImpl<$Res, _$PayOnchainAmount_DrainImpl> - implements _$$PayOnchainAmount_DrainImplCopyWith<$Res> { - __$$PayOnchainAmount_DrainImplCopyWithImpl( - _$PayOnchainAmount_DrainImpl _value, $Res Function(_$PayOnchainAmount_DrainImpl) _then) +class __$$PayAmount_DrainImplCopyWithImpl<$Res> extends _$PayAmountCopyWithImpl<$Res, _$PayAmount_DrainImpl> + implements _$$PayAmount_DrainImplCopyWith<$Res> { + __$$PayAmount_DrainImplCopyWithImpl( + _$PayAmount_DrainImpl _value, $Res Function(_$PayAmount_DrainImpl) _then) : super(_value, _then); - /// Create a copy of PayOnchainAmount + /// Create a copy of PayAmount /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$PayOnchainAmount_DrainImpl extends PayOnchainAmount_Drain { - const _$PayOnchainAmount_DrainImpl() : super._(); +class _$PayAmount_DrainImpl extends PayAmount_Drain { + const _$PayAmount_DrainImpl() : super._(); @override String toString() { - return 'PayOnchainAmount.drain()'; + return 'PayAmount.drain()'; } @override bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$PayOnchainAmount_DrainImpl); + return identical(this, other) || (other.runtimeType == runtimeType && other is _$PayAmount_DrainImpl); } @override int get hashCode => runtimeType.hashCode; } -abstract class PayOnchainAmount_Drain extends PayOnchainAmount { - const factory PayOnchainAmount_Drain() = _$PayOnchainAmount_DrainImpl; - const PayOnchainAmount_Drain._() : super._(); +abstract class PayAmount_Drain extends PayAmount { + const factory PayAmount_Drain() = _$PayAmount_DrainImpl; + const PayAmount_Drain._() : super._(); } /// @nodoc diff --git a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart index 2a6411ee9..e623c13ac 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -1116,16 +1116,16 @@ class FlutterBreezLiquidBindings { _frbgen_breez_liquid_cst_new_box_autoadd_message_success_action_dataPtr .asFunction Function()>(); - ffi.Pointer frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount() { - return _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount(); + ffi.Pointer frbgen_breez_liquid_cst_new_box_autoadd_pay_amount() { + return _frbgen_breez_liquid_cst_new_box_autoadd_pay_amount(); } - late final _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amountPtr = - _lookup Function()>>( - 'frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount'); - late final _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amount = - _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_amountPtr - .asFunction Function()>(); + late final _frbgen_breez_liquid_cst_new_box_autoadd_pay_amountPtr = + _lookup Function()>>( + 'frbgen_breez_liquid_cst_new_box_autoadd_pay_amount'); + late final _frbgen_breez_liquid_cst_new_box_autoadd_pay_amount = + _frbgen_breez_liquid_cst_new_box_autoadd_pay_amountPtr + .asFunction Function()>(); ffi.Pointer frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request() { return _frbgen_breez_liquid_cst_new_box_autoadd_pay_onchain_request(); @@ -4154,24 +4154,24 @@ final class wire_cst_prepare_ln_url_pay_request extends ffi.Struct { external ffi.Pointer validate_success_action_url; } -final class wire_cst_PayOnchainAmount_Receiver extends ffi.Struct { +final class wire_cst_PayAmount_Receiver extends ffi.Struct { @ffi.Uint64() external int amount_sat; } -final class PayOnchainAmountKind extends ffi.Union { - external wire_cst_PayOnchainAmount_Receiver Receiver; +final class PayAmountKind extends ffi.Union { + external wire_cst_PayAmount_Receiver Receiver; } -final class wire_cst_pay_onchain_amount extends ffi.Struct { +final class wire_cst_pay_amount extends ffi.Struct { @ffi.Int32() external int tag; - external PayOnchainAmountKind kind; + external PayAmountKind kind; } final class wire_cst_prepare_pay_onchain_request extends ffi.Struct { - external wire_cst_pay_onchain_amount amount; + external wire_cst_pay_amount amount; external ffi.Pointer fee_rate_sat_per_vbyte; } @@ -4195,7 +4195,7 @@ final class wire_cst_prepare_refund_request extends ffi.Struct { final class wire_cst_prepare_send_request extends ffi.Struct { external ffi.Pointer destination; - external ffi.Pointer amount; + external ffi.Pointer amount; } final class wire_cst_prepare_receive_response extends ffi.Struct { diff --git a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt index 2dabc9bea..9759daed3 100644 --- a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt +++ b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt @@ -1487,7 +1487,7 @@ fun asPreparePayOnchainRequest(preparePayOnchainRequest: ReadableMap): PreparePa ) { return null } - val amount = preparePayOnchainRequest.getMap("amount")?.let { asPayOnchainAmount(it) }!! + val amount = preparePayOnchainRequest.getMap("amount")?.let { asPayAmount(it) }!! val feeRateSatPerVbyte = if (hasNonNullKey( preparePayOnchainRequest, @@ -1721,16 +1721,7 @@ fun asPrepareSendRequest(prepareSendRequest: ReadableMap): PrepareSendRequest? { return null } val destination = prepareSendRequest.getString("destination")!! - val amount = - if (hasNonNullKey( - prepareSendRequest, - "amount", - ) - ) { - prepareSendRequest.getMap("amount")?.let { asPayOnchainAmount(it) } - } else { - null - } + val amount = if (hasNonNullKey(prepareSendRequest, "amount")) prepareSendRequest.getMap("amount")?.let { asPayAmount(it) } else null return PrepareSendRequest(destination, amount) } @@ -2717,38 +2708,38 @@ fun asNetworkList(arr: ReadableArray): List { return list } -fun asPayOnchainAmount(payOnchainAmount: ReadableMap): PayOnchainAmount? { - val type = payOnchainAmount.getString("type") +fun asPayAmount(payAmount: ReadableMap): PayAmount? { + val type = payAmount.getString("type") if (type == "receiver") { - val amountSat = payOnchainAmount.getDouble("amountSat").toULong() - return PayOnchainAmount.Receiver(amountSat) + val amountSat = payAmount.getDouble("amountSat").toULong() + return PayAmount.Receiver(amountSat) } if (type == "drain") { - return PayOnchainAmount.Drain + return PayAmount.Drain } return null } -fun readableMapOf(payOnchainAmount: PayOnchainAmount): ReadableMap? { +fun readableMapOf(payAmount: PayAmount): ReadableMap? { val map = Arguments.createMap() - when (payOnchainAmount) { - is PayOnchainAmount.Receiver -> { + when (payAmount) { + is PayAmount.Receiver -> { pushToMap(map, "type", "receiver") - pushToMap(map, "amountSat", payOnchainAmount.amountSat) + pushToMap(map, "amountSat", payAmount.amountSat) } - is PayOnchainAmount.Drain -> { + is PayAmount.Drain -> { pushToMap(map, "type", "drain") } } return map } -fun asPayOnchainAmountList(arr: ReadableArray): List { - val list = ArrayList() +fun asPayAmountList(arr: ReadableArray): List { + val list = ArrayList() for (value in arr.toList()) { when (value) { - is ReadableMap -> list.add(asPayOnchainAmount(value)!!) + is ReadableMap -> list.add(asPayAmount(value)!!) else -> throw SdkException.Generic(errUnexpectedType(value)) } } diff --git a/packages/react-native/ios/BreezSDKLiquidMapper.swift b/packages/react-native/ios/BreezSDKLiquidMapper.swift index cc0637b8a..baaad5850 100644 --- a/packages/react-native/ios/BreezSDKLiquidMapper.swift +++ b/packages/react-native/ios/BreezSDKLiquidMapper.swift @@ -1728,7 +1728,7 @@ enum BreezSDKLiquidMapper { guard let amountTmp = preparePayOnchainRequest["amount"] as? [String: Any?] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amount", typeName: "PreparePayOnchainRequest")) } - let amount = try asPayOnchainAmount(payOnchainAmount: amountTmp) + let amount = try asPayAmount(payAmount: amountTmp) var feeRateSatPerVbyte: UInt32? if hasNonNilKey(data: preparePayOnchainRequest, key: "feeRateSatPerVbyte") { @@ -1743,7 +1743,7 @@ enum BreezSDKLiquidMapper { static func dictionaryOf(preparePayOnchainRequest: PreparePayOnchainRequest) -> [String: Any?] { return [ - "amount": dictionaryOf(payOnchainAmount: preparePayOnchainRequest.amount), + "amount": dictionaryOf(payAmount: preparePayOnchainRequest.amount), "feeRateSatPerVbyte": preparePayOnchainRequest.feeRateSatPerVbyte == nil ? nil : preparePayOnchainRequest.feeRateSatPerVbyte, ] } @@ -1976,9 +1976,9 @@ enum BreezSDKLiquidMapper { guard let destination = prepareSendRequest["destination"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "destination", typeName: "PrepareSendRequest")) } - var amount: PayOnchainAmount? + var amount: PayAmount? if let amountTmp = prepareSendRequest["amount"] as? [String: Any?] { - amount = try asPayOnchainAmount(payOnchainAmount: amountTmp) + amount = try asPayAmount(payAmount: amountTmp) } return PrepareSendRequest(destination: destination, amount: amount) @@ -1987,7 +1987,7 @@ enum BreezSDKLiquidMapper { static func dictionaryOf(prepareSendRequest: PrepareSendRequest) -> [String: Any?] { return [ "destination": prepareSendRequest.destination, - "amount": prepareSendRequest.amount == nil ? nil : dictionaryOf(payOnchainAmount: prepareSendRequest.amount!), + "amount": prepareSendRequest.amount == nil ? nil : dictionaryOf(payAmount: prepareSendRequest.amount!), ] } @@ -3314,23 +3314,23 @@ enum BreezSDKLiquidMapper { return list } - static func asPayOnchainAmount(payOnchainAmount: [String: Any?]) throws -> PayOnchainAmount { - let type = payOnchainAmount["type"] as! String + static func asPayAmount(payAmount: [String: Any?]) throws -> PayAmount { + let type = payAmount["type"] as! String if type == "receiver" { - guard let _amountSat = payOnchainAmount["amountSat"] as? UInt64 else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountSat", typeName: "PayOnchainAmount")) + guard let _amountSat = payAmount["amountSat"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountSat", typeName: "PayAmount")) } - return PayOnchainAmount.receiver(amountSat: _amountSat) + return PayAmount.receiver(amountSat: _amountSat) } if type == "drain" { - return PayOnchainAmount.drain + return PayAmount.drain } - throw SdkError.Generic(message: "Unexpected type \(type) for enum PayOnchainAmount") + throw SdkError.Generic(message: "Unexpected type \(type) for enum PayAmount") } - static func dictionaryOf(payOnchainAmount: PayOnchainAmount) -> [String: Any?] { - switch payOnchainAmount { + static func dictionaryOf(payAmount: PayAmount) -> [String: Any?] { + switch payAmount { case let .receiver( amountSat ): @@ -3346,18 +3346,18 @@ enum BreezSDKLiquidMapper { } } - static func arrayOf(payOnchainAmountList: [PayOnchainAmount]) -> [Any] { - return payOnchainAmountList.map { v -> [String: Any?] in return dictionaryOf(payOnchainAmount: v) } + static func arrayOf(payAmountList: [PayAmount]) -> [Any] { + return payAmountList.map { v -> [String: Any?] in return dictionaryOf(payAmount: v) } } - static func asPayOnchainAmountList(arr: [Any]) throws -> [PayOnchainAmount] { - var list = [PayOnchainAmount]() + static func asPayAmountList(arr: [Any]) throws -> [PayAmount] { + var list = [PayAmount]() for value in arr { if let val = value as? [String: Any?] { - var payOnchainAmount = try asPayOnchainAmount(payOnchainAmount: val) - list.append(payOnchainAmount) + var payAmount = try asPayAmount(payAmount: val) + list.append(payAmount) } else { - throw SdkError.Generic(message: errUnexpectedType(typeName: "PayOnchainAmount")) + throw SdkError.Generic(message: errUnexpectedType(typeName: "PayAmount")) } } return list diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts index c4f46bc60..5ec413950 100644 --- a/packages/react-native/src/index.ts +++ b/packages/react-native/src/index.ts @@ -266,7 +266,7 @@ export interface PrepareLnUrlPayResponse { } export interface PreparePayOnchainRequest { - amount: PayOnchainAmount + amount: PayAmount feeRateSatPerVbyte?: number } @@ -301,7 +301,7 @@ export interface PrepareRefundResponse { export interface PrepareSendRequest { destination: string - amount?: PayOnchainAmount + amount?: PayAmount } export interface PrepareSendResponse { @@ -533,16 +533,16 @@ export enum Network { REGTEST = "regtest" } -export enum PayOnchainAmountVariant { +export enum PayAmountVariant { RECEIVER = "receiver", DRAIN = "drain" } -export type PayOnchainAmount = { - type: PayOnchainAmountVariant.RECEIVER, +export type PayAmount = { + type: PayAmountVariant.RECEIVER, amountSat: number } | { - type: PayOnchainAmountVariant.DRAIN + type: PayAmountVariant.DRAIN } export enum PaymentDetailsVariant {