Skip to content

chore(suite-native): slightly refactor native supported networks#16938

Merged
vytick merged 1 commit intodevelopfrom
chore/native/purge-network-config
Feb 21, 2025
Merged

chore(suite-native): slightly refactor native supported networks#16938
vytick merged 1 commit intodevelopfrom
chore/native/purge-network-config

Conversation

@vytick
Copy link
Copy Markdown
Contributor

@vytick vytick commented Feb 11, 2025

cleaning

Related Issue

Resolve #16683

@vytick vytick added the mobile Suite Lite issues and PRs label Feb 11, 2025
@vytick vytick requested a review from a team as a code owner February 11, 2025 21:23
coderabbitai[bot]

This comment was marked as resolved.

@vytick vytick changed the title chore(suite-native): refactor slightly native supported networks chore(suite-native): slightly refactor native supported networks Feb 12, 2025
@vytick vytick force-pushed the chore/native/purge-network-config branch from f42129c to e41362c Compare February 20, 2025 21:56
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 20, 2025

🚀 Expo preview is ready!

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

Learn more about 𝝠 Expo Github Action

@trezor trezor deleted a comment from coderabbitai Bot Feb 21, 2025
Copy link
Copy Markdown
Contributor

@yanascz yanascz left a comment

Choose a reason for hiding this comment

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

Seems to work fine!

@vytick
Copy link
Copy Markdown
Contributor Author

vytick commented Feb 21, 2025

/rebase

@vytick vytick enabled auto-merge (rebase) February 21, 2025 13:44
@github-actions
Copy link
Copy Markdown

@trezor-ci trezor-ci force-pushed the chore/native/purge-network-config branch from e41362c to fce1aea Compare February 21, 2025 13:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 21, 2025

Walkthrough

This pull request refactors how network symbols are managed across the suite. In the configuration module, static constants used to hold collections of mainnet and testnet network symbols have been removed and replaced by two functions, getNativeMainnetSymbols and getNativeTestnetSymbols, which dynamically filter and sort the symbols. In the discovery module, selectors have been updated and renamed to reference these new functions instead of the old constants. The UI components, including the selectable network list and the account import summary screen, have also been modified to import and use the updated functions and selectors. Local variable names have been adjusted accordingly to reflect the new data sources, ensuring that the retrieval and utilization of network symbols now follow a dynamic function-based approach rather than relying on predefined constants.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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. (Beta)
  • @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
Copy Markdown

@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: 0

🧹 Nitpick comments (1)
suite-native/discovery/src/discoveryConfigSlice.ts (1)

145-148: Consider memoizing mainnet symbols.

The getNativeMainnetSymbols() is called on every selector execution. Consider adding it to the selector dependencies to leverage Redux's memoization:

 export const selectSupportedNetworkSymbols = createMemoizedSelector(
-    [selectSupportedTestnetNetworkSymbols],
-    testnets => returnStableArrayIfEmpty([...getNativeMainnetSymbols(), ...testnets]),
+    [selectSupportedTestnetNetworkSymbols, () => getNativeMainnetSymbols()],
+    (testnets, mainnets) => returnStableArrayIfEmpty([...mainnets, ...testnets]),
 );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 057452f and fce1aea.

📒 Files selected for processing (4)
  • suite-native/config/src/supportedNetworks.ts (1 hunks)
  • suite-native/discovery/src/discoveryConfigSlice.ts (2 hunks)
  • suite-native/module-accounts-import/src/components/SelectableNetworkList.tsx (2 hunks)
  • suite-native/module-accounts-import/src/screens/AccountImportSummaryScreen.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: EAS Update
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (4)
suite-native/module-accounts-import/src/components/SelectableNetworkList.tsx (1)

7-8: LGTM! Clean refactoring of network symbol management.

The changes improve code clarity by:

  1. Using more descriptive function/selector names
  2. Replacing static constants with dynamic functions
  3. Using consistent naming across the codebase

Also applies to: 34-36, 42-42, 47-47

suite-native/config/src/supportedNetworks.ts (1)

63-71: Well-structured refactoring of network symbol management!

The new functions improve maintainability by:

  1. Encapsulating filtering and sorting logic
  2. Using consistent patterns for both mainnet and testnet
  3. Leveraging existing whitelist configuration
suite-native/module-accounts-import/src/screens/AccountImportSummaryScreen.tsx (1)

9-9: LGTM! Clean variable renaming.

The changes maintain functionality while improving naming consistency across the codebase.

Also applies to: 42-42, 45-45

suite-native/discovery/src/discoveryConfigSlice.ts (1)

14-15: LGTM! Clean selector renaming.

The changes improve code clarity by using consistent naming across selectors.

Also applies to: 135-143

@vytick vytick merged commit 918dc5b into develop Feb 21, 2025
@vytick vytick deleted the chore/native/purge-network-config branch February 21, 2025 13:53
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.

supportedNetworks.ts cleanup

2 participants