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

importAccountWithStrategy shouldn't select address #1309

Merged
merged 4 commits into from
May 5, 2023

Conversation

mikesposito
Copy link
Member

@mikesposito mikesposito commented May 3, 2023

Description

This PR refactors the importAccountWithStrategy method from KeyringController to not select the imported account.

As a new test case has been added, I took the chance to refactor tests groups for the importAccountWithStrategy.

Changes

  • CHANGED: KeyringController.importAccountWithStrategy to not select imported address

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@mikesposito mikesposito force-pushed the feat/1249-importaccountwithstrategy branch from 4644392 to d6a88a0 Compare May 3, 2023 11:53
@mikesposito mikesposito marked this pull request as ready for review May 3, 2023 11:54
@mikesposito mikesposito requested a review from a team as a code owner May 3, 2023 11:54
@mikesposito mikesposito changed the title importAccountWithStrategy shouldn't select address importAccountWithStrategy shouldn't select address May 3, 2023
).rejects.toThrow(
'Expected private key to be an Uint8Array with length 32',
);
it('should not select imported account', async () => {
Copy link
Member

@Gudahtt Gudahtt May 3, 2023

Choose a reason for hiding this comment

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

Nit: Should we repeat this test for the JSON input as well? Or maybe bring it to the top-level of the importAccountWithStrategy block to show that it's not expected to differ between strategies?

Copy link
Member Author

@mikesposito mikesposito May 3, 2023

Choose a reason for hiding this comment

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

Uhm, good point - I think it would make more sense to add it for the JSON input, rather than moving it to the top-level group because otherwise it would go along with:

  • using strategy privateKey
  • using strategy json
  • using unrecognized strategy

EDIT: Also, the actual test would be different, as we would use a different strategy - so I think it makes even more sense to repeat it for JSON

@mikesposito mikesposito force-pushed the feat/1249-importaccountwithstrategy branch from d6a88a0 to 78d3c40 Compare May 4, 2023 07:19
@mikesposito mikesposito force-pushed the feat/1249-importaccountwithstrategy branch from bee319d to edd0460 Compare May 4, 2023 09:52
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!

@mikesposito mikesposito merged commit 50d2c4f into main May 5, 2023
@mikesposito mikesposito deleted the feat/1249-importaccountwithstrategy branch May 5, 2023 07:57
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* feat: importAccountWithStrategy doesn't select new address

* test: add test case for json import
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* feat: importAccountWithStrategy doesn't select new address

* test: add test case for json import
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.

KeyringController: importAccountWithStrategy should not change selected account
2 participants