Return LsSdkError if getting a wallet instance fails

Add missing import
This commit is contained in:
Erdem Yerebasmaz
2024-04-29 18:31:17 +03:00
parent 0b07484bfd
commit d4adb5580f

View File

@@ -3,7 +3,7 @@ pub(crate) use boltz_client::util::secrets::LBtcReverseRecovery;
use std::sync::{Arc, OnceLock};
use crate::{
error::PaymentError,
error::{LsSdkError, PaymentError},
model::{
Network, PrepareReceiveRequest, PrepareReceiveResponse, PrepareSendResponse,
ReceivePaymentResponse, SendPaymentResponse, WalletInfo,
@@ -32,7 +32,7 @@ pub fn prepare_send_payment(invoice: String) -> Result<PrepareSendResponse, Paym
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.prepare_send_payment(&invoice)
}
@@ -40,7 +40,7 @@ pub fn send_payment(req: PrepareSendResponse) -> Result<SendPaymentResponse, Pay
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.send_payment(&req)
}
@@ -50,7 +50,7 @@ pub fn prepare_receive_payment(
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.prepare_receive_payment(&req)
}
@@ -60,7 +60,7 @@ pub fn receive_payment(
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.receive_payment(&req)
}
@@ -68,7 +68,7 @@ pub fn list_payments(with_scan: bool, include_pending: bool) -> Result<Vec<Payme
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.list_payments(with_scan, include_pending)
}
@@ -76,7 +76,7 @@ pub fn recover_funds(recovery: LBtcReverseRecovery) -> Result<String> {
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.recover_funds(&recovery)
}
@@ -84,7 +84,7 @@ pub fn empty_wallet_cache() -> Result<()> {
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.empty_wallet_cache()
}
@@ -92,7 +92,7 @@ pub fn backup() -> Result<()> {
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.backup()
}
@@ -100,6 +100,6 @@ pub fn restore(backup_path: Option<String>) -> Result<()> {
WALLET_INSTANCE
.get()
.ok_or(anyhow!("Not initialized"))
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
.restore(backup_path)
}