refactor(rn_cli_wallet): simplify payment flow with centralized store#384
refactor(rn_cli_wallet): simplify payment flow with centralized store#384ignaciosantise wants to merge 4 commits intomainfrom
Conversation
Migrate payment state from local useReducer to centralized Valtio PaymentStore, reducing PaymentOptionsModal from 573 to 203 lines. Remove IntroView, CollectDataView, and reducer.ts. Add theme support for WebView data collection and improve deep link debugging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ignaciosantise's task in 1m 49s —— View job 🔍 Reviewing Payment Flow Refactoring
|
There was a problem hiding this comment.
Pull request overview
Refactors the RN CLI wallet’s WalletConnect Pay modal flow by moving payment state from component-local useReducer into a centralized Valtio PaymentStore, simplifying the modal’s step orchestration and removing now-redundant view/reducer files.
Changes:
- Introduce
PaymentStoreas the single source of truth for payment lifecycle/steps and migratePaymentOptionsModal+ pairing logic to use it. - Remove legacy payment modal reducer and intro/native collect-data views; keep WebView-based collect-data and add theme propagation.
- Misc platform/tooling updates (pinned
react-native-webview, Android debug deep links/internal run script, iOS pods lock updates, versionCode bump, doc updates).
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wallets/rn_cli_wallet/src/store/PaymentStore.ts | New centralized Valtio store for payment flow state and business logic. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/index.tsx | Payment modal rewritten to drive UI purely from PaymentStore steps/state. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/CollectDataWebView.tsx | Add theme param support and adjust prefill URL construction. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/ViewWrapper.tsx | Simplify wrapper step handling; add isWebView prop to control layout. |
| wallets/rn_cli_wallet/src/hooks/usePairing.ts | Initialize payment flow via PaymentStore and open modal without payment data in ModalStore. |
| wallets/rn_cli_wallet/src/store/ModalStore.ts | Remove payment-specific modal data; make open() data optional. |
| wallets/rn_cli_wallet/src/screens/App.tsx | Add additional deep link logging and listener lifecycle logs. |
| wallets/rn_cli_wallet/src/utils/TypesUtil.ts | Add shared Step union type for the payment modal flow. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/reducer.ts | Deleted legacy reducer. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/IntroView.tsx | Deleted legacy intro step view. |
| wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/CollectDataView.tsx | Deleted legacy native data collection form. |
| wallets/rn_cli_wallet/package.json | Pin react-native-webview and add android:internal script. |
| wallets/rn_cli_wallet/yarn.lock | Lockfile update for pinned react-native-webview. |
| wallets/rn_cli_wallet/ios/Podfile.lock | Pod dependency/metadata updates. |
| wallets/rn_cli_wallet/android/app/src/debug/AndroidManifest.xml | Add debug-only deep link intent filters. |
| wallets/rn_cli_wallet/android/app/build.gradle | Bump versionCode. |
| wallets/rn_cli_wallet/AGENTS.md | Update docs to reference PaymentStore and logging guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wallets/rn_cli_wallet/src/modals/PaymentOptionsModal/CollectDataWebView.tsx
Show resolved
Hide resolved
Prevent duplicate payment submissions by checking if step is already 'confirming' before proceeding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lectDataUrl Remove dead `dataCollectionSuccess` flag from PaymentStore. Use the already-computed `collectDataUrl` variable in `goBack` instead of re-deriving it with a type cast. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Summary
This refactoring streamlines the WalletConnect Pay payment flow by migrating from local component state (
useReducer) to a centralized Valtio store. Removes 3 files (IntroView, CollectDataView, reducer) and reduces PaymentOptionsModal by 63% (573 → 203 lines).Key Changes
PaymentStore.ts: Centralized payment state with lifecycle managementArchitecture
graph TB subgraph Before["Before: Local State"] direction LR OM1["PaymentOptionsModal<br/>(573 lines)"] IV["IntroView"] CV["CollectDataView"] R["reducer.ts"] OM1 --> IV & CV & R end subgraph After["After: Centralized Store"] direction LR OM2["PaymentOptionsModal<br/>(203 lines)"] PS["PaymentStore<br/>(Valtio)"] OM2 --> PS end Before -->|Refactor| AfterTest Plan