Skip to content

Conversation

soralit
Copy link
Contributor

@soralit soralit commented Jan 29, 2022

Add QR hardware support

Description

  • CHANGED:

    • Change signTypedMessage method to support QR hardware.
  • ADDED:

    • Add QR hardware Keyring
    • Add QR hardware's interactive methods, including read keyring, submit signature and related methods.

Checklist

  • Tests are included if applicable
  • Any added code is fully documented

@soralit soralit requested a review from a team as a code owner January 29, 2022 08:30
@soralit soralit force-pushed the integrate-keystone branch from d6ff421 to e0e5c41 Compare January 29, 2022 08:31
@soralit
Copy link
Contributor Author

soralit commented Jan 29, 2022

Hi @gantunesr , I will be on holidays next week, so I just raised this PR (which is not fully tested) to talk about the API definition and code style. Please have a look when you get time.

Besides, I have a question about signTypedMessage: Why not just use the signTypedMessage method in ETHKeyringController but exporting the account and sign messages in a raw way? I think all the keyring types have implemented signTypedData method.

@gantunesr
Copy link
Member

gantunesr commented Feb 3, 2022

Hey @soralit, to answer your question regarding signTypedMessage and the other devs in the team can correct me if needed. Looks like the reason was mainly about the standardization around the method and the controllers. I wasn't here at that moment, so I'm not really sure about the details.

@soralit soralit force-pushed the integrate-keystone branch 2 times, most recently from a2f53e8 to a6d13d4 Compare February 17, 2022 07:19
@soralit soralit changed the title [WIP]Support QR hardware Support QR hardware Feb 17, 2022
@soralit soralit force-pushed the integrate-keystone branch 2 times, most recently from fc75371 to 0e9d52b Compare February 23, 2022 10:34
@soralit soralit force-pushed the integrate-keystone branch 2 times, most recently from ca1cd1b to e5c0eef Compare March 1, 2022 11:14
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

I took a look at this PR. I am a bit wary of these changes because it feels like it expands the responsibilities of KeyringController in a way that doesn't feel quite right. After this change, there will be some methods that are designed to work with our Keyring objects, and there will be some methods that are designed to work with yours.

That said, we know that our existing keyring code could use work. In this case, it doesn't help that our keyring modules are untyped. We plan on addressing these and other concerns in future updates, so I'm okay with this now with the knowledge that these changes are fairly self-contained and that we have plans for improvement later.

With that in mind I made some suggestions for how we could improve this code.

@soralit soralit force-pushed the integrate-keystone branch from 44bbc2f to fab77d7 Compare March 11, 2022 12:02
@soralit
Copy link
Contributor Author

soralit commented Mar 11, 2022

Hi @mcmire , thanks for your review and comments. I will look into your suggestions and update the code ASAP.

@soralit soralit force-pushed the integrate-keystone branch from 54536d1 to f2a5777 Compare March 14, 2022 08:16
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Just a few more code improvement suggestions.

Crucially I noticed that there don't seem to be any unit tests for the new methods you've added to the controller. Would you be willing to add that to this file?

@soralit
Copy link
Contributor Author

soralit commented Mar 15, 2022

Hi @mcmire , thanks for your suggestions. I will append a commit to add unit tests later.

@soralit soralit force-pushed the integrate-keystone branch from 44521ff to b3e9b03 Compare March 16, 2022 13:21
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

A few more things. Also — would you mind adding return types to each method? I know TypeScript can fill these in automatically but I think it's better if we are explicit as 1) it forces the author to think about what the return type should be and 2) it removes one step for the reader to understand what the expected return type of the methods are.

@soralit soralit force-pushed the integrate-keystone branch from 1b59c55 to 8a2bd9e Compare March 17, 2022 16:05
@soralit
Copy link
Contributor Author

soralit commented Mar 17, 2022

Hi @mcmire , sorry for the late reply. I'm working on the bug fixing on mobile side these days. I just resolved the code issues and add types for new methods. I will append the unit tests tomorrow.

@soralit soralit force-pushed the integrate-keystone branch 2 times, most recently from 8f15b52 to ee0ef9e Compare March 18, 2022 12:20
@soralit
Copy link
Contributor Author

soralit commented Mar 18, 2022

Hi @mcmire , just update the unit tests and rebased the code, please have a review when you have time.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Just a few more minor things. Everything generally looks good to me otherwise (although I'll ping some other people to get some second opinions).

Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

I'm leaving some more comments to get the opinion of the other devs related to this development.

@gantunesr
Copy link
Member

@soralit looks like your PR is not meeting the code coverage requirement

Jest: "global" coverage threshold for functions (96%) not met: 95.94%

@mcmire
Copy link
Contributor

mcmire commented Mar 23, 2022

@gantunesr The existing coverage is very close to the threshold, so any small changes could send it over the edge. I agree we should double-check the test coverage but I have a PR here that should make this better: #736.

@soralit soralit force-pushed the integrate-keystone branch 3 times, most recently from 8b79c43 to 594eab9 Compare March 24, 2022 14:45
mcmire
mcmire previously approved these changes Mar 24, 2022
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Thanks for putting up with all of our comments! I'm quite happy with this. Nice work!

gantunesr
gantunesr previously approved these changes Mar 24, 2022
Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀 🚀

@soralit soralit dismissed stale reviews from gantunesr and mcmire via fa40eb3 March 25, 2022 02:03
@soralit soralit force-pushed the integrate-keystone branch from 594eab9 to fa40eb3 Compare March 25, 2022 02:03
@gantunesr gantunesr merged commit 7142251 into MetaMask:main Mar 25, 2022
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants