-
Notifications
You must be signed in to change notification settings - Fork 5
ETH-795: Export chain-related types along with the config #923
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
Conversation
jtakalai
left a comment
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.
problem with removing ""s from the rawConfig is now it's not JSON anymore. Even better would be to put it into a separate json file (which is valid JSON), then read from there and give correct types for typescript. We want non-JS/TS languages be able to read this config as well.
b35c654 to
931d4e4
Compare
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.
@jtakalai, have a look at how it all evolved. We now have
- A single source file (config.json), and
- The generated typed version of it in
src/generated/config.ts
The config module exports the index file which in turn exports the typed config to satisfy @harbu's as const request.
Additionally, the index file exports
Chain,ChainKeyi.e.dev1,polygon, …,Configwhich is the entire thing, andContractAddressKeyi.e.DATA,XDATA,SponsorshipFactory, and so on.
LMK your thoughts.
A couple of screenshots
|
I seem to be unable to install per-package deps with npm v10.7… Corrupts the root package-lock. |
This reverts commit b21a733.
ETH-795: Export chain-related types along with the config
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
jtakalai
left a comment
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.
very nice! 👍
harbu
left a comment
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! 👍 See my suggestion for small clarification on README
|
|
||
| /** | ||
| * The following line makes sure the format of the source json file matches | ||
| * the types. It's a validation step. Keep it. |
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.
👍 useful clarifying comment
packages/config/README.md
Outdated
| After each update to the source config file (config.json) re-generate and validate types: | ||
| ```bash | ||
| npm run generate-types && npx tsc --noEmit | ||
| ``` | ||
|
|
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.
I think we should direct the user towards running npm run build right? My first impression reading this what that I'm required to remember to run generate-types manually before publishing when really npm run build would take care of it.



No description provided.