Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(suite-native): enable and discover account via trade #17266

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

vytick
Copy link
Contributor

@vytick vytick commented Feb 26, 2025

  • When network is not enabled for selected asset, let user to enable it and run discovery in trade
  • Let user to add new account for discovered network
  • When device is not connected (portfolio, view only) do not allow discovery or adding new account

Related Issue

Resolve #16990

Screenshots:

Simulator.Screen.Recording.-.iPhone.16.-.2025-02-26.at.23.03.31.mp4
Simulator.Screen.Recording.-.iPhone.16.-.2025-02-26.at.23.05.14.mp4

@vytick vytick added the mobile Suite Lite issues and PRs label Feb 26, 2025
Copy link

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

@vytick vytick marked this pull request as ready for review February 26, 2025 22:09
@vytick vytick requested a review from a team as a code owner February 26, 2025 22:09
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The update restructures internationalization messages by organizing account and address empty states into nested objects. In the add coin account module, new type definitions and modified function signatures have been introduced to improve type safety and update navigation logic, including the addition of a confirmation handler. Exports have been extended to include new hooks and components. Several screens have been updated to simplify account confirmation processes and adjust navigation based on flow types. The trading module now integrates Redux for managing state in components, updates imports and dependencies, and removes obsolete tests and components. Additionally, the navigation configuration has been expanded to include a new route for receiving accounts, and the package configuration has been updated with new dependencies.

✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
suite-native/module-trading/src/hooks/useSectionListData.tsx (2)

8-12: Rename or clarify the ItemRenderConfig type name for broader usage.
While ItemRenderConfig is descriptive, consider adding more context or a doc comment about its purpose and usage, as it’s a core interface for the item rendering logic.


137-187: Excellent custom hook architecture for section lists.
The combined usage of useMemo for item counts and list size calculations is beneficial for performance. Ensure that upstream changes (e.g., dynamic item heights) are tracked if future design requirements evolve.

suite-native/module-trading/src/components/general/AccountSheet/NoAccountsComponent.tsx (1)

34-59: Good implementation of conditional UI based on device mode.

The component correctly implements different messages based on the device's view-only mode status, which aligns with the PR requirement that account discovery should be restricted when the device is not connected.

Consider extracting the translation IDs into constants to avoid hardcoding strings in the component:

+const TRANSLATION_IDS = {
+  VIEW_ONLY_TITLE: 'moduleTrading.accountSheet.accountEmpty.viewOnly.title',
+  VIEW_ONLY_DESCRIPTION: 'moduleTrading.accountSheet.accountEmpty.viewOnly.description',
+  NETWORK_NOT_ENABLED_TITLE: 'moduleTrading.accountSheet.accountEmpty.networkNotEnabled.title',
+  NETWORK_NOT_ENABLED_DESCRIPTION: 'moduleTrading.accountSheet.accountEmpty.networkNotEnabled.description'
+};

 export const NoAccountsComponent = ({ isBottomRounded }: NoAccountsComponentProps) => {
   const { applyStyle } = useNativeStyles();
   const isDeviceInViewOnlyMode = useSelector(selectIsDeviceInViewOnlyMode);

   const title = isDeviceInViewOnlyMode ? (
-    <Translation id="moduleTrading.accountSheet.accountEmpty.viewOnly.title" />
+    <Translation id={TRANSLATION_IDS.VIEW_ONLY_TITLE} />
   ) : (
-    <Translation id="moduleTrading.accountSheet.accountEmpty.networkNotEnabled.title" />
+    <Translation id={TRANSLATION_IDS.NETWORK_NOT_ENABLED_TITLE} />
   );
   const description = isDeviceInViewOnlyMode ? (
-    <Translation id="moduleTrading.accountSheet.accountEmpty.viewOnly.description" />
+    <Translation id={TRANSLATION_IDS.VIEW_ONLY_DESCRIPTION} />
   ) : (
-    <Translation id="moduleTrading.accountSheet.accountEmpty.networkNotEnabled.description" />
+    <Translation id={TRANSLATION_IDS.NETWORK_NOT_ENABLED_DESCRIPTION} />
   );
suite-native/module-trading/src/screens/ReceiveAccountsPickerScreen.tsx (1)

154-159: Ensure empty state handling is comprehensive.

The filter variable is defined but appears to not be used anywhere else in the component. Consider removing it if unused or implement filtering functionality.

-const filter = '';
-const emptyComponent =
-    filter.length > 0 ? (
-        <AddressListEmptyComponent />
-    ) : (
-        <NoAccountsComponent isBottomRounded={isDeviceInViewOnlyMode} />
-    );
+const emptyComponent = pickerMode === 'address' 
+    ? <AddressListEmptyComponent />
+    : <NoAccountsComponent isBottomRounded={isDeviceInViewOnlyMode} />;
suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts (1)

377-389: Added account type confirmation handler with timeout.

The new handleAccountTypeConfirmation function improves the user experience by streamlining the confirmation process and includes a timeout to prevent UI crashes during transitions.

Consider extracting the timeout value to a named constant to make the code more maintainable:

+const ACCOUNT_TYPE_CONFIRMATION_TIMEOUT = 100; // ms
+
 const handleAccountTypeConfirmation = (flowType: AddCoinFlowType) => {
     if (networkSymbolWithTypeToBeAdded) {
         // Timeout is needed so AccountTypeDecisionBottomSheet has time to hide otherwise app crashes
         setTimeout(() => {
             addCoinAccount({
                 symbol: networkSymbolWithTypeToBeAdded[0],
                 accountType: networkSymbolWithTypeToBeAdded[1],
                 flowType,
             });
-        }, 100);
+        }, ACCOUNT_TYPE_CONFIRMATION_TIMEOUT);
         clearNetworkWithTypeToBeAdded();
     }
 };
