fix: cashout on peanut wallet#646
Conversation
- updated cashout kyc flow - updated wallet header component to handle wallet selection if no external wallet is connected - some minor ui fxies in kyc flow
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces several changes across multiple components and utilities, primarily focusing on user data management, KYC status handling, and component restructuring. The changes involve updating user-related interfaces, modifying component rendering logic, and refining type definitions. Key modifications include introducing a Changes
Sequence DiagramsequenceDiagram
participant User
participant UpdateUserComponent
participant API
User->>UpdateUserComponent: Provide user details
UpdateUserComponent->>API: Submit user update request
alt Successful Update
API-->>UpdateUserComponent: Update confirmed
UpdateUserComponent-->>User: Display success message
else Update Failed
API-->>UpdateUserComponent: Return error
UpdateUserComponent-->>User: Display error message
end
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/utils/cashout.utils.ts (1)
Line range hint
324-351: Watch out for potential precision loss
UsingNumber(tokenAmount)might introduce floating-point inaccuracies for large values. Consider a library likedecimal.jsto handle big number arithmetic more reliably or parse the string carefully to avoid precision loss.
🧹 Nitpick comments (5)
src/components/Kyc/index.tsx (1)
10-10: Ensure robust handling of null or incomplete user objects.
While this hook usage looks simple, consider adding a fallback or defensive checks for edges cases (e.g., user object is undefined).src/app/api/peanut/user/update-user/route.ts (1)
17-17: Check for consistent naming convention.
You are mixingbridge_customer_idwithpushSubscriptionIdandfullName. Consider staying consistent (e.g., always snake_case or camelCase) for better clarity.src/components/Global/UpdateUserComponent/index.tsx (2)
6-13: Consider removing the unusedpasswordproperty.
It appears the password field is no longer part of the form. If you are no longer collecting or using passwords, removing the optionalpasswordproperty would simplify the interface.interface IUpdateUserComponentProps { userId?: string name?: string email?: string - password?: string onSubmit?: ({ status, message }: { status: 'success' | 'error' | 'login'; message: string }) => void }
40-78: Handle response data or confirm no data usage.
The API response JSON is parsed but not used for any logic beyond status checks. Ensure there is no relevant data you might need to handle or display (e.g., updated user details).const handleOnSubmit = async (data: IForm) => { try { setLoadingState('Submitting details') const response = await fetch('/api/peanut/user/update-user', { ... }) - await response.json() + const responseData = await response.json() + // If needed, handle responseData to confirm that the updated user data was saved ... } catch (error) { ... } }src/components/Global/LinkAccountComponent/index.tsx (1)
112-112: Simplify conditional check
You can unify the condition toif (user?.user?.kycStatus !== 'approved')for a more concise approach.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
src/app/api/peanut/user/update-user/route.ts(2 hunks)src/components/Cashout/Components/Initial.view.tsx(4 hunks)src/components/Global/IframeWrapper/index.tsx(2 hunks)src/components/Global/KYCComponent/index.tsx(5 hunks)src/components/Global/LinkAccountComponent/index.tsx(3 hunks)src/components/Global/UpdateUserComponent/index.tsx(2 hunks)src/components/Global/WalletHeader/index.tsx(2 hunks)src/components/Kyc/index.tsx(2 hunks)src/components/LinkAccount/index.tsx(1 hunks)src/components/Offramp/Confirm.view.tsx(1 hunks)src/components/Profile/Components/SkeletonPage.tsx(2 hunks)src/components/Register/index.tsx(0 hunks)src/components/index.ts(0 hunks)src/constants/index.ts(1 hunks)src/hooks/wallet/useWallet.ts(1 hunks)src/interfaces/interfaces.ts(2 hunks)src/utils/cashout.utils.ts(2 hunks)
💤 Files with no reviewable changes (2)
- src/components/index.ts
- src/components/Register/index.tsx
🔇 Additional comments (33)
src/constants/index.ts (2)
4-4: Good addition ofloadingStates.constsexport.
Consolidating loading states under a single export can simplify state tracking across the application.
1-1: Confirm usage ofcashout.constsexport.
Please verify thatcashout.constsis still needed, as it may conflict with the PR's goal of deprecating or revising old cashout constants.✅ Verification successful
cashout.constsexports are actively used and maintained
The constants defined in this file are currently used across multiple components (Cashout, Claim, KYC) and contain up-to-date configurations for modern chains and tokens. These exports should be retained.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search the codebase for references to cashout.consts rg "cashout\.consts" -A 5Length of output: 312
Script:
#!/bin/bash # View content of cashout.consts cat src/constants/cashout.consts.tsLength of output: 2343
Script:
#!/bin/bash # Search for usage of the exported constants rg "supportedBridgeChainsDictionary|supportedBridgeTokensDictionary|IOfframpForm" -lLength of output: 375
src/components/Kyc/index.tsx (2)
31-32: Looks good.
Linking to the/cashoutroute after successful KYC is intuitive for the user.
23-23: Verify consistent usage of'approved'across the codebase.
Previously, many components relied on'verified'. Confirm all references match the new KYC status to avoid inconsistent flows.src/app/api/peanut/user/update-user/route.ts (1)
13-13: OptionalfullNamefield is a useful addition.
This adds flexibility to storing user data. Make sure you're handling undefined cases gracefully in the downstream code.src/components/LinkAccount/index.tsx (1)
58-58: Confirm fallback KYC statuses.
If the user’s status can be something other than'approved'or'rejected', ensure all statuses are handled. Enumerating them in a constant or type guard will reduce confusion.src/components/Global/UpdateUserComponent/index.tsx (3)
14-18: Confirm ifuserIdshould be required in the form.
TheuserIdprop is optional inIUpdateUserComponentProps, but here, the form captures onlynameandIForm, or makeuserIdrequired to ensure clarity.
19-39: Great rename reflecting updated functionality.
Renaming toUpdateUserComponentaligns with the shift from registration to user updates. The new component structure is clear and coherent.
124-124: Button label consistency.
“Submit details” is clear and reflects the update operation. This is consistent with the new purpose of the component.src/components/Global/IframeWrapper/index.tsx (2)
1-2: Explicit import is correct.
ImportingKYCStatusclarifies intended usage and improves type safety.
55-55: Good addition of strong typing.
TypingkycStatusasKYCStatushelps enforce valid status values and reduces runtime errors.src/hooks/wallet/useWallet.ts (1)
44-44: Enhanced check for wallet presence.
This additional check ensures the logic only proceeds when bothwagmiAddressandwalletare defined, preventing potential runtime errors.src/interfaces/interfaces.ts (1)
1-1: Consistent KYC status typing.
ImportingKYCStatusand assigning it tokycStatusin theUserinterface promotes uniformity and reliability across the codebase.Also applies to: 352-352
src/components/Global/WalletHeader/index.tsx (3)
8-8: New interface import looks consistentThis import introduces
IDBWalletfor specialized wallet usage. Ensure type overlaps withIWalletare kept minimal to avoid confusion.
43-46: Validating wallet selection logicRestricting selected wallets to Peanut or connected external wallets is a good safeguard, preventing the user from unknowingly selecting an unconnected wallet.
49-71: Ensures a valid default wallet selectionThe fallback logic to automatically select a connected external wallet, or a Peanut wallet if no external wallet is connected, is well-structured to maintain a valid wallet state at all times. Consider adding tests to confirm that no infinite re-render cycles occur when the selected wallet changes rapidly.
src/components/Profile/Components/SkeletonPage.tsx (2)
4-4: Properly replacing registration import
UpdateUserComponentimport aligns with the shift to user updates. Looks good.
161-161: Successful transition from registration to update user flowReplacing the old registration component with
UpdateUserComponentstreamlines the UI. Ensure that any underlying registration logic is updated or removed where necessary around this integration.src/components/Global/KYCComponent/index.tsx (5)
17-17: Introducing the new user update componentImporting
UpdateUserComponentfor KYC flow is consistent with the broader refactor.
326-326: Seamless user data submission within KYC
UpdateUserComponentis invoked correctly for collecting user info before stepping through KYC. The callback logic for handling success or errors is straightforward.
391-391: KYC process step logic looks fineThe button to open or reopen KYC is clearly presented. Consider verifying whether repeated KYC submissions or partial completions can cause any race conditions.
412-415: Clear UI text for KYC processOutlining the KYC purpose and regulatory requirements provides a good user experience.
440-440: Decoupled rendering containerWrapping
{renderComponent()}inside a dedicated container helps keep styling consistent and maintainable.src/components/Cashout/Components/Initial.view.tsx (4)
82-82: Refined modal management with appkitRenaming to
appkitModalclarifies the source of the modal, improving overall readability. Confirm that oldersignInModalreferences are either removed or replaced where appropriate.
279-279: Graceful fallback to appkit modalUsing
appkitModal()for unconnected states simplifies your logic. Consider verifying that the user is prompted with the correct flow once the modal is closed.
295-295: User prompt for buying tokens
appkitModal()triggers the wallet connection before token purchase—this helps ensure a consistent user experience.
428-428: Consolidated connection handlingIf an external wallet is not connected but the user is on a Peanut wallet, triggers a different login flow before proceeding. This is a logical approach to unify all connection states.
src/utils/cashout.utils.ts (3)
2-2: Looks Good
No issues with these import changes.Also applies to: 4-4
134-135: Strong typing for KYC
Using a union type for KYC phases enhances clarity and maintainability.
143-143: Refined type usage
Switchingkyc_statusto use theKYCStatustype ensures consistency throughout the codebase.src/components/Global/LinkAccountComponent/index.tsx (2)
5-5: Import statement
ImportingKYCComponentdirectly is straightforward and aligns with the file’s usage.
625-625: Streamlined KYC flow
Displaying the<KYCComponent />directly when KYC is not yet approved simplifies the user experience.src/components/Offramp/Confirm.view.tsx (1)
686-686: Padding enhancement
Addingp-6makes the content layout more spacious and consistent.
jjramirezn
left a comment
There was a problem hiding this comment.
Good PR, finally letting go of email/password
fixes TASK-8306
fixes TASK-8305
Summary by CodeRabbit
Release Notes
New Features
fullNameproperty to user update functionality.User Experience Improvements
Bug Fixes
Refactoring