-
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?
Changes from all commits
48f8b46
23a7c46
2adeb6b
0c083bb
6c8b880
12ffb4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Support asynchronous packet acknowledgements. | ||
([\#1392](https://github.com/cosmos/ibc-rs/pull/1392)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this under the |
||
methods, with the aim of contextually parsing `Signer` instances. | ||
([\#1393](https://github.com/cosmos/ibc-rs/pull/1393)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,14 @@ use ibc_core::primitives::Signer; | |
|
||
/// Methods required in token transfer validation, to be implemented by the host | ||
pub trait TokenTransferValidationContext { | ||
type AccountId: TryFrom<Signer>; | ||
/// Native chain account id. | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I suggest renaming these methods to |
||
|
||
/// Attempt to convert a [`Signer`] to a native chain receiver account. | ||
fn receiver_account_from_signer(&self, signer: &Signer) -> Option<Self::AccountId>; | ||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you update the return type to |
||
|
||
/// get_port returns the portID for the transfer module. | ||
fn get_port(&self) -> Result<PortId, HostError>; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,9 @@ where | |
|
||
let token = &msg.packet_data.token; | ||
|
||
let sender: TokenCtx::AccountId = msg | ||
.packet_data | ||
.sender | ||
.clone() | ||
.try_into() | ||
.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 commentThe reason will be displayed to describe this comment to others. Learn more. With the update requested in the other comment, this |
||
|
||
if is_sender_chain_source( | ||
msg.port_id_on_a.clone(), | ||
|
@@ -129,12 +126,9 @@ where | |
|
||
let token = &msg.packet_data.token; | ||
|
||
let sender = msg | ||
.packet_data | ||
.sender | ||
.clone() | ||
.try_into() | ||
.map_err(|_| TokenTransferError::FailedToParseAccount)?; | ||
let sender = token_ctx_a | ||
.sender_account_from_signer(&msg.packet_data.sender) | ||
.ok_or(TokenTransferError::FailedToParseAccount)?; | ||
|
||
if is_sender_chain_source( | ||
msg.port_id_on_a.clone(), | ||
|
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.