feature: providererror conversion to middleware error (#1920)
* feature: providererror conversion to middleware error * chore: update changelog
This commit is contained in:
parent
5af2800f15
commit
d6fea13d23
|
@ -3,6 +3,7 @@
|
|||
## ethers-core
|
||||
|
||||
### Unreleased
|
||||
|
||||
- Graceful handling of WebSocket transport errors [#1889](https://github.com/gakonst/ethers-rs/issues/1889) [#1815](https://github.com/gakonst/ethers-rs/issues/1815)
|
||||
- `MiddlewareBuilder` trait to instantiate a `Provider` as `Middleware` layers.
|
||||
- An `Event` builder can be instantiated specifying the event filter type, without the need to instantiate a contract.
|
||||
|
@ -105,6 +106,7 @@
|
|||
## ethers-contract-abigen
|
||||
|
||||
### Unreleased
|
||||
|
||||
- Fix Cargo.toml generation issue that could cause dependency conflicts [#1852](https://github.com/gakonst/ethers-rs/pull/1852)
|
||||
- Use corresponding rust structs for event fields if they're solidity structs [#1674](https://github.com/gakonst/ethers-rs/pull/1674)
|
||||
- Add `ContractFilter` to filter contracts in `MultiAbigen` [#1564](https://github.com/gakonst/ethers-rs/pull/1564)
|
||||
|
@ -222,6 +224,8 @@
|
|||
|
||||
### Unreleased
|
||||
|
||||
- Convert provider errors to arbitrary middleware errors
|
||||
[#1920](https://github.com/gakonst/ethers-rs/pull/1920)
|
||||
- Add a subset of the `admin` namespace
|
||||
[1880](https://github.com/gakonst/ethers-rs/pull/1880)
|
||||
- Return String for net version
|
||||
|
|
|
@ -159,6 +159,13 @@ pub trait Middleware: Sync + Send + Debug {
|
|||
/// The next middleware in the stack
|
||||
fn inner(&self) -> &Self::Inner;
|
||||
|
||||
/// Convert a provider error into the associated error type by successively
|
||||
/// converting it to every intermediate middleware error
|
||||
fn convert_err(p: ProviderError) -> Self::Error {
|
||||
let e = <Self as Middleware>::Inner::convert_err(p);
|
||||
FromErr::from(e)
|
||||
}
|
||||
|
||||
/// The HTTP or Websocket provider.
|
||||
fn provider(&self) -> &Provider<Self::Provider> {
|
||||
self.inner().provider()
|
||||
|
|
|
@ -304,6 +304,11 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
|
|||
self
|
||||
}
|
||||
|
||||
fn convert_err(p: ProviderError) -> Self::Error {
|
||||
// no conversion necessary
|
||||
p
|
||||
}
|
||||
|
||||
fn default_sender(&self) -> Option<Address> {
|
||||
self.from
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue