Skip to content

Conversation

@dawnseeker8
Copy link
Contributor

@dawnseeker8 dawnseeker8 commented May 6, 2024

This PR apply patch code from this PR to keyringController to fix the issue found in this issue

References

PR 23903
Fix Issue 23804

Changelog

@metamask/keyring-controlller

  • Fixed: Fix creation of new QR keyrings
    • Previously the QR keyring would get initialized with invalid state when created for the first time

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@dawnseeker8 dawnseeker8 requested a review from a team May 6, 2024 07:51
@dawnseeker8 dawnseeker8 added team-wallet-framework Deprecated: Please use `team-core-platform` instead. needs-dev-review labels May 6, 2024
@Gudahtt
Copy link
Member

Gudahtt commented May 6, 2024

Thanks, the diff looks good! Had some questions about the changelog entry though.

It seems like this fixes a bug, but there is no description of what that bug is at the controller API level. The linked issue only shows the bug's impact upon the extension. Could you clarify, does this code prevent a crash? Or does the QR Keyring get instantiated correctly, but then crash later at runtime? Or does it get instantiated correctly and never crash, but fails to initialize?

We can omit the signature change to #newKeyring from the changelog; we typically only list public-facing changes, not internal changes.

@dawnseeker8
Copy link
Contributor Author

Thanks, the diff looks good! Had some questions about the changelog entry though.

It seems like this fixes a bug, but there is no description of what that bug is at the controller API level. The linked issue only shows the bug's impact upon the extension. Could you clarify, does this code prevent a crash? Or does the QR Keyring get instantiated correctly, but then crash later at runtime? Or does it get instantiated correctly and never crash, but fails to initialize?

We can omit the signature change to #newKeyring from the changelog; we typically only list public-facing changes, not internal changes.

Hi, Mark, following is the bug detail from controller API level.

  1. in the keyringController.#addQRKeyring() method, this function will be called when user want to import a QR account to metamask in mobile or extension app.

  2. The #addQRKeyring() put a empty accounts array as extra argument to #newKeyring() method. this extra argument will be used in line 2004 in #newKeyring() method

       await keyring.deserialize(data);
  3. if you look at the @keystonehq/base-eth-keyring BaseKeyring file, Their deserialize(opts) function

  deserialize(opts) {
    if (opts) {
      //common props;
      this.accounts = opts.accounts;
      this.currentAccount = opts.currentAccount;
      this.page = opts.page;
      this.perPage = opts.perPage;
      this.name = opts.name;
      this.initialized = opts.initialized;
      this.keyringMode = opts.keyringMode || KEYRING_MODE.hd;
      this.keyringAccount = opts.keyringAccount || KEYRING_ACCOUNT.standard;
      this.xfp = opts.xfp; //hd props;

      this.xpub = opts.xpub;
      this.hdPath = opts.hdPath;
      this.indexes = opts.indexes;
      this.paths = opts.paths;
      this.childrenPath = opts.childrenPath || DEFAULT_CHILDREN_PATH;
    }
  }

The empty accounts array will set the keystone QR keyring all the default properties to undefined except for accounts which will be empty array. this change will cause a lot of functions of keystone QR break due to default properties have been overrided by bug.

@Gudahtt
Copy link
Member

Gudahtt commented May 7, 2024

OK, I have updated the PR description with this change entry:

  • Fixed: Fix creation of new QR keyrings
    • Previously the QR keyring would get initialized with invalid state when created for the first time

Does that sound right? That was my interpretation of your explanation, considering that this entry is written for users of the package who don't understand the internals.

@dawnseeker8
Copy link
Contributor Author

OK, I have updated the PR description with this change entry:

  • Fixed: Fix creation of new QR keyrings

    • Previously the QR keyring would get initialized with invalid state when created for the first time

Does that sound right? That was my interpretation of your explanation, considering that this entry is written for users of the package who don't understand the internals.

yea, your explanation is better. :)

@Gudahtt
Copy link
Member

Gudahtt commented May 7, 2024

Thanks for confirming that it was accurate!

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@dawnseeker8 dawnseeker8 merged commit ee543fa into main May 7, 2024
@dawnseeker8 dawnseeker8 deleted the feat/keyring-controller-patch-for-23804 branch May 7, 2024 13:29
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Sep 18, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

We recently removed `eth_sign` operations from extension:
MetaMask/metamask-extension#24756
This PR aims to remove `eth_sign` and all related components from
mobile. Also updates `@metamask/signature-controller@17.0.0`.

### Notes
- Removes `keyring-controller` patch ([patch
branch](MetaMask/core@main...keyring-controller-v16-patch))
because it's already addressed in `@metamask/keyring-controller@16.1.0`
[here](MetaMask/core#4256) .

## **Related issues**

Fixes: N/A

## **Manual testing steps**

1. Go to the [e2e test dapp] in-app browser
(https://metamask.github.io/test-dapp/)
2. Connect the wallet
3. Scroll down to the `Eth Sign` card
(https://metamask.github.io/test-dapp/#ethSign)
4. Click `Sign`
5. You should see `Error: The method "eth_sign" does not exist / is not
available.`

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

N/A

<!-- [screenshots/recordings] -->

### **After**

N/A

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [X] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [X] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [X] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [X] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-dev-review team-wallet-framework Deprecated: Please use `team-core-platform` instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hardware wallet QR connection unsuccessful

3 participants