-
Notifications
You must be signed in to change notification settings - Fork 0
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
automatic chain addition #22
Labels
enhancement
New feature or request
Comments
generateIndex.js:
|
package.json:
|
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create the Dynamic Index Generator Script
Description:
Create a script that will automatically generate an index.ts file in the configs directory, which imports all .config.ts files.
Steps:
Create a new script file named generateIndex.js.
In this script, use Node.js's fs module to read all files from the configs directory.
Filter out files that aren't .config.ts.
For each .config.ts file, add an import statement to a string.
Write this string of import statements to a new index.ts file in the configs directory.
Modify package.json Scripts
Description:
Add a new script to run the generateIndex.js file and modify the prebuild script to run this new script before the build process.
Steps:
Add a new script named generate-index to the scripts section of package.json that runs generateIndex.js.
Modify the prebuild script to run the generate-index script before any other commands.
Update Chain Configuration Files
Description: Modify each .config.ts file to use the new class-based approach, so they automatically register themselves upon being imported.
Steps:
Ensure each .config.ts file exports a class instance of TChainConfig.
The class constructor should handle the registration to the central AVAILABLE_CHAINS map.
Simplify the Constant Index File
Description:
Since configurations will register themselves upon import, the constant index file (where you previously manually added each chain to the map) can be simplified.
Steps:
Remove manual AVAILABLE_CHAINS.set(...) calls from the constant index file.
Import the new index.ts from the configs directory to ensure all configurations are loaded and registered.
Test
Description:
Ensure that all configurations are correctly registered and accessible.
Steps:
Run the build script to ensure everything compiles without errors.
Write tests or manually verify that all configurations are correctly loaded and registered in the AVAILABLE_CHAINS map.
Update Documentation
Description:
Update any relevant documentation or README files to describe the new dynamic import process and how to add new configurations.
Steps:
Describe the new class-based approach for chain configurations.
Explain how the generateIndex.js script works and its role in the build process.
Provide instructions for adding new chain configurations, emphasizing that there's no need to manually register them in the constant index file anymore.
By following these steps, you'll have a streamlined process for adding and registering new chain configurations, making the system more maintainable and reducing potential sources of error.
The text was updated successfully, but these errors were encountered: