Skip to content

refactor: adopt WalletFactory pattern for type-safe wallet IDs#2588

Open
DanielSinclair wants to merge 3 commits intomainfrom
daniel/type-safe-wallet-ids
Open

refactor: adopt WalletFactory pattern for type-safe wallet IDs#2588
DanielSinclair wants to merge 3 commits intomainfrom
daniel/type-safe-wallet-ids

Conversation

@DanielSinclair
Copy link
Collaborator

@DanielSinclair DanielSinclair commented Dec 7, 2025

Refactors wallet connectors to use the new WalletFactory helper type,

which preserves literal ID types through 'as const' assertions. This
provides better type safety and enables stricter type checking for
wallet identifiers throughout the codebase.

Changes:

  • Add WalletFactory helper type to Wallet.ts
  • Add appName and appIcon to CreateWalletFn type for wallets that require them
    (baseAccount, coinbaseWallet, geminiWallet)
  • Convert all wallet connectors to use WalletFactory pattern
  • Flatten type definitions in baseAccount and coinbaseWallet
  • Update WalletButton components to work with new types
  • All wallet IDs now use 'as const' for literal type preservation

PR-Codex overview

This PR focuses on improving the TypeScript typings and structure of various wallet connector implementations in the rainbowkit package. It enhances type safety and consistency by utilizing the satisfies operator and updating the wallet connector functions.

Detailed summary

  • Updated wallet connector functions to use satisfies Wallet for type safety.
  • Changed return types from (): Wallet to () => for consistency.
  • Replaced id definitions with as const for literal type preservation.
  • Modified the WalletButton and related props to use WalletId.
  • Refactored argentWallet, wigwamWallet, tahoWallet, and others to align with new type definitions.
  • Enhanced the mapping of wallet connectors to ensure consistent typing across the board.

The following files were skipped due to too many changes: packages/rainbowkit/src/wallets/walletConnectors/oktoWallet/oktoWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/omniWallet/omniWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/oneInchWallet/oneInchWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/kresusWallet/kresusWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/bestWallet/bestWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/readyWallet/readyWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/bitverseWallet/bitverseWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/talismanWallet/talismanWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/iopayWallet/iopayWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/imTokenWallet/imTokenWallet.ts, packages/rainbowkit/src/wallets/walletConnectors/ledgerWallet/ledgerWallet.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2025

⚠️ No Changeset found

Latest commit: eac8f7f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Dec 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rainbowkit-example Error Error Dec 7, 2025 8:17am
rainbowkit-site Ready Ready Preview Comment Dec 7, 2025 8:17am

@DanielSinclair
Copy link
Collaborator Author

DanielSinclair commented Dec 7, 2025

@DanielSinclair DanielSinclair marked this pull request as ready for review December 7, 2025 06:17
@DanielSinclair DanielSinclair requested a review from a team as a code owner December 7, 2025 06:17
@DanielSinclair DanielSinclair changed the base branch from main to graphite-base/2588 December 7, 2025 08:11
@DanielSinclair DanielSinclair force-pushed the daniel/type-safe-wallet-ids branch from 7204b49 to b6ff8bb Compare December 7, 2025 08:11
@DanielSinclair DanielSinclair changed the base branch from graphite-base/2588 to daniel/next-route-types December 7, 2025 08:11
Base automatically changed from daniel/next-route-types to main December 7, 2025 08:12
DanielSinclair and others added 3 commits December 7, 2025 03:12
Refactors wallet connectors to use the new WalletFactory helper type,
which preserves literal ID types through 'as const' assertions. This
provides better type safety and enables stricter type checking for
wallet identifiers throughout the codebase.

Changes:
- Add WalletFactory helper type to Wallet.ts
- Add appName and appIcon to CreateWalletFn type for wallets that require them
  (baseAccount, coinbaseWallet, geminiWallet)
- Convert all wallet connectors to use WalletFactory pattern
- Flatten type definitions in baseAccount and coinbaseWallet
- Update WalletButton components to work with new types
- All wallet IDs now use 'as const' for literal type preservation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant