-
Notifications
You must be signed in to change notification settings - Fork 101
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
[r2r] Implement methods used in recover_funds_of_swap for Tendermint. #1527
Conversation
Also implemented validate_address. Add dummy error return for others to avoid occasional panics.
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.
LGTM!
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.
Great work. Just couple non-blocker suggestions.
let request = GetTxsEventRequest { | ||
events: vec![events_string], | ||
pagination: None, | ||
order_by: 0, |
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.
TendermintResultOrder::Ascending
can be used here.
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.
@ozkanonur I got expected i32, found enum cosmrs::tendermint_rpc::Order
error when tried to use it. TendermintResultOrder
is used in tx_search
and block_search
, but not for GetTxsEventRequest
.
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.
TendermintResultOrder::Ascending
I thught they implemented into
for numbers. I will create new Order
enum which implements TendermintResultOrder
type and also can convert to i32
. Since this PR is P0 I will do this refactoring on my side.
match AccountId::from_str(address) { | ||
Ok(account) => { | ||
if account.prefix() == self.account_prefix { | ||
ValidateAddressResult { | ||
is_valid: true, | ||
reason: None, | ||
} | ||
} else { | ||
ValidateAddressResult { | ||
is_valid: false, | ||
reason: Some(format!( | ||
"Expected {} account prefix, got {}", | ||
self.account_prefix, | ||
account.prefix() | ||
)), | ||
} | ||
} | ||
}, | ||
Err(e) => ValidateAddressResult { | ||
is_valid: false, | ||
reason: Some(e.to_string()), | ||
}, | ||
} |
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.
Less nested version:
match AccountId::from_str(address) {
Ok(account) if account.prefix() != self.account_prefix => ValidateAddressResult {
is_valid: false,
reason: Some(format!(
"Expected {} account prefix, got {}",
self.account_prefix,
account.prefix()
)),
},
Ok(_) => ValidateAddressResult {
is_valid: true,
reason: None,
},
Err(e) => ValidateAddressResult {
is_valid: false,
reason: Some(e.to_string()),
},
}
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.
@ozkanonur Done, thanks for the note!
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.
Great!
Also implemented validate_address.
Add dummy error return for others to avoid occasional panics.
#1432
This is one more P0 required for the upcoming WebDEX release.