Skip to content

Commit

Permalink
refactor: set default on all config values (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm authored Oct 9, 2024
1 parent f8bd4d9 commit 999b7b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion crates/cdk-config/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ fn default_address() -> Address {
.unwrap()
}

#[cfg(any(test, feature = "testutils"))]
impl Default for Aggregator {
fn default() -> Self {
// Values are coming from https://github.com/0xPolygon/agglayer/blob/main/config/default.go#L11
Expand Down
11 changes: 5 additions & 6 deletions crates/cdk-config/src/l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ use serde::Deserialize;
/// The L1 configuration.
#[derive(Deserialize, Debug, Clone)]
pub struct L1 {
#[serde(rename = "L1ChainID")]
#[serde(rename = "L1ChainID", alias = "ChainID", default)]
pub l1_chain_id: String,
#[serde(rename = "PolAddr")]
#[serde(rename = "PolAddr", default)]
pub pol_addr: Address,
#[serde(rename = "ZkEVMAddr")]
#[serde(rename = "ZkEVMAddr", default)]
pub zk_evm_addr: Address,
#[serde(rename = "RollupManagerAddr")]
#[serde(rename = "RollupManagerAddr", default)]
pub rollup_manager_addr: Address,
#[serde(rename = "GlobalExitRootManagerAddr")]
#[serde(rename = "GlobalExitRootManagerAddr", default)]
pub global_exit_root_manager_addr: Address,
}

#[cfg(any(test, feature = "testutils"))]
impl Default for L1 {
fn default() -> Self {
// Values are coming from https://github.com/0xPolygon/agglayer/blob/main/config/default.go#L11
Expand Down
8 changes: 4 additions & 4 deletions crates/cdk-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ use sequence_sender::SequenceSender;
#[cfg_attr(any(test, feature = "testutils"), derive(Default))]
pub struct Config {
/// The log configuration.
#[serde(rename = "Log")]
#[serde(rename = "Log", default)]
pub log: Log,

#[serde(rename = "ForkUpgradeBatchNumber")]
pub fork_upgrade_batch_number: Option<u64>,

#[serde(rename = "NetworkConfig")]
#[serde(rename = "NetworkConfig", default)]
pub network_config: network_config::NetworkConfig,

#[serde(rename = "Aggregator")]
#[serde(rename = "Aggregator", default)]
pub aggregator: aggregator::Aggregator,

#[serde(rename = "SequenceSender")]
#[serde(rename = "SequenceSender", default)]
pub sequence_sender: SequenceSender,
}
3 changes: 1 addition & 2 deletions crates/cdk-config/src/network_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use serde::Deserialize;
/// The L1 configuration.
#[derive(Deserialize, Debug, Clone)]
pub struct NetworkConfig {
#[serde(rename = "L1")]
#[serde(rename = "L1", default)]
pub l1: L1,
}

#[cfg(any(test, feature = "testutils"))]
impl Default for NetworkConfig {
fn default() -> Self {
Self { l1: L1::default() }
Expand Down

0 comments on commit 999b7b6

Please sign in to comment.