fix: upgrade script now correctly handles pre-defined versions in registry

When upgrading to a version that already exists in registry.json (like 2.12.0),
the script now uses that version's initializerVersion instead of incrementing
from the latest version. This fixes the reinitializer validation for the
governance upgrade.
This commit is contained in:
Evi Nova
2025-12-10 15:21:01 +10:00
parent 672c996632
commit 1306f973e2

View File

@@ -34,6 +34,7 @@ import {
createGitTag,
gitCommit,
getLatestVersionInfo,
getVersionInfo,
getGovernanceConfig,
validateReinitializerVersion,
} from "./utils";
@@ -310,8 +311,14 @@ task("upgrade", "Deploy new implementation and create Safe proposal for upgrade"
// ========================================================================
log.step("Checking reinitializer version...");
// Check if target version already exists in registry
const targetVersionInfo = getVersionInfo(contractId, newVersion);
const latestVersionInfo = getLatestVersionInfo(contractId);
const expectedInitializerVersion = (latestVersionInfo?.info.initializerVersion || 0) + 1;
// If target version exists, use its initializerVersion; otherwise increment latest
const expectedInitializerVersion = targetVersionInfo
? targetVersionInfo.initializerVersion
: (latestVersionInfo?.info.initializerVersion || 0) + 1;
if (contractFilePath) {
const reinitValidation = validateReinitializerVersion(contractFilePath, expectedInitializerVersion);