Sitelet https://github.com/njelich/examples/commit/27a56b15d48fea51861ae4e875d276252ab91118
Skip to content

Commit 27a56b1

Browse files
authored
chore: alloy 0.11 (alloy-rs#175)
* chore: bump alloy 0.11 * update reth db example * fmt * fix * fmt
1 parent 9db483f commit 27a56b1

32 files changed

Lines changed: 72 additions & 82 deletions

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ significant_drop_tightening = "allow"
9595
needless_return = "allow"
9696

9797
[workspace.dependencies]
98-
alloy = { version = "0.9", features = [
98+
alloy = { version = "0.11", features = [
9999
"eips",
100100
"full",
101101
"hyper",
@@ -113,7 +113,7 @@ alloy = { version = "0.9", features = [
113113
"signer-yubihsm",
114114
] }
115115

116-
foundry-fork-db = "0.10"
116+
foundry-fork-db = "0.11"
117117

118118
revm-primitives = "15.0"
119119
revm = "19.0"

‎examples/advanced/examples/any_network.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ async fn main() -> Result<()> {
4949

5050
// Create a provider with the Arbitrum Sepolia network and the wallet.
5151
let rpc_url = "https://sepolia-rollup.arbitrum.io/rpc".parse()?;
52-
let provider = ProviderBuilder::new()
53-
.with_recommended_fillers()
54-
.network::<AnyNetwork>()
55-
.wallet(wallet)
56-
.on_http(rpc_url);
52+
let provider = ProviderBuilder::new().network::<AnyNetwork>().wallet(wallet).on_http(rpc_url);
5753

5854
// Create a contract instance.
5955
let contract = Counter::new(COUNTER_CONTRACT_ADDRESS, &provider);

‎examples/advanced/examples/reth_db_provider.rs‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//!
1212
//! Learn more about `ProviderCall` [here](https://github.com/alloy-rs/alloy/pull/788).
1313
14-
use std::{marker::PhantomData, path::PathBuf, sync::Arc};
14+
use std::{path::PathBuf, sync::Arc};
1515

1616
use alloy::{
1717
eips::{BlockId, BlockNumberOrTag},
@@ -21,7 +21,7 @@ use alloy::{
2121
Provider, ProviderBuilder, ProviderCall, ProviderLayer, RootProvider, RpcWithBlock,
2222
},
2323
rpc::client::NoParams,
24-
transports::{Transport, TransportErrorKind},
24+
transports::TransportErrorKind,
2525
};
2626
use eyre::Result;
2727

@@ -96,12 +96,11 @@ async fn main() -> Result<()> {
9696
}
9797

9898
/// Implement the `ProviderLayer` trait for the `RethDBLayer` struct.
99-
impl<P, T> ProviderLayer<P, T> for RethDbLayer
99+
impl<P> ProviderLayer<P> for RethDbLayer
100100
where
101-
P: Provider<T>,
102-
T: Transport + Clone,
101+
P: Provider,
103102
{
104-
type Provider = RethDbProvider<P, T>;
103+
type Provider = RethDbProvider<P>;
105104

106105
fn layer(&self, inner: P) -> Self::Provider {
107106
RethDbProvider::new(inner, self.db_path().clone())
@@ -113,14 +112,13 @@ where
113112
/// It holds the `reth_provider::ProviderFactory` that enables read-only access to the database
114113
/// tables and static files.
115114
#[derive(Clone, Debug)]
116-
pub struct RethDbProvider<P, T> {
115+
pub struct RethDbProvider<P> {
117116
inner: P,
118117
db_path: PathBuf,
119118
provider_factory: DbAccessor,
120-
_pd: PhantomData<T>,
121119
}
122120

123-
impl<P, T> RethDbProvider<P, T> {
121+
impl<P> RethDbProvider<P> {
124122
/// Create a new `RethDbProvider` instance.
125123
pub fn new(inner: P, db_path: PathBuf) -> Self {
126124
let db = open_db_read_only(&db_path, Default::default()).unwrap();
@@ -134,7 +132,7 @@ impl<P, T> RethDbProvider<P, T> {
134132
let db_accessor: DbAccessor<
135133
ProviderFactory<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>,
136134
> = DbAccessor::new(provider_factory);
137-
Self { inner, db_path, provider_factory: db_accessor, _pd: PhantomData }
135+
Self { inner, db_path, provider_factory: db_accessor }
138136
}
139137

140138
const fn factory(&self) -> &DbAccessor {
@@ -150,17 +148,16 @@ impl<P, T> RethDbProvider<P, T> {
150148
/// Implement the `Provider` trait for the `RethDbProvider` struct.
151149
///
152150
/// This is where we override specific RPC methods to fetch from the reth-db.
153-
impl<P, T> Provider<T> for RethDbProvider<P, T>
151+
impl<P> Provider for RethDbProvider<P>
154152
where
155-
P: Provider<T>,
156-
T: Transport + Clone,
153+
P: Provider,
157154
{
158-
fn root(&self) -> &RootProvider<T> {
155+
fn root(&self) -> &RootProvider {
159156
self.inner.root()
160157
}
161158

162159
/// Override the `get_block_number` method to fetch the latest block number from the reth-db.
163-
fn get_block_number(&self) -> ProviderCall<T, NoParams, U64, u64> {
160+
fn get_block_number(&self) -> ProviderCall<NoParams, U64, u64> {
164161
let provider = self.factory().provider().map_err(TransportErrorKind::custom).unwrap();
165162

166163
let best = provider.best_block_number().map_err(TransportErrorKind::custom);
@@ -171,7 +168,7 @@ where
171168
/// Override the `get_transaction_count` method to fetch the transaction count of an address.
172169
///
173170
/// `RpcWithBlock` uses `ProviderCall` under the hood.
174-
fn get_transaction_count(&self, address: Address) -> RpcWithBlock<T, Address, U64, u64> {
171+
fn get_transaction_count(&self, address: Address) -> RpcWithBlock<Address, U64, u64> {
175172
let this = self.factory().clone();
176173
RpcWithBlock::new_provider(move |block_id| {
177174
let provider = this.provider_at(block_id).map_err(TransportErrorKind::custom).unwrap();

‎examples/contracts/examples/deploy_from_artifact.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sol!(
1616
async fn main() -> Result<()> {
1717
// Spin up a local Anvil node.
1818
// Ensure `anvil` is available in $PATH.
19-
let provider = ProviderBuilder::new().with_recommended_fillers().on_anvil_with_wallet();
19+
let provider = ProviderBuilder::new().on_anvil_with_wallet();
2020

2121
// Deploy the `Counter` contract.
2222
let contract = Counter::deploy(&provider).await?;

‎examples/contracts/examples/deploy_from_bytecode.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sol! {
3434
async fn main() -> Result<()> {
3535
// Spin up a local Anvil node.
3636
// Ensure `anvil` is available in $PATH.
37-
let provider = ProviderBuilder::new().with_recommended_fillers().on_anvil_with_wallet();
37+
let provider = ProviderBuilder::new().on_anvil_with_wallet();
3838

3939
// Deploy the `Counter` contract from bytecode at runtime.
4040
let bytecode = hex::decode(

‎examples/contracts/examples/deploy_from_contract.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sol! {
2626
async fn main() -> Result<()> {
2727
// Spin up a local Anvil node.
2828
// Ensure `anvil` is available in $PATH.
29-
let provider = ProviderBuilder::new().with_recommended_fillers().on_anvil_with_wallet();
29+
let provider = ProviderBuilder::new().on_anvil_with_wallet();
3030

3131
// Deploy the `Counter` contract.
3232
let contract = Counter::deploy(&provider).await?;

‎examples/contracts/examples/interact_with_abi.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn main() -> Result<()> {
1717
// Ensure `anvil` is available in $PATH.
1818
let rpc_url = "https://eth.merkle.io";
1919
let provider =
20-
ProviderBuilder::new().on_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url));
20+
ProviderBuilder::new().on_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?;
2121

2222
// Create a contract instance.
2323
let contract = IWETH9::new(address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), provider);

‎examples/contracts/examples/interact_with_contract_instance.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use eyre::Result;
1515
async fn main() -> Result<()> {
1616
// Spin up a local Anvil node.
1717
// Ensure `anvil` is available in $PATH.
18-
let provider = ProviderBuilder::new().with_recommended_fillers().on_anvil_with_wallet();
18+
let provider = ProviderBuilder::new().on_anvil_with_wallet();
1919

2020
// Deploy the `Counter` contract from bytecode at runtime.
2121
let bytecode = hex::decode(

‎examples/contracts/examples/unknown_return_types.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use eyre::Result;
1515
async fn main() -> Result<()> {
1616
// Spin up a local Anvil node.
1717
// Ensure `anvil` is available in $PATH.
18-
let provider = ProviderBuilder::new().with_recommended_fillers().on_anvil_with_wallet();
18+
let provider = ProviderBuilder::new().on_anvil_with_wallet();
1919

2020
// Get the first account from the wallet, Alice.
2121
let alice = provider.get_accounts().await?[0];

‎examples/fillers/examples/gas_filler.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use eyre::Result;
1313
async fn main() -> Result<()> {
1414
// Spin up a local Anvil node.
1515
// Ensure `anvil` is available in $PATH.
16-
let provider = ProviderBuilder::new()
16+
let provider = ProviderBuilder::default()
1717
// Add the `GasFiller` to the provider.
18-
// It is generally recommended to use the `.with_recommended_fillers()` method, which
19-
// includes the `GasFiller`.
18+
// It is generally recommended to use the recommended fillers which includes the GasFiller,
19+
// enabled by building the provider using ProviderBuilder::new().
2020
.with_gas_estimation()
2121
.on_anvil_with_wallet();
2222

0 commit comments

Comments
 (0)