From fdacbe33be8c07fd595aceeafafc74535a02108f Mon Sep 17 00:00:00 2001 From: Galmanus Date: Tue, 25 Aug 2026 08:13:22 -0300 Subject: [PATCH] fix(core): upgrade skip path returns artifacts file path, not cwd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an upgrade is skipped via ifChanged (unchanged WASM hash), upgradeContractInPlace returned artifactPath: cwd (the working directory). The non-skip path and deploy-contract both return the artifacts file path. Return path.resolve(cwd, 'caatinga.artifacts.json') so the skip and non-skip results are consistent. Kept the field name artifactPath (renaming to artifactsPath, as the issue notes for consistency with deploy, would be a breaking return-type change for CLI consumers — left for a maintainer API decision). Closes #85 --- packages/core/src/contracts/upgrade-contract.test.ts | 2 ++ packages/core/src/contracts/upgrade-contract.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/contracts/upgrade-contract.test.ts b/packages/core/src/contracts/upgrade-contract.test.ts index 23192e10..4f4bc9d2 100644 --- a/packages/core/src/contracts/upgrade-contract.test.ts +++ b/packages/core/src/contracts/upgrade-contract.test.ts @@ -141,6 +141,8 @@ describe("upgradeContractInPlace", () => { }); expect(result.skipped).toBe(true); + // #85: the skip path must return the artifacts file path, not cwd. + expect(result.artifactPath).toBe(path.join(tmpDir, "caatinga.artifacts.json")); const uploadCalls = runCommand.mock.calls.filter(([, args]) => args[1] === "upload"); const invokeCalls = runCommand.mock.calls.filter(([, args]) => args[1] === "invoke"); expect(uploadCalls).toHaveLength(0); diff --git a/packages/core/src/contracts/upgrade-contract.ts b/packages/core/src/contracts/upgrade-contract.ts index 7bf0aea8..e97176c8 100644 --- a/packages/core/src/contracts/upgrade-contract.ts +++ b/packages/core/src/contracts/upgrade-contract.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { withArtifactsLock } from "../artifacts/artifacts-lock.js"; import { readArtifacts } from "../artifacts/read-artifacts.js"; import { updateArtifact } from "../artifacts/update-artifact.js"; @@ -102,7 +103,9 @@ export async function upgradeContractInPlace( wasmHash: existing.wasmHash, network, skipped: true, - artifactPath: cwd, + // Match the non-skip path (and deploy-contract), which returns the + // artifacts file path — not the working directory. + artifactPath: path.resolve(cwd, "caatinga.artifacts.json"), }; }