Skip to content

feat(keyring-controller): add filter selector callback to withKeyring#8348

Merged
ccharly merged 2 commits intomainfrom
cc/feat/with-keyring-filter
Mar 31, 2026
Merged

feat(keyring-controller): add filter selector callback to withKeyring#8348
ccharly merged 2 commits intomainfrom
cc/feat/with-keyring-filter

Conversation

@ccharly
Copy link
Copy Markdown
Contributor

@ccharly ccharly commented Mar 31, 2026

Explanation

Adding a new way to filter out keyring instances with withKeyring.

The idea is to be able to filter by keyring instance logic/property. Since KeyringObject data are pretty limited, we cannot do things like:

const specificKeyring = controller.withKeyring({
  filter: (keyring): keyring is MyKeyring => {
    return isMyKeyring(keyring) && keyring.useSpecificMethodOrProp() !== undefined;
  },
}, ({ keyring }) => {
  // `keyring` is inferred as `MyKeyring` here, so `filter` type-predicate is also
  // used in type inference in the `operation` callback!
  ...
});

Here, the useSpecificMethodOrProp is specific to MyKeyring type.

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

Medium Risk
Touches keyring selection logic in withKeyring, so incorrect predicate handling or selection order could affect any caller using the new variant, though coverage is strong and the change is localized.

Overview
Extends KeyringController.withKeyring to support selecting a keyring via a new KeyringSelector variant { filter: ({ keyring, metadata }) => boolean }, which picks the first keyring matching the predicate.

Adds a focused test suite covering filter-based selection (result passthrough, metadata availability, first-match behavior, and error cases like KeyringNotFound/UnsafeDirectKeyringAccess) and documents the addition in the package changelog.

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

@ccharly ccharly force-pushed the cc/feat/with-keyring-filter branch 2 times, most recently from 7dd1631 to e6c2af1 Compare March 31, 2026 09:24
@ccharly ccharly marked this pull request as ready for review March 31, 2026 09:24
@ccharly ccharly requested review from a team as code owners March 31, 2026 09:24
@ccharly ccharly force-pushed the cc/feat/with-keyring-filter branch from e6c2af1 to f5e25d2 Compare March 31, 2026 09:27
@ccharly ccharly added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit f395196 Mar 31, 2026
332 checks passed
@ccharly ccharly deleted the cc/feat/with-keyring-filter branch March 31, 2026 18:48
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