suite-native/module-add-accounts/src/screens/AddCoinDiscoveryFinishedScreen.tsx (1)

115-115: Confirm coin name usage.
Passing networkSymbol as coinName might differ from the human-readable coin name. If needed, consider retrieving the full coin name from getNetwork(networkSymbol).name for consistency.

suite-native/module-trading/src/components/buy/ReceiveAccountPicker.tsx (1)

92-96: Conditional navigation in openAccountPicker.
Selecting the route only when selectedSymbol is defined prevents erroneous navigation. Consider logging or providing user feedback if selectedSymbol is absent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fce4f90 and b0db7b1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (25)
  • suite-native/intl/src/en.ts (1 hunks)
  • suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts (11 hunks)
  • suite-native/module-add-accounts/src/index.ts (1 hunks)
  • suite-native/module-add-accounts/src/screens/AddCoinAccountScreen.tsx (1 hunks)
  • suite-native/module-add-accounts/src/screens/AddCoinDiscoveryFinishedScreen.tsx (4 hunks)
  • suite-native/module-add-accounts/src/screens/AddCoinDiscoveryRunningScreen.tsx (2 hunks)
  • suite-native/module-add-accounts/src/screens/SelectAccountTypeScreen.tsx (5 hunks)
  • suite-native/module-trading/package.json (1 hunks)
  • suite-native/module-trading/src/components/buy/BuyCard.tsx (4 hunks)
  • suite-native/module-trading/src/components/buy/ReceiveAccountPicker.tsx (3 hunks)
  • suite-native/module-trading/src/components/buy/__tests__/ReceiveAccountPicker.comp.test.tsx (0 hunks)
  • suite-native/module-trading/src/components/general/AccountSheet/AccountSheet.tsx (0 hunks)
  • suite-native/module-trading/src/components/general/AccountSheet/AddressListEmptyComponent.tsx (1 hunks)
  • suite-native/module-trading/src/components/general/AccountSheet/NoAccountsComponent.tsx (1 hunks)
  • suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx (1 hunks)
  • suite-native/module-trading/src/components/general/TradingBottomSheetSectionList.tsx (2 hunks)
  • suite-native/module-trading/src/hooks/__tests__/useReceiveAccountsListData.test.tsx (10 hunks)
  • suite-native/module-trading/src/hooks/__tests__/useSelectedAccount.test.ts (0 hunks)
  • suite-native/module-trading/src/hooks/useReceiveAccountsListData.ts (3 hunks)
  • suite-native/module-trading/src/hooks/useSectionListData.tsx (1 hunks)
  • suite-native/module-trading/src/hooks/useSelectedAccount.ts (0 hunks)
  • suite-native/module-trading/src/navigation/TradingStackNavigator.tsx (2 hunks)
  • suite-native/module-trading/src/screens/ReceiveAccountsPickerScreen.tsx (1 hunks)
  • suite-native/navigation/src/navigators.ts (2 hunks)
  • suite-native/navigation/src/routes.ts (1 hunks)
