From ab60a5e7380a1c2dd86ccd0c1352d98a12203e99 Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Thu, 18 Nov 2021 19:56:31 +0100 Subject: [PATCH] add net_version call (#595) * add net_version call * add change log --- CHANGELOG.md | 1 + ethers-providers/src/lib.rs | 4 ++++ ethers-providers/src/provider.rs | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ec7dc1..d717b4b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) - 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. +- Add support for `net_version` RPC method. [595](https://github.com/gakonst/ethers-rs/pull/595) ### 0.5.3 diff --git a/ethers-providers/src/lib.rs b/ethers-providers/src/lib.rs index 4ae61897..3f2c6365 100644 --- a/ethers-providers/src/lib.rs +++ b/ethers-providers/src/lib.rs @@ -390,6 +390,10 @@ pub trait Middleware: Sync + Send + Debug { self.inner().get_chainid().await.map_err(FromErr::from) } + async fn get_net_version(&self) -> Result { + self.inner().get_net_version().await.map_err(FromErr::from) + } + async fn get_balance + Send + Sync>( &self, from: T, diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index 72125e53..0b3c2dc8 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -432,6 +432,11 @@ impl Middleware for Provider

{ self.request("eth_chainId", ()).await } + /// Returns the network version. + async fn get_net_version(&self) -> Result { + self.request("net_version", ()).await + } + ////// Contract Execution // // These are relatively low-level calls. The Contracts API should usually be used instead.