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

chore: impl serialize config for chain info #98

Merged
Merged
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
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,
),
])
}
}
Loading