Skip to content

Commit 0f05a0b

Browse files
committed
move file
1 parent 77ba43a commit 0f05a0b

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

apps/fortuna/src/chain.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub(crate) mod ethereum;
22
pub(crate) mod reader;
3-
pub(crate) mod utils;

apps/fortuna/src/chain/ethereum.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use {
1616
axum::async_trait,
1717
ethers::{
1818
abi::RawLog,
19-
contract::{abigen, ContractCall, EthLogDecode},
19+
contract::{abigen, EthLogDecode},
2020
core::types::Address,
2121
middleware::{gas_oracle::GasOracleMiddleware, SignerMiddleware},
2222
prelude::JsonRpcClient,
@@ -45,8 +45,6 @@ pub type SignablePythContractInner<T> = PythRandom<MiddlewaresWrapper<T>>;
4545
pub type SignablePythContract = SignablePythContractInner<Http>;
4646
pub type InstrumentedSignablePythContract = SignablePythContractInner<TracedClient>;
4747

48-
pub type PythContractCall = ContractCall<MiddlewaresWrapper<TracedClient>, ()>;
49-
5048
pub type PythContract = PythRandom<Provider<Http>>;
5149
pub type InstrumentedPythContract = PythRandom<Provider<TracedClient>>;
5250

apps/fortuna/src/eth_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pub mod eth_gas_oracle;
22
pub mod legacy_tx_middleware;
33
pub mod nonce_manager;
44
pub mod traced_client;
5+
pub mod utils;

apps/fortuna/src/chain/utils.rs renamed to apps/fortuna/src/eth_utils/utils.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use {
2-
crate::chain::ethereum::{InstrumentedSignablePythContract, PythContractCall},
32
anyhow::{anyhow, Result},
4-
ethers::middleware::Middleware,
3+
ethers::{contract::ContractCall, middleware::Middleware},
54
std::sync::Arc,
65
tracing,
76
};
87

9-
pub async fn send_and_confirm(contract_call: PythContractCall) -> Result<()> {
8+
pub async fn send_and_confirm<A: Middleware>(contract_call: ContractCall<A, ()>) -> Result<()> {
109
let call_name = contract_call.function.name.as_str();
1110
let pending_tx = contract_call
1211
.send()
@@ -39,13 +38,11 @@ pub async fn send_and_confirm(contract_call: PythContractCall) -> Result<()> {
3938
}
4039

4140
/// Estimate the cost (in wei) of a transaction consuming gas_used gas.
42-
pub async fn estimate_tx_cost(
43-
contract: Arc<InstrumentedSignablePythContract>,
41+
pub async fn estimate_tx_cost<T: Middleware + 'static>(
42+
middleware: Arc<T>,
4443
use_legacy_tx: bool,
4544
gas_used: u128,
4645
) -> Result<u128> {
47-
let middleware = contract.client();
48-
4946
let gas_price: u128 = if use_legacy_tx {
5047
middleware
5148
.get_gas_price()

apps/fortuna/src/keeper/commitment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use {
22
crate::{
33
api::BlockchainState, chain::ethereum::InstrumentedSignablePythContract,
4-
chain::utils::send_and_confirm, keeper::block::get_latest_safe_block,
4+
eth_utils::utils::send_and_confirm, keeper::block::get_latest_safe_block,
55
},
66
anyhow::{anyhow, Result},
77
std::sync::Arc,

apps/fortuna/src/keeper/fee.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use {
22
crate::{
33
api::BlockchainState, chain::ethereum::InstrumentedSignablePythContract,
4-
chain::utils::estimate_tx_cost, chain::utils::send_and_confirm, keeper::AccountLabel,
5-
keeper::ChainId, keeper::KeeperMetrics,
4+
eth_utils::utils::estimate_tx_cost, eth_utils::utils::send_and_confirm,
5+
keeper::AccountLabel, keeper::ChainId, keeper::KeeperMetrics,
66
},
77
anyhow::{anyhow, Result},
88
ethers::{
@@ -152,7 +152,8 @@ pub async fn adjust_fee_if_necessary(
152152
}
153153

154154
// Calculate target window for the on-chain fee.
155-
let max_callback_cost: u128 = estimate_tx_cost(contract.clone(), legacy_tx, gas_limit.into())
155+
let middleware = contract.client();
156+
let max_callback_cost: u128 = estimate_tx_cost(middleware, legacy_tx, gas_limit.into())
156157
.await
157158
.map_err(|e| anyhow!("Could not estimate transaction cost. error {:?}", e))?;
158159

0 commit comments

Comments
 (0)