Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix(contract): support state overrides for gas estimation #967

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/contract/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,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