Add FiatAPI methods to Liquid SDK (#331)

* Add FiatAPI methods to Liquid SDK

* Add mirrored structs of fiat crate on Dart bindings

* Re-generate bindings

* Fix sdk-common imports

* Avoid using hardcoded Breez Server URL, re-use sdk-common constant

* Update Cargo.lock

---------

Co-authored-by: Erdem Yerebasmaz <erdem@yerebasmaz.com>
This commit is contained in:
ok300
2024-06-26 13:55:44 +00:00
committed by GitHub
parent 079be185c6
commit ef5cd28fa5
20 changed files with 3701 additions and 390 deletions

500
lib/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -329,11 +329,69 @@ typedef struct wire_cst_ln_url_withdraw_success_data {
struct wire_cst_ln_invoice invoice;
} wire_cst_ln_url_withdraw_success_data;
typedef struct wire_cst_symbol {
struct wire_cst_list_prim_u_8_strict *grapheme;
struct wire_cst_list_prim_u_8_strict *template_;
bool *rtl;
uint32_t *position;
} wire_cst_symbol;
typedef struct wire_cst_localized_name {
struct wire_cst_list_prim_u_8_strict *locale;
struct wire_cst_list_prim_u_8_strict *name;
} wire_cst_localized_name;
typedef struct wire_cst_list_localized_name {
struct wire_cst_localized_name *ptr;
int32_t len;
} wire_cst_list_localized_name;
typedef struct wire_cst_locale_overrides {
struct wire_cst_list_prim_u_8_strict *locale;
uint32_t *spacing;
struct wire_cst_symbol symbol;
} wire_cst_locale_overrides;
typedef struct wire_cst_list_locale_overrides {
struct wire_cst_locale_overrides *ptr;
int32_t len;
} wire_cst_list_locale_overrides;
typedef struct wire_cst_currency_info {
struct wire_cst_list_prim_u_8_strict *name;
uint32_t fraction_size;
uint32_t *spacing;
struct wire_cst_symbol *symbol;
struct wire_cst_symbol *uniq_symbol;
struct wire_cst_list_localized_name *localized_name;
struct wire_cst_list_locale_overrides *locale_overrides;
} wire_cst_currency_info;
typedef struct wire_cst_fiat_currency {
struct wire_cst_list_prim_u_8_strict *id;
struct wire_cst_currency_info info;
} wire_cst_fiat_currency;
typedef struct wire_cst_list_fiat_currency {
struct wire_cst_fiat_currency *ptr;
int32_t len;
} wire_cst_list_fiat_currency;
typedef struct wire_cst_list_payment {
struct wire_cst_payment *ptr;
int32_t len;
} wire_cst_list_payment;
typedef struct wire_cst_rate {
struct wire_cst_list_prim_u_8_strict *coin;
double value;
} wire_cst_rate;
typedef struct wire_cst_list_rate {
struct wire_cst_rate *ptr;
int32_t len;
} wire_cst_list_rate;
typedef struct wire_cst_refundable_swap {
struct wire_cst_list_prim_u_8_strict *swap_address;
uint32_t timestamp;
@@ -680,9 +738,15 @@ 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_fetch_fiat_rates(int64_t port_,
uintptr_t that);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(int64_t port_,
uintptr_t that);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_fiat_currencies(int64_t port_,
uintptr_t that);
void frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments(int64_t port_,
uintptr_t that);
@@ -778,6 +842,8 @@ struct wire_cst_binding_event_listener *frbgen_breez_liquid_cst_new_box_autoadd_
struct wire_cst_bitcoin_address_data *frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data(void);
bool *frbgen_breez_liquid_cst_new_box_autoadd_bool(bool value);
struct wire_cst_connect_request *frbgen_breez_liquid_cst_new_box_autoadd_connect_request(void);
struct wire_cst_liquid_sdk_event *frbgen_breez_liquid_cst_new_box_autoadd_liquid_sdk_event(void);
@@ -830,14 +896,26 @@ struct wire_cst_restore_request *frbgen_breez_liquid_cst_new_box_autoadd_restore
struct wire_cst_success_action_processed *frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed(void);
struct wire_cst_symbol *frbgen_breez_liquid_cst_new_box_autoadd_symbol(void);
uint32_t *frbgen_breez_liquid_cst_new_box_autoadd_u_32(uint32_t value);
uint64_t *frbgen_breez_liquid_cst_new_box_autoadd_u_64(uint64_t value);
struct wire_cst_url_success_action_data *frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data(void);
struct wire_cst_list_fiat_currency *frbgen_breez_liquid_cst_new_list_fiat_currency(int32_t len);
struct wire_cst_list_locale_overrides *frbgen_breez_liquid_cst_new_list_locale_overrides(int32_t len);
struct wire_cst_list_localized_name *frbgen_breez_liquid_cst_new_list_localized_name(int32_t len);
struct wire_cst_list_payment *frbgen_breez_liquid_cst_new_list_payment(int32_t len);
struct wire_cst_list_prim_u_8_strict *frbgen_breez_liquid_cst_new_list_prim_u_8_strict(int32_t len);
struct wire_cst_list_rate *frbgen_breez_liquid_cst_new_list_rate(int32_t len);
struct wire_cst_list_refundable_swap *frbgen_breez_liquid_cst_new_list_refundable_swap(int32_t len);
struct wire_cst_list_route_hint *frbgen_breez_liquid_cst_new_list_route_hint(int32_t len);
@@ -850,6 +928,7 @@ 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_bitcoin_address_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_bool);
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_liquid_sdk_event);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_ln_invoice);
@@ -876,10 +955,16 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_refund_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_restore_request);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_success_action_processed);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_symbol);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_32);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_u_64);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_data);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_fiat_currency);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_locale_overrides);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_localized_name);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_payment);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_prim_u_8_strict);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_rate);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_refundable_swap);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_route_hint);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_cst_new_list_route_hint_hop);
@@ -889,7 +974,9 @@ static int64_t dummy_method_to_enforce_bundling(void) {
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_backup);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_disconnect);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_fetch_fiat_rates);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_fiat_currencies);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_refundables);
dummy_var ^= ((int64_t) (void*) frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_lnurl_auth);

