diff --git a/crates/starknet_gateway/src/config.rs b/crates/starknet_gateway/src/config.rs index f0e02aee90..2ce2c97654 100644 --- a/crates/starknet_gateway/src/config.rs +++ b/crates/starknet_gateway/src/config.rs @@ -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, @@ -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()) } }