Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ccharly
Copy link
Contributor

@ccharly ccharly commented Dec 8, 2025

Explanation

Fix existing lint errors (since the introduction of the new linting configuration).

Those are the bare minimum required to avoid having a failing CI for any new change to this controller.

References

N/A

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 communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Fixes lint/type issues across KeyringController (explicit return types, nullish coalescing, tuple typing, safer conversions) and adds/export KeyringBuilder type; updates changelog and ESLint suppressions.

  • Keyring Controller (packages/keyring-controller/src/KeyringController.ts):
    • Types/Lint: Add explicit return types to various methods (e.g., createNewVaultAndKeychain, verifyPassword, signPersonalMessage, private helpers); use ?? instead of ||; refine error variable names; ensure await ordering and tuple typing (as const); adjust indices with ?? 0.
    • Types: Import Keyring and add/export new KeyringBuilder type; update keyringBuilderFactory to return KeyringBuilder and typed builder function.
    • Safety: Use bytesToHex(new Uint8Array(wallet.getPrivateKey())); minor logic cleanups in account import and keyring selection.
  • Changelog: Note addition of KeyringBuilder type in packages/keyring-controller/CHANGELOG.md.
  • ESLint suppressions: Reduce suppressions for packages/keyring-controller/src/KeyringController.ts reflecting resolved lint errors.

Written by Cursor Bugbot for commit 66b6c1d. This will update automatically on new commits. Configure here.

@ccharly ccharly force-pushed the fix/keyring-controller-lint branch from 7273f0b to 66b6c1d Compare December 8, 2025 11:21
wallet = wallet ?? (await Wallet.fromV3(input, password, true));
}
privateKey = bytesToHex(wallet.getPrivateKey());
privateKey = bytesToHex(new Uint8Array(wallet.getPrivateKey()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like Buffer is not compatible with Uint8Array here for some reason?

let privateKey;
switch (strategy) {
case AccountImportStrategy.privateKey:
case AccountImportStrategy.privateKey: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Declare a block-scope now, since we're doing some local vars declarations, and that's not allowed without block-scopes!

const candidates = await Promise.all(
this.#keyrings.map(async ({ keyring }) => {
return Promise.all([keyring, keyring.getAccounts()]);
return [keyring, await keyring.getAccounts()] as const;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why Promise.all was used here, but we effectively just need to await keyring.getAccounts() here.

I've also added the as const to properly type [..., ...] as a tuple.

Comment on lines +494 to +496
/**
* Keyring selector used for `withKeyring`.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for consistency.

@ccharly ccharly marked this pull request as ready for review December 8, 2025 11:34
@ccharly ccharly requested review from a team as code owners December 8, 2025 11:34
Copy link
Contributor

@mathieuartu mathieuartu left a comment

Choose a reason for hiding this comment

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

Looks good!

@ccharly ccharly added this pull request to the merge queue Dec 8, 2025
Merged via the queue into main with commit 8a42225 Dec 8, 2025
283 checks passed
@ccharly ccharly deleted the fix/keyring-controller-lint branch December 8, 2025 13:46
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.

3 participants