Skip to content

Commit efb6193

Browse files
committed
chore: improve code style
1 parent 5339e92 commit efb6193

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ name = "basic_transact"
3131

3232
[[example]]
3333
name = "fork_ref_transact"
34-
required-features = ["alloydb"]
34+
required-features = ["alloy-db"]
3535

3636
[dependencies]
3737
alloy = { version = "1.0.5", default-features = false, features = [
@@ -76,8 +76,7 @@ default = [
7676
"revm/secp256k1",
7777
]
7878

79-
alloydb = ["dep:tokio"]
80-
79+
alloy-db = ["dep:tokio"]
8180

8281
call = ["optional_eip3607", "optional_no_base_fee"]
8382

examples/fork_ref_transact.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use alloy::{
99
sol_types::SolCall,
1010
};
1111
use revm::{context::TxEnv, database::WrapDatabaseAsync};
12-
use trevm::{db::alloy::AlloyDB, revm::database::CacheDB, NoopBlock, NoopCfg, TrevmBuilder, Tx};
12+
use trevm::{db::alloy::AlloyDb, revm::database::CacheDB, NoopBlock, NoopCfg, TrevmBuilder, Tx};
1313

1414
sol! {
1515
#[allow(missing_docs)]
@@ -52,7 +52,7 @@ async fn main() -> eyre::Result<()> {
5252
// =========================================================== //
5353

5454
// initialize new AlloyDB
55-
let alloydb = WrapDatabaseAsync::new(AlloyDB::new(client, BlockId::default())).unwrap();
55+
let alloydb = WrapDatabaseAsync::new(AlloyDb::new(client, BlockId::default())).unwrap();
5656

5757
// initialise empty in-memory-db
5858
let cache_db = CacheDB::new(alloydb);

src/db/alloy.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
pub use alloy::eips::BlockId;
2-
use alloy::transports::TransportError;
31
use alloy::{
2+
eips::BlockId,
43
primitives::{StorageValue, U256},
54
providers::{
65
network::{primitives::HeaderResponse, BlockResponse},
76
Network, Provider,
87
},
8+
transports::TransportError,
99
};
1010
use core::error::Error;
11-
use revm::database_interface::{async_db::DatabaseAsyncRef, DBErrorMarker};
12-
use revm::primitives::{Address, B256};
13-
14-
use revm::state::{AccountInfo, Bytecode};
11+
use revm::{
12+
database_interface::{async_db::DatabaseAsyncRef, DBErrorMarker},
13+
primitives::{Address, B256},
14+
state::{AccountInfo, Bytecode},
15+
};
1516
use std::fmt::Display;
1617

1718
/// A type alias for the storage key used in the database.
@@ -43,15 +44,15 @@ impl From<TransportError> for DBTransportError {
4344
///
4445
/// When accessing the database, it'll use the given provider to fetch the corresponding account's data.
4546
#[derive(Debug)]
46-
pub struct AlloyDB<N: Network, P: Provider<N>> {
47+
pub struct AlloyDb<N: Network, P: Provider<N>> {
4748
/// The provider to fetch the data from.
4849
provider: P,
4950
/// The block number on which the queries will be based on.
5051
block_number: BlockId,
5152
_marker: core::marker::PhantomData<fn() -> N>,
5253
}
5354

54-
impl<N: Network, P: Provider<N>> AlloyDB<N, P> {
55+
impl<N: Network, P: Provider<N>> AlloyDb<N, P> {
5556
/// Creates a new AlloyDB instance, with a [Provider] and a block.
5657
pub fn new(provider: P, block_number: BlockId) -> Self {
5758
Self { provider, block_number, _marker: core::marker::PhantomData }
@@ -63,7 +64,7 @@ impl<N: Network, P: Provider<N>> AlloyDB<N, P> {
6364
}
6465
}
6566

66-
impl<N: Network, P: Provider<N>> DatabaseAsyncRef for AlloyDB<N, P> {
67+
impl<N: Network, P: Provider<N>> DatabaseAsyncRef for AlloyDb<N, P> {
6768
type Error = DBTransportError;
6869

6970
async fn basic_async_ref(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
@@ -117,7 +118,7 @@ mod tests {
117118
let client = ProviderBuilder::new().connect_http(
118119
"https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27".parse().unwrap(),
119120
);
120-
let alloydb = AlloyDB::new(client, BlockId::from(16148323));
121+
let alloydb = AlloyDb::new(client, BlockId::from(16148323));
121122
let wrapped_alloydb = WrapDatabaseAsync::new(alloydb).unwrap();
122123

123124
// ETH/USDT pair on Uniswap V2

src/db/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pub use traits::{ArcUpgradeError, CachingDb, StateAcc, TryCachingDb, TryStateAcc
1010
/// read. Intended to wrap some other caching database.
1111
pub mod cow;
1212

13-
#[cfg(feature = "alloydb")]
13+
#[cfg(feature = "alloy-db")]
1414
/// Alloy-powered revm Database implementation that fetches data over the network.
1515
pub mod alloy;

0 commit comments

Comments
 (0)