💤 Files with no reviewable changes (4)
  • suite-native/module-trading/src/components/buy/tests/ReceiveAccountPicker.comp.test.tsx
  • suite-native/module-trading/src/components/general/AccountSheet/AccountSheet.tsx
  • suite-native/module-trading/src/hooks/useSelectedAccount.ts
  • suite-native/module-trading/src/hooks/tests/useSelectedAccount.test.ts
✅ Files skipped from review due to trivial changes (1)
  • suite-native/module-trading/src/components/general/TradeableAssetsSheet/TradeableAssetsSheet.tsx
🔇 Additional comments (70)
suite-native/module-trading/src/hooks/useSectionListData.tsx (6)

1-3: Nice use of React Native Reanimated imports.
The fade-in/out animations bring a smooth visual transition for section headers and items.


14-25: Thorough type definitions for sectioned data and internal item shapes.
These definitions effectively separate concerns for section headers versus items. This enhances readability and helps ensure correct usage in the rendering logic.


36-59: Conditional border styling is well-structured.
Using the extend array to conditionally apply corner radii based on isFirst/isLast provides clean and maintainable styling for card-like sections.


60-88: Verify the single-section header logic.
(!noSingletonSectionHeader || inputData.length > 1) ensures headers are rendered for multiple sections or if noSingletonSectionHeader is false, but consider edge cases where a single section might contain many items. If the design requires a header even for one large section, this logic might need revisiting.


90-104: Great usage of UnreachableCaseError.
This pattern enforces exhaustive handling of union types, catching changes in the data structure at compile time. Keep it up!


106-135: Clear separation of section header vs. item rendering.
The switch statement is straightforward and leverages AnimatedBox for subtle transitions, resulting in well-organized item rendering code.

suite-native/module-trading/src/components/general/TradingBottomSheetSectionList.tsx (4)

1-3: Imports are concise and relevant.
Removing unnecessary imports keeps the file cleaner.


5-10: Defer to new hook definitions for data structures.
Centralizing ItemRenderConfig, SectionListData, and ListInternalItemShape in the hook promotes a more modular design.


39-50: Seamless integration with useSectionList.
The component effectively delegates data transformation and rendering concerns to the new hook, simplifying local logic.


53-55: Using BottomSheetFlashList with internal data.
Passing the derived props (internalData, internalKeyExtractor, internalRenderItem) keeps the component minimal and focused on its role.

suite-native/navigation/src/routes.ts (1)

129-132: Nice addition to the trading stack routes!

Adding ReceiveAccounts to the TradingStackRoutes enum aligns well with the PR objective of enabling account discovery within the trade section. This route will be used for the new account selection screen where users can choose accounts for receiving assets.

suite-native/module-add-accounts/src/index.ts (1)

2-3: Good modularity improvement

Exposing these hooks and components makes them available for the trading module to utilize, which is essential for the account discovery feature described in the PR objectives. This approach promotes code reuse across modules.

suite-native/module-trading/src/components/general/AccountSheet/AddressListEmptyComponent.tsx (1)

7-8:

❓ Verification inconclusive

Translation keys restructured for better organization

The translation keys have been updated to use a more hierarchical structure, changing from flat keys to nested ones. This is a good practice for better organization of internationalization resources.

Make sure these new translation keys are properly added to all language files to prevent any missing translations.


🏁 Script executed:

#!/bin/bash
# Search for the new translation keys in language files
echo "Checking for new translation keys in language files"
grep -r "moduleTrading.accountSheet.addressEmpty" --include="*.ts" suite-native/intl/src/

Length of output: 202


Translation Keys Update Verification Needed

The AddressListEmptyComponent now uses the updated translation keys ("moduleTrading.accountSheet.addressEmpty.title" and "moduleTrading.accountSheet.addressEmpty.description") to enforce a more hierarchical structure. However, our search in the language files (under suite-native/intl/src) did not return any matches for these keys. Please manually verify that these keys have been added to all relevant language files (including both TS and, if applicable, JSON files) to prevent missing translations at runtime.

suite-native/module-trading/src/navigation/TradingStackNavigator.tsx (2)

9-9: Clean import addition.

Import for the new ReceiveAccountsPickerScreen component is correctly added to support the new navigation route.


24-28: Good implementation of the new screen route.

The ReceiveAccounts screen is properly added to the TradingStack navigator with appropriate title and component configuration, which enables the account discovery functionality mentioned in the PR objectives.