View File

@@ -191,6 +191,44 @@ interface LnUrlAuthError {
ServiceConnectivity(string err);
};
dictionary Rate {
string coin;
f64 value;
};
dictionary FiatCurrency {
string id;
CurrencyInfo info;
};
dictionary Symbol {
string? grapheme;
string? template;
boolean? rtl;
u32? position;
};
dictionary LocaleOverrides {
string locale;
u32? spacing;
Symbol symbol;
};
dictionary LocalizedName {
string locale;
string name;
};
dictionary CurrencyInfo {
string name;
u32 fraction_size;
u32? spacing;
Symbol? symbol;
Symbol? uniq_symbol;
sequence<LocalizedName> localized_name;
sequence<LocaleOverrides> locale_overrides;
};
// END sdk-common mirror imports
////////////////////////////////
@@ -498,4 +536,10 @@ interface BindingLiquidSdk {
[Throws=LnUrlAuthError]
LnUrlCallbackStatus lnurl_auth(LnUrlAuthRequestData req_data);
[Throws=LiquidSdkError]
sequence<Rate> fetch_fiat_rates();
[Throws=LiquidSdkError]
sequence<FiatCurrency> list_fiat_currencies();
};

View File

@@ -6,11 +6,12 @@ use anyhow::Result;
use breez_liquid_sdk::logger::Logger;
use breez_liquid_sdk::{
error::*, model::*, sdk::LiquidSdk, AesSuccessActionDataDecrypted, AesSuccessActionDataResult,
BitcoinAddressData, InputType, LNInvoice, LnUrlAuthError, LnUrlAuthRequestData,
LnUrlCallbackStatus, LnUrlErrorData, LnUrlPayError, LnUrlPayErrorData, LnUrlPayRequest,
LnUrlPayRequestData, LnUrlWithdrawError, LnUrlWithdrawRequest, LnUrlWithdrawRequestData,
LnUrlWithdrawResult, LnUrlWithdrawSuccessData, MessageSuccessActionData, Network, RouteHint,
RouteHintHop, SuccessActionProcessed, UrlSuccessActionData,
BitcoinAddressData, CurrencyInfo, FiatCurrency, InputType, LNInvoice, LnUrlAuthError,
LnUrlAuthRequestData, LnUrlCallbackStatus, LnUrlErrorData, LnUrlPayError, LnUrlPayErrorData,
LnUrlPayRequest, LnUrlPayRequestData, LnUrlWithdrawError, LnUrlWithdrawRequest,
LnUrlWithdrawRequestData, LnUrlWithdrawResult, LnUrlWithdrawSuccessData, LocaleOverrides,
LocalizedName, MessageSuccessActionData, Network, Rate, RouteHint, RouteHintHop,
SuccessActionProcessed, Symbol, UrlSuccessActionData,
};
use log::{Metadata, Record, SetLoggerError};
use once_cell::sync::Lazy;
@@ -169,6 +170,14 @@ impl BindingLiquidSdk {
rt().block_on(self.sdk.lnurl_auth(req_data))
}
pub fn fetch_fiat_rates(&self) -> Result<Vec<Rate>, LiquidSdkError> {
rt().block_on(self.sdk.fetch_fiat_rates())
}
pub fn list_fiat_currencies(&self) -> Result<Vec<FiatCurrency>, LiquidSdkError> {
rt().block_on(self.sdk.list_fiat_currencies())
}
pub fn list_refundables(&self) -> LiquidSdkResult<Vec<RefundableSwap>> {
rt().block_on(self.sdk.list_refundables())
}

View File

