Skip to content

Commit

Permalink
fix(compilation): crate-level compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Trantorian1 authored and jbcaron committed Jan 5, 2025
1 parent 922d7a8 commit a96e747
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- fix(compilation): crate-level compilation
- chore: Move crates under a madara subdir
- chore(nix): resolve flake and direnv compatibility issues
- fix: Gateway path fix
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/madara/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub struct MadaraBackend {
trie_log_config: TrieLogConfig,
sender_block_info: tokio::sync::broadcast::Sender<mp_block::MadaraBlockInfo>,
write_opt_no_wal: WriteOptions,
#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
_temp_dir: Option<tempfile::TempDir>,
}

Expand Down Expand Up @@ -373,7 +373,7 @@ impl MadaraBackend {
&self.chain_config
}

#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
pub fn open_for_testing(chain_config: Arc<ChainConfig>) -> Arc<MadaraBackend> {
let temp_dir = tempfile::TempDir::with_prefix("madara-test").unwrap();
let db = open_rocksdb(temp_dir.as_ref()).unwrap();
Expand Down Expand Up @@ -446,7 +446,7 @@ impl MadaraBackend {
trie_log_config,
sender_block_info: tokio::sync::broadcast::channel(100).0,
write_opt_no_wal: make_write_opt_no_wal(),
#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
_temp_dir: None,
});
backend.check_configuration()?;
Expand Down
2 changes: 1 addition & 1 deletion crates/madara/client/db/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use mp_transactions::{
use starknet_api::felt;
use starknet_types_core::felt::Felt;

#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
pub mod temp_db {
use crate::DatabaseService;
use mp_chain_config::ChainConfig;
Expand Down
1 change: 1 addition & 0 deletions crates/madara/client/eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ tracing-test = "0.2.5"
serial_test.workspace = true
lazy_static.workspace = true
mp-utils = { workspace = true, features = ["testing"] }
mc-mempool = { workspace = true, features = ["testing"] }
1 change: 1 addition & 0 deletions crates/madara/primitives/oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ targets = ["x86_64-unknown-linux-gnu"]
# Other
anyhow.workspace = true
async-trait.workspace = true
mp-utils.workspace = true
reqwest.workspace = true
serde = { workspace = true, features = ["derive"] }
7 changes: 6 additions & 1 deletion crates/madara/primitives/oracle/src/pragma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt;

use anyhow::{bail, Context};
use async_trait::async_trait;
use mp_utils::serde::{deserialize_url, serialize_url};
use reqwest::Url;
use serde::{Deserialize, Serialize};

Expand All @@ -11,7 +12,11 @@ pub const DEFAULT_API_URL: &str = "https://api.dev.pragma.build/node/v1/data/";

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PragmaOracle {
#[serde(default = "default_oracle_api_url")]
#[serde(
default = "default_oracle_api_url",
serialize_with = "serialize_url",
deserialize_with = "deserialize_url"
)]
pub api_url: Url,
#[serde(default)]
pub api_key: String,
Expand Down
18 changes: 17 additions & 1 deletion crates/madara/primitives/utils/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use std::time::Duration;

use serde::{Deserialize, Deserializer};
use starknet_types_core::felt::Felt;
use url::Url;

use crate::{crypto::ZeroingPrivateKey, parsers::parse_duration};
use crate::{crypto::ZeroingPrivateKey, parsers::parse_duration, parsers::parse_url};

pub fn deserialize_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
Expand All @@ -23,6 +24,14 @@ where
parse_duration(&s).map_err(serde::de::Error::custom).map(Some)
}

pub fn deserialize_url<'de, D>(deserializer: D) -> Result<Url, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
parse_url(&s).map_err(serde::de::Error::custom)
}

pub fn serialize_optional_duration<S>(duration: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -45,6 +54,13 @@ where
}
}

pub fn serialize_url<S>(url: &Url, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(url.as_str())
}

pub fn deserialize_private_key<'de, D>(deserializer: D) -> Result<ZeroingPrivateKey, D::Error>
where
D: Deserializer<'de>,
Expand Down

0 comments on commit a96e747

Please sign in to comment.