Skip to content

Commit

Permalink
chore(starknet_gateway): use const for json rpc version
Browse files Browse the repository at this point in the history
commit-id:69ba79bd
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 10, 2024
1 parent 863c7ad commit 6e16fe6
Showing 1 changed file with 16 additions and 2 deletions.
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

0 comments on commit 6e16fe6

Please sign in to comment.