fix(examples): deprecated gas oracle (#1986)
This commit is contained in:
parent
a42cc9f63f
commit
4274a27531
|
@ -1,6 +1,10 @@
|
||||||
use ethers::{
|
use ethers::{
|
||||||
core::types::BlockNumber,
|
core::types::BlockNumber,
|
||||||
middleware::{gas_escalator::*, gas_oracle::*, *},
|
middleware::{
|
||||||
|
gas_escalator::{Frequency, GasEscalatorMiddleware, GeometricGasPrice},
|
||||||
|
gas_oracle::{GasNow, GasOracleMiddleware},
|
||||||
|
MiddlewareBuilder, NonceManagerMiddleware, SignerMiddleware,
|
||||||
|
},
|
||||||
providers::{Http, Middleware, Provider},
|
providers::{Http, Middleware, Provider},
|
||||||
signers::{LocalWallet, Signer},
|
signers::{LocalWallet, Signer},
|
||||||
};
|
};
|
||||||
|
@ -24,7 +28,7 @@ async fn builder_example() {
|
||||||
let signer = SIGNING_KEY.parse::<LocalWallet>().unwrap();
|
let signer = SIGNING_KEY.parse::<LocalWallet>().unwrap();
|
||||||
let address = signer.address();
|
let address = signer.address();
|
||||||
let escalator = GeometricGasPrice::new(1.125, 60_u64, None::<u64>);
|
let escalator = GeometricGasPrice::new(1.125, 60_u64, None::<u64>);
|
||||||
let gas_oracle = EthGasStation::new(None);
|
let gas_oracle = GasNow::new();
|
||||||
|
|
||||||
let provider = Provider::<Http>::try_from(RPC_URL)
|
let provider = Provider::<Http>::try_from(RPC_URL)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -48,7 +52,7 @@ async fn builder_example_raw_wrap() {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.wrap_into(|p| GasEscalatorMiddleware::new(p, escalator, Frequency::PerBlock))
|
.wrap_into(|p| GasEscalatorMiddleware::new(p, escalator, Frequency::PerBlock))
|
||||||
.wrap_into(|p| SignerMiddleware::new(p, signer))
|
.wrap_into(|p| SignerMiddleware::new(p, signer))
|
||||||
.wrap_into(|p| GasOracleMiddleware::new(p, EthGasStation::new(None)))
|
.wrap_into(|p| GasOracleMiddleware::new(p, GasNow::new()))
|
||||||
.wrap_into(|p| NonceManagerMiddleware::new(p, address)); // Outermost layer
|
.wrap_into(|p| NonceManagerMiddleware::new(p, address)); // Outermost layer
|
||||||
|
|
||||||
match provider.get_block(BlockNumber::Latest).await {
|
match provider.get_block(BlockNumber::Latest).await {
|
||||||
|
|
Loading…
Reference in New Issue