suite-native/module-add-accounts/src/screens/AddCoinAccountScreen.tsx (2)

28-28: Function rename looks good.

The change from addCoinAccount to handleAccountTypeConfirmation improves readability by clearly describing the function's purpose.


36-36:

❓ Verification inconclusive

Simplified implementation.

The handleConfirmTap function has been simplified to directly call handleAccountTypeConfirmation with the flowType parameter, removing any previous timeout logic.

Verify that the timeout logic is properly implemented in the handleAccountTypeConfirmation function to prevent potential UI freezes during confirmation:


🏁 Script executed:

#!/bin/bash
# Search for the implementation of handleAccountTypeConfirmation
rg -A 10 "handleAccountTypeConfirmation.*=" --type typescript

Length of output: 98


I'll re-run the verification without specifying the file type to ensure we capture all possible locations for the handleAccountTypeConfirmation implementation. Please run the following script:

#!/bin/bash
# Searching for the implementation of handleAccountTypeConfirmation without specifying file type
rg -A 10 "handleAccountTypeConfirmation" .

Once you obtain the output, we can verify if the timeout logic is integrated as expected in the handleAccountTypeConfirmation function. Please share the results.

suite-native/module-trading/src/components/general/AccountSheet/NoAccountsComponent.tsx (2)

8-10: Good props definition.

The props interface is clear and properly typed with a boolean flag for styling control.


12-32: Well-structured styling.

The styling approach using prepareNativeStyle with conditional styling for bottom corners is clean and maintainable.

suite-native/navigation/src/navigators.ts (2)

146-146: Good type extension.

Adding 'trade' to AddCoinFlowType properly extends the navigation capabilities to support the account discovery functionality within the trading context.


236-236: Well-defined route parameter.

The new ReceiveAccounts route is correctly defined with a required symbol parameter of type NetworkSymbol, which enables proper type checking for this route.

suite-native/module-trading/src/components/buy/BuyCard.tsx (5)

2-2: Moving to Redux for state management.

You've added Redux imports here, which is consistent with the architectural changes needed to support account discovery within the trading flow.


14-15: Appropriate imports for Redux integration.

The imports for Redux selectors and actions are properly added, along with the required type import.


27-28: Redux setup for account management.

Good implementation of the Redux hooks to manage the selected receive account state centrally, which will make it easier to share this state with other components that need to access it.


35-37: State management moved to Redux.

The useEffect hook now properly dispatches a Redux action instead of using local state. This is a good change for centralizing state management, particularly for features that need to be accessed across different components.


64-64: Simplified ReceiveAccountPicker props.

You've simplified the component by only passing the selectedSymbol and removing the local state management props, which is appropriate since this state is now managed in Redux.

suite-native/module-add-accounts/src/screens/AddCoinDiscoveryRunningScreen.tsx (3)

21-26: Import structure improvements.

Good organization of imports with explicit type imports from navigation, which improves code readability and maintainability.


30-32: Enhanced type safety with StackProps.

The component now properly types its props using StackProps with specific route parameters, which improves type safety and developer experience.


62-66: Special handling for trade flow.

This new conditional block implements the special handling for the 'trade' flow type, allowing users to return to the trade section after account discovery. This is a key part of the new feature to enable account discovery from the trade section.

suite-native/module-add-accounts/src/screens/SelectAccountTypeScreen.tsx (5)

28-32: Improved import structure.

The destructured imports are now more explicit, which improves code readability.


89-95: New helper function for safer translation access.

The getAccountTypeTranslations function adds robustness by safely checking if a translation exists before attempting to access it, which prevents potential runtime errors.


115-115: Safer access to translation keys.

Now using the helper function to safely retrieve the translation key, which is more robust against potential missing translations.


145-149: Null check for missing translations.

Good defensive programming by checking if translation data exists before attempting to use it, which prevents potential errors if account types are added without corresponding translations.


187-189: Conditional translation for undefined keys.

The translation function now safely handles the case where accountTypeKey might be undefined, preventing potential rendering issues.

suite-native/module-trading/src/hooks/__tests__/useReceiveAccountsListData.test.tsx (6)

10-10: Updated import for new mode parameter.

The import now correctly includes the ReceiveAccountsListMode type which is used in the updated hook interface.


62-62: Added mode parameter to test helper function.

The test helper function signature has been updated to include the new mode parameter, which matches the changes in the hook API.


66-67: Updated hook call with mode parameter.

