Skip to content
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

imp(02-client): implement TryFrom<TmAbciEvent> for event types #1253

Merged
merged 18 commits into from
Jun 25, 2024

Conversation

TropicalDog17
Copy link
Contributor

@TropicalDog17 TropicalDog17 commented Jun 10, 2024

Partially addresses: #1220

Description


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@TropicalDog17
Copy link
Contributor Author

Hey @rnbguy, could you please review my implementation of CreateClient. Before I do the others, I want to make sure I'm on the right track. Thanks.

Comment on lines 294 to 304
fn parse_attribute_value<T>(
attribute: &abci::EventAttribute,
f: impl FnOnce(&str) -> Result<T, ClientError>,
) -> Result<T, ClientError> {
match attribute.value_str() {
Ok(value) => f(value),
Err(_) => Err(ClientError::Other {
description: "Invalid attribute value".to_string(),
}),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use .map(|value| ...).map_err(|_| ClientError::Other { ... }) directly.

ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
@TropicalDog17 TropicalDog17 changed the title imp: implement TryFrom<TmAbciEvent> for event types imp(02-client): implement TryFrom<TmAbciEvent> for event types Jun 11, 2024
@TropicalDog17 TropicalDog17 marked this pull request as ready for review June 11, 2024 06:25
@TropicalDog17 TropicalDog17 requested a review from rnbguy June 11, 2024 06:25
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 80.14706% with 54 lines in your changes missing coverage. Please review.

Project coverage is 67.42%. Comparing base (5dc0b09) to head (7a00527).
Report is 3 commits behind head on main.

Files Patch % Lines
ibc-core/ics02-client/types/src/events.rs 80.14% 54 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1253      +/-   ##
==========================================
+ Coverage   67.27%   67.42%   +0.14%     
==========================================
  Files         235      235              
  Lines       23538    23811     +273     
==========================================
+ Hits        15836    16055     +219     
- Misses       7702     7756      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seanchen1991
Copy link
Contributor

Hey @TropicalDog17, looks like there are a bunch of clippy errors that need addressing. Could you handle those before we circle back for a review on this? 🙏

Comment on lines 229 to 230
// impl TryFrom<abci::EventAttribute> for ConsensusHeightsAttribute {
// type Error = ClientError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these commented-out lines

ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
ibc-core/ics02-client/types/src/events.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@seanchen1991 seanchen1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny nit, but otherwise it looks good to me 👍
Thanks for wrapping up this PR @TropicalDog17!

ibc-core/ics02-client/types/src/events.rs Show resolved Hide resolved
@seanchen1991 seanchen1991 added this pull request to the merge queue Jun 25, 2024
Merged via the queue into cosmos:main with commit 7ff41b3 Jun 25, 2024
18 checks passed
@TropicalDog17 TropicalDog17 deleted the feat/tryfrom-abcievent branch June 25, 2024 16:13
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
* add tryfrom for CreateClient event

* add try from for other event and attribute

* use ClientError::MissingAttributeKey

* refactor error type

* add tests

* linting, refactor complex type

* lint

* refactor

* lint

* refactor

* add newline

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants