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

Add addNewAccountForKeyring method #1591

Merged
merged 3 commits into from
Aug 18, 2023
Merged

Conversation

mikesposito
Copy link
Member

@mikesposito mikesposito commented Aug 17, 2023

Explanation

This PR adds the addNewAccountForKeyring method to KeyringController, that can be used to add a new account for a specific keyring, which might not be the primary simple keyrings.

To align it with the addNewAccount method that works for primaryKeyring, also addNewAccountForKeyring expects an optional accountCount parameter to make the function idempotent.

This method is needed to migrate some controllers from @metamask/eth-keyring-controller to @metamask/keyring-controller.

References

Changelog

@metamask/keyring-controller

  • ADDED: Added addNewAccountForKeyring method

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

@mikesposito mikesposito requested a review from a team as a code owner August 17, 2023 10:01
const [primaryKeyring] = controller.getKeyringsByType(
KeyringTypes.hd,
) as Keyring<Json>[];
const addedAccountAddress =
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Typically we separate the test into sections separated by newlines (the sections being "arrange, act, assert" for the setup, code-under-test, and assertions respectively). These tests would be a bit easier to read if we had those newlines surrounding each of these calls under test

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!

@Gudahtt Gudahtt merged commit a1feb8b into main Aug 18, 2023
91 checks passed
@Gudahtt Gudahtt deleted the feat/add-account-for-keyring branch August 18, 2023 22:13
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
feat: add new account for keyring

Co-authored-by: Mark Stacey <[email protected]>
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
feat: add new account for keyring

Co-authored-by: Mark Stacey <[email protected]>
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.

2 participants