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

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())
}