improve flexibility of gethwrapper helpers#316
Conversation
| } else { | ||
| outDirSuffix = "latest" | ||
| } | ||
| outDirSuffix := "latest" |
There was a problem hiding this comment.
Wrappers are always generated into latest. Teams that wish to adopt this new wrapper generation should also adopt the versioned gethwrappers.
There was a problem hiding this comment.
Pull request overview
This PR improves the flexibility of gethwrapper helpers by removing the hardcoded relative location for the abigen executable. Instead, the changes allow passing the abigen executable path as an argument, making the wrapper generation more configurable.
Changes:
- Removed
GetProjectRoot()helper function that walked the filesystem to find the project root - Refactored wrapper generation logic into a reusable
wrappackage - Added
AbiGenPathparameter toAbigenArgsstruct to accept the abigen executable path as an argument
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| gethwrappers/helpers/utils.go | Removed unused GetProjectRoot() function and filepath import |
| gethwrappers/helpers/generate/wrap/wrap.go | New package containing extracted GenWrapper() and GetOutDir() functions |
| gethwrappers/helpers/generate/wrap.go | Refactored to use new wrap package and accept abiGenPath as command-line argument |
| gethwrappers/helpers/abigen.go | Updated to accept and use AbiGenPath parameter instead of computing path via GetProjectRoot() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // <project>/generated/<pkgName>/<pkgName>.go. The suffix will take place after | ||
| // the <project>/generated, so the overridden location would be | ||
| // <project>/generated/<outDirSuffixInput>/<pkgName>/<pkgName>.go. | ||
| func GenWrapper(projectRoot, contract, pkgName, outDirSuffixInput, abiGenPath string) { |
There was a problem hiding this comment.
q: is this function not used in this repo and only intended to be a helper for other repos? it looks to me like this repo only uses https://github.com/smartcontractkit/chainlink-evm/blob/modify-gethwrapper-helpers/gethwrappers/generation/generate/genwrapper/genwrapper.go?
nit: could we add a comment/example of what the projectRoot arg is?
The previous helpers required abigen to be in a hard coded relative location. These changes allow us to call the gethwrapper logic directly with args for the abigen executable.