fix(providers): don't default to "latest" block ID for `eth_estimateGas` (#1657)
* Don't default to 'latest' block ID for eth_estimateGas * Add changelog entry * Amend comment
This commit is contained in:
parent
78e406b261
commit
c568fd3934
|
@ -4,6 +4,7 @@
|
|||
|
||||
### Unreleased
|
||||
|
||||
- Stop defaulting to the `"latest"` block in `eth_estimateGas` params [#1657](https://github.com/gakonst/ethers-rs/pull/1657)
|
||||
- Fix geth trace types for debug_traceTransaction rpc
|
||||
- Fix RLP decoding of legacy `Transaction`
|
||||
- Fix RLP encoding of `TransactionReceipt` [#1661](https://github.com/gakonst/ethers-rs/pull/1661)
|
||||
|
|
|
@ -574,8 +574,14 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
|
|||
block: Option<BlockId>,
|
||||
) -> Result<U256, ProviderError> {
|
||||
let tx = utils::serialize(tx);
|
||||
let block = utils::serialize(&block.unwrap_or_else(|| BlockNumber::Latest.into()));
|
||||
self.request("eth_estimateGas", [tx, block]).await
|
||||
// Some nodes (e.g. old Optimism clients) don't support a block ID being passed as a param,
|
||||
// so refrain from defaulting to BlockNumber::Latest.
|
||||
let params = if let Some(block_id) = block {
|
||||
vec![tx, utils::serialize(&block_id)]
|
||||
} else {
|
||||
vec![tx]
|
||||
};
|
||||
self.request("eth_estimateGas", params).await
|
||||
}
|
||||
|
||||
async fn create_access_list(
|
||||
|
|
Loading…
Reference in New Issue