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

fix: refactor ibc-derive to handle context with generic types and projects dependent on ibc-core #1037

Merged
merged 8 commits into from
Jan 12, 2024

Conversation

Farhad-Shabani
Copy link
Member

Closes: #910
Closes: #999


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).

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (8a552f7) 71.21% compared to head (59b01a7) 71.36%.
Report is 1 commits behind head on main.

Files Patch % Lines
ibc-derive/src/client_state.rs 74.71% 22 Missing ⚠️
ibc-derive/src/lib.rs 73.91% 6 Missing ⚠️
ibc-derive/src/utils.rs 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
+ Coverage   71.21%   71.36%   +0.14%     
==========================================
  Files         178      178              
  Lines       18198    18352     +154     
==========================================
+ Hits        12959    13096     +137     
- Misses       5239     5256      +17     

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

@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review January 10, 2024 07:31
@Farhad-Shabani Farhad-Shabani changed the title fix: refactor ibc-derive to handle context with generic types and project dependent on ibc-core fix: refactor ibc-derive to handle context with generic types and projects dependent on ibc-core Jan 10, 2024
Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

really awesome PR @Farhad-Shabani ! Really like the solution. 👍

I asked for some clarifications in the comments.

ibc-derive/src/utils.rs Outdated Show resolved Hide resolved
ibc-derive/src/client_state.rs Outdated Show resolved Hide resolved
ibc-derive/src/lib.rs Outdated Show resolved Hide resolved
@rnbguy
Copy link
Collaborator

rnbguy commented Jan 10, 2024

If I have a context with trait-bounded generics as following:

struct MyIbcContext<T: MyTrait> { ... }

How do I the trait-bound its generics while deriving IbcClientState? The following doesn't work.

#[derive(IbcClientState)]
#[validation(MyIbcContext<T: MyTrait>)]
#[execution(MyIbcContext<T: MyTrait>)]
enum AnyClientState { ... }

@Farhad-Shabani
Copy link
Member Author

How do I the trait-bound its generics while deriving IbcClientState? The following doesn't work.

What about this?

#[derive(IbcClientState)]
 #[validation(MyIbcContext<T>)]
 #[execution(MyIbcContext<T>)]
 enum AnyClientState { ... }

@rnbguy
Copy link
Collaborator

rnbguy commented Jan 10, 2024

The trait bounds are needed when we are deriving the ClientState{Validation, Execution} 😅

@Farhad-Shabani
Copy link
Member Author

The trait bounds are needed when we are deriving the ClientState{Validation, Execution} 😅

Ahh, that's right. That's a new case!

Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Thanks @Farhad-Shabani ! Looks awesome. Great work 🎉

@Farhad-Shabani Farhad-Shabani added this to the 0.50.0 milestone Jan 12, 2024
@Farhad-Shabani Farhad-Shabani merged commit fcc8c57 into main Jan 12, 2024
15 checks passed
@Farhad-Shabani Farhad-Shabani deleted the farhad/refactor-client-state-derive branch January 12, 2024 02:17
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
…rojects dependent on `ibc-core` (#1037)

* fix: refactor ibc-derive to support broader cases

* fix: cargo doc

* imp: define get_impl_quote

* imp: move each set of derives to the related meta-crate

* imp: refactor ClientState drive to work with generics with trait-bounds

* fix: remove redundant derive feature

* docs: improve derive docstrings

* imp: define SupportedCrate enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants