Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

add net_version call #595

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions ethers-providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<U64, Self::Error> {
self.inner().get_net_version().await.map_err(FromErr::from)
}

async fn get_balance<T: Into<NameOrAddress> + Send + Sync>(
&self,
from: T,
Expand Down
5 changes: 5 additions & 0 deletions ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
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
//
// These are relatively low-level calls. The Contracts API should usually be used instead.
Expand Down