@@ -6,10 +6,11 @@ use anyhow::Result;
use flutter_rust_bridge::frb;
use log::{Level, LevelFilter, Metadata, Record, SetLoggerError};
pub use sdk_common::prelude::{
AesSuccessActionDataDecrypted, AesSuccessActionDataResult, BitcoinAddressData, InputType,
LNInvoice, LnUrlAuthRequestData, LnUrlErrorData, LnUrlPayErrorData, LnUrlPayRequest,
LnUrlPayRequestData, LnUrlWithdrawRequest, LnUrlWithdrawRequestData, MessageSuccessActionData,
Network, RouteHint, RouteHintHop, SuccessActionProcessed, UrlSuccessActionData,
AesSuccessActionDataDecrypted, AesSuccessActionDataResult, BitcoinAddressData, CurrencyInfo,
FiatCurrency, InputType, LNInvoice, LnUrlAuthRequestData, LnUrlErrorData, LnUrlPayErrorData,
LnUrlPayRequest, LnUrlPayRequestData, LnUrlWithdrawRequest, LnUrlWithdrawRequestData,
LocaleOverrides, LocalizedName, MessageSuccessActionData, Network, Rate, RouteHint,
RouteHintHop, SuccessActionProcessed, Symbol, UrlSuccessActionData,
};
use crate::{error::*, frb_generated::StreamSink, model::*, sdk::LiquidSdk};
@@ -186,6 +187,14 @@ impl BindingLiquidSdk {
.map_err(Into::into)
}
pub async fn fetch_fiat_rates(&self) -> Result<Vec<Rate>, LiquidSdkError> {
self.sdk.fetch_fiat_rates().await
}
pub async fn list_fiat_currencies(&self) -> Result<Vec<FiatCurrency>, LiquidSdkError> {
self.sdk.list_fiat_currencies().await
}
pub async fn list_refundables(&self) -> Result<Vec<RefundableSwap>, LiquidSdkError> {
self.sdk.list_refundables().await
}
@@ -378,6 +387,50 @@ pub struct _LnUrlWithdrawRequest {
pub description: Option<String>,
}
#[frb(mirror(Rate))]
pub struct _Rate {
pub coin: String,
pub value: f64,
}
#[frb(mirror(FiatCurrency))]
pub struct _FiatCurrency {
pub id: String,
pub info: CurrencyInfo,
}
#[frb(mirror(CurrencyInfo))]
pub struct _CurrencyInfo {
pub name: String,
pub fraction_size: u32,
pub spacing: Option<u32>,
pub symbol: Option<Symbol>,
pub uniq_symbol: Option<Symbol>,
pub localized_name: Vec<LocalizedName>,
pub locale_overrides: Vec<LocaleOverrides>,
}
#[frb(mirror(LocaleOverrides))]
pub struct _LocaleOverrides {
pub locale: String,
pub spacing: Option<u32>,
pub symbol: Symbol,
}
#[frb(mirror(LocalizedName))]
pub struct _LocalizedName {
pub locale: String,
pub name: String,
}
#[frb(mirror(Symbol))]
pub struct _Symbol {
pub grapheme: Option<String>,
pub template: Option<String>,
pub rtl: Option<bool>,
pub position: Option<u32>,
}
/// External structs that cannot be mirrored for FRB, so are therefore duplicated instead
pub mod duplicates {
use sdk_common::prelude::*;

View File

@@ -181,6 +181,12 @@ impl CstDecode<crate::bindings::BitcoinAddressData> for *mut wire_cst_bitcoin_ad
CstDecode::<crate::bindings::BitcoinAddressData>::cst_decode(*wrap).into()
}
}
impl CstDecode<bool> for *mut bool {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> bool {
unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }
}
}
impl CstDecode<crate::model::ConnectRequest> for *mut wire_cst_connect_request {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::ConnectRequest {
@@ -373,6 +379,19 @@ impl CstDecode<crate::bindings::SuccessActionProcessed> for *mut wire_cst_succes
CstDecode::<crate::bindings::SuccessActionProcessed>::cst_decode(*wrap).into()
}
}
impl CstDecode<crate::bindings::Symbol> for *mut wire_cst_symbol {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::Symbol {
let wrap = unsafe { flutter_rust_bridge::for_generated::box_from_leak_ptr(self) };
CstDecode::<crate::bindings::Symbol>::cst_decode(*wrap).into()
}
}
impl CstDecode<u32> for *mut u32 {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> u32 {
unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }
}
}
impl CstDecode<u64> for *mut u64 {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> u64 {
@@ -409,6 +428,29 @@ impl CstDecode<crate::model::ConnectRequest> for wire_cst_connect_request {
}
}
}
impl CstDecode<crate::bindings::CurrencyInfo> for wire_cst_currency_info {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::CurrencyInfo {
crate::bindings::CurrencyInfo {
name: self.name.cst_decode(),
fraction_size: self.fraction_size.cst_decode(),
spacing: self.spacing.cst_decode(),
symbol: self.symbol.cst_decode(),
uniq_symbol: self.uniq_symbol.cst_decode(),
localized_name: self.localized_name.cst_decode(),
locale_overrides: self.locale_overrides.cst_decode(),
}
}
}
impl CstDecode<crate::bindings::FiatCurrency> for wire_cst_fiat_currency {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::FiatCurrency {
crate::bindings::FiatCurrency {
id: self.id.cst_decode(),
info: self.info.cst_decode(),
}
}
}
impl CstDecode<crate::model::GetInfoResponse> for wire_cst_get_info_response {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::GetInfoResponse {
@@ -543,6 +585,36 @@ impl CstDecode<crate::model::LiquidSdkEvent> for wire_cst_liquid_sdk_event {
}
}
}
impl CstDecode<Vec<crate::bindings::FiatCurrency>> for *mut wire_cst_list_fiat_currency {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::bindings::FiatCurrency> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<Vec<crate::bindings::LocaleOverrides>> for *mut wire_cst_list_locale_overrides {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::bindings::LocaleOverrides> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<Vec<crate::bindings::LocalizedName>> for *mut wire_cst_list_localized_name {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::bindings::LocalizedName> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<Vec<crate::model::Payment>> for *mut wire_cst_list_payment {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::model::Payment> {
@@ -562,6 +634,16 @@ impl CstDecode<Vec<u8>> for *mut wire_cst_list_prim_u_8_strict {
}
}
}
impl CstDecode<Vec<crate::bindings::Rate>> for *mut wire_cst_list_rate {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::bindings::Rate> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<Vec<crate::model::RefundableSwap>> for *mut wire_cst_list_refundable_swap {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::model::RefundableSwap> {
@@ -919,6 +1001,25 @@ impl CstDecode<crate::bindings::duplicates::LnUrlWithdrawSuccessData>
}
}
}
impl CstDecode<crate::bindings::LocaleOverrides> for wire_cst_locale_overrides {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::LocaleOverrides {
crate::bindings::LocaleOverrides {
locale: self.locale.cst_decode(),
spacing: self.spacing.cst_decode(),
symbol: self.symbol.cst_decode(),
}
}
}
impl CstDecode<crate::bindings::LocalizedName> for wire_cst_localized_name {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::LocalizedName {
crate::bindings::LocalizedName {
locale: self.locale.cst_decode(),
name: self.name.cst_decode(),
}
}
}
impl CstDecode<crate::model::LogEntry> for wire_cst_log_entry {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::LogEntry {
@@ -1116,6 +1217,15 @@ impl CstDecode<crate::model::PrepareSendResponse> for wire_cst_prepare_send_resp
}
}
}
impl CstDecode<crate::bindings::Rate> for wire_cst_rate {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::Rate {
crate::bindings::Rate {
coin: self.coin.cst_decode(),
value: self.value.cst_decode(),
}
}
}
impl CstDecode<crate::model::ReceiveOnchainRequest> for wire_cst_receive_onchain_request {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::ReceiveOnchainRequest {
@@ -1234,6 +1344,17 @@ impl CstDecode<crate::bindings::SuccessActionProcessed> for wire_cst_success_act
}
}
}
impl CstDecode<crate::bindings::Symbol> for wire_cst_symbol {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::Symbol {
crate::bindings::Symbol {
grapheme: self.grapheme.cst_decode(),
template: self.template.cst_decode(),
rtl: self.rtl.cst_decode(),
position: self.position.cst_decode(),
}
}
}
impl CstDecode<crate::bindings::UrlSuccessActionData> for wire_cst_url_success_action_data {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::bindings::UrlSuccessActionData {
@@ -1340,6 +1461,37 @@ impl Default for wire_cst_connect_request {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_currency_info {
fn new_with_null_ptr() -> Self {
Self {
name: core::ptr::null_mut(),
fraction_size: Default::default(),
spacing: core::ptr::null_mut(),
symbol: core::ptr::null_mut(),
uniq_symbol: core::ptr::null_mut(),
localized_name: core::ptr::null_mut(),
locale_overrides: core::ptr::null_mut(),
}
}
}
impl Default for wire_cst_currency_info {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_fiat_currency {
fn new_with_null_ptr() -> Self {
Self {
id: core::ptr::null_mut(),
info: Default::default(),
}
}
}
impl Default for wire_cst_fiat_currency {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_get_info_response {
fn new_with_null_ptr() -> Self {
Self {
@@ -1625,6 +1777,33 @@ impl Default for wire_cst_ln_url_withdraw_success_data {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_locale_overrides {
fn new_with_null_ptr() -> Self {
Self {
locale: core::ptr::null_mut(),
spacing: core::ptr::null_mut(),
symbol: Default::default(),
}
}
}
impl Default for wire_cst_locale_overrides {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_localized_name {
fn new_with_null_ptr() -> Self {
Self {
locale: core::ptr::null_mut(),
name: core::ptr::null_mut(),
}
}
}
impl Default for wire_cst_localized_name {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_log_entry {
fn new_with_null_ptr() -> Self {
Self {
@@ -1825,6 +2004,19 @@ impl Default for wire_cst_prepare_send_response {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_rate {
fn new_with_null_ptr() -> Self {
Self {
coin: core::ptr::null_mut(),
value: Default::default(),
}
}
}
impl Default for wire_cst_rate {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_receive_onchain_request {
fn new_with_null_ptr() -> Self {
Self {
@@ -1970,6 +2162,21 @@ impl Default for wire_cst_success_action_processed {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_symbol {
fn new_with_null_ptr() -> Self {
Self {
grapheme: core::ptr::null_mut(),
template: core::ptr::null_mut(),
rtl: core::ptr::null_mut(),
position: core::ptr::null_mut(),
}
}
}
impl Default for wire_cst_symbol {
fn default() -> Self {
Self::new_with_null_ptr()
}
}
impl NewWithNullPtr for wire_cst_url_success_action_data {
fn new_with_null_ptr() -> Self {
Self {
@@ -2016,6 +2223,14 @@ pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_em
wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache_impl(that)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_fetch_fiat_rates(
port_: i64,
that: usize,
) {
wire__crate__bindings__BindingLiquidSdk_fetch_fiat_rates_impl(port_, that)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_get_info(
port_: i64,
@@ -2024,6 +2239,14 @@ pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_ge
wire__crate__bindings__BindingLiquidSdk_get_info_impl(port_, that)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_fiat_currencies(
port_: i64,
that: usize,
) {
wire__crate__bindings__BindingLiquidSdk_list_fiat_currencies_impl(port_, that)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_list_payments(
port_: i64,
@@ -2278,6 +2501,11 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_bitcoin_address_data(
)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_bool(value: bool) -> *mut bool {
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_connect_request(
) -> *mut wire_cst_connect_request {
@@ -2480,6 +2708,16 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_success_action_process
)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_symbol() -> *mut wire_cst_symbol {
flutter_rust_bridge::for_generated::new_leak_box_ptr(wire_cst_symbol::new_with_null_ptr())
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_u_32(value: u32) -> *mut u32 {
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 {
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
@@ -2493,6 +2731,48 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_box_autoadd_url_success_action_dat
)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_fiat_currency(
len: i32,
) -> *mut wire_cst_list_fiat_currency {
let wrap = wire_cst_list_fiat_currency {
ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(
<wire_cst_fiat_currency>::new_with_null_ptr(),
len,
),
len,
};
flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_locale_overrides(
len: i32,
) -> *mut wire_cst_list_locale_overrides {
let wrap = wire_cst_list_locale_overrides {
ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(
<wire_cst_locale_overrides>::new_with_null_ptr(),
len,
),
len,
};
flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_localized_name(
len: i32,
) -> *mut wire_cst_list_localized_name {
let wrap = wire_cst_list_localized_name {
ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(
<wire_cst_localized_name>::new_with_null_ptr(),
len,
),
len,
};
flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_payment(len: i32) -> *mut wire_cst_list_payment {
let wrap = wire_cst_list_payment {
@@ -2516,6 +2796,18 @@ pub extern "C" fn frbgen_breez_liquid_cst_new_list_prim_u_8_strict(
flutter_rust_bridge::for_generated::new_leak_box_ptr(ans)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_rate(len: i32) -> *mut wire_cst_list_rate {
let wrap = wire_cst_list_rate {
ptr: flutter_rust_bridge::for_generated::new_leak_vec_ptr(
<wire_cst_rate>::new_with_null_ptr(),
len,
),
len,
};
flutter_rust_bridge::for_generated::new_leak_box_ptr(wrap)
}
#[no_mangle]
pub extern "C" fn frbgen_breez_liquid_cst_new_list_refundable_swap(
len: i32,
@@ -2625,6 +2917,23 @@ pub struct wire_cst_connect_request {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_currency_info {
name: *mut wire_cst_list_prim_u_8_strict,
fraction_size: u32,
spacing: *mut u32,
symbol: *mut wire_cst_symbol,
uniq_symbol: *mut wire_cst_symbol,
localized_name: *mut wire_cst_list_localized_name,
locale_overrides: *mut wire_cst_list_locale_overrides,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_fiat_currency {
id: *mut wire_cst_list_prim_u_8_strict,
info: wire_cst_currency_info,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_get_info_response {
balance_sat: u64,
pending_send_sat: u64,
@@ -2762,6 +3071,24 @@ pub struct wire_cst_LiquidSdkEvent_PaymentWaitingConfirmation {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_fiat_currency {
ptr: *mut wire_cst_fiat_currency,
len: i32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_locale_overrides {
ptr: *mut wire_cst_locale_overrides,
len: i32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_localized_name {
ptr: *mut wire_cst_localized_name,
len: i32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_payment {
ptr: *mut wire_cst_payment,
len: i32,
@@ -2774,6 +3101,12 @@ pub struct wire_cst_list_prim_u_8_strict {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_rate {
ptr: *mut wire_cst_rate,
len: i32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_list_refundable_swap {
ptr: *mut wire_cst_refundable_swap,
len: i32,
@@ -3097,6 +3430,19 @@ pub struct wire_cst_ln_url_withdraw_success_data {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_locale_overrides {
locale: *mut wire_cst_list_prim_u_8_strict,
spacing: *mut u32,
symbol: wire_cst_symbol,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_localized_name {
locale: *mut wire_cst_list_prim_u_8_strict,
name: *mut wire_cst_list_prim_u_8_strict,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_log_entry {
line: *mut wire_cst_list_prim_u_8_strict,
level: *mut wire_cst_list_prim_u_8_strict,
@@ -3240,6 +3586,12 @@ pub struct wire_cst_prepare_send_response {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_rate {
coin: *mut wire_cst_list_prim_u_8_strict,
value: f64,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_receive_onchain_request {
prepare_res: wire_cst_prepare_receive_onchain_response,
}
@@ -3331,6 +3683,14 @@ pub struct wire_cst_SuccessActionProcessed_Url {
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_symbol {
grapheme: *mut wire_cst_list_prim_u_8_strict,
template: *mut wire_cst_list_prim_u_8_strict,
rtl: *mut bool,
position: *mut u32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct wire_cst_url_success_action_data {
description: *mut wire_cst_list_prim_u_8_strict,
url: *mut wire_cst_list_prim_u_8_strict,

View File

@@ -39,7 +39,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
default_rust_auto_opaque = RustAutoOpaqueNom,
);
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0";
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 671987080;
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1268203752;
// Section: executor
@@ -214,6 +214,51 @@ fn wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache_impl(
},
)
}
fn wire__crate__bindings__BindingLiquidSdk_fetch_fiat_rates_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode<
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
>,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "BindingLiquidSdk_fetch_fiat_rates",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let api_that = that.cst_decode();
move |context| async move {
transform_result_dco::<_, _, crate::error::LiquidSdkError>(
(move || async move {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => {
api_that_guard =
Some(api_that.lockable_decode_async_ref().await)
}
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok =
crate::bindings::BindingLiquidSdk::fetch_fiat_rates(&*api_that_guard)
.await?;
Ok(output_ok)
})()
.await,
)
}
},
)
}
fn wire__crate__bindings__BindingLiquidSdk_get_info_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode<
@@ -258,6 +303,52 @@ fn wire__crate__bindings__BindingLiquidSdk_get_info_impl(
},
)
}
fn wire__crate__bindings__BindingLiquidSdk_list_fiat_currencies_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode<
RustOpaqueNom<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<BindingLiquidSdk>>,
>,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "BindingLiquidSdk_list_fiat_currencies",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let api_that = that.cst_decode();
move |context| async move {
transform_result_dco::<_, _, crate::error::LiquidSdkError>(
(move || async move {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => {
api_that_guard =
Some(api_that.lockable_decode_async_ref().await)
}
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::bindings::BindingLiquidSdk::list_fiat_currencies(
&*api_that_guard,
)
.await?;
Ok(output_ok)
})()
.await,
)
}
},
)
}
fn wire__crate__bindings__BindingLiquidSdk_list_payments_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
that: impl CstDecode<
@@ -1221,6 +1312,21 @@ const _: fn() = || {
let _: Option<String> = BitcoinAddressData.label;
let _: Option<String> = BitcoinAddressData.message;
}
{
let CurrencyInfo = None::<crate::bindings::CurrencyInfo>.unwrap();
let _: String = CurrencyInfo.name;
let _: u32 = CurrencyInfo.fraction_size;
let _: Option<u32> = CurrencyInfo.spacing;
let _: Option<crate::bindings::Symbol> = CurrencyInfo.symbol;
let _: Option<crate::bindings::Symbol> = CurrencyInfo.uniq_symbol;
let _: Vec<crate::bindings::LocalizedName> = CurrencyInfo.localized_name;
let _: Vec<crate::bindings::LocaleOverrides> = CurrencyInfo.locale_overrides;
}
{
let FiatCurrency = None::<crate::bindings::FiatCurrency>.unwrap();
let _: String = FiatCurrency.id;
let _: crate::bindings::CurrencyInfo = FiatCurrency.info;
}
match None::<crate::bindings::InputType>.unwrap() {
crate::bindings::InputType::BitcoinAddress { address } => {
let _: crate::bindings::BitcoinAddressData = address;
@@ -1311,10 +1417,26 @@ const _: fn() = || {
let _: u64 = LnUrlWithdrawRequestData.min_withdrawable;
let _: u64 = LnUrlWithdrawRequestData.max_withdrawable;
}
{
let LocaleOverrides = None::<crate::bindings::LocaleOverrides>.unwrap();
let _: String = LocaleOverrides.locale;
let _: Option<u32> = LocaleOverrides.spacing;
let _: crate::bindings::Symbol = LocaleOverrides.symbol;
}
{
let LocalizedName = None::<crate::bindings::LocalizedName>.unwrap();
let _: String = LocalizedName.locale;
let _: String = LocalizedName.name;
}
{
let MessageSuccessActionData = None::<crate::bindings::MessageSuccessActionData>.unwrap();
let _: String = MessageSuccessActionData.message;
}
{
let Rate = None::<crate::bindings::Rate>.unwrap();
let _: String = Rate.coin;
let _: f64 = Rate.value;
}
{
let RouteHint = None::<crate::bindings::RouteHint>.unwrap();
let _: Vec<crate::bindings::RouteHintHop> = RouteHint.hops;
@@ -1340,6 +1462,13 @@ const _: fn() = || {
let _: crate::bindings::UrlSuccessActionData = data;
}
}
{
let Symbol = None::<crate::bindings::Symbol>.unwrap();
let _: Option<String> = Symbol.grapheme;
let _: Option<String> = Symbol.template;
let _: Option<bool> = Symbol.rtl;
let _: Option<u32> = Symbol.position;
}
{
let UrlSuccessActionData = None::<crate::bindings::UrlSuccessActionData>.unwrap();
let _: String = UrlSuccessActionData.description;
@@ -1361,6 +1490,12 @@ impl CstDecode<f32> for f32 {
self
}
}
impl CstDecode<f64> for f64 {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> f64 {
self
}
}
impl CstDecode<i32> for i32 {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> i32 {
@@ -1614,6 +1749,29 @@ impl SseDecode for crate::model::ConnectRequest {
}
}
impl SseDecode for crate::bindings::CurrencyInfo {
// 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_name = <String>::sse_decode(deserializer);
let mut var_fractionSize = <u32>::sse_decode(deserializer);
let mut var_spacing = <Option<u32>>::sse_decode(deserializer);
let mut var_symbol = <Option<crate::bindings::Symbol>>::sse_decode(deserializer);
let mut var_uniqSymbol = <Option<crate::bindings::Symbol>>::sse_decode(deserializer);
let mut var_localizedName = <Vec<crate::bindings::LocalizedName>>::sse_decode(deserializer);
let mut var_localeOverrides =
<Vec<crate::bindings::LocaleOverrides>>::sse_decode(deserializer);
return crate::bindings::CurrencyInfo {
name: var_name,
fraction_size: var_fractionSize,
spacing: var_spacing,
symbol: var_symbol,
uniq_symbol: var_uniqSymbol,
localized_name: var_localizedName,
locale_overrides: var_localeOverrides,
};
}
}
impl SseDecode for f32 {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -1621,6 +1779,25 @@ impl SseDecode for f32 {
}
}
impl SseDecode for f64 {
// 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_f64::<NativeEndian>().unwrap()
}
}
impl SseDecode for crate::bindings::FiatCurrency {
// 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_id = <String>::sse_decode(deserializer);
let mut var_info = <crate::bindings::CurrencyInfo>::sse_decode(deserializer);
return crate::bindings::FiatCurrency {
id: var_id,
info: var_info,
};
}
}
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 {
@@ -1786,6 +1963,42 @@ impl SseDecode for crate::model::LiquidSdkEvent {
}
}
impl SseDecode for Vec<crate::bindings::FiatCurrency> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = vec![];
for idx_ in 0..len_ {
ans_.push(<crate::bindings::FiatCurrency>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::bindings::LocaleOverrides> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = vec![];
for idx_ in 0..len_ {
ans_.push(<crate::bindings::LocaleOverrides>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::bindings::LocalizedName> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = vec![];
for idx_ in 0..len_ {
ans_.push(<crate::bindings::LocalizedName>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::model::Payment> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -1810,6 +2023,18 @@ impl SseDecode for Vec<u8> {
}
}
impl SseDecode for Vec<crate::bindings::Rate> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = vec![];
for idx_ in 0..len_ {
ans_.push(<crate::bindings::Rate>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::model::RefundableSwap> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2216,6 +2441,32 @@ impl SseDecode for crate::bindings::duplicates::LnUrlWithdrawSuccessData {
}
}
impl SseDecode for crate::bindings::LocaleOverrides {
// 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_locale = <String>::sse_decode(deserializer);
let mut var_spacing = <Option<u32>>::sse_decode(deserializer);
let mut var_symbol = <crate::bindings::Symbol>::sse_decode(deserializer);
return crate::bindings::LocaleOverrides {
locale: var_locale,
spacing: var_spacing,
symbol: var_symbol,
};
}
}
impl SseDecode for crate::bindings::LocalizedName {
// 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_locale = <String>::sse_decode(deserializer);
let mut var_name = <String>::sse_decode(deserializer);
return crate::bindings::LocalizedName {
locale: var_locale,
name: var_name,
};
}
}
impl SseDecode for crate::model::LogEntry {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2263,6 +2514,17 @@ impl SseDecode for Option<String> {
}
}
impl SseDecode for Option<bool> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
if (<bool>::sse_decode(deserializer)) {
return Some(<bool>::sse_decode(deserializer));
} else {
return None;
}
}
}
impl SseDecode for Option<crate::bindings::SuccessActionProcessed> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2276,6 +2538,28 @@ impl SseDecode for Option<crate::bindings::SuccessActionProcessed> {
}
}
impl SseDecode for Option<crate::bindings::Symbol> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
if (<bool>::sse_decode(deserializer)) {
return Some(<crate::bindings::Symbol>::sse_decode(deserializer));
} else {
return None;
}
}
}
impl SseDecode for Option<u32> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
if (<bool>::sse_decode(deserializer)) {
return Some(<u32>::sse_decode(deserializer));
} else {
return None;
}
}
}
impl SseDecode for Option<u64> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2549,6 +2833,18 @@ impl SseDecode for crate::model::PrepareSendResponse {
}
}
impl SseDecode for crate::bindings::Rate {
// 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_coin = <String>::sse_decode(deserializer);
let mut var_value = <f64>::sse_decode(deserializer);
return crate::bindings::Rate {
coin: var_coin,
value: var_value,
};
}
}
impl SseDecode for crate::model::ReceiveOnchainRequest {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2699,6 +2995,22 @@ impl SseDecode for crate::bindings::SuccessActionProcessed {
}
}
impl SseDecode for crate::bindings::Symbol {
// 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_grapheme = <Option<String>>::sse_decode(deserializer);
let mut var_template = <Option<String>>::sse_decode(deserializer);
let mut var_rtl = <Option<bool>>::sse_decode(deserializer);
let mut var_position = <Option<u32>>::sse_decode(deserializer);
return crate::bindings::Symbol {
grapheme: var_grapheme,
template: var_template,
rtl: var_rtl,
position: var_position,
};
}
}
impl SseDecode for u16 {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -2936,6 +3248,53 @@ impl flutter_rust_bridge::IntoIntoDart<crate::model::ConnectRequest>
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::CurrencyInfo> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.name.into_into_dart().into_dart(),
self.0.fraction_size.into_into_dart().into_dart(),
self.0.spacing.into_into_dart().into_dart(),
self.0.symbol.into_into_dart().into_dart(),
self.0.uniq_symbol.into_into_dart().into_dart(),
self.0.localized_name.into_into_dart().into_dart(),
self.0.locale_overrides.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::CurrencyInfo>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::CurrencyInfo>>
for crate::bindings::CurrencyInfo
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::CurrencyInfo> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::FiatCurrency> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.id.into_into_dart().into_dart(),
self.0.info.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::FiatCurrency>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::FiatCurrency>>
for crate::bindings::FiatCurrency
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::FiatCurrency> {
self.into()
}
}
// 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 {
[
@@ -3515,6 +3874,49 @@ impl flutter_rust_bridge::IntoIntoDart<crate::bindings::duplicates::LnUrlWithdra
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::LocaleOverrides> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.locale.into_into_dart().into_dart(),
self.0.spacing.into_into_dart().into_dart(),
self.0.symbol.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::LocaleOverrides>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::LocaleOverrides>>
for crate::bindings::LocaleOverrides
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::LocaleOverrides> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::LocalizedName> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.locale.into_into_dart().into_dart(),
self.0.name.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::LocalizedName>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::LocalizedName>>
for crate::bindings::LocalizedName
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::LocalizedName> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::model::LogEntry {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
@@ -3899,6 +4301,27 @@ impl flutter_rust_bridge::IntoIntoDart<crate::model::PrepareSendResponse>
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::Rate> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.coin.into_into_dart().into_dart(),
self.0.value.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::Rate>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::Rate>>
for crate::bindings::Rate
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::Rate> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::model::ReceiveOnchainRequest {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[self.prepare_res.into_into_dart().into_dart()].into_dart()
@@ -4117,6 +4540,29 @@ impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::SuccessAction
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::Symbol> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.0.grapheme.into_into_dart().into_dart(),
self.0.template.into_into_dart().into_dart(),
self.0.rtl.into_into_dart().into_dart(),
self.0.position.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for FrbWrapper<crate::bindings::Symbol>
{
}
impl flutter_rust_bridge::IntoIntoDart<FrbWrapper<crate::bindings::Symbol>>
for crate::bindings::Symbol
{
fn into_into_dart(self) -> FrbWrapper<crate::bindings::Symbol> {
self.into()
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for FrbWrapper<crate::bindings::UrlSuccessActionData> {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
@@ -4268,6 +4714,19 @@ impl SseEncode for crate::model::ConnectRequest {
}
}
impl SseEncode for crate::bindings::CurrencyInfo {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.name, serializer);
<u32>::sse_encode(self.fraction_size, serializer);
<Option<u32>>::sse_encode(self.spacing, serializer);
<Option<crate::bindings::Symbol>>::sse_encode(self.symbol, serializer);
<Option<crate::bindings::Symbol>>::sse_encode(self.uniq_symbol, serializer);
<Vec<crate::bindings::LocalizedName>>::sse_encode(self.localized_name, serializer);
<Vec<crate::bindings::LocaleOverrides>>::sse_encode(self.locale_overrides, serializer);
}
}
impl SseEncode for f32 {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -4275,6 +4734,21 @@ impl SseEncode for f32 {
}
}
impl SseEncode for f64 {
// 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_f64::<NativeEndian>(self).unwrap();
}
}
impl SseEncode for crate::bindings::FiatCurrency {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.id, serializer);
<crate::bindings::CurrencyInfo>::sse_encode(self.info, 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) {
@@ -4414,6 +4888,36 @@ impl SseEncode for crate::model::LiquidSdkEvent {
}
}
impl SseEncode for Vec<crate::bindings::FiatCurrency> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::bindings::FiatCurrency>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::bindings::LocaleOverrides> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::bindings::LocaleOverrides>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::bindings::LocalizedName> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::bindings::LocalizedName>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::model::Payment> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -4434,6 +4938,16 @@ impl SseEncode for Vec<u8> {
}
}
impl SseEncode for Vec<crate::bindings::Rate> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::bindings::Rate>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::model::RefundableSwap> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -4748,6 +5262,23 @@ impl SseEncode for crate::bindings::duplicates::LnUrlWithdrawSuccessData {
}
}
impl SseEncode for crate::bindings::LocaleOverrides {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.locale, serializer);
<Option<u32>>::sse_encode(self.spacing, serializer);
<crate::bindings::Symbol>::sse_encode(self.symbol, serializer);
}
}
impl SseEncode for crate::bindings::LocalizedName {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.locale, serializer);
<String>::sse_encode(self.name, serializer);
}
}
impl SseEncode for crate::model::LogEntry {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -4791,6 +5322,16 @@ impl SseEncode for Option<String> {
}
}
impl SseEncode for Option<bool> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<bool>::sse_encode(self.is_some(), serializer);
if let Some(value) = self {
<bool>::sse_encode(value, serializer);
}
}
}
impl SseEncode for Option<crate::bindings::SuccessActionProcessed> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -4801,6 +5342,26 @@ impl SseEncode for Option<crate::bindings::SuccessActionProcessed> {
}
}
impl SseEncode for Option<crate::bindings::Symbol> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<bool>::sse_encode(self.is_some(), serializer);
if let Some(value) = self {
<crate::bindings::Symbol>::sse_encode(value, serializer);
}
}
}
impl SseEncode for Option<u32> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<bool>::sse_encode(self.is_some(), serializer);
if let Some(value) = self {
<u32>::sse_encode(value, serializer);
}
}
}
impl SseEncode for Option<u64> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -5022,6 +5583,14 @@ impl SseEncode for crate::model::PrepareSendResponse {
}
}
impl SseEncode for crate::bindings::Rate {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.coin, serializer);
<f64>::sse_encode(self.value, serializer);
}
}
impl SseEncode for crate::model::ReceiveOnchainRequest {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -5127,6 +5696,16 @@ impl SseEncode for crate::bindings::SuccessActionProcessed {
}
}
impl SseEncode for crate::bindings::Symbol {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<Option<String>>::sse_encode(self.grapheme, serializer);
<Option<String>>::sse_encode(self.template, serializer);
<Option<bool>>::sse_encode(self.rtl, serializer);
<Option<u32>>::sse_encode(self.position, serializer);
}
}
impl SseEncode for u16 {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {

View File

@@ -16,6 +16,7 @@ use lwk_wollet::secp256k1::ThirtyTwoByteHash;
use lwk_wollet::{elements, ElectrumUrl, ElementsNetwork};
use sdk_common::bitcoin::secp256k1::Secp256k1;
use sdk_common::bitcoin::util::bip32::ChildNumber;
use sdk_common::prelude::{FiatAPI, FiatCurrency, LnUrlPayError, LnUrlWithdrawError, Rate};
use tokio::sync::{watch, Mutex, RwLock};
use tokio::time::MissedTickBehavior;
use tokio_stream::wrappers::BroadcastStream;
@@ -48,6 +49,7 @@ pub struct LiquidSdk {
swapper: Arc<dyn Swapper>,
liquid_chain_service: Arc<Mutex<dyn LiquidChainService>>,
bitcoin_chain_service: Arc<Mutex<dyn BitcoinChainService>>,
fiat_api: Arc<dyn FiatAPI>,
is_started: RwLock<bool>,
shutdown_sender: watch::Sender<()>,
shutdown_receiver: watch::Receiver<()>,
@@ -126,6 +128,8 @@ impl LiquidSdk {
bitcoin_chain_service.clone(),
)?;
let breez_server = BreezServer::new(PRODUCTION_BREEZSERVER_URL.into(), None)?;
let sdk = Arc::new(LiquidSdk {
config: config.clone(),
onchain_wallet,
@@ -135,6 +139,7 @@ impl LiquidSdk {
swapper,
bitcoin_chain_service,
liquid_chain_service,
fiat_api: Arc::new(breez_server),
is_started: RwLock::new(false),
shutdown_sender,
shutdown_receiver,
@@ -1498,7 +1503,7 @@ impl LiquidSdk {
.unwrap();
let preimage =
sha256::Hash::from_str(&preimage_str).map_err(|_| {
sdk_common::prelude::LnUrlPayError::Generic {
LnUrlPayError::Generic {
err: "Invalid preimage".to_string(),
}
})?;
@@ -1540,7 +1545,7 @@ impl LiquidSdk {
pub async fn lnurl_withdraw(
&self,
req: LnUrlWithdrawRequest,
) -> Result<LnUrlWithdrawResult, sdk_common::prelude::LnUrlWithdrawError> {
) -> Result<LnUrlWithdrawResult, LnUrlWithdrawError> {
let prepare_receive_res = self
.prepare_receive_payment(&{
PrepareReceiveRequest {
@@ -1580,6 +1585,20 @@ impl LiquidSdk {
Ok(perform_lnurl_auth(linking_keys, req_data).await?)
}
/// Fetch live rates of fiat currencies, sorted by name
pub async fn fetch_fiat_rates(&self) -> Result<Vec<Rate>, LiquidSdkError> {
self.fiat_api.fetch_fiat_rates().await.map_err(Into::into)
}
/// List all supported fiat currencies for which there is a known exchange rate.
/// List is sorted by the canonical name of the currency
pub async fn list_fiat_currencies(&self) -> Result<Vec<FiatCurrency>, LiquidSdkError> {
self.fiat_api
.list_fiat_currencies()
.await
.map_err(Into::into)
}
pub fn default_config(network: LiquidNetwork) -> Config {
match network {
LiquidNetwork::Mainnet => Config::mainnet(),