The hook call now correctly passes the mode parameter along with the other arguments, matching the updated hook interface.


77-77: Default mode in initial props.

Setting a default mode in the initial props ensures backward compatibility in test cases that might not explicitly specify a mode.


91-95: Updated all test cases with mode parameter.

All test cases now correctly include the mode parameter, ensuring complete test coverage for both 'account' and 'address' modes.

Also applies to: 110-113, 128-136, 145-157, 189-192, 220-224


116-116: Updated rerender call with mode parameter.

The rerender call now correctly includes the mode parameter to maintain consistency with the initial render.

suite-native/module-trading/src/hooks/useReceiveAccountsListData.ts (4)

16-22: Type definitions look good and improve code clarity.

The introduction of clear type definitions for ReceiveAccountsListMode and UseReceiveAccountsListDataProps provides better structure and makes the code more maintainable.


36-49: Improved conditional logic with the new mode parameter.

The logic now relies on the explicit mode parameter rather than inferring it from whether selectedAccount exists. This makes the code's intention clearer and more maintainable.


78-78: Correctly updated useMemo dependencies.

The mode parameter has been properly added to the dependency array, ensuring the memoized value recalculates when the mode changes.


24-28:

✅ Verification successful

API change improves flexibility but requires updates to all consumers.

The hook signature change from individual parameters to an object parameter follows React best practices and makes it easier to add or modify parameters in the future.

Note that this is a breaking change that requires updating all places where this hook is called.


🏁 Script executed:

#!/bin/bash
# Find all usages of useReceiveAccountsListData to verify they've been updated
rg "useReceiveAccountsListData\(" --type tsx --type ts

Length of output: 84


Refactor hook API usage across the codebase

The updated hook signature now accepts an object parameter, which follows React best practices and allows for easier modifications in the future. However, since this is a breaking change, please ensure that every consumer of useReceiveAccountsListData has been updated accordingly.

  • Verify that there are no lingering calls using the old parameter format.
  • Re-run the above script or perform a manual code review to confirm that all invocations match the updated hook signature.

🏁 Script executed:

#!/bin/bash
# Re-run the search for all usages of useReceiveAccountsListData in .ts and .tsx files
rg "useReceiveAccountsListData\(" -g "*.ts" -g "*.tsx"

Length of output: 328


Hook API change verified in consumer usage

The updated hook signature (taking an object parameter) is now properly propagated. The search confirms that both the main consumer in suite-native/module-trading/src/screens/ReceiveAccountsPickerScreen.tsx and the test in suite-native/module-trading/src/hooks/tests/useReceiveAccountsListData.test.tsx are updated to use the new object parameter.

No further changes are required.

suite-native/module-trading/src/screens/ReceiveAccountsPickerScreen.tsx (6)

76-76: State management looks good.

Proper initialization of picker mode state using the ReceiveAccountsListMode type from the hooks file.


78-83: Good integration with the modified hook.

The component correctly uses the updated useReceiveAccountsListData hook with the new parameter structure.


94-103: Account selection logic is well-implemented.

The onItemSelect function handles account selection, correctly updating Redux state and managing navigation based on whether the selected account has addresses.


123-129: Well-structured handler methods.

The handler methods are concise and each have a single responsibility, following good functional programming principles.


133-151: Conditional footer rendering improves UX.

The footer component is conditionally rendered based on device mode and picker mode, providing a good user experience with appropriate actions available in different states.


181-188: Good integration with AccountTypeDecisionBottomSheet.

The component properly integrates with the AccountTypeDecisionBottomSheet and passes all required props for account type selection.

suite-native/intl/src/en.ts (1)

1294-1309: Improved i18n structure with more specific error messages.

The restructuring of the accountSheet messages into nested objects provides better context-specific error messages for different empty states:

  1. View-only mode without accounts
  2. Network not enabled without accounts
  3. Address not found (preserved from previous structure)

This change aligns well with the new account selection functionality introduced in the ReceiveAccountsPickerScreen.

suite-native/module-add-accounts/src/hooks/useAddCoinAccount.ts (5)

53-53: Improved type safety with AddCoinEnabledAccountType.

The new type properly excludes unsupported account types, making the code more type-safe.


189-196: Added support for 'trade' flow type.

The navigation logic correctly handles the 'trade' flow type, checking the current route and using appropriate navigation actions.


233-233: Enhanced type safety with explicit parameter typing.

The explicit type annotation for the flowType parameter improves type safety and code clarity.


