Skip to content

Commit

Permalink
dev: rename StarknetConfig to KakarotConfig (#569)
Browse files Browse the repository at this point in the history
dev: rename `StarknetConfig` to `KakarotRpcConfig`

Co-authored-by: Harsh Bajpai <[email protected]>
  • Loading branch information
bajpai244 and Harsh Bajpai authored Sep 14, 2023
1 parent 549fbc9 commit f4ad2ab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions crates/core/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Network {

#[derive(Default, Clone)]
/// Configuration for the Starknet RPC client.
pub struct StarknetConfig {
pub struct KakarotRpcConfig {
/// Starknet network.
pub network: Network,
/// Kakarot contract address.
Expand All @@ -63,9 +63,9 @@ pub struct StarknetConfig {
pub proxy_account_class_hash: FieldElement,
}

impl StarknetConfig {
impl KakarotRpcConfig {
pub fn new(network: Network, kakarot_address: FieldElement, proxy_account_class_hash: FieldElement) -> Self {
StarknetConfig { network, kakarot_address, proxy_account_class_hash }
KakarotRpcConfig { network, kakarot_address, proxy_account_class_hash }
}

/// Create a new `StarknetConfig` from environment variables.
Expand Down Expand Up @@ -99,7 +99,7 @@ impl StarknetConfig {
))
})?;

Ok(StarknetConfig::new(network, kakarot_address, proxy_account_class_hash))
Ok(KakarotRpcConfig::new(network, kakarot_address, proxy_account_class_hash))
}
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl JsonRpcClientBuilder<HttpTransport> {
/// let starknet_provider: JsonRpcClient<HttpTransport> =
/// JsonRpcClientBuilder::with_http(&config).unwrap().build();
/// ```
pub fn with_http(config: &StarknetConfig) -> Result<Self> {
pub fn with_http(config: &KakarotRpcConfig) -> Result<Self> {
let url = config.network.provider_url()?;
let transport = HttpTransport::new(url);
Ok(Self::new(transport))
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use starknet::providers::{MaybeUnknownErrorCode, Provider, ProviderError, Starkn
use starknet::signers::LocalWallet;

use self::api::{KakarotEthApi, KakarotStarknetApi};
use self::config::{Network, StarknetConfig};
use self::config::{KakarotRpcConfig, Network};
use self::constants::gas::{BASE_FEE_PER_GAS, MAX_PRIORITY_FEE_PER_GAS, MINIMUM_GAS_FEE};
use self::constants::{
CHAIN_ID, CHUNK_SIZE_LIMIT, COUNTER_CALL_MAINNET, COUNTER_CALL_TESTNET1, COUNTER_CALL_TESTNET2,
Expand Down Expand Up @@ -71,11 +71,11 @@ pub struct KakarotClient<P: Provider + Send + Sync> {
impl<P: Provider + Send + Sync + 'static> KakarotClient<P> {
/// Create a new `KakarotClient`.
pub fn new(
starknet_config: StarknetConfig,
starknet_config: KakarotRpcConfig,
starknet_provider: Arc<P>,
starknet_account: SingleOwnerAccount<Arc<P>, LocalWallet>,
) -> Self {
let StarknetConfig { kakarot_address, proxy_account_class_hash, network } = starknet_config;
let KakarotRpcConfig { kakarot_address, proxy_account_class_hash, network } = starknet_config;

let kakarot_contract =
KakarotContract::new(Arc::clone(&starknet_provider), kakarot_address, proxy_account_class_hash);
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/mock/mock_starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use starknet_crypto::FieldElement;
use walkdir::WalkDir;

use super::constants::{KAKAROT_ADDRESS, KAKAROT_TESTNET_ADDRESS, PROXY_ACCOUNT_CLASS_HASH};
use crate::client::config::{Network, SequencerGatewayProviderBuilder, StarknetConfig};
use crate::client::config::{KakarotRpcConfig, Network, SequencerGatewayProviderBuilder};
use crate::client::KakarotClient;

/// A fixture for a Starknet RPC call.
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn mock_starknet_provider(fixtures: Option<Vec<StarknetRpcFixture>>) -> Json

pub fn init_testnet_client() -> KakarotClient<SequencerGatewayProvider> {
let kakarot_address = FieldElement::from_hex_be(KAKAROT_TESTNET_ADDRESS).unwrap();
let config = StarknetConfig::new(Network::Goerli1Gateway, kakarot_address, Default::default());
let config = KakarotRpcConfig::new(Network::Goerli1Gateway, kakarot_address, Default::default());

let provider = Arc::new(SequencerGatewayProviderBuilder::new(&Network::Goerli1Gateway).build());
let starknet_account = mock_account(provider.clone());
Expand All @@ -216,7 +216,7 @@ pub fn init_mock_client(
let starknet_provider = Arc::new(mock_starknet_provider(fixtures));
let starknet_account = mock_account(starknet_provider.clone());

let config = StarknetConfig::new(Network::Katana, *KAKAROT_ADDRESS, *PROXY_ACCOUNT_CLASS_HASH);
let config = KakarotRpcConfig::new(Network::Katana, *KAKAROT_ADDRESS, *PROXY_ACCOUNT_CLASS_HASH);

KakarotClient::new(config, starknet_provider, starknet_account)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/eth-rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use kakarot_rpc::config::RPCConfig;
use kakarot_rpc::rpc::KakarotRpcModuleBuilder;
use kakarot_rpc::run_server;
use kakarot_rpc_core::client::config::{
get_starknet_account_from_env, JsonRpcClientBuilder, Network, SequencerGatewayProviderBuilder, StarknetConfig,
get_starknet_account_from_env, JsonRpcClientBuilder, KakarotRpcConfig, Network, SequencerGatewayProviderBuilder,
};
use kakarot_rpc_core::client::KakarotClient;
use starknet::providers::jsonrpc::HttpTransport;
Expand All @@ -26,7 +26,7 @@ async fn main() -> Result<()> {
let filter = tracing_subscriber::EnvFilter::try_from_default_env()?;
tracing_subscriber::FmtSubscriber::builder().with_env_filter(filter).finish().try_init()?;

let starknet_config = StarknetConfig::from_env()?;
let starknet_config = KakarotRpcConfig::from_env()?;

let rpc_config = RPCConfig::from_env()?;

Expand Down
6 changes: 3 additions & 3 deletions crates/test-utils/src/deploy_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ethers::types::Address as EthersAddress;
use ethers_solc::artifacts::CompactContractBytecode;
use foundry_config::utils::{find_project_root_path, load_config};
use kakarot_rpc_core::client::api::KakarotStarknetApi;
use kakarot_rpc_core::client::config::{Network, StarknetConfig as StarknetClientConfig};
use kakarot_rpc_core::client::config::{KakarotRpcConfig, Network};
use kakarot_rpc_core::client::constants::{CHAIN_ID, DEPLOY_FEE, STARKNET_NATIVE_TOKEN};
use kakarot_rpc_core::client::waiter::TransactionWaiter;
use kakarot_rpc_core::client::KakarotClient;
Expand Down Expand Up @@ -699,7 +699,7 @@ impl KakarotTestEnvironmentContext {

// Create a Kakarot client
let kakarot_client = KakarotClient::new(
StarknetClientConfig::new(
KakarotRpcConfig::new(
Network::JsonRpcProvider(sequencer.url()),
kakarot.kakarot_address,
kakarot.proxy_class_hash,
Expand Down Expand Up @@ -813,7 +813,7 @@ impl KakarotTestEnvironmentContext {

// Create a Kakarot client
let kakarot_client = KakarotClient::new(
StarknetClientConfig::new(
KakarotRpcConfig::new(
Network::JsonRpcProvider(sequencer.url()),
kakarot.kakarot_address,
kakarot.proxy_class_hash,
Expand Down
4 changes: 2 additions & 2 deletions crates/test-utils/src/rpc_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use kakarot_rpc::config::RPCConfig;
use kakarot_rpc::rpc::KakarotRpcModuleBuilder;
use kakarot_rpc::run_server;
use kakarot_rpc_core::client::api::KakarotStarknetApi;
use kakarot_rpc_core::client::config::{Network, StarknetConfig};
use kakarot_rpc_core::client::config::{KakarotRpcConfig, Network};
use kakarot_rpc_core::client::KakarotClient;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::JsonRpcClient;
Expand Down Expand Up @@ -66,7 +66,7 @@ pub async fn start_kakarot_rpc_server(
let kakarot = kakarot_test_env.kakarot();

let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url())));
let starknet_config = StarknetConfig::new(
let starknet_config = KakarotRpcConfig::new(
Network::JsonRpcProvider(sequencer.url()),
kakarot.kakarot_address,
kakarot.proxy_class_hash,
Expand Down

0 comments on commit f4ad2ab

Please sign in to comment.