add net_version call (#595)

* add net_version call

* add change log
This commit is contained in:
Rohit Narurkar 2021-11-18 19:56:31 +01:00 committed by GitHub
parent 8a3ee415b7
commit ab60a5e738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,7 @@
- add a method on the `Middleware` to broadcast a tx with a series of escalating gas prices via [#566](https://github.com/gakonst/ethers-rs/pull/566) - add a method on the `Middleware` to broadcast a tx with a series of escalating gas prices via [#566](https://github.com/gakonst/ethers-rs/pull/566)
- Remove unnecessary `Serialize` constraint to `R` (the Response type) in the `request` method of `JsonRpcClient`. - Remove unnecessary `Serialize` constraint to `R` (the Response type) in the `request` method of `JsonRpcClient`.
- Fix `http Provider` data race when generating new request `id`s. - Fix `http Provider` data race when generating new request `id`s.
- Add support for `net_version` RPC method. [595](https://github.com/gakonst/ethers-rs/pull/595)
### 0.5.3 ### 0.5.3

View File

@ -390,6 +390,10 @@ pub trait Middleware: Sync + Send + Debug {
self.inner().get_chainid().await.map_err(FromErr::from) self.inner().get_chainid().await.map_err(FromErr::from)
} }
async fn get_net_version(&self) -> Result<U64, Self::Error> {
self.inner().get_net_version().await.map_err(FromErr::from)
}
async fn get_balance<T: Into<NameOrAddress> + Send + Sync>( async fn get_balance<T: Into<NameOrAddress> + Send + Sync>(
&self, &self,
from: T, from: T,

View File

@ -432,6 +432,11 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
self.request("eth_chainId", ()).await self.request("eth_chainId", ()).await
} }
/// Returns the network version.
async fn get_net_version(&self) -> Result<U64, ProviderError> {
self.request("net_version", ()).await
}
////// Contract Execution ////// Contract Execution
// //
// These are relatively low-level calls. The Contracts API should usually be used instead. // These are relatively low-level calls. The Contracts API should usually be used instead.