Skip to content

Commit

Permalink
hotfix(contract): support state overrides for gas estimation (alloy-r…
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinson authored and ben186 committed Jul 27, 2024
1 parent 2f732f1 commit 6119848
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/contract/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,13 @@ impl<T: Transport + Clone, P: Provider<T, N>, D: CallDecoder, N: Network> CallBu
}

/// Returns the estimated gas cost for the underlying transaction to be executed
/// If [`state overrides`](Self::state) are set, they will be applied to the gas estimation.
pub async fn estimate_gas(&self) -> Result<u128> {
self.provider.estimate_gas(&self.request).block(self.block).await.map_err(Into::into)
let mut estimate = self.provider.estimate_gas(&self.request);
if let Some(state) = &self.state {
estimate = estimate.overrides(state);
}
estimate.block(self.block).await.map_err(Into::into)
}

/// Queries the blockchain via an `eth_call` without submitting a transaction to the network.
Expand Down

0 comments on commit 6119848

Please sign in to comment.