-
-
Notifications
You must be signed in to change notification settings - Fork 207
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!: addNewKeyring
returns metadata instead of keyring
#5372
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Owned files LGTM, thanks!
* @param keyring - The keyring instance to get the metadata for. | ||
* @returns The keyring metadata. | ||
*/ | ||
#getKeyringMetadata(keyring: unknown): KeyringMetadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm keeping this method as internal because consumers are not supposed to carry keyring instances around
keyring: SelectedKeyring; | ||
metadata: KeyringMetadata; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Explanation
This PR changes the return type of
addNewKeyring
to return a promise resolving inKeyringMetadata
instead of the keyring instance. The reason is that accessing keyring instances outside of KeyringController safeguards is considered unsafe.The
withKeyring
method signature has also been changed: the operation callback now will be called with{keyring: SelectedKeyring; metadata: KeyringMetadata }
instead ofSelectedKeyring
References
addNewKeyring
should not return the keyring instance #5371Changelog
@metamask/keyring-controller
addNewKeyring
method now returnsPromise<KeyringMetadata>
instead ofPromise<unknown>
(#5372)KeyringMetadata.id
to access the created keyring instance viawithKeyring
.withKeyring
method now requires a callback argument of type({ keyring: SelectedKeyring; metadata: KeyringMetadata }) => Promise<CallbackResult>
(#5372)@metamask/profile-sync-controller
Checklist