Skip to content

refactor(wallet): make wallet provider extensible end-to-end#5

Merged
0xkkkn merged 2 commits intomainfrom
chore/wallet-provider-extensibility
Apr 22, 2026
Merged

refactor(wallet): make wallet provider extensible end-to-end#5
0xkkkn merged 2 commits intomainfrom
chore/wallet-provider-extensibility

Conversation

@0xkkkn
Copy link
Copy Markdown
Contributor

@0xkkkn 0xkkkn commented Apr 21, 2026

Summary

Prepares platform-modules to onboard additional wallet providers (specifically JustaLab / jaw.id) without requiring any refactor of existing flows. After this lands, adding a new provider is a purely additive PR — one new class + one switch case + env keys.

Also fixes a pre-existing bug where walletProvider on user creation was hardcoded to 'walletconnect' regardless of which wallet the user actually authenticated with.

Changes

Frontend (packages/app)

  • stores/wallet-store.ts — extract createProvider(type) factory; reconnect() reads persisted provider type from localStorage instead of hardcoding zerodev. register(type, username) now takes provider type.
  • hooks/use-auth.tslogin(providerType) and register(username, providerType) flow the type through the entire chain (default 'zerodev', backwards-compatible).
  • services/AuthService.tsverifyWallet() accepts an optional walletProvider, sent as wallet_provider in the POST body.

Backend (packages/backend)

  • application/dto/auth/verify-wallet.dto.ts — accepts optional wallet_provider: z.string().min(1).max(64).
  • application/use-case/auth/verify-wallet.use-case.ts — persists dto.wallet_provider ?? 'unknown' instead of the previously hardcoded 'walletconnect'.
  • domain/auth/model/user.ts — opens WalletProvider type from 'zerodev' | 'walletconnect' to string (open extension point — domain shouldn't gatekeep provider names).
  • infrastructure/repository/postgres/schema.ts — drops the walletProviderEnum and uses a text column. New providers no longer require a Postgres enum migration.

Test plan

  • pnpm typecheck passes in packages/app
  • pnpm typecheck passes in packages/backend
  • pnpm test — 13/13 in packages/app
  • pnpm test — 262/262 in packages/backend
  • Manual smoke: ZeroDev login still works in dev (pnpm dev:app)
  • Manual smoke: a fresh user record now stores the actual provider used (was always 'walletconnect')

What this unlocks for partners (e.g. JustaLab)

A partner adding a new wallet provider only needs to:

  1. Implement IWalletProvider in packages/app/src/providers/<name>/<name>.provider.ts.
  2. Add one case to the createProvider() switch in wallet-store.ts and extend WalletProviderType.
  3. Add VITE_<NAME>_* env keys and the SDK to package.json.
  4. (Optional) Wallet-picker UI on login/register routes.

No edits to use-auth.ts, no edits to backend SIWE verification (already EIP-1271-aware via viem), no schema migrations.

@0xkkkn 0xkkkn mentioned this pull request Apr 22, 2026
3 tasks
0xkkkn added 2 commits April 22, 2026 13:02
Frontend:
- Extract createProvider(type) factory in wallet-store; reconnect()
  reads persisted provider type instead of hardcoding zerodev
- Parameterize providerType through use-auth login/register flows
- AuthService.verifyWallet sends optional wallet_provider field

Backend:
- VerifyWalletDto accepts optional wallet_provider (<=64 chars)
- Persist dto.wallet_provider on user creation (was hardcoded
  to 'walletconnect', mismatching the frontend's 'zerodev')
- Open WalletProvider domain type to string; replace Postgres
  enum with text column so new providers don't require migration
@0xkkkn 0xkkkn force-pushed the chore/wallet-provider-extensibility branch from ebe929b to 76672ab Compare April 22, 2026 10:03
@0xkkkn 0xkkkn merged commit 7a9ada0 into main Apr 22, 2026
3 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 0.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant