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

refactor: use generics on chain queries #260

Merged
merged 13 commits into from
Jun 18, 2020
Merged

Conversation

rflechtner
Copy link
Contributor

@rflechtner rflechtner commented Apr 29, 2020

fixes KILTProtocol/ticket#305

This adds generics to polkadot api calls for chain queries, which communicates the expected return type to our typescript code. It also removes the custom QueryResult type as a return type for chain queries which included null and undefined, which was simply not correct - queries will always return Codec types.

This also implements type checks at runtime for codec types provided to decoder methods, making sure that they are only used in appropriate contexts.

How to test:

Run integration tests with mashnet-node v 0.22 and a develop version

Checklist:

  • I have verified that the code works
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)

This commit is a very strict implementation that will not work with
mashnet-node v 0.22 and below and will not handle any other codec input
reimplemented support for decoding of tuple return types (0.22 and below)
@rflechtner rflechtner self-assigned this Apr 29, 2020
@rflechtner rflechtner added the ♻️ refactoring chore: refactoring label Apr 29, 2020
@rflechtner
Copy link
Contributor Author

Timo requested I open this for review and implement type checks on a separate ticket: https://github.com/KILTprotocol/ticket/issues/486

@rflechtner rflechtner marked this pull request as ready for review April 29, 2020 14:13
@rflechtner rflechtner requested a review from wischli April 29, 2020 14:13
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

I guess you already know that some stuff like the RootDelegationRecord or DelegationNodeRecord breaks stuff in the tests. Besides that, almost all of my complaints are towards the documentation (and really minor).

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

One tests needs fixing. Other than that, minor stuff.

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

LGTM

@rflechtner rflechtner merged commit 791206c into develop Jun 18, 2020
@rflechtner rflechtner deleted the rf-generics-on-queries branch June 18, 2020 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ refactoring chore: refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants