Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add missing jsdocs
  • Loading branch information
ccharly committed Dec 12, 2025
commit 81198db37e0e512a9df15e8f6470290de64a9533
5 changes: 0 additions & 5 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@
"count": 1
}
},
"packages/accounts-controller/src/AccountsController.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 2
}
},
"packages/address-book-controller/src/AddressBookController.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
Expand Down
15 changes: 13 additions & 2 deletions packages/accounts-controller/src/AccountsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
);
Copy link

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 #handleOnKeyringAccountRemoved method uses strict equality (===) to compare addresses, while the existing getAccountByAddress method 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 the KeyringController:accountRemoved event, the account lookup will fail silently and the account won't be removed from the state.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Address comparison uses strict equality instead of case-insensitive

The #handleOnKeyringAccountRemoved method uses strict equality (===) to compare addresses, but the codebase convention (seen in getAccountByAddress and utils.ts) uses case-insensitive comparison with .toLowerCase(). Ethereum addresses can be checksummed (mixed case) or lowercase, so if the KeyringController emits an address with different casing than what's stored in AccountsController, the account won't be found and won't be removed, leaving orphaned accounts in state.

Fix in Cursor Fix in Web

Expand Down
Loading