rainbowkit icon indicating copy to clipboard operation
rainbowkit copied to clipboard

refactor: adopt WalletFactory pattern for type-safe wallet IDs

Open DanielSinclair opened this issue 1 month ago • 3 comments

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}

DanielSinclair avatar Dec 07 '25 06:12 DanielSinclair

⚠️ No Changeset found

Latest commit: eac8f7ff52590b3a95a3ed381bed4e9c4dab5f62

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

changeset-bot[bot] avatar Dec 07 '25 06:12 changeset-bot[bot]

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

vercel[bot] avatar Dec 07 '25 06:12 vercel[bot]

This stack of pull requests is managed by Graphite. Learn more about stacking.

DanielSinclair avatar Dec 07 '25 06:12 DanielSinclair