-
Notifications
You must be signed in to change notification settings - Fork 94
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
Signer parsing from context #1393
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1393 +/- ##
==========================================
- Coverage 67.09% 67.06% -0.04%
==========================================
Files 226 226
Lines 22425 22483 +58
==========================================
+ Hits 15047 15079 +32
- Misses 7378 7404 +26 ☔ View full report in Codecov by Sentry. |
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.
Thanks for splitting out this PR! Please take a look at the comments. Additionally:
- Update the PR with the main branch.
- Apply the same changes to the
pub trait NftTransferValidationContext {
/// Attempt to convert a [`Signer`] to a native chain sender account. | ||
fn sender_account_from_signer(&self, signer: &Signer) -> Option<Self::AccountId>; | ||
|
||
/// Attempt to convert a [`Signer`] to a native chain receiver account. | ||
fn receiver_account_from_signer(&self, signer: &Signer) -> Option<Self::AccountId>; |
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.
Can you update the return type to Result<Self::AccountId, HostError>
? It’d keep it consistent with our other APIs. Since the account ID isn’t always derivable from the signer, and ibc-rs
typically propagates errors originating from the host boundary as HostError
, it makes more sense to classify it this way. This also gives hosts the flexibility to include contextual information in the error, which ibc-rs
can then pass along.
(This PR seems like a good move from this perspective too.)
type AccountId; | ||
|
||
/// Attempt to convert a [`Signer`] to a native chain sender account. | ||
fn sender_account_from_signer(&self, signer: &Signer) -> Option<Self::AccountId>; |
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.
I suggest renaming these methods to sender_account
and receiver_account
. The Signer
type is currently used for account-like fields everywhere in ibc-rs
, but it actually need improvement later since it can be confusing. As you can see, the sender and receiver aren’t actually signers here. So, I'm suggesting to avoid breaking the API naming in the future. Even the args can be updated to sender
and receiver
.
.map_err(|_| TokenTransferError::FailedToParseAccount)?; | ||
let sender = token_ctx_a | ||
.sender_account_from_signer(&msg.packet_data.sender) | ||
.ok_or(TokenTransferError::FailedToParseAccount)?; |
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.
With the update requested in the other comment, this FailedToParseAccount
variant can completely be removed.
@@ -0,0 +1,3 @@ | |||
- Replace the `TryFrom<Signer>` bound on `AccountId` with new context |
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.
- Replace the `TryFrom<Signer>` bound on `AccountId` with new context | |
- [ibc-apps] Replace the `TryFrom<Signer>` bound on `AccountId` with new context |
@@ -0,0 +1,3 @@ | |||
- Replace the `TryFrom<Signer>` bound on `AccountId` with new context |
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.
Let's put this under the /unreleased/breaking-changes/
directory.
Based on #1392
Diff: https://github.com/heliaxdev/cosmos-ibc-rs/compare/heliaxdev:cosmos-ibc-rs:tiago/optional-ack-rebased..heliaxdev:cosmos-ibc-rs:tiago/signer-parsing-from-ctx
Description
This PR replaces the
TryFrom<Signer>
bound onAccountId
with new context methods, with the aim of contextually parsingSigner
instances.(Some context: #1392 (comment))
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.