Skip to content

fix(wallet-setup): remove mutable static secureStorage singleton - #121

Merged
jonathunne merged 1 commit into
mainfrom
npc/remove-mutable-secure-storage-singleton
Sep 21, 2026
Merged

jonathunne merged 1 commit into
mainfrom
npc/remove-mutable-secure-storage-singleton

Conversation

@nulllpc

@nulllpc nulllpc commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #91

Summary

  • WalletSetupService cached an externally-injected SecureStorage instance in a mutable static field, set by WdkAppProvider on mount - multiple WdkAppProviders would silently overwrite each other's instance, with no per-provider scoping and no unmount cleanup.
  • createSecureStorage() is now a config-free call that always returns the same singleton, so there's nothing left to inject or cache - every method calls it directly instead of going through setSecureStorage/getSecureStorage.
  • Drop the now-unused injection wiring from WdkAppProvider and the dead isSecureStorageInitialized() method.
  • Fully internal refactor - WalletSetupService isn't exported from the package root and WdkAppProviderProps never exposed a secureStorage override, so no public API change.

Test plan

  • npm test / npm run lint / tsc --noEmit - all clean.
  • Smoke-tested in wdk-examples/react-native-showcase against this branch: create wallet, restore/load wallet, and delete wallet all work against the real keychain.

- WalletSetupService cached an externally-injected SecureStorage
  instance in a mutable static field, set by WdkAppProvider on mount.
  Multiple WdkAppProviders silently overwrote each other's instance,
  with no per-provider scoping and no unmount cleanup (#91).
- createSecureStorage() is now a config-free call that always returns
  the same singleton (see storage/secureStorage.ts), so there was
  nothing left to inject or cache - every method now calls it
  directly instead of going through setSecureStorage/getSecureStorage.
- Drop the now-unused injection wiring from WdkAppProvider and the
  dead isSecureStorageInitialized() method.
- WalletSetupService isn't exported from the package root and
  WdkAppProviderProps never exposed a secureStorage override, so this
  is a fully internal refactor with no public API change.
@nulllpc
nulllpc requested a review from jonathunne September 21, 2026 10:24

@jonathunne jonathunne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jonathunne
jonathunne merged commit 170f0a5 into main Sep 21, 2026
7 checks passed
@nulllpc
nulllpc deleted the npc/remove-mutable-secure-storage-singleton branch September 21, 2026 13:27
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.

Replace Mutable Static SecureStorage Singleton

3 participants