chore(scripts): add contract upgrade automation scripts #996
+146
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Descriptions
This PR introduces automation scripts to streamline the process of creating and deploying versioned contract upgrades.
Changes
1. New Script:
tests/scripts/patch-upgrade.shA bash script that automates the creation of upgradeable contract versions by:
*test.gno) from the copygnomod.tomlmodule paths from/v1to the target versionpackage v1declarations withpackage {version}in all.gnofiles2. Enhanced Makefile Targets
Added two new high-level targets in
tests/Makefile:deploy-version: Creates a new contract version and deploys itupgrade-version: Upgrades an existing contract to a new versionAdded supporting targets in
tests/scripts/deploy.mk:deploy-contract-version: Deploys a specific contract versionupgrade-version: Calls theUpgradeImplfunction to upgrade a contractUsage
Creating and Deploying a New Version
Syntax
make deploy-version CONTRACT=<contract_name> VERSION=
Examples
make deploy-version CONTRACT=pool VERSION=v2
make deploy-version CONTRACT=launchpad VERSION=v3
make deploy-version CONTRACT=staker VERSION=v2This command will:
Upgrading an Existing Contract
Syntax
make upgrade-version CONTRACT=<contract_name> VERSION=
Examples
make upgrade-version CONTRACT=pool VERSION=v2
make upgrade-version CONTRACT=launchpad VERSION=v3This command calls the
UpgradeImplfunction on the contract to switch to the new implementation.Using the Script Directly
Syntax
./tests/scripts/patch-upgrade.sh <contract_path>
Example
./tests/scripts/patch-upgrade.sh contract/r/gnoswap/launchpad v2### Environment Configuration
The deployment targets respect the
ENVvariable for environment-specific configurations:Deploy to specific environment
make deploy-version CONTRACT=pool VERSION=v2 ENV=dev.local
Upgrade on specific environment
make upgrade-version CONTRACT=pool VERSION=v2 ENV=test9.local### Version Format
Version must follow the format
v<number>(e.g., v2, v3, v4). The script validates this format and will error if invalid.