Skip to content

Commit

Permalink
chore: impl serialize config for chain info
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Jul 25, 2024
1 parent b544021 commit 500504b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
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.

1 change: 1 addition & 0 deletions crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ num-integer.workspace = true
num-rational.workspace = true
num-traits.workspace = true
once_cell.workspace = true
papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0"}
paste.workspace = true
phf.workspace = true
rand = { workspace = true, optional = true }
Expand Down
42 changes: 42 additions & 0 deletions crates/blockifier/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use std::collections::BTreeMap;

use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use serde::{Deserialize, Serialize};
use starknet_api::core::{ChainId, ContractAddress};

Expand Down Expand Up @@ -93,6 +97,25 @@ impl Default for ChainInfo {
}
}

impl SerializeConfig for ChainInfo {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
let members = BTreeMap::from_iter([ser_param(
"chain_id",
&self.chain_id,
"The chain ID of the StarkNet chain.",
ParamPrivacyInput::Public,
)]);

vec![
members,
append_sub_config_name(self.fee_token_addresses.dump(), "fee_token_addresses"),
]
.into_iter()
.flatten()
.collect()
}
}

#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct FeeTokenAddresses {
pub strk_fee_token_address: ContractAddress,
Expand All @@ -107,3 +130,22 @@ impl FeeTokenAddresses {
}
}
}

impl SerializeConfig for FeeTokenAddresses {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
BTreeMap::from_iter([
ser_param(
"strk_fee_token_address",
&self.strk_fee_token_address,
"Address of the STRK fee token.",
ParamPrivacyInput::Public,
),
ser_param(
"eth_fee_token_address",
&self.eth_fee_token_address,
"Address of the ETH fee token.",
ParamPrivacyInput::Public,
),
])
}
}

0 comments on commit 500504b

Please sign in to comment.