-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
WalkthroughThis 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
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()
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
Possibly related PRs
Suggested reviewers
Poem
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
src/lib/layout/network-menu/network-card/NetworkCardCta.tsxOops! 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:
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.tsOops! 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:
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.tsOops! 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:
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.
✨ Finishing Touches
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 (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
There was a problem hiding this 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
📒 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
, andzWasmConfig
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 inzAddNetworkJsonChainConfigJson
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary by CodeRabbit
New Features
Bug Fixes
Documentation