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: remove unnecessary configs in custom configs #1236

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

songwongtp
Copy link
Collaborator

@songwongtp songwongtp commented Feb 18, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced custom network configuration with refined defaults, including a new wallet management option.
    • Expanded support for advanced network customization with improved JSON export and feature validations.
  • Bug Fixes

    • Fixed an issue with network settings interactions to prevent unintended navigation behavior.
  • Documentation

    • Updated changelog entries to reflect the streamlined configuration options for custom networks.

Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request updates documentation, user interface behavior, network configuration defaults, and type definitions. A new changelog entry is added under "Improvements." In the UI, a click event handler now stops event propagation on the settings icon. Default network configuration constants have been modified, and the JSON generation in the custom network edit page now uses a more selective property extraction approach. Additionally, new Zod schemas for EVM, Move, and WASM configurations have been introduced and exported for broader use.

Changes

File(s) Change Summary
CHANGELOG.md Added new entry under "Improvements": removal of unnecessary configs for users in custom network configurations (#1236).
src/lib/.../network-card/NetworkCardCta.tsx Modified onClick handler to include an event parameter and call e.stopPropagation() before navigation.
src/lib/pages/custom-network/constant.ts, src/lib/pages/custom-network/edit/index.tsx, src/lib/pages/custom-network/types.ts, src/lib/types/chainConfig.ts Updated default configuration constants (e.g., disabling public project config, adding wallets), replaced omit with pick in JSON generation, introduced new Zod schemas (zEvmConfig, zMoveConfig, zWasmConfig), and exported these schemas for external access.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant C as NetworkCardCta Component
    participant N as Navigator
    U->>C: Click on settings icon
    C->>C: Call stopPropagation()
    C->>N: Invoke navigate()
Loading
sequenceDiagram
    participant N as NetworkConfigBody Component
    participant D as chainConfig Data
    N->>N: Check if chainConfig exists
    alt chainConfig is undefined
        N->>N: Return empty string
    else
        N->>N: Use pick() to select specific properties and features (wasm, move, evm)
        N->>JSON: Generate JSON export with selected data
    end
Loading

Possibly related PRs

Suggested reviewers

  • evilpeach

Poem

I'm hopping through the lines of code so bright,
Cleaning up configs and setting things just right.
With each stopPropagation and picked key in sight,
My code garden blooms both day and night.
A rabbit's cheer for changes that delight!
🥕🐇 Happy coding, all is light!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/lib/layout/network-menu/network-card/NetworkCardCta.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.json".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

src/lib/pages/custom-network/types.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.json".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

src/lib/types/chainConfig.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.json".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 2 others
✨ 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

vercel bot commented Feb 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
celatone-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 18, 2025 11:12am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am
initia-celatone-frontend ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am
sei-celatone-frontend ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am
terra-celatone-frontend ⬜️ Ignored (Inspect) Feb 18, 2025 11:12am

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

🧹 Nitpick comments (1)
src/lib/pages/custom-network/edit/index.tsx (1)

60-76: Consider using a type-safe approach for JSON property selection.

While the explicit property selection improves clarity and ensures consistent output, hardcoding the property list might make maintenance more challenging. Consider defining a type or constant for the required properties to improve maintainability.

+// Define required properties as a constant
+const REQUIRED_CHAIN_CONFIG_PROPERTIES = [
+  'chainId',
+  'registryChainName',
+  'prettyName',
+  'logo_URIs',
+  'lcd',
+  'rpc',
+  'features',
+  'gas',
+  'fees',
+  'registry',
+] as const;

 const json = useMemo(() => {
   if (!chainConfig) return "";

-  // NOTE: hardcoding so the order is fixed
-  return JSON.stringify({
-    chainId: chainConfig.chainId,
-    registryChainName: chainConfig.registryChainName,
-    prettyName: chainConfig.prettyName,
-    logo_URIs: chainConfig.logo_URIs,
-    lcd: chainConfig.lcd,
-    rpc: chainConfig.rpc,
-    features: pick(chainConfig.features, ["wasm", "move", "evm"]),
-    gas: chainConfig.gas,
-    fees: chainConfig.fees,
-    registry: chainConfig.registry,
-  });
+  const selectedConfig = pick(chainConfig, REQUIRED_CHAIN_CONFIG_PROPERTIES);
+  selectedConfig.features = pick(chainConfig.features, ["wasm", "move", "evm"]);
+  return JSON.stringify(selectedConfig);
 }, [chainConfig]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d1fb3f0 and df4aafc.

📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • src/lib/layout/network-menu/network-card/NetworkCardCta.tsx (1 hunks)
  • src/lib/pages/custom-network/constant.ts (2 hunks)
  • src/lib/pages/custom-network/edit/index.tsx (2 hunks)
  • src/lib/pages/custom-network/types.ts (2 hunks)
  • src/lib/types/chainConfig.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (8)
src/lib/types/chainConfig.ts (1)

18-47: LGTM! Improved schema reusability.

Exporting these VM configuration schemas enhances modularity by allowing their reuse across the application, particularly in network configuration validation.

src/lib/pages/custom-network/constant.ts (2)

20-20: LGTM! Improved default configuration.

Setting enabled: false as the default for public projects aligns with the goal of removing unnecessary configurations.


45-49: LGTM! Enhanced type safety.

Adding the wallets property with an empty array as default ensures type consistency and prevents potential undefined errors.

src/lib/layout/network-menu/network-card/NetworkCardCta.tsx (1)

98-106: LGTM! Improved event handling.

Adding e.stopPropagation() prevents unintended event bubbling, ensuring the settings icon click behaves independently of parent click handlers.

src/lib/pages/custom-network/edit/index.tsx (1)

61-61: LGTM! Improved null handling.

Adding the null check for chainConfig prevents potential runtime errors.

src/lib/pages/custom-network/types.ts (2)

11-11: LGTM! Added VM-specific configuration imports.

The addition of zEvmConfig, zMoveConfig, and zWasmConfig imports enables proper type validation for different virtual machine configurations.

Also applies to: 16-16, 19-19


451-457: LGTM! Enhanced features schema with VM-specific configurations.

The features object in zAddNetworkJsonChainConfigJson now properly includes dedicated configurations for WASM, Move, and EVM virtual machines, improving type safety and validation.

CHANGELOG.md (1)

81-81: LGTM! Clear and concise changelog entry.

The changelog entry accurately describes the PR's purpose of removing unnecessary configurations from custom network configs.

Copy link
Collaborator

@Poafs1 Poafs1 left a comment

Choose a reason for hiding this comment

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

lgtm

@songwongtp songwongtp merged commit 9a9ef42 into develop Feb 18, 2025
13 checks passed
@songwongtp songwongtp deleted the feat/modify-custom-configs branch February 18, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants