2023-02-24 20:36:00 +00:00
|
|
|
#![allow(clippy::extra_unused_type_parameters)]
|
|
|
|
#![cfg(not(target_arch = "wasm32"))]
|
|
|
|
|
2023-02-25 22:24:20 +00:00
|
|
|
use ethers_core::utils::{Anvil, AnvilInstance};
|
|
|
|
use ethers_providers::{Http, Provider, Ws};
|
|
|
|
use ethers_signers::{LocalWallet, Signer};
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2023-02-24 20:36:00 +00:00
|
|
|
mod builder;
|
|
|
|
|
|
|
|
mod gas_escalator;
|
|
|
|
|
|
|
|
mod gas_oracle;
|
|
|
|
|
2023-02-25 22:24:20 +00:00
|
|
|
// #[cfg(not(feature = "celo"))]
|
2023-02-24 20:36:00 +00:00
|
|
|
mod signer;
|
|
|
|
|
2023-02-25 22:24:20 +00:00
|
|
|
// #[cfg(not(feature = "celo"))]
|
2023-02-24 20:36:00 +00:00
|
|
|
mod nonce_manager;
|
|
|
|
|
2023-02-25 22:24:20 +00:00
|
|
|
// #[cfg(not(feature = "celo"))]
|
2023-02-24 20:36:00 +00:00
|
|
|
mod stack;
|
|
|
|
|
2023-02-25 22:24:20 +00:00
|
|
|
// #[cfg(not(feature = "celo"))]
|
2023-02-24 20:36:00 +00:00
|
|
|
mod transformer;
|
2023-02-25 22:24:20 +00:00
|
|
|
|
|
|
|
/// Spawns Anvil and instantiates an HTTP provider.
|
|
|
|
pub fn spawn_anvil() -> (Provider<Http>, AnvilInstance) {
|
|
|
|
let anvil = Anvil::new().spawn();
|
|
|
|
let provider = Provider::<Http>::try_from(anvil.endpoint())
|
|
|
|
.unwrap()
|
|
|
|
.interval(Duration::from_millis(10u64));
|
|
|
|
(provider, anvil)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Spawns Anvil and instantiates a WS provider.
|
|
|
|
pub async fn spawn_anvil_ws() -> (Provider<Ws>, AnvilInstance) {
|
|
|
|
let anvil = Anvil::new().spawn();
|
|
|
|
let provider = Provider::<Ws>::connect(anvil.ws_endpoint())
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.interval(Duration::from_millis(10u64));
|
|
|
|
(provider, anvil)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Gets `idx` wallet from the given anvil instance.
|
|
|
|
pub fn get_wallet(anvil: &AnvilInstance, idx: usize) -> LocalWallet {
|
|
|
|
LocalWallet::from(anvil.keys()[idx].clone()).with_chain_id(anvil.chain_id())
|
|
|
|
}
|