Skip to content

Commit

Permalink
update: removing EthProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Aug 18, 2024
1 parent a8f4bb1 commit 30e8584
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 7 additions & 11 deletions crates/settlement-clients/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ pub mod conversion;
mod tests;
pub mod types;

#[cfg(test)]
use {alloy::providers::RootProvider, alloy::transports::http::Http, reqwest::Client};

#[cfg(not(test))]
use types::EthHttpProvider;

pub const ENV_PRIVATE_KEY: &str = "ETHEREUM_PRIVATE_KEY";

lazy_static! {
Expand All @@ -71,14 +67,10 @@ pub struct EthereumSettlementClient {
core_contract_client: StarknetValidityContractClient,
wallet: EthereumWallet,
wallet_address: Address,
#[cfg(not(test))]
provider: Arc<EthHttpProvider>,
#[cfg(test)]
provider: RootProvider<Http<Client>>,
}

impl EthereumSettlementClient {
#[cfg(not(test))]
pub fn with_settings(settings: &impl SettingsProvider) -> Self {
let settlement_cfg: EthereumSettlementConfig = settings.get_settings(SETTLEMENT_SETTINGS_NAME).unwrap();

Expand All @@ -87,15 +79,19 @@ impl EthereumSettlementClient {
let wallet_address = signer.address();
let wallet = EthereumWallet::from(signer);

let provider = Arc::new(
ProviderBuilder::new().with_recommended_fillers().wallet(wallet.clone()).on_http(settlement_cfg.rpc_url),
let fill_provider = Arc::new(
ProviderBuilder::new()
.with_recommended_fillers()
.wallet(wallet.clone())
.on_http(settlement_cfg.rpc_url.clone()),
);
let provider = ProviderBuilder::new().on_http(settlement_cfg.rpc_url);
let core_contract_client = StarknetValidityContractClient::new(
Address::from_str(&settlement_cfg.core_contract_address)
.expect("Failed to convert the validity contract address.")
.0
.into(),
provider.clone(),
fill_provider.clone(),
);

EthereumSettlementClient { provider, core_contract_client, wallet, wallet_address }
Expand Down
4 changes: 3 additions & 1 deletion crates/settlement-clients/ethereum/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ async fn get_last_settled_block_typical_works(#[case] fork_block_no: u64) {
dotenvy::from_filename(&*ENV_FILE_PATH).expect("Could not load .env.test file.");
env::set_var("DEFAULT_SETTLEMENT_CLIENT_RPC", &*ETH_RPC);

let TestSetup { anvil: _, ethereum_settlement_client, provider: _ } = setup_ethereum_test(fork_block_no);
let TestSetup { anvil, ethereum_settlement_client, provider: _ } = setup_ethereum_test(fork_block_no);

println!("{:?}", anvil);

let _ = ethereum_settlement_client.get_last_settled_block().await.expect("Could not get last settled block.");
}
Expand Down

0 comments on commit 30e8584

Please sign in to comment.