350-363: Conditional navigation based on flow type.

The function now handles navigation differently for 'trade' flow versus other flows, using the appropriate navigation method based on context.


401-401: Export for the new confirmation handler function.

The function is properly added to the hook's return object, making it available to consumers.

suite-native/module-add-accounts/src/screens/AddCoinDiscoveryFinishedScreen.tsx (5)

15-23: Good use of typed imports for navigation.
These new imports from @suite-native/navigation enhance type safety and maintain consistency across files.


29-33: Navigation type aligns well with stack structure.
Introducing AddCoinDiscoveryFinishedScreenNavigationProps keeps the route parameters strongly typed and helps avoid runtime navigation errors.


37-42: Screen parameters strongly defined.
Wrapping the screen component with typed StackProps ensures the route prop matches the expected structure for AddCoinDiscoveryFinishedScreen.


51-51: Ensure usage consistency of handleAccountTypeConfirmation.
This function replaces the older account confirmation logic. Double-check that all references are updated and tested.

Would you like me to generate a script that scans for any remaining calls to deprecated handlers, so you can verify everything points to handleAccountTypeConfirmation?


71-71: Simple direct call to handle confirmations.
This approach is more streamlined, but verify that flowType is always defined to avoid unexpected behavior if navigated incorrectly.

suite-native/module-trading/src/components/buy/ReceiveAccountPicker.tsx (9)

2-2: Redux useSelector import is consistent with the pattern.
This standard approach integrates component state with the global Redux store effectively.


4-4: Navigation import is appropriate.
Using useNavigation helps decouple the component from higher-level navigators while maintaining typed route support.


9-14: Extended navigation types.
Bringing in RootStackParamList, TradingStackParamList, and TradingStackRoutes clarifies route transitions and ensures type checking across route boundaries.


17-17: Select function from Redux store.
selectBuySelectedReceiveAccount is well named. Confirm that the state slice is tested so the component always gets correct account data.


32-36: Dedicated NavigationProps is clear.
Defining a specialized type for navigation props improves maintainability and avoids duplication in multiple components.


38-40: Streamlined ReceiveAccountPickerProps.
Removing unneeded dependencies and exposing only selectedSymbol makes the component’s interface more focused.


87-90: Hook-based navigation and Redux integration.
This pattern is concise and consistent. Make sure that edge cases (e.g., selectedSymbol is undefined) are handled upstream.


98-104: Fetch address text from account object.
The fallback to account.descriptor if addresses are missing is a logical approach. Ensure that other parts of the UI handle descriptor gracefully if no addresses exist.


107-119: Enhanced layout with TradingOverviewRow.
This approach organizes the UI clearly, placing the account information in the right column. The refactor away from inline sheet rendering simplifies the component structure.

Comment on lines +14 to +15
"@mobily/ts-belt": "^3.13.1",
"@react-navigation/native": "6.1.18",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

New dependencies support the account discovery feature

The added dependencies support the PR objective of enabling account discovery via trade:

  • @mobily/ts-belt: Provides functional programming utilities
  • @react-navigation/native: Essential for the new navigation routes
  • @shopify/flash-list: Optimized list rendering for account selection
  • react-native-safe-area-context: Ensures proper layout within safe areas

Note that there's a mix of version specification styles (some with ^ and some with exact versions). Consider standardizing the versioning approach for better maintenance.

Also applies to: 18-18, 26-26


🏁 Script executed:

#!/bin/bash
# Check if all the new dependencies are properly installed
echo "Verifying new dependencies in node_modules"
ls -la node_modules/@mobily/ts-belt node_modules/@react-navigation/native node_modules/@shopify/flash-list node_modules/react-native-safe-area-context 2>/dev/null || echo "Some dependencies might not be installed"

Length of output: 338


Attention: Missing Dependency Installations

While the new dependencies in suite-native/module-trading/package.json support the account discovery feature, the verification step indicates that one or more of the following dependencies are not present in the node_modules directory:

  • @mobily/ts-belt
  • @react-navigation/native
  • @shopify/flash-list
  • react-native-safe-area-context

Please ensure that the package install process (e.g. running npm install or yarn install) completes successfully. Additionally, note the mix of version specifications (some using the caret ^ and others exact); it is recommended to standardize the versioning approach for consistency and better maintenance.

Also applies to similar dependency entries on lines 18 and 26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mobile Trade: Enable network via trade account select
1 participant