You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dynamic Import Check Ensure that the dynamic import of all chains from viem/chains using wildcard import and subsequent usage in SUPPORTED_NETWORKS does not introduce any runtime errors or issues with missing or undefined chain configurations.
Add validation for the 'chains' object to ensure it contains valid data
Consider validating the chains object before using it in createNetworkMap. This ensures that the object is not empty and contains valid data, preventing runtime errors if the import fails or the data structure is not as expected.
+if (!chains || Object.keys(chains).length === 0) {+ throw new Error("No chains found or invalid chains object.");+}
const SUPPORTED_NETWORKS = createNetworkMap(Object.values(chains));
Suggestion importance[1-10]: 9
Why: This suggestion adds a crucial validation step to ensure that the 'chains' object is not empty or invalid, which can prevent potential runtime errors. This is a significant improvement in terms of robustness and error handling.
9
Possible bug
Handle cases where 'Object.values(chains)' might return an empty array in 'createNetworkMap'
Ensure that the createNetworkMap function handles cases where Object.values(chains) might return an empty array, which could lead to unexpected behavior if not handled properly.
Why: This suggestion ensures that the 'createNetworkMap' function handles empty arrays gracefully, preventing potential issues. It is a valuable addition for robustness.
8
Best practice
Add a type definition for the 'SUPPORTED_NETWORKS' variable to enhance readability and maintain type safety
To enhance readability and maintainability, consider adding a type definition for the SUPPORTED_NETWORKS variable. This will help developers understand what kind of data structure they are working with and ensure type safety.
Why: Adding a type definition improves code readability and maintainability by making the data structure explicit. This is a good practice but not as critical as runtime validation.
7
Enhancement
Add a unit test to verify the integrity and completeness of the 'SUPPORTED_NETWORKS' map
To ensure that all networks are correctly supported and initialized, consider adding a unit test that verifies the integrity and completeness of the SUPPORTED_NETWORKS map.
Why: Adding a unit test is beneficial for ensuring the integrity of the 'SUPPORTED_NETWORKS' map. While it is an enhancement for testing, it is not as critical as runtime checks or type definitions.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Instead of having a finite supported chain list, we now support all chains provided by viem.
PR Type
enhancement, dependencies
Description
viem/chains
.SUPPORTED_NETWORKS
to include all chains exported byviem
, allowing dynamic support for any new chains added by theviem
library.Changes walkthrough 📝
network.ts
Support all chains exported by `viem` in network configuration
src/network.ts
viem/chains
.SUPPORTED_NETWORKS
to include all chains exported byviem
.