-
Notifications
You must be signed in to change notification settings - Fork 83
Extract contract addresses from artifacts #3086
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
We want to resolve the package to download with `npm view` as it checks the registry for the current package that is tagged. When `npm pack` was used it used cached version of the tagged package and wasn't downloading the latest one.
We already download artifacts of deployed contracts from NPM registry. Here we add support of extracting addresses of contracts from the artifacts. The address is extracted and stored in `_address/<CONTRACT>` file and then embeded into the go code. This solution is intended to be used for clients building for specific environment. For example if we set `CONTRACTS_NPM_PACKAGE_TAG` environment variable to `goerli`. It will download a package of contracts deployed on Goerli network and extract addresses from it. The client will be build specific for Goerli network, without a need of configuring the addresses in a config file. There will be a possibility to overwrite the addresses with a configuration file or environment variables. Addresses extraction will happen on `go generate ./...` command execution along with the go bindings generation. To test the solution for Goerli please run: `CONTRACTS_NPM_PACKAGE_TAG=goerli go generate./...` Please note that for `development` which is a default tag the addresses will be replaced with zeros, as the contracts artifacts that are published with `development` tags are intended only for ABIs generation, as the contracts are deployed locally in CI, and won't be accessible anywhere.
We cleanup always before running bindings generation as current configuration of make doesn't work well with source artifacts that are extracted from tar archive.
Added a json artifact reference as a prerequisite for binding generation.
`jq` is required by go generator command.
The files are required to exist by gosec.
|
I am having problems testing it locally. Anything extra I should do? |
For goerli only threshold network and random beacon generation will work. We need to publish contracts first. I suggest in this PR we test just the |
OK, this is fine. I tested with just |
The directory no longer exist.
The directories have missing `_address/*` files so gosec fails. We could put the files into repo or generate them, but also just exclude the directories.
We already download artifacts of deployed contracts from the NPM registry.
Here we add support for extracting addresses of contracts from the
artifacts. The address is extracted and stored in
_address/<CONTRACT>file and then embedded into the go code.
This solution is intended to be used for clients building for a specific environment. For example, if we set
CONTRACTS_NPM_PACKAGE_TAGenvironment variable togoerli. It will download a package of contracts deployed on the Goerli network and extract addresses from it. The client will be built specifically for the Goerli network, without the need of configuring the addresses in a config file.There will be a possibility to overwrite the addresses with a configuration file or environment variables.
Addresses extraction will happen on
go generate ./...command execution along with the go bindings generation.To test the solution for Goerli please run:
CONTRACTS_NPM_PACKAGE_TAG=goerli go generate./...Please note that for
developmentwhich is a default tag the addresses will be replaced with zeros, as the contracts artifacts that are published withdevelopmenttags are intended only for ABIs generation, as the contracts are deployed locally in CI, and won't be accessible anywhere.In a follow-up PR we will resolve contract addresses to initialize the chain handle.