Skip to content

Conversation

@jinoosss
Copy link
Member

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.sh

A bash script that automates the creation of upgradeable contract versions by:

  • Copying the v1 contract directory to a new version directory
  • Excluding test files (*test.gno) from the copy
  • Updating gnomod.toml module paths from /v1 to the target version
  • Replacing package v1 declarations with package {version} in all .gno files
  • Cross-platform support (macOS and Linux)

2. Enhanced Makefile Targets

Added two new high-level targets in tests/Makefile:

  • deploy-version: Creates a new contract version and deploys it
  • upgrade-version: Upgrades an existing contract to a new version

Added supporting targets in tests/scripts/deploy.mk:

  • deploy-contract-version: Deploys a specific contract version
  • upgrade-version: Calls the UpgradeImpl function to upgrade a contract

Usage

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:

  1. Create a new version directory by copying from v1 (excluding tests)
  2. Update all version references in the code
  3. Deploy the new version to the blockchain

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 UpgradeImpl function 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 ENV variable 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.

@sonarqubecloud
Copy link

@jinoosss jinoosss merged commit 15bc233 into main Nov 20, 2025
84 of 86 checks passed
@jinoosss jinoosss deleted the chore/add-upgrade-scrips branch November 20, 2025 10:00
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.

3 participants