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(starknet_gateway): use const for json rpc version #2609

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 16 additions & 2 deletions crates/starknet_gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use validator::Validate;

use crate::compiler_version::VersionId;

const JSON_RPC_VERSION: &str = "2.0";

#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
pub struct GatewayConfig {
pub stateless_tx_validator_config: StatelessTransactionValidatorConfig,
Expand Down Expand Up @@ -119,16 +121,28 @@ impl SerializeConfig for StatelessTransactionValidatorConfig {
}
}

#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)]
pub struct RpcStateReaderConfig {
pub url: String,
pub json_rpc_version: String,
}

impl RpcStateReaderConfig {
pub fn from_url(url: String) -> Self {
Self { url, ..Default::default() }
}
}

impl Default for RpcStateReaderConfig {
fn default() -> Self {
Self { url: Default::default(), json_rpc_version: JSON_RPC_VERSION.to_string() }
}
}

#[cfg(any(feature = "testing", test))]
impl RpcStateReaderConfig {
pub fn create_for_testing() -> Self {
Self { url: "http://localhost:8080".to_string(), json_rpc_version: "2.0".to_string() }
Self::from_url("http://localhost:8080".to_string())
}
}

Expand Down
Loading