-
-
Notifications
You must be signed in to change notification settings - Fork 256
feat: add KeyringController:accountAdded event + use keyring events in AccountsController
#7328
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
3fe4986
b4700b2
537e318
e137a0b
1a2a27c
e6eaaa1
98c92c6
fe85881
cab3f12
fda91cd
f7f52ce
5fee36e
54d6e16
a5c5f5d
81198db
5009b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -754,7 +754,13 @@ export class AccountsController extends BaseController< | |
| this.messenger.publish(event, ...payload); | ||
| } | ||
|
|
||
| #handleOnKeyringAccountAdded(address: string, keyring: KeyringObject) { | ||
| /** | ||
| * Handle the addition of a new account in a keyring. | ||
| * | ||
| * @param address - The address of the new account. | ||
| * @param keyring - The keyring object of that new account. | ||
| */ | ||
| #handleOnKeyringAccountAdded(address: string, keyring: KeyringObject): void { | ||
| let account = this.#getInternalAccountFromAddressAndType(address, keyring); | ||
| if (account) { | ||
| // Re-compute the list of accounts everytime, so we can make sure new names | ||
|
|
@@ -799,7 +805,12 @@ export class AccountsController extends BaseController< | |
| } | ||
| } | ||
|
|
||
| #handleOnKeyringAccountRemoved(address: string) { | ||
| /** | ||
| * Handle the removal of an existing account from a keyring. | ||
| * | ||
| * @param address - The address of the new account. | ||
| */ | ||
| #handleOnKeyringAccountRemoved(address: string): void { | ||
| const account = this.listMultichainAccounts().find( | ||
| ({ address: accountAddress }) => accountAddress === address, | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Address comparison uses strict equality instead of case-insensitiveThe |
||
|
|
||
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.
Bug: Case-sensitive address comparison may fail to find accounts
The
#handleOnKeyringAccountRemovedmethod uses strict equality (===) to compare addresses, while the existinggetAccountByAddressmethod uses case-insensitive comparison with.toLowerCase()on both sides. Ethereum addresses can exist in different case formats (checksummed vs lowercase), so if there's any inconsistency in how addresses are stored versus how they're received from theKeyringController:accountRemovedevent, the account lookup will fail silently and the account won't be removed from the state.