Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap breez services with replaceable variant #1112

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libs/sdk-bindings/src/uniffi_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ impl BlockingBreezServices {
}

pub fn node_credentials(&self) -> SdkResult<Option<NodeCredentials>> {
self.breez_services.node_credentials()
rt().block_on(self.breez_services.node_credentials())
}

pub fn node_info(&self) -> SdkResult<NodeState> {
self.breez_services.node_info()
rt().block_on(self.breez_services.node_info())
}

pub fn sign_message(&self, req: SignMessageRequest) -> SdkResult<SignMessageResponse> {
Expand All @@ -168,7 +168,7 @@ impl BlockingBreezServices {
}

pub fn backup_status(&self) -> SdkResult<BackupStatus> {
self.breez_services.backup_status()
rt().block_on(self.breez_services.backup_status())
}

pub fn backup(&self) -> SdkResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-core/src/backup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
breez_services::BackupFailedData,
error::SdkResult,
internal_breez_services::BackupFailedData,
persist::db::{HookEvent, SqliteStorage},
BreezEvent, Config,
};
Expand Down
21 changes: 7 additions & 14 deletions libs/sdk-core/src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ pub use sdk_common::prelude::{
};
use tokio::sync::Mutex;

use crate::breez_services::{self, BreezEvent, BreezServices, EventListener};
use crate::breez_services::{self, BreezServices};
use crate::chain::RecommendedFees;
use crate::error::{
ConnectError, ReceiveOnchainError, ReceivePaymentError, RedeemOnchainError, SdkError,
SendOnchainError, SendPaymentError,
};
use crate::internal_breez_services::{BreezEvent, EventListener};
use crate::lsp::LspInformation;
use crate::models::{Config, LogEntry, NodeState, Payment, SwapInfo};
use crate::{
Expand Down Expand Up @@ -332,22 +333,14 @@ pub fn sync() -> Result<()> {

/// See [BreezServices::node_credentials]
pub fn node_credentials() -> Result<Option<NodeCredentials>> {
block_on(async {
get_breez_services()
.await?
.node_credentials()
.map_err(anyhow::Error::new::<SdkError>)
})
block_on(async { get_breez_services().await?.node_credentials().await })
.map_err(anyhow::Error::new::<SdkError>)
}

/// See [BreezServices::node_info]
pub fn node_info() -> Result<NodeState> {
block_on(async {
get_breez_services()
.await?
.node_info()
.map_err(anyhow::Error::new::<SdkError>)
})
block_on(async { get_breez_services().await?.node_info().await })
.map_err(anyhow::Error::new::<SdkError>)
}

/// See [BreezServices::configure_node]
Expand Down Expand Up @@ -497,7 +490,7 @@ pub fn backup() -> Result<()> {

/// See [BreezServices::backup_status]
pub fn backup_status() -> Result<BackupStatus> {
block_on(async { get_breez_services().await?.backup_status() })
block_on(async { get_breez_services().await?.backup_status().await })
.map_err(anyhow::Error::new::<SdkError>)
}

Expand Down
Loading
Loading