refactor(wallet): make wallet provider extensible end-to-end#5
Merged
Conversation
3 tasks
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
ebe929b to
76672ab
Compare
|
🎉 This PR is included in version 0.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prepares
platform-modulesto 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
walletProvideron user creation was hardcoded to'walletconnect'regardless of which wallet the user actually authenticated with.Changes
Frontend (
packages/app)stores/wallet-store.ts— extractcreateProvider(type)factory;reconnect()reads persisted provider type fromlocalStorageinstead of hardcodingzerodev.register(type, username)now takes provider type.hooks/use-auth.ts—login(providerType)andregister(username, providerType)flow the type through the entire chain (default'zerodev', backwards-compatible).services/AuthService.ts—verifyWallet()accepts an optionalwalletProvider, sent aswallet_providerin the POST body.Backend (
packages/backend)application/dto/auth/verify-wallet.dto.ts— accepts optionalwallet_provider: z.string().min(1).max(64).application/use-case/auth/verify-wallet.use-case.ts— persistsdto.wallet_provider ?? 'unknown'instead of the previously hardcoded'walletconnect'.domain/auth/model/user.ts— opensWalletProvidertype from'zerodev' | 'walletconnect'tostring(open extension point — domain shouldn't gatekeep provider names).infrastructure/repository/postgres/schema.ts— drops thewalletProviderEnumand uses atextcolumn. New providers no longer require a Postgres enum migration.Test plan
pnpm typecheckpasses inpackages/apppnpm typecheckpasses inpackages/backendpnpm test— 13/13 inpackages/apppnpm test— 262/262 inpackages/backendpnpm dev:app)'walletconnect')What this unlocks for partners (e.g. JustaLab)
A partner adding a new wallet provider only needs to:
IWalletProviderinpackages/app/src/providers/<name>/<name>.provider.ts.createProvider()switch inwallet-store.tsand extendWalletProviderType.VITE_<NAME>_*env keys and the SDK topackage.json.No edits to
use-auth.ts, no edits to backend SIWE verification (already EIP-1271-aware via viem), no schema migrations.