-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: finish removing unwraps #2881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
// use bech32::Error; | ||
use hyperlane_core::ChainCommunicationError; | ||
|
||
/// Errors from the crates specific to the hyperlane-cosmos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
@@ -0,0 +1,22 @@ | |||
// use bech32::Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rm
rust/hyperlane-core/src/error.rs
Outdated
@@ -6,6 +6,7 @@ use std::ops::Deref; | |||
use crate::config::StrOrIntParseError; | |||
use cosmrs::proto::prost; | |||
use cosmrs::Error as CosmrsError; | |||
// use fixed_hash::rustc_hex::FromHexError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rm
355c4a8
into
trevor/new-featv3-cosmos-oct-28
### Description - Removes unwraps and expects from everywhere but `run-locally` - Precomputes the `address` in `Signer` at construction time, to propagate the error early and keep signatures ergonomic by not requiring a `Result`. Couldn't also precompile `SigningKey` (the privkey type) because it's not `Sync` 😢 - Defines a `hyperlane-cosmos`-specific error enum (`HyperlaneCosmosError`), which can be converted to `ChainCommunicationError` with the `?` operator. This is a pattern we'd like to refactor towards in the future, to remove dependencies from `hyperlane-core` as much as possible - One inconvenience is that you need to `.map_err()` to `HyperlaneCosmosError` first, to use `?`. I wish `?` had deref coercion semantics where it'd keep covnerting until an error matches, but I assume this isn't possible because while you can only have a single `Deref` impl, you can have multiple `From<Err>` impls. - Writing this I'm realising we could write a small macro to implement `From<Err> for ChainCommunicationError` for all the sub-errors of `HyperlaneCosmosError` et al (cc @tkporter)
Description
run-locally
address
inSigner
at construction time, to propagate the error early and keep signatures ergonomic by not requiring aResult
. Couldn't also precompileSigningKey
(the privkey type) because it's notSync
😢hyperlane-cosmos
-specific error enum (HyperlaneCosmosError
), which can be converted toChainCommunicationError
with the?
operator. This is a pattern we'd like to refactor towards in the future, to remove dependencies fromhyperlane-core
as much as possible.map_err()
toHyperlaneCosmosError
first, to use?
. I wish?
had deref coercion semantics where it'd keep covnerting until an error matches, but I assume this isn't possible because while you can only have a singleDeref
impl, you can have multipleFrom<Err>
impls.From<Err> for ChainCommunicationError
for all the sub-errors ofHyperlaneCosmosError
et al (cc @tkporter)