Skip to content

Conversation

@mondoreale
Copy link
Contributor

No description provided.

@mondoreale mondoreale requested a review from jtakalai October 31, 2024 12:41
@linear
Copy link

linear bot commented Oct 31, 2024

Copy link

@jtakalai jtakalai left a 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.

@jtakalai jtakalai self-requested a review December 9, 2024 09:22
@mondoreale mondoreale force-pushed the eth-795-export-chain-type-in-config branch from b35c654 to 931d4e4 Compare January 27, 2025 16:38
Copy link
Contributor Author

@mondoreale mondoreale left a 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,
  • ChainKey i.e. dev1, polygon, …,
  • Config which is the entire thing, and
  • ContractAddressKey i.e. DATA, XDATA, SponsorshipFactory, and so on.

LMK your thoughts.


A couple of screenshots

image

image

image

@mondoreale mondoreale requested a review from jtakalai January 27, 2025 16:48
@mondoreale
Copy link
Contributor Author

I seem to be unable to install per-package deps with npm v10.7… Corrupts the root package-lock.

@openzeppelin-code
Copy link

ETH-795: Export chain-related types along with the config

Generated at commit: b21a73350131fc28972bf01e31760bf9e92ae66e

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
1
0
13
40
57
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

Copy link

@jtakalai jtakalai left a comment

Choose a reason for hiding this comment

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

very nice! 👍

Copy link
Contributor

@harbu harbu left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 useful clarifying comment

Comment on lines 50 to 54
After each update to the source config file (config.json) re-generate and validate types:
```bash
npm run generate-types && npx tsc --noEmit
```

Copy link
Contributor

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.

@mondoreale mondoreale merged commit 5a06601 into master Jan 29, 2025
3 checks passed
@mondoreale mondoreale deleted the eth-795-export-chain-type-in-config branch January 29, 2025 14:42
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.

4 participants