From d4adb5580fd90f7f445ee4c1b997d7bbdbd3aa08 Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Mon, 29 Apr 2024 18:31:17 +0300 Subject: [PATCH] Return LsSdkError if getting a wallet instance fails Add missing import --- lib/ls-sdk-core/src/bindings.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ls-sdk-core/src/bindings.rs b/lib/ls-sdk-core/src/bindings.rs index 9e33a9d..8cc8c23 100644 --- a/lib/ls-sdk-core/src/bindings.rs +++ b/lib/ls-sdk-core/src/bindings.rs @@ -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 Result Result 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() })? .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) -> 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) }