Skip to content

Commit

Permalink
chore: add cfg throughout for espidf
Browse files Browse the repository at this point in the history
  • Loading branch information
EthnTuttle committed Feb 27, 2024
1 parent 6ee48e1 commit 16471c9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions moksha-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ async-trait = "0.1.77"
lightning-invoice = "0.29.0"
url = "2.5.0"

[target.'cfg(not(target_os="espidf"))'.dependencies]
dirs = "5.0.1"

[target.'cfg(target_family = "wasm")'.dependencies]
gloo-net = { version = "0.5.0" }
serde-wasm-bindgen = "0.6.3"
wasm-bindgen = "0.2.90"
rexie = "0.5.0"
tokio = { version = "1.35.1", features = ["rt", "sync"] }
dirs = "5.0.1"

[target.'cfg(all(not(target_family="wasm"), not(target_os="espidf")))'.dependencies]
reqwest = { version = "0.11.23", features = ["serde_json", "json", "rustls-tls"], default-features = false }
tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread", "macros"] }
sqlx = { version = "0.7.3", default-features = false, features = ["sqlite", "runtime-tokio", "tls-rustls", "migrate", "macros"] }
dirs = "5.0.1"


[target.xtensa-esp32s3-none-elf.dependencies]
[target.'cfg(target_os="espidf")'.dependencies]
gloo-net = { version = "0.5.0" }
rexie = "0.5.0"
tokio = { version = "1.35.1", features = ["rt", "sync"] }

[dev-dependencies]
tempfile = "3.9.0"
mockall = "0.12.1"
mockall = "0.12.1"
1 change: 1 addition & 0 deletions moksha-wallet/src/btcprice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::error::MokshaWalletError;

async fn execute_request(url: &str) -> Result<String, MokshaWalletError> {
#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
{
let request_client = reqwest::Client::new();
Expand Down
3 changes: 3 additions & 0 deletions moksha-wallet/src/config_path.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(target_os = "espidf"))]
use dirs::home_dir;
use std::{fs::create_dir, path::PathBuf};

Expand All @@ -15,6 +16,7 @@ pub const ENV_DB_PATH: &str = "WALLET_DB_PATH";
/// let db_path = moksha_wallet::config_path::db_path();
/// println!("Database path: {}", db_path);
/// ```
#[cfg(not(target_os = "espidf"))]
pub fn db_path() -> String {
std::env::var(ENV_DB_PATH).map_or_else(
|_| {
Expand Down Expand Up @@ -43,6 +45,7 @@ pub fn db_path() -> String {
)
}

#[cfg(not(target_os = "espidf"))]
pub fn config_dir() -> PathBuf {
let home = home_dir()
.expect("home dir not found")
Expand Down
4 changes: 4 additions & 0 deletions moksha-wallet/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ pub enum MokshaWalletError {
#[error("SerdeJsonError - {0}")]
Json(#[from] serde_json::Error),

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
#[error("ReqwestError - {0}")]
Reqwest(#[from] reqwest::Error),

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
#[error("InvalidHeaderValueError - {0}")]
InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
Expand All @@ -31,10 +33,12 @@ pub enum MokshaWalletError {
#[error("MokshaCoreError - {0}")]
MokshaCore(#[from] moksha_core::error::MokshaCoreError),

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
#[error("DB Error {0}")]
Db(#[from] sqlx::Error),

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
#[error("Sqlite Error {0}")]
Sqlite(#[from] sqlx::sqlite::SqliteError),
Expand Down
2 changes: 2 additions & 0 deletions moksha-wallet/src/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
pub mod reqwest;

Expand All @@ -6,6 +7,7 @@ pub mod wasm;

#[derive(Debug, Clone)]
pub struct CrossPlatformHttpClient {
#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
client: ::reqwest::Client,
}
Expand Down
2 changes: 2 additions & 0 deletions moksha-wallet/src/localstore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use moksha_core::proof::Proofs;

use crate::error::MokshaWalletError;

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
pub mod sqlite;

Expand All @@ -15,6 +16,7 @@ pub struct WalletKeyset {
pub mint_url: String,
}

#[cfg(not(target_os = "espidf"))]
#[cfg(not(target_arch = "wasm32"))]
#[async_trait(?Send)]
pub trait LocalStore {
Expand Down

0 comments on commit 16471c9

Please sign in to comment.