From 92b46a85182e04ba2f72b240cac7127b07c73d1e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Aug 2025 20:20:15 -0300 Subject: [PATCH 01/40] add wrapAsEither circuits --- contracts/src/utils/Utils.compact | 46 +++++++++++++++++++ .../src/utils/test/mocks/MockUtils.compact | 16 +++++++ .../utils/test/simulators/UtilsSimulator.ts | 28 +++++++++++ contracts/src/utils/test/utils.test.ts | 29 ++++++++++++ 4 files changed, 119 insertions(+) diff --git a/contracts/src/utils/Utils.compact b/contracts/src/utils/Utils.compact index 3528e10e..b7291176 100644 --- a/contracts/src/utils/Utils.compact +++ b/contracts/src/utils/Utils.compact @@ -66,6 +66,52 @@ module Utils { return !keyOrAddress.is_left; } + /** + * @description Wraps a value as the `L` variant of a disjoint union (`Either`), + * following Compact conventions. + * + * Sets `is_left` to true, assigns the provided value to `left`, and sets `right` to `default` per convention. + * + * This helper is useful when you already have a value of type `L`, but the circuit interface expects an `Either`. + * It avoids manually constructing the full struct and ensures consistent formatting. + * + * @template L - Type of the Left variant. + * @template R - Type of the Right variant. + * + * @param {L} left - The value to wrap as the Left variant. + * @returns {Either} A disjoint union (`Either`) with the value in the `L` variant. + */ + export pure circuit wrapAsEitherLeft(left: L): Either { + return Either { + is_left: true, + left: left, + right: default + }; + } + + /** + * @description Wraps a value as the `R` variant of a disjoint union (`Either`), + * following Compact conventions. + * + * Sets `is_left` to false, assigns the provided value to `right`, and sets `left` to `default` per convention. + * + * This helper is useful when you already have a value of type `R`, but the circuit interface expects an `Either`. + * It avoids manually constructing the full struct and ensures consistent formatting. + * + * @template L - Type of the Left variant. + * @template R - Type of the Right variant. + * + * @param {R} right - The value to wrap as the `R` variant. + * @returns {Either} A disjoint union (`Either`) with the value in the `R` variant. + */ + export pure circuit wrapAsEitherRight(right: R): Either { + return Either { + is_left: false, + left: default, + right: right + }; + } + /** * @description A helper function that returns the empty string: "". * diff --git a/contracts/src/utils/test/mocks/MockUtils.compact b/contracts/src/utils/test/mocks/MockUtils.compact index 54fd45f3..c3b66d64 100644 --- a/contracts/src/utils/test/mocks/MockUtils.compact +++ b/contracts/src/utils/test/mocks/MockUtils.compact @@ -25,6 +25,22 @@ export pure circuit isContractAddress(keyOrAddress: Either { + return Utils_wrapAsEitherLeft(pk); +} + +// Find a better way to test different combinations +// other than creating a circuit for each pair +export pure circuit wrapAsEitherPkOrAddressRight( + address: ContractAddress, +): Either { + return Utils_wrapAsEitherRight(address); +} + export pure circuit emptyString(): Opaque<"string"> { return Utils_emptyString(); } diff --git a/contracts/src/utils/test/simulators/UtilsSimulator.ts b/contracts/src/utils/test/simulators/UtilsSimulator.ts index 715569f8..5f46223e 100644 --- a/contracts/src/utils/test/simulators/UtilsSimulator.ts +++ b/contracts/src/utils/test/simulators/UtilsSimulator.ts @@ -139,6 +139,34 @@ export class UtilsSimulator ).result; } + /** + * @description Returns `pk` wrapped in an `Either` type. + * @param pk The target value to wrap. + * @returns `Either` with `pk` in the left position. + */ + public wrapAsEitherPkOrAddressLeft( + pk: ZswapCoinPublicKey, + ): Either { + return this.contract.circuits.wrapAsEitherPkOrAddressLeft( + this.circuitContext, + pk, + ).result; + } + + /** + * @description Returns `address` wrapped in an `Either` type. + * @param pk The target value to wrap. + * @returns `Either` with `address` in the right position. + */ + public wrapAsEitherPkOrAddressRight( + address: ContractAddress, + ): Either { + return this.contract.circuits.wrapAsEitherPkOrAddressRight( + this.circuitContext, + address, + ).result; + } + /** * @description A helper function that returns the empty string: "" * @returns The empty string: "" diff --git a/contracts/src/utils/test/utils.test.ts b/contracts/src/utils/test/utils.test.ts index 1398d4d9..52b78acc 100644 --- a/contracts/src/utils/test/utils.test.ts +++ b/contracts/src/utils/test/utils.test.ts @@ -1,4 +1,9 @@ import { describe, expect, it } from 'vitest'; +import type { + ContractAddress, + Either, + ZswapCoinPublicKey, +} from './../../../artifacts/MockUtils/contract/index.cjs'; // Combined imports import { UtilsSimulator } from './simulators/UtilsSimulator.js'; import * as contractUtils from './utils/address.js'; @@ -87,6 +92,30 @@ describe('Utils', () => { }); }); + describe('wrapAsEitherLeft', () => { + it('should wrap pk as left', () => { + const pk = contractUtils.encodeToPK('PK'); + const exp: Either = { + is_left: true, + left: pk, + right: { bytes: new Uint8Array(32).fill(0) }, + }; + expect(contract.wrapAsEitherPkOrAddressLeft(pk)).toEqual(exp); + }); + }); + + describe('wrapAsEitherRight', () => { + it('should wrap address as right', () => { + const address = contractUtils.encodeToPK('ADDRESS'); + const exp: Either = { + is_left: false, + left: { bytes: new Uint8Array(32).fill(0) }, + right: address, + }; + expect(contract.wrapAsEitherPkOrAddressRight(address)).toEqual(exp); + }); + }); + describe('emptyString', () => { it('should return the empty string', () => { expect(contract.emptyString()).toBe(EMPTY_STRING); From 9fc5bbee9cccb63e3c3e6eec6c979af959dfcec9 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Aug 2025 21:23:23 -0300 Subject: [PATCH 02/40] add option to compile directory in compact --- compact/src/Compiler.ts | 39 +++++++++++++++++++++++++++++++------- compact/src/runCompiler.ts | 37 ++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/compact/src/Compiler.ts b/compact/src/Compiler.ts index 53b292ae..e79bd48f 100755 --- a/compact/src/Compiler.ts +++ b/compact/src/Compiler.ts @@ -27,6 +27,12 @@ const COMPACTC_PATH: string = join(COMPACT_HOME, 'compactc'); * compiler.compile().catch(err => console.error(err)); * ``` * + * @example Compile specific directory + * ```typescript + * const compiler = new CompactCompiler('--skip-zk', 'security'); + * compiler.compile().catch(err => console.error(err)); + * ``` + * * @example Successful Compilation Output * ``` * ℹ [COMPILE] Found 2 .compact file(s) to compile @@ -48,19 +54,26 @@ const COMPACTC_PATH: string = join(COMPACT_HOME, 'compactc'); export class CompactCompiler { /** Stores the compiler flags passed via command-line arguments */ private readonly flags: string; + /** Optional target directory to limit compilation scope */ + private readonly targetDir?: string; /** * Constructs a new CompactCompiler instance, validating the `compactc` binary path. * * @param flags - Space-separated string of `compactc` flags (e.g., "--skip-zk --no-communications-commitment") + * @param targetDir - Optional subdirectory within src/ to limit compilation (e.g., "security", "utils") * @throws {Error} If the `compactc` binary is not found at the resolved path */ - constructor(flags: string) { + constructor(flags: string, targetDir?: string) { this.flags = flags.trim(); + this.targetDir = targetDir; const spinner = ora(); spinner.info(chalk.blue(`[COMPILE] COMPACT_HOME: ${COMPACT_HOME}`)); spinner.info(chalk.blue(`[COMPILE] COMPACTC_PATH: ${COMPACTC_PATH}`)); + if (this.targetDir) { + spinner.info(chalk.blue(`[COMPILE] TARGET_DIR: ${this.targetDir}`)); + } if (!existsSync(COMPACTC_PATH)) { spinner.fail( @@ -73,25 +86,36 @@ export class CompactCompiler { } /** - * Compiles all `.compact` files in the source directory and its subdirectories (e.g., `src/test/mock/`). - * Scans the `src` directory recursively for `.compact` files, compiles each one using `compactc`, - * and displays progress with a spinner and colored output. + * Compiles all `.compact` files in the source directory (or target subdirectory) and its subdirectories. + * Scans the `src` directory (or `src/{targetDir}`) recursively for `.compact` files, + * compiles each one using `compactc`, and displays progress with a spinner and colored output. * * @returns A promise that resolves when all files are compiled successfully * @throws {Error} If compilation fails for any file */ public async compile(): Promise { - const compactFiles: string[] = await this.getCompactFiles(SRC_DIR); + const searchDir = this.targetDir ? join(SRC_DIR, this.targetDir) : SRC_DIR; + + // Validate target directory exists + if (this.targetDir && !existsSync(searchDir)) { + const spinner = ora(); + spinner.fail(chalk.red(`[COMPILE] Error: Target directory ${searchDir} does not exist.`)); + throw new Error(`Target directory ${searchDir} does not exist`); + } + + const compactFiles: string[] = await this.getCompactFiles(searchDir); const spinner = ora(); if (compactFiles.length === 0) { - spinner.warn(chalk.yellow('[COMPILE] No .compact files found.')); + const searchLocation = this.targetDir ? `${this.targetDir}/` : ''; + spinner.warn(chalk.yellow(`[COMPILE] No .compact files found in ${searchLocation}.`)); return; } + const searchLocation = this.targetDir ? ` in ${this.targetDir}/` : ''; spinner.info( chalk.blue( - `[COMPILE] Found ${compactFiles.length} .compact file(s) to compile`, + `[COMPILE] Found ${compactFiles.length} .compact file(s) to compile${searchLocation}`, ), ); @@ -123,6 +147,7 @@ export class CompactCompiler { } if (entry.isFile() && fullPath.endsWith('.compact')) { + // Always return relative path from SRC_DIR, regardless of search directory return [relative(SRC_DIR, fullPath)]; } return []; diff --git a/compact/src/runCompiler.ts b/compact/src/runCompiler.ts index b7a84f24..9c6215ff 100644 --- a/compact/src/runCompiler.ts +++ b/compact/src/runCompiler.ts @@ -12,13 +12,20 @@ import { CompactCompiler } from './Compiler.js'; * ```bash * npx compact-compiler --skip-zk * ``` + * + * @example Compile specific directory + * ```bash + * npx compact-compiler --dir security --skip-zk + * ``` + * * Expected output: * ``` * ℹ [COMPILE] Compact compiler started * ℹ [COMPILE] COMPACT_HOME: /path/to/compactc * ℹ [COMPILE] COMPACTC_PATH: /path/to/compactc/compactc - * ℹ [COMPILE] Found 1 .compact file(s) to compile - * ✔ [COMPILE] [1/1] Compiled Foo.compact + * ℹ [COMPILE] TARGET_DIR: security + * ℹ [COMPILE] Found 1 .compact file(s) to compile in security/ + * ✔ [COMPILE] [1/1] Compiled security/AccessControl.compact * Compactc version: 0.24.0 * ``` */ @@ -26,8 +33,30 @@ async function runCompiler(): Promise { const spinner = ora(chalk.blue('[COMPILE] Compact Compiler started')).info(); try { - const compilerFlags = process.argv.slice(2).join(' '); - const compiler = new CompactCompiler(compilerFlags); + const args = process.argv.slice(2); + + // Parse arguments more robustly + let targetDir: string | undefined; + const compilerFlags: string[] = []; + + for (let i = 0; i < args.length; i++) { + if (args[i] === '--dir') { + if (i + 1 < args.length && !args[i + 1].startsWith('--')) { + targetDir = args[i + 1]; + i++; // Skip the next argument (directory name) + } else { + spinner.fail(chalk.red('[COMPILE] Error: --dir flag requires a directory name')); + console.log(chalk.yellow('Usage: compact-compiler --dir [other-flags]')); + console.log(chalk.yellow('Example: compact-compiler --dir security --skip-zk')); + process.exit(1); + } + } else { + // All other arguments are compiler flags + compilerFlags.push(args[i]); + } + } + + const compiler = new CompactCompiler(compilerFlags.join(' '), targetDir); await compiler.compile(); } catch (err) { spinner.fail( From 98b7a3210f04cb5f925fcc89b1259fda1a8c1a7f Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Aug 2025 21:24:23 -0300 Subject: [PATCH 03/40] add granular compile scripts --- contracts/package.json | 5 ++++ turbo.json | 57 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/contracts/package.json b/contracts/package.json index 493433f8..fc36646d 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -15,6 +15,11 @@ }, "scripts": { "compact": "compact-compiler", + "compact:access": "compact-compiler --dir access", + "compact:archive": "compact-compiler --dir archive", + "compact:security": "compact-compiler --dir security", + "compact:token": "compact-compiler --dir token", + "compact:utils": "compact-compiler --dir utils", "build": "compact-builder && tsc", "test": "vitest run", "types": "tsc -p tsconfig.json --noEmit", diff --git a/turbo.json b/turbo.json index fc4bb12f..4b5acd9c 100644 --- a/turbo.json +++ b/turbo.json @@ -1,10 +1,63 @@ { "$schema": "https://turbo.build/schema.json", "tasks": { - "compact": { + "compact:security": { "dependsOn": ["^build"], "env": ["COMPACT_HOME"], - "inputs": ["contracts/src/**/*.compact"], + "inputs": ["src/security/**/*.compact"], + "outputLogs": "new-only", + "outputs": ["artifacts/**/"] + }, + "compact:utils": { + "dependsOn": ["^build"], + "env": ["COMPACT_HOME"], + "inputs": ["src/utils/**/*.compact"], + "outputLogs": "new-only", + "outputs": ["artifacts/**/"] + }, + "compact:access": { + "dependsOn": ["^build", "compact:security", "compact:utils"], + "env": ["COMPACT_HOME"], + "inputs": [ + "src/access/**/*.compact", + "artifacts/**" + ], + "outputLogs": "new-only", + "outputs": ["artifacts/**/"] + }, + "compact:archive": { + "dependsOn": ["^build", "compact:utils"], + "env": ["COMPACT_HOME"], + "inputs": [ + "src/archive/**/*.compact", + "artifacts/**" + ], + "outputLogs": "new-only", + "outputs": ["artifacts/**/"] + }, + "compact:token": { + "dependsOn": ["^build", "compact:security", "compact:utils"], + "env": ["COMPACT_HOME"], + "inputs": [ + "src/token/**/*.compact", + "artifacts/**" + ], + "outputLogs": "new-only", + "outputs": ["artifacts/**/"] + }, + "compact": { + "dependsOn": [ + "compact:security", + "compact:utils", + "compact:access", + "compact:archive", + "compact:token" + ], + "env": ["COMPACT_HOME"], + "inputs": [ + "src/**/*.compact", + "test/**/*.compact" + ], "outputLogs": "new-only", "outputs": ["artifacts/**"] }, From ae9e3118b8df28b02d847e4aed97d7e68ecf8bf9 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Aug 2025 21:36:15 -0300 Subject: [PATCH 04/40] fix fmt --- compact/src/Compiler.ts | 10 ++++++++-- compact/src/runCompiler.ts | 14 +++++++++++--- turbo.json | 20 ++++---------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/compact/src/Compiler.ts b/compact/src/Compiler.ts index e79bd48f..af426286 100755 --- a/compact/src/Compiler.ts +++ b/compact/src/Compiler.ts @@ -99,7 +99,11 @@ export class CompactCompiler { // Validate target directory exists if (this.targetDir && !existsSync(searchDir)) { const spinner = ora(); - spinner.fail(chalk.red(`[COMPILE] Error: Target directory ${searchDir} does not exist.`)); + spinner.fail( + chalk.red( + `[COMPILE] Error: Target directory ${searchDir} does not exist.`, + ), + ); throw new Error(`Target directory ${searchDir} does not exist`); } @@ -108,7 +112,9 @@ export class CompactCompiler { const spinner = ora(); if (compactFiles.length === 0) { const searchLocation = this.targetDir ? `${this.targetDir}/` : ''; - spinner.warn(chalk.yellow(`[COMPILE] No .compact files found in ${searchLocation}.`)); + spinner.warn( + chalk.yellow(`[COMPILE] No .compact files found in ${searchLocation}.`), + ); return; } diff --git a/compact/src/runCompiler.ts b/compact/src/runCompiler.ts index 9c6215ff..a1e9e002 100644 --- a/compact/src/runCompiler.ts +++ b/compact/src/runCompiler.ts @@ -45,9 +45,17 @@ async function runCompiler(): Promise { targetDir = args[i + 1]; i++; // Skip the next argument (directory name) } else { - spinner.fail(chalk.red('[COMPILE] Error: --dir flag requires a directory name')); - console.log(chalk.yellow('Usage: compact-compiler --dir [other-flags]')); - console.log(chalk.yellow('Example: compact-compiler --dir security --skip-zk')); + spinner.fail( + chalk.red('[COMPILE] Error: --dir flag requires a directory name'), + ); + console.log( + chalk.yellow( + 'Usage: compact-compiler --dir [other-flags]', + ), + ); + console.log( + chalk.yellow('Example: compact-compiler --dir security --skip-zk'), + ); process.exit(1); } } else { diff --git a/turbo.json b/turbo.json index 4b5acd9c..fdc0cb74 100644 --- a/turbo.json +++ b/turbo.json @@ -18,30 +18,21 @@ "compact:access": { "dependsOn": ["^build", "compact:security", "compact:utils"], "env": ["COMPACT_HOME"], - "inputs": [ - "src/access/**/*.compact", - "artifacts/**" - ], + "inputs": ["src/access/**/*.compact", "artifacts/**"], "outputLogs": "new-only", "outputs": ["artifacts/**/"] }, "compact:archive": { "dependsOn": ["^build", "compact:utils"], "env": ["COMPACT_HOME"], - "inputs": [ - "src/archive/**/*.compact", - "artifacts/**" - ], + "inputs": ["src/archive/**/*.compact", "artifacts/**"], "outputLogs": "new-only", "outputs": ["artifacts/**/"] }, "compact:token": { "dependsOn": ["^build", "compact:security", "compact:utils"], "env": ["COMPACT_HOME"], - "inputs": [ - "src/token/**/*.compact", - "artifacts/**" - ], + "inputs": ["src/token/**/*.compact", "artifacts/**"], "outputLogs": "new-only", "outputs": ["artifacts/**/"] }, @@ -54,10 +45,7 @@ "compact:token" ], "env": ["COMPACT_HOME"], - "inputs": [ - "src/**/*.compact", - "test/**/*.compact" - ], + "inputs": ["src/**/*.compact", "test/**/*.compact"], "outputLogs": "new-only", "outputs": ["artifacts/**"] }, From 4a9885ba116b7303b11a014e057e6cb3e69675d4 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Aug 2025 22:53:48 -0300 Subject: [PATCH 05/40] use fast compilation prior to tests, cache tests --- contracts/package.json | 2 +- turbo.json | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/contracts/package.json b/contracts/package.json index fc36646d..acd41414 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -21,7 +21,7 @@ "compact:token": "compact-compiler --dir token", "compact:utils": "compact-compiler --dir utils", "build": "compact-builder && tsc", - "test": "vitest run", + "test": "compact-compiler --skip-zk && vitest run", "types": "tsc -p tsconfig.json --noEmit", "clean": "git clean -fXd" }, diff --git a/turbo.json b/turbo.json index fdc0cb74..86592d3e 100644 --- a/turbo.json +++ b/turbo.json @@ -50,9 +50,16 @@ "outputs": ["artifacts/**"] }, "test": { - "dependsOn": ["^build", "compact"], + "dependsOn": ["^build"], + "env": ["COMPACT_HOME"], + "inputs": [ + "src/**/*.ts", + "src/**/*.compact", + "vitest.config.ts", + "package.json" + ], "outputs": [], - "cache": false + "cache": true }, "build": { "dependsOn": ["^build"], From d707d2837d2ad247495bc68d5f00d0308170870e Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 18 Aug 2025 02:54:47 -0300 Subject: [PATCH 06/40] revert changes --- contracts/src/utils/Utils.compact | 46 ------------------- .../src/utils/test/mocks/MockUtils.compact | 16 ------- .../utils/test/simulators/UtilsSimulator.ts | 28 ----------- contracts/src/utils/test/utils.test.ts | 29 ------------ 4 files changed, 119 deletions(-) diff --git a/contracts/src/utils/Utils.compact b/contracts/src/utils/Utils.compact index b7291176..3528e10e 100644 --- a/contracts/src/utils/Utils.compact +++ b/contracts/src/utils/Utils.compact @@ -66,52 +66,6 @@ module Utils { return !keyOrAddress.is_left; } - /** - * @description Wraps a value as the `L` variant of a disjoint union (`Either`), - * following Compact conventions. - * - * Sets `is_left` to true, assigns the provided value to `left`, and sets `right` to `default` per convention. - * - * This helper is useful when you already have a value of type `L`, but the circuit interface expects an `Either`. - * It avoids manually constructing the full struct and ensures consistent formatting. - * - * @template L - Type of the Left variant. - * @template R - Type of the Right variant. - * - * @param {L} left - The value to wrap as the Left variant. - * @returns {Either} A disjoint union (`Either`) with the value in the `L` variant. - */ - export pure circuit wrapAsEitherLeft(left: L): Either { - return Either { - is_left: true, - left: left, - right: default - }; - } - - /** - * @description Wraps a value as the `R` variant of a disjoint union (`Either`), - * following Compact conventions. - * - * Sets `is_left` to false, assigns the provided value to `right`, and sets `left` to `default` per convention. - * - * This helper is useful when you already have a value of type `R`, but the circuit interface expects an `Either`. - * It avoids manually constructing the full struct and ensures consistent formatting. - * - * @template L - Type of the Left variant. - * @template R - Type of the Right variant. - * - * @param {R} right - The value to wrap as the `R` variant. - * @returns {Either} A disjoint union (`Either`) with the value in the `R` variant. - */ - export pure circuit wrapAsEitherRight(right: R): Either { - return Either { - is_left: false, - left: default, - right: right - }; - } - /** * @description A helper function that returns the empty string: "". * diff --git a/contracts/src/utils/test/mocks/MockUtils.compact b/contracts/src/utils/test/mocks/MockUtils.compact index c3b66d64..54fd45f3 100644 --- a/contracts/src/utils/test/mocks/MockUtils.compact +++ b/contracts/src/utils/test/mocks/MockUtils.compact @@ -25,22 +25,6 @@ export pure circuit isContractAddress(keyOrAddress: Either { - return Utils_wrapAsEitherLeft(pk); -} - -// Find a better way to test different combinations -// other than creating a circuit for each pair -export pure circuit wrapAsEitherPkOrAddressRight( - address: ContractAddress, -): Either { - return Utils_wrapAsEitherRight(address); -} - export pure circuit emptyString(): Opaque<"string"> { return Utils_emptyString(); } diff --git a/contracts/src/utils/test/simulators/UtilsSimulator.ts b/contracts/src/utils/test/simulators/UtilsSimulator.ts index 5f46223e..715569f8 100644 --- a/contracts/src/utils/test/simulators/UtilsSimulator.ts +++ b/contracts/src/utils/test/simulators/UtilsSimulator.ts @@ -139,34 +139,6 @@ export class UtilsSimulator ).result; } - /** - * @description Returns `pk` wrapped in an `Either` type. - * @param pk The target value to wrap. - * @returns `Either` with `pk` in the left position. - */ - public wrapAsEitherPkOrAddressLeft( - pk: ZswapCoinPublicKey, - ): Either { - return this.contract.circuits.wrapAsEitherPkOrAddressLeft( - this.circuitContext, - pk, - ).result; - } - - /** - * @description Returns `address` wrapped in an `Either` type. - * @param pk The target value to wrap. - * @returns `Either` with `address` in the right position. - */ - public wrapAsEitherPkOrAddressRight( - address: ContractAddress, - ): Either { - return this.contract.circuits.wrapAsEitherPkOrAddressRight( - this.circuitContext, - address, - ).result; - } - /** * @description A helper function that returns the empty string: "" * @returns The empty string: "" diff --git a/contracts/src/utils/test/utils.test.ts b/contracts/src/utils/test/utils.test.ts index 52b78acc..1398d4d9 100644 --- a/contracts/src/utils/test/utils.test.ts +++ b/contracts/src/utils/test/utils.test.ts @@ -1,9 +1,4 @@ import { describe, expect, it } from 'vitest'; -import type { - ContractAddress, - Either, - ZswapCoinPublicKey, -} from './../../../artifacts/MockUtils/contract/index.cjs'; // Combined imports import { UtilsSimulator } from './simulators/UtilsSimulator.js'; import * as contractUtils from './utils/address.js'; @@ -92,30 +87,6 @@ describe('Utils', () => { }); }); - describe('wrapAsEitherLeft', () => { - it('should wrap pk as left', () => { - const pk = contractUtils.encodeToPK('PK'); - const exp: Either = { - is_left: true, - left: pk, - right: { bytes: new Uint8Array(32).fill(0) }, - }; - expect(contract.wrapAsEitherPkOrAddressLeft(pk)).toEqual(exp); - }); - }); - - describe('wrapAsEitherRight', () => { - it('should wrap address as right', () => { - const address = contractUtils.encodeToPK('ADDRESS'); - const exp: Either = { - is_left: false, - left: { bytes: new Uint8Array(32).fill(0) }, - right: address, - }; - expect(contract.wrapAsEitherPkOrAddressRight(address)).toEqual(exp); - }); - }); - describe('emptyString', () => { it('should return the empty string', () => { expect(contract.emptyString()).toBe(EMPTY_STRING); From d11380220b2e38b1266629bc7a3e7c35e0194dba Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 18 Aug 2025 03:05:44 -0300 Subject: [PATCH 07/40] update readme with targeted compilation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e730124..bc8d31ab 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,10 @@ Cached: 0 cached, 2 total Time: 7.178s ``` -**Note:** Speed up the development process by skipping the prover and verifier key file generation: +**Note:** Speed up the development process by targeting a single directory and skipping the prover and verifier key file generation: ```bash -turbo compact -- --skip-zk +turbo compact:token -- --skip-zk ``` ### Run tests From c004dd8a051b37f7a8dedfd0f4bf363936627075 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 21 Aug 2025 12:49:28 -0300 Subject: [PATCH 08/40] build preserves dir structure --- compact/src/Builder.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compact/src/Builder.ts b/compact/src/Builder.ts index b8f05197..55e90bf2 100755 --- a/compact/src/Builder.ts +++ b/compact/src/Builder.ts @@ -59,18 +59,21 @@ export class CompactBuilder { private readonly compilerFlags: string; private readonly steps: Array<{ cmd: string; msg: string; shell?: string }> = [ - { - cmd: 'tsc --project tsconfig.build.json', - msg: 'Compiling TypeScript', - }, { cmd: 'mkdir -p dist/artifacts && cp -Rf src/artifacts/* dist/artifacts/ 2>/dev/null || true', msg: 'Copying artifacts', shell: '/bin/bash', }, { - cmd: 'mkdir -p dist && find src -type f -name "*.compact" -exec cp {} dist/ \\; 2>/dev/null && rm dist/Mock*.compact 2>/dev/null || true', - msg: 'Copying and cleaning .compact files', + cmd: ` + # Copy .compact files preserving directory structure + find src -type f -name "*.compact" | while read file; do + rel_path="\${file#src/}" + mkdir -p "dist/\$(dirname "\$rel_path")" + cp "\$file" "dist/\$rel_path" + done + `, + msg: 'Copying .compact files (preserving structure)', shell: '/bin/bash', }, ]; From 6de7a17bfc26df09853e3f79186ddd349d3ee34d Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:01:01 -0300 Subject: [PATCH 09/40] keep compact files in directories in dist, add tsc in build --- compact/src/Builder.ts | 96 +++++++++++++++++++++++------------------- contracts/package.json | 2 +- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/compact/src/Builder.ts b/compact/src/Builder.ts index 55e90bf2..de4e2ab7 100755 --- a/compact/src/Builder.ts +++ b/compact/src/Builder.ts @@ -13,8 +13,9 @@ const execAsync = promisify(exec); /** * A class to handle the build process for a project. * Runs CompactCompiler as a prerequisite, then executes build steps (TypeScript compilation, - * artifact copying, etc.) - * with progress feedback and colored output for success and error states. + * artifact copying, etc.) with progress feedback and colored output for success and error states. + * + * Creates a clean distribution structure without src/ paths for professional import experience. * * @notice `cmd` scripts discard `stderr` output and fail silently because this is * handled in `executeStep`. @@ -32,51 +33,53 @@ const execAsync = promisify(exec); * Compactc version: 0.24.0 * ✔ [COMPILE] [2/2] Compiled MockAccessControl.compact * Compactc version: 0.24.0 - * ✔ [BUILD] [1/3] Compiling TypeScript - * ✔ [BUILD] [2/3] Copying artifacts - * ✔ [BUILD] [3/3] Copying and cleaning .compact files - * ``` - * - * @example Failed Compilation Output - * ``` - * ℹ [COMPILE] Found 2 .compact file(s) to compile - * ✖ [COMPILE] [1/2] Failed AccessControl.compact - * Compactc version: 0.24.0 - * Error: Expected ';' at line 5 in AccessControl.compact - * ``` - * - * @example Failed Build Step Output - * ``` - * ℹ [COMPILE] Found 2 .compact file(s) to compile - * ✔ [COMPILE] [1/2] Compiled AccessControl.compact - * ✔ [COMPILE] [2/2] Compiled MockAccessControl.compact - * ✖ [BUILD] [1/3] Failed Compiling TypeScript - * error TS1005: ';' expected at line 10 in file.ts - * [BUILD] ❌ Build failed: Command failed: tsc --project tsconfig.build.json + * ✔ [BUILD] [1/4] Cleaning dist directory + * ✔ [BUILD] [2/4] Compiling TypeScript + * ✔ [BUILD] [3/4] Copying .compact files + * ✔ [BUILD] [4/4] Copying package metadata * ``` */ export class CompactBuilder { private readonly compilerFlags: string; - private readonly steps: Array<{ cmd: string; msg: string; shell?: string }> = - [ - { - cmd: 'mkdir -p dist/artifacts && cp -Rf src/artifacts/* dist/artifacts/ 2>/dev/null || true', - msg: 'Copying artifacts', - shell: '/bin/bash', - }, - { - cmd: ` - # Copy .compact files preserving directory structure - find src -type f -name "*.compact" | while read file; do - rel_path="\${file#src/}" - mkdir -p "dist/\$(dirname "\$rel_path")" - cp "\$file" "dist/\$rel_path" - done - `, - msg: 'Copying .compact files (preserving structure)', - shell: '/bin/bash', - }, - ]; + private readonly steps: Array<{ cmd: string; msg: string; shell?: string }> = [ + // Step 1: Clean dist directory + { + cmd: 'rm -rf dist && mkdir -p dist', + msg: 'Cleaning dist directory', + shell: '/bin/bash', + }, + + // Step 2: TypeScript compilation (witnesses/ -> dist/witnesses/) + { + cmd: 'tsc --project tsconfig.build.json', + msg: 'Compiling TypeScript', + }, + + // Step 3: Copy .compact files preserving structure (excludes Mock* files and archive/) + { + cmd: ` + find src -type f -name "*.compact" ! -name "Mock*" ! -path "*/archive/*" | while read file; do + # Remove src/ prefix from path + rel_path="\${file#src/}" + mkdir -p "dist/\$(dirname "\$rel_path")" + cp "\$file" "dist/\$rel_path" + done + `, + msg: 'Copying .compact files (excluding mocks and archive)', + shell: '/bin/bash', + }, + + // Step 4: Copy essential files for distribution + { + cmd: ` + # Copy package.json and README + cp package.json dist/ 2>/dev/null || true + cp ../README.md dist/ # Go up one level to monorepo root + `, + msg: 'Copying package metadata', + shell: '/bin/bash', + }, + ]; /** * Constructs a new ProjectBuilder instance. @@ -102,6 +105,9 @@ export class CompactBuilder { for (const [index, step] of this.steps.entries()) { await this.executeStep(step, index, this.steps.length); } + + // Log completion + console.log(chalk.green('\n✅ Build complete!')); } /** @@ -158,6 +164,8 @@ export class CompactBuilder { .split('\n') .filter((line: string): boolean => line.trim() !== '') .map((line: string): string => ` ${line}`); - console.log(colorFn(lines.join('\n'))); + if (lines.length > 0) { + console.log(colorFn(lines.join('\n'))); + } } } diff --git a/contracts/package.json b/contracts/package.json index acd41414..1fdbf78a 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -20,7 +20,7 @@ "compact:security": "compact-compiler --dir security", "compact:token": "compact-compiler --dir token", "compact:utils": "compact-compiler --dir utils", - "build": "compact-builder && tsc", + "build": "compact-builder", "test": "compact-compiler --skip-zk && vitest run", "types": "tsc -p tsconfig.json --noEmit", "clean": "git clean -fXd" From 787f91bf476ad2e31b23028daa399ea1715e834d Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:03:07 -0300 Subject: [PATCH 10/40] include explicit witnesses in tsconfig, remove sourceMap --- contracts/tsconfig.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/tsconfig.json b/contracts/tsconfig.json index 3e90b0a9..fc89bbac 100644 --- a/contracts/tsconfig.json +++ b/contracts/tsconfig.json @@ -1,5 +1,10 @@ { - "include": ["src/**/*.ts"], + "include": [ + "src/access/witnesses/**/*.ts", + "src/security/witnesses/**/*.ts", + "src/token/witnesses/**/*.ts", + "src/utils/witnesses/**/*.ts", + ], "compilerOptions": { "rootDir": "src", "outDir": "dist", @@ -13,7 +18,6 @@ "noImplicitAny": true, "strict": true, "isolatedModules": true, - "sourceMap": true, "resolveJsonModule": true, "esModuleInterop": true, "skipLibCheck": true From 865aa1101fd4fe040000172893d6cf964c97073e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:04:01 -0300 Subject: [PATCH 11/40] move compact compiler install to composite action --- .github/actions/setup/action.yml | 113 ++++++++++++++++++++++++++++++- .github/workflows/test.yml | 83 +---------------------- 2 files changed, 113 insertions(+), 83 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9cdc577c..d9a8565f 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,9 +1,29 @@ name: "Setup Environment" -description: "Sets up the environment with yarn, Node.js, and turbo" +description: "Sets up the environment with yarn, Node.js, turbo, and Compact compiler" + +inputs: + skip-compact: + description: "Skip Compact compiler installation" + required: false + default: "false" + +outputs: + compact-home: + description: "Path to Compact compiler installation" + value: ${{ steps.compact-outputs.outputs.compact-home }} + compact-version: + description: "Installed Compact compiler version" + value: ${{ steps.compact-outputs.outputs.version }} runs: using: "composite" steps: + - name: Set shared environment variables + shell: bash + run: | + echo "COMPILER_VERSION=0.24.0" >> $GITHUB_ENV + echo "LANGUAGE_VERSION=0.16.0" >> $GITHUB_ENV + - name: Get yarn cache directory path shell: bash id: yarn-cache-dir-path @@ -25,6 +45,14 @@ runs: restore-keys: | ${{ runner.os }}-turbo-${{ hashFiles('.turbo/*') }} + - name: Cache Compact compiler + if: inputs.skip-compact != 'true' + uses: actions/cache@v4 + id: compact-cache + with: + path: ~/compactc + key: compact-compiler-${{ env.COMPILER_VERSION }}-${{ runner.os }} + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -40,5 +68,86 @@ runs: env: TURBO_MAJOR_VERSION: 2 TURBO_TELEMETRY_DISABLED: 1 + run: npm install turbo@${{ env.TURBO_MAJOR_VERSION }} -g + + - name: Install Compact compiler + if: inputs.skip-compact != 'true' && steps.compact-cache.outputs.cache-hit != 'true' + shell: bash + run: | + set -euo pipefail + + COMPACT_HOME="$HOME/compactc" + COMPACT_ZIP_DIR="$HOME/compactc_download" + + echo "🔧 Installing Compact compiler v$COMPILER_VERSION..." + + mkdir -p "$COMPACT_HOME" + mkdir -p "$COMPACT_ZIP_DIR" + + ZIP_FILE="compactc_v${COMPILER_VERSION}_x86_64-unknown-linux-musl.zip" + DOWNLOAD_URL="https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_${COMPILER_VERSION}/${ZIP_FILE}" + + echo "⬇️ Downloading Compact compiler from $DOWNLOAD_URL..." + curl -fLs "$DOWNLOAD_URL" -o "$COMPACT_ZIP_DIR/compactc.zip" + + echo "🧪 Validating ZIP archive..." + if ! unzip -tq "$COMPACT_ZIP_DIR/compactc.zip"; then + echo "::error::❌ ZIP file is invalid or corrupted." + exit 1 + fi + + echo "📦 Extracting Compact compiler..." + unzip -q "$COMPACT_ZIP_DIR/compactc.zip" -d "$COMPACT_HOME" + chmod +x "$COMPACT_HOME"/{compactc,compactc.bin,zkir} + + echo "✅ Compact compiler extracted to $COMPACT_HOME" + + - name: Setup Compact environment + if: inputs.skip-compact != 'true' + shell: bash + run: | + COMPACT_HOME="$HOME/compactc" + echo "📁 Setting Compact environment variables..." + echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV" + echo "$COMPACT_HOME" >> "$GITHUB_PATH" + + if [ -f "$COMPACT_HOME/compactc" ]; then + echo "✅ Compact compiler is installed at $COMPACT_HOME" + else + echo "::error::❌ Compact compiler not found in $COMPACT_HOME" + exit 1 + fi + + - name: Set Compact outputs + if: inputs.skip-compact != 'true' + id: compact-outputs + shell: bash + run: | + echo "compact-home=$HOME/compactc" >> $GITHUB_OUTPUT + echo "version=$COMPILER_VERSION" >> $GITHUB_OUTPUT + + - name: Check compiler and language version + if: inputs.skip-compact != 'true' + shell: bash run: | - npm install turbo@${{ env.TURBO_MAJOR_VERSION }} -g + set -euo pipefail + + echo "🔍 Checking Compact compiler version..." + COMPILER_OUTPUT=$(compactc --version) + COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1) + + if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then + echo "::error::❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION" + exit 1 + fi + echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION" + + echo "🔍 Checking Compact language version..." + LANGUAGE_OUTPUT=$(compactc --language-version) + COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1) + + if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then + echo "::error::❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION" + exit 1 + fi + echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb523efd..17a35ff2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,11 +6,6 @@ on: branches: - main -env: - TURBO_TELEMETRY_DISABLED: 1 - COMPILER_VERSION: "0.24.0" - LANGUAGE_VERSION: "0.16.0" - jobs: run-suite: name: Run Test Suite @@ -26,82 +21,8 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup - - name: Install Compact compiler - id: setup - shell: bash - run: | - set -euo pipefail - # Create directory for compiler - COMPACT_HOME="$HOME/compactc" - mkdir -p "$COMPACT_HOME" - - # Create URL - ZIP_FILE="compactc_v${COMPILER_VERSION}_x86_64-unknown-linux-musl.zip" - DOWNLOAD_URL="https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_${COMPILER_VERSION}/${ZIP_FILE}" - - echo "⬇️ Downloading Compact compiler..." - curl -Ls "$DOWNLOAD_URL" -o "$COMPACT_HOME/compactc.zip" - - echo "📦 Extracting..." - unzip -q "$COMPACT_HOME/compactc.zip" -d "$COMPACT_HOME" - chmod +x "$COMPACT_HOME"/{compactc,compactc.bin,zkir} - - echo "📁 Setting environment variables..." - echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV" - echo "$COMPACT_HOME" >> "$GITHUB_PATH" - - echo "✅ Verifying installation..." - if [ ! -f "$COMPACT_HOME/compactc" ]; then - echo "::error::❌ compactc not found in $COMPACT_HOME" - exit 1 - fi - - echo "🤖 Testing installation..." - "$COMPACT_HOME/compactc" --version - - - name: Check compiler and language version - run: | - COMPILER_OUTPUT=$(compactc --version) - COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1) - if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then - errMsg="❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION" - echo "::error::$errMsg" - exit 1 - fi - echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION" - - LANGUAGE_OUTPUT=$(compactc --language-version) - COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1) - if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then - errMsg="❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION" - echo "::error::$errMsg" - exit 1 - fi - - echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION" - - - name: Compile contracts (with retry on hash mismatch) - shell: bash - run: | - set -euo pipefail - - compile() { - echo "⚙️ Running Compact compilation..." - if ! output=$(turbo compact --concurrency=1 2>&1); then - echo "❌ Compilation failed." - if echo "$output" | grep -q "Hash mismatch" && [ -d "$HOME/.cache/midnight/zk-params" ]; then - echo "⚠️ Hash mismatch detected *and* zk-params exists. Removing cache..." - rm -rf "$HOME/.cache/midnight/zk-params" - echo "::notice::♻️ Retrying compilation after clearing zk-params..." - turbo compact --concurrency=1 || { echo "::error::❌ Retry also failed."; exit 1; } - else - echo "🚫 Compilation failed for another reason or zk-params missing. No retry." - exit 1 - fi - fi - } - - compile + - name: Compile contracts (with retry) + run: turbo compact --concurrency=1 - name: Run type checks run: turbo types From 579ef4de2c8012d216dcef97f2dc87835c53e8d3 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:05:34 -0300 Subject: [PATCH 12/40] add prepare-release workflow (version bump) --- .github/workflows/prepare-release.yml | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/prepare-release.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000..2fa28eff --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,57 @@ +name: Update version on new release branch + +on: + create: + +permissions: + contents: write + pull-requests: write + +jobs: + update_version: + if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/release-v') + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Extract current version + run: | + CURRENT_VERSION=$(node -p "require('./contracts/package.json').version") + echo "CURRENT_VERSION=$CURRENT_VERSION" >> "$GITHUB_ENV" + + - name: Extract new version number + run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> "$GITHUB_ENV" + + - name: Replace version in files + run: | + echo "Current version: $CURRENT_VERSION" + echo "New version: $NEW_VERSION" + + # Update package.json version field manually + cd contracts + node -e " + const fs = require('fs'); + const pkg = require('./package.json'); + pkg.version = '$NEW_VERSION'; + fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n'); + console.log('Updated package.json to version $NEW_VERSION'); + " + # Update yarn.lock to reflect the new version + yarn install + cd .. + + # Escape special regex characters in version strings + ESCAPED_CURRENT=$(echo "$CURRENT_VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g') + ESCAPED_NEW=$(echo "$NEW_VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g') + find . -type f \ + -not -path '*/\.*' \ + -not -path './docs/package-lock.json' \ + -not -path './RELEASING.md' \ + -exec sed -i "s/$ESCAPED_CURRENT/$ESCAPED_NEW/g" {} + 2>/dev/null || true + + - name: Auto-commit changes + uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 #v6.0.1 + with: + commit_message: Bump version to ${{ env.NEW_VERSION }} From 7f64555aff2d0e7629516b06b5aee08f1f7f3624 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:05:51 -0300 Subject: [PATCH 13/40] add release workflow --- .github/workflows/release.yml | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7fd6b42b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: Publish Package on Release + +on: + release: + types: [published] + +env: + COMPILER_VERSION: "0.24.0" + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + + - name: Compile contracts (with retry) + run: | + # Your retry logic - Compact is already in PATH + turbo compact --concurrency=1 + + - name: Validate version consistency + run: | + RELEASE_VERSION=${GITHUB_REF#refs/tags/v} + PACKAGE_VERSION=$(node -p "require('./contracts/package.json').version") + if [ "$RELEASE_VERSION" != "$PACKAGE_VERSION" ]; then + echo "❌ Version mismatch: Release $RELEASE_VERSION vs Package $PACKAGE_VERSION" + exit 1 + fi + echo "✅ Version consistency validated: $RELEASE_VERSION" + + - name: Setup npm registry + uses: actions/setup-node@v4 + with: + registry-url: 'https://registry.npmjs.org' + + - name: Build + run: turbo build + + - name: Pack tarball + id: pack + run: | + cd contracts/dist + TARBALL=$(npm pack | tail -1) + echo "tarball_name=$TARBALL" >> $GITHUB_OUTPUT + echo "tarball=$(pwd)/$TARBALL" >> $GITHUB_OUTPUT + + # Determine dist-tag based on semver prerelease + PACKAGE_VERSION=$(node -p "require('./package.json').version") + if [[ "$PACKAGE_VERSION" =~ -.*$ ]]; then + # Has prerelease suffix (anything after -) + if [[ "$PACKAGE_VERSION" =~ -(alpha|beta|rc) ]]; then + echo "tag=beta" >> $GITHUB_OUTPUT + else + echo "tag=next" >> $GITHUB_OUTPUT + fi + else + # Stable release + echo "tag=latest" >> $GITHUB_OUTPUT + fi + + - name: Verify tarball integrity + run: | + echo "=== Verifying tarball contents ===" + PACKAGE_NAME=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .name) + PACKAGE_VERSION=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .version) + PRIVATE_FIELD=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r '.private // "not found"') + + echo "📦 Package: $PACKAGE_NAME@$PACKAGE_VERSION" + echo "🏷️ Tag: ${{ steps.pack.outputs.tag }}" + echo "🔒 Private field: $PRIVATE_FIELD" + + # Ensure no private field + if [ "$PRIVATE_FIELD" = "true" ]; then + echo "❌ Tarball contains private: true - cannot publish" + exit 1 + fi + + - name: Publish to npm + run: | + # Create .npmrc with auth token + echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc + + # Publish the tarball with appropriate tag + npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Log success + run: | + PACKAGE_NAME=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .name) + PACKAGE_VERSION=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .version) + echo "✅ Successfully published $PACKAGE_NAME@$PACKAGE_VERSION to npm with tag ${{ steps.pack.outputs.tag }}" + echo "📦 Install with: npm install $PACKAGE_NAME@${{ steps.pack.outputs.tag }}" From f2067a8e7698e523799343420d56129e2b9d8fb3 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:17:01 -0300 Subject: [PATCH 14/40] add releasing doc --- RELEASING.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 RELEASING.md diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 00000000..6ad36f80 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,42 @@ +# Releasing + +(1) Checkout the branch to be released. +This will usually be `main` except in the event of a hotfix. +For hotfixes, checkout the release branch you want to fix. + +(2) Create a new release branch. + +```sh +git checkout -b release-v0.2.0 +``` + +(3) Push and open a PR targeting `main` to carefully review the release changes. +This will trigger a GitHub workflow that automatically bumps the version number throughout the project. + +```sh +git push release-v0.2.0 +``` + +(4) Once merged, pull the changes from the release branch. +Then, create a tag on the release branch and push it to the main repository. +Note that the version changes must be pulled *before* the tag is created; +otherwise, the version validation check will fail in the release workflow. + +```sh +git pull +git tag v0.2.0 +git push origin v0.2.0 +``` + +(5) After that, go to the repo's [releases page](https://github.com/OpenZeppelin/compact-contracts/releases/). +[Create a new release](https://github.com/OpenZeppelin/compact-contracts/releases/new) with the new tag and the base branch as target (`main` except in the event of a hotfix). +Make sure to write a detailed release description and a short changelog. +Once published, this will trigger a workflow to upload the release tarball to npm. + +(6) Finally, from the released tag, +create and push a doc branch to deploy the corresponding version to the doc-site. + +```sh +git checkout -b docs-v0.2.0 +git push docs-v0.2.0 +``` From f6c7c5cdb5336fd88572ccb28f80cb20102466ad Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:24:33 -0300 Subject: [PATCH 15/40] remove comment --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fd6b42b..f62cbc69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,6 @@ jobs: - name: Compile contracts (with retry) run: | - # Your retry logic - Compact is already in PATH turbo compact --concurrency=1 - name: Validate version consistency From d46ffaf2fc3766045d78ff593252e4bef3b2fe6a Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:32:22 -0300 Subject: [PATCH 16/40] remove unused env, remove redundant compile in favor of build --- .github/workflows/release.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f62cbc69..86c8a32e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,6 @@ on: release: types: [published] -env: - COMPILER_VERSION: "0.24.0" - jobs: publish: runs-on: ubuntu-latest @@ -21,9 +18,8 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup - - name: Compile contracts (with retry) - run: | - turbo compact --concurrency=1 + - name: Build contracts + run: turbo build - name: Validate version consistency run: | @@ -40,9 +36,6 @@ jobs: with: registry-url: 'https://registry.npmjs.org' - - name: Build - run: turbo build - - name: Pack tarball id: pack run: | From f71f6160bf77de92fdfad6d5ec19d0a63c50cbc8 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 20:46:07 -0300 Subject: [PATCH 17/40] add provenance --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86c8a32e..132ab34b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,6 +84,7 @@ jobs: npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true - name: Log success run: | From 9f9be1edd6ad2b01e027934d4197f217ee9b1d5e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 21:17:45 -0300 Subject: [PATCH 18/40] remove private field from contracts --- contracts/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/package.json b/contracts/package.json index 1fdbf78a..b18995b6 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,6 +1,5 @@ { "name": "@openzeppelin-compact/contracts", - "private": true, "type": "module", "main": "dist/index.js", "module": "dist/index.js", From 60b5b3adfc6b7c73c4c307d9ae1cc62a0caa635f Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 21:28:10 -0300 Subject: [PATCH 19/40] add manifest metadata, remove private field --- contracts/package.json | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/contracts/package.json b/contracts/package.json index b18995b6..6290b9f4 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,17 +1,25 @@ { "name": "@openzeppelin-compact/contracts", - "type": "module", - "main": "dist/index.js", - "module": "dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.js", - "default": "./dist/index.js" - } + "version": "0.0.1", + "description": "OpenZeppelin Compact contract library", + "keywords": [ + "openzeppelin", + "compact", + "midnight", + "contracts", + "security" + ], + "repository": { + "type": "git", + "url": "https://github.com/OpenZeppelin/compact-contracts.git" + }, + "license": "MIT", + "author": "OpenZeppelin Community ", + "bugs": { + "url": "https://github.com/OpenZeppelin/compact-contracts/issues" }, + "homepage": "https://docs.openzeppelin.com/contracts-compact/", + "type": "module", "scripts": { "compact": "compact-compiler", "compact:access": "compact-compiler --dir access", From 67c95ff4d3118089795f779565be0a4925c37719 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 23 Aug 2025 21:29:37 -0300 Subject: [PATCH 20/40] fix fmt --- compact/src/Builder.ts | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/compact/src/Builder.ts b/compact/src/Builder.ts index de4e2ab7..3c4d2c78 100755 --- a/compact/src/Builder.ts +++ b/compact/src/Builder.ts @@ -14,7 +14,7 @@ const execAsync = promisify(exec); * A class to handle the build process for a project. * Runs CompactCompiler as a prerequisite, then executes build steps (TypeScript compilation, * artifact copying, etc.) with progress feedback and colored output for success and error states. - * + * * Creates a clean distribution structure without src/ paths for professional import experience. * * @notice `cmd` scripts discard `stderr` output and fail silently because this is @@ -41,23 +41,24 @@ const execAsync = promisify(exec); */ export class CompactBuilder { private readonly compilerFlags: string; - private readonly steps: Array<{ cmd: string; msg: string; shell?: string }> = [ - // Step 1: Clean dist directory - { - cmd: 'rm -rf dist && mkdir -p dist', - msg: 'Cleaning dist directory', - shell: '/bin/bash', - }, + private readonly steps: Array<{ cmd: string; msg: string; shell?: string }> = + [ + // Step 1: Clean dist directory + { + cmd: 'rm -rf dist && mkdir -p dist', + msg: 'Cleaning dist directory', + shell: '/bin/bash', + }, - // Step 2: TypeScript compilation (witnesses/ -> dist/witnesses/) - { - cmd: 'tsc --project tsconfig.build.json', - msg: 'Compiling TypeScript', - }, + // Step 2: TypeScript compilation (witnesses/ -> dist/witnesses/) + { + cmd: 'tsc --project tsconfig.build.json', + msg: 'Compiling TypeScript', + }, - // Step 3: Copy .compact files preserving structure (excludes Mock* files and archive/) - { - cmd: ` + // Step 3: Copy .compact files preserving structure (excludes Mock* files and archive/) + { + cmd: ` find src -type f -name "*.compact" ! -name "Mock*" ! -path "*/archive/*" | while read file; do # Remove src/ prefix from path rel_path="\${file#src/}" @@ -65,21 +66,21 @@ export class CompactBuilder { cp "\$file" "dist/\$rel_path" done `, - msg: 'Copying .compact files (excluding mocks and archive)', - shell: '/bin/bash', - }, + msg: 'Copying .compact files (excluding mocks and archive)', + shell: '/bin/bash', + }, - // Step 4: Copy essential files for distribution - { - cmd: ` + // Step 4: Copy essential files for distribution + { + cmd: ` # Copy package.json and README cp package.json dist/ 2>/dev/null || true cp ../README.md dist/ # Go up one level to monorepo root `, - msg: 'Copying package metadata', - shell: '/bin/bash', - }, - ]; + msg: 'Copying package metadata', + shell: '/bin/bash', + }, + ]; /** * Constructs a new ProjectBuilder instance. @@ -106,7 +107,6 @@ export class CompactBuilder { await this.executeStep(step, index, this.steps.length); } - // Log completion console.log(chalk.green('\n✅ Build complete!')); } From 9982d953105bd03cf66e4ee0be9f24ecc10f8f75 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 24 Aug 2025 02:27:33 -0300 Subject: [PATCH 21/40] improve find pattern --- .github/workflows/prepare-release.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 2fa28eff..e0d88a52 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -42,14 +42,20 @@ jobs: yarn install cd .. - # Escape special regex characters in version strings - ESCAPED_CURRENT=$(echo "$CURRENT_VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g') - ESCAPED_NEW=$(echo "$NEW_VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g') - find . -type f \ + # Escape special characters for sed + ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g') + ESCAPED_NEW=$(printf '%s' "$NEW_VERSION" | sed -e 's/[\/&]/\\&/g') + + # Replace version in contracts/src/ + find ./contracts/src/ -type f \ + -not -path '*/\.*' \ + -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + + + # Replace version in docs/, excluding package-lock.json + find ./docs/ -type f \ -not -path '*/\.*' \ -not -path './docs/package-lock.json' \ - -not -path './RELEASING.md' \ - -exec sed -i "s/$ESCAPED_CURRENT/$ESCAPED_NEW/g" {} + 2>/dev/null || true + -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + - name: Auto-commit changes uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 #v6.0.1 From 5cb630012fe04d43004b6626f3e1a7802718e045 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 24 Aug 2025 02:44:33 -0300 Subject: [PATCH 22/40] further improve find pattern --- .github/workflows/prepare-release.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index e0d88a52..82b1cc93 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -47,15 +47,12 @@ jobs: ESCAPED_NEW=$(printf '%s' "$NEW_VERSION" | sed -e 's/[\/&]/\\&/g') # Replace version in contracts/src/ - find ./contracts/src/ -type f \ - -not -path '*/\.*' \ - -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + + find ./contracts/src/ -type d -name '.*' -prune -o \ + -type f -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + # Replace version in docs/, excluding package-lock.json - find ./docs/ -type f \ - -not -path '*/\.*' \ - -not -path './docs/package-lock.json' \ - -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + + find ./docs/ -type d -name '.*' -prune -o \ + -type f ! -name 'package-lock.json' -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} + - name: Auto-commit changes uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 #v6.0.1 From 90f876232088ee45f86fccd3e564a7fa322cd84f Mon Sep 17 00:00:00 2001 From: Andrew Fleming Date: Fri, 29 Aug 2025 11:26:04 -0500 Subject: [PATCH 23/40] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> Signed-off-by: Andrew Fleming --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 2 +- contracts/tsconfig.json | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 132ab34b..7a57be73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,13 +13,13 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Environment uses: ./.github/actions/setup - name: Build contracts - run: turbo build + run: turbo build --filter=!'docs' - name: Validate version consistency run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17a35ff2..a21f657b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: uses: ./.github/actions/setup - name: Compile contracts (with retry) - run: turbo compact --concurrency=1 + run: turbo compact --filter=@openzeppelin-compact/contracts --concurrency=1 - name: Run type checks run: turbo types diff --git a/contracts/tsconfig.json b/contracts/tsconfig.json index fc89bbac..04859e06 100644 --- a/contracts/tsconfig.json +++ b/contracts/tsconfig.json @@ -1,10 +1,8 @@ { "include": [ - "src/access/witnesses/**/*.ts", - "src/security/witnesses/**/*.ts", - "src/token/witnesses/**/*.ts", - "src/utils/witnesses/**/*.ts", + "src/**/witnesses/**/*.ts" ], + "exclude": ["src/archive/"], "compilerOptions": { "rootDir": "src", "outDir": "dist", From e5e650f3010d90f50e04914881dd26fec8ac0cdc Mon Sep 17 00:00:00 2001 From: Emanuel Solis Date: Wed, 28 May 2025 18:59:25 -0400 Subject: [PATCH 24/40] Standardize zero address structure --- contracts/src/utils/test/utils.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/src/utils/test/utils.test.ts b/contracts/src/utils/test/utils.test.ts index 1398d4d9..17f573cc 100644 --- a/contracts/src/utils/test/utils.test.ts +++ b/contracts/src/utils/test/utils.test.ts @@ -19,15 +19,16 @@ describe('Utils', () => { describe('isKeyOrAddressZero', () => { it('should return zero for the zero address', () => { expect(contract.isKeyOrAddressZero(contractUtils.ZERO_KEY)).toBe(true); - expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe( - true, - ); }); it('should not return zero for nonzero addresses', () => { expect(contract.isKeyOrAddressZero(Z_SOME_KEY)).toBe(false); expect(contract.isKeyOrAddressZero(SOME_CONTRACT)).toBe(false); }); + + it('should not return zero for a zero contract address', () => { + expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe(false); + }); }); describe('isKeyOrAddressEqual', () => { From ae88fea8eef6bfd68638c0adbb421569399da198 Mon Sep 17 00:00:00 2001 From: 0xisk Date: Fri, 31 Oct 2025 16:14:33 +0100 Subject: [PATCH 25/40] fix: compcat install url variable --- .github/actions/setup/action.yml | 29 +++++---------------------- .github/workflows/checks.yml | 3 +++ .github/workflows/codeql.yml | 3 +++ .github/workflows/prepare-release.yml | 3 +++ .github/workflows/release.yml | 3 +++ .github/workflows/test.yml | 3 +++ 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index d9a8565f..98a31779 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,8 +21,8 @@ runs: - name: Set shared environment variables shell: bash run: | - echo "COMPILER_VERSION=0.24.0" >> $GITHUB_ENV - echo "LANGUAGE_VERSION=0.16.0" >> $GITHUB_ENV + echo "COMPILER_VERSION=0.25.0" >> $GITHUB_ENV + echo "LANGUAGE_VERSION=0.17.0" >> $GITHUB_ENV - name: Get yarn cache directory path shell: bash @@ -75,32 +75,13 @@ runs: shell: bash run: | set -euo pipefail - COMPACT_HOME="$HOME/compactc" - COMPACT_ZIP_DIR="$HOME/compactc_download" - - echo "🔧 Installing Compact compiler v$COMPILER_VERSION..." - mkdir -p "$COMPACT_HOME" - mkdir -p "$COMPACT_ZIP_DIR" - - ZIP_FILE="compactc_v${COMPILER_VERSION}_x86_64-unknown-linux-musl.zip" - DOWNLOAD_URL="https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_${COMPILER_VERSION}/${ZIP_FILE}" - - echo "⬇️ Downloading Compact compiler from $DOWNLOAD_URL..." - curl -fLs "$DOWNLOAD_URL" -o "$COMPACT_ZIP_DIR/compactc.zip" - - echo "🧪 Validating ZIP archive..." - if ! unzip -tq "$COMPACT_ZIP_DIR/compactc.zip"; then - echo "::error::❌ ZIP file is invalid or corrupted." - exit 1 - fi - echo "📦 Extracting Compact compiler..." - unzip -q "$COMPACT_ZIP_DIR/compactc.zip" -d "$COMPACT_HOME" - chmod +x "$COMPACT_HOME"/{compactc,compactc.bin,zkir} + echo "🔧 Installing Compact compiler from $COMPACT_INSTALLER_URL ..." + curl --proto '=https' --tlsv1.2 -LsSf "$COMPACT_INSTALLER_URL" | sh - echo "✅ Compact compiler extracted to $COMPACT_HOME" + echo "✅ Compact compiler installed" - name: Setup Compact environment if: inputs.skip-compact != 'true' diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0e8576e8..5213f030 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -14,6 +14,9 @@ jobs: name: Run Checks runs-on: ubuntu-24.04 + env: + COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} + steps: - name: Check out code uses: actions/checkout@v4 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ed52739b..bcf46b43 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -22,6 +22,9 @@ jobs: matrix: language: ["javascript", "typescript"] + env: + COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} + steps: - name: Check out code uses: actions/checkout@v4 diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 82b1cc93..2c153f8d 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -12,6 +12,9 @@ jobs: if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/release-v') runs-on: ubuntu-latest + env: + COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} + steps: - name: Checkout repository uses: actions/checkout@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a57be73..b0ea01c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,9 @@ jobs: contents: read id-token: write + env: + COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} + steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a21f657b..ebe4d6f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,9 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 15 + env: + COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }} + steps: - name: Check out code uses: actions/checkout@v4 From 88728ba38a6312d12f891ffe4a8e4153c2d394ea Mon Sep 17 00:00:00 2001 From: 0xisk Date: Mon, 3 Nov 2025 10:07:46 +0100 Subject: [PATCH 26/40] fix: trusted publisher, and node check --- .github/workflows/prepare-release.yml | 6 ++++++ .github/workflows/release.yml | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 2c153f8d..a325d8a0 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -19,6 +19,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: "yarn" + - name: Extract current version run: | CURRENT_VERSION=$(node -p "require('./contracts/package.json').version") diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0ea01c0..445a734d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,13 +80,9 @@ jobs: - name: Publish to npm run: | - # Create .npmrc with auth token - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - # Publish the tarball with appropriate tag - npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public + npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public --provenance env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true - name: Log success From e2b244ccd9564183b7733a93a0ba30bd35ada8a5 Mon Sep 17 00:00:00 2001 From: 0xisk Date: Mon, 3 Nov 2025 10:49:34 +0100 Subject: [PATCH 27/40] fix: requested changes from code rabbit --- .github/workflows/prepare-release.yml | 32 +++++++++++++++++++++++++-- RELEASING.md | 4 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 8b131e5b..c625b617 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -30,7 +30,34 @@ jobs: - name: Extract new version number run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> "$GITHUB_ENV" + - name: Validate new version + run: | + BRANCH="${GITHUB_REF#refs/heads/}" + echo "Branch: $BRANCH" + echo "Current version: $CURRENT_VERSION" + echo "New version: $NEW_VERSION" + + # 1) Branch must match release-v + if ! echo "$BRANCH" | grep -Eq '^release-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then + echo "Error: Branch '$BRANCH' must match 'release-v' (e.g., release-v1.2.3)." >&2 + exit 1 + fi + + # 2) NEW_VERSION must be valid semver + node -e "const v=process.env.NEW_VERSION; const semver=/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/; if(!semver.test(v)){ console.error('Error: NEW_VERSION is not valid semver:', v); process.exit(1); }" + if [ $? -ne 0 ]; then + exit 1 + fi + + # 3) NEW_VERSION must differ from CURRENT_VERSION + if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then + echo "Error: NEW_VERSION equals CURRENT_VERSION ($CURRENT_VERSION). Nothing to release." >&2 + exit 1 + fi + - name: Replace version in files + env: + NEW_VERSION: ${{ env.NEW_VERSION }} run: | echo "Current version: $CURRENT_VERSION" echo "New version: $NEW_VERSION" @@ -39,10 +66,11 @@ jobs: cd contracts node -e " const fs = require('fs'); + const newVersion = process.env.NEW_VERSION; const pkg = require('./package.json'); - pkg.version = '$NEW_VERSION'; + pkg.version = newVersion; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n'); - console.log('Updated package.json to version $NEW_VERSION'); + console.log('Updated package.json to version ' + newVersion); " # Update yarn.lock to reflect the new version yarn install diff --git a/RELEASING.md b/RELEASING.md index 6ad36f80..93a7b172 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -14,7 +14,7 @@ git checkout -b release-v0.2.0 This will trigger a GitHub workflow that automatically bumps the version number throughout the project. ```sh -git push release-v0.2.0 +git push origin release-v0.2.0 ``` (4) Once merged, pull the changes from the release branch. @@ -38,5 +38,5 @@ create and push a doc branch to deploy the corresponding version to the doc-site ```sh git checkout -b docs-v0.2.0 -git push docs-v0.2.0 +git push origin docs-v0.2.0 ``` From 2233d580336fdde7618c64755d7256be21666858 Mon Sep 17 00:00:00 2001 From: 0xisk Date: Mon, 3 Nov 2025 12:00:55 +0100 Subject: [PATCH 28/40] fix: ci issues --- .github/actions/setup/action.yml | 40 ++++++++------------------------ packages/compact/src/Compiler.ts | 7 ++++++ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0573c68d..2f9e5e07 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -66,9 +66,15 @@ runs: shell: bash run: | set -euo pipefail - COMPACT_HOME="$HOME/compactc" + COMPACT_HOME="$HOME/.local/bin" mkdir -p "$COMPACT_HOME" + # Require COMPACT_INSTALLER_URL to be provided by the caller + if [ -z "${COMPACT_INSTALLER_URL:-}" ]; then + echo "::error::COMPACT_INSTALLER_URL is required but not set. Provide it via env or secrets." + exit 1 + fi + echo "🔧 Installing Compact compiler from $COMPACT_INSTALLER_URL ..." curl --proto '=https' --tlsv1.2 -LsSf "$COMPACT_INSTALLER_URL" | sh @@ -78,12 +84,12 @@ runs: if: inputs.skip-compact != 'true' shell: bash run: | - COMPACT_HOME="$HOME/compactc" + COMPACT_HOME="$HOME/.local/bin" echo "📁 Setting Compact environment variables..." echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV" echo "$COMPACT_HOME" >> "$GITHUB_PATH" - if [ -f "$COMPACT_HOME/compactc" ]; then + if [ -f "$COMPACT_HOME/compact" ]; then echo "✅ Compact compiler is installed at $COMPACT_HOME" else echo "::error::❌ Compact compiler not found in $COMPACT_HOME" @@ -95,31 +101,5 @@ runs: id: compact-outputs shell: bash run: | - echo "compact-home=$HOME/compactc" >> $GITHUB_OUTPUT + echo "compact-home=$HOME/compact" >> $GITHUB_OUTPUT echo "version=$COMPILER_VERSION" >> $GITHUB_OUTPUT - - - name: Check compiler and language version - if: inputs.skip-compact != 'true' - shell: bash - run: | - set -euo pipefail - - echo "🔍 Checking Compact compiler version..." - COMPILER_OUTPUT=$(compactc --version) - COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1) - - if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then - echo "::error::❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION" - exit 1 - fi - echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION" - - echo "🔍 Checking Compact language version..." - LANGUAGE_OUTPUT=$(compactc --language-version) - COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1) - - if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then - echo "::error::❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION" - exit 1 - fi - echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION" diff --git a/packages/compact/src/Compiler.ts b/packages/compact/src/Compiler.ts index 5138f93f..a95d20dd 100755 --- a/packages/compact/src/Compiler.ts +++ b/packages/compact/src/Compiler.ts @@ -433,6 +433,8 @@ export const UIService = { * ``` */ export class CompactCompiler { + /** Default Compact version used when none is explicitly provided */ + private static readonly DEFAULT_COMPACT_VERSION = '0.25.0'; /** Environment validation service */ private readonly environmentValidator: EnvironmentValidator; /** File discovery service */ @@ -549,6 +551,11 @@ export class CompactCompiler { } } + // Apply default toolchain version if none provided; allow env to override + if (!version) { + version = env.COMPACT_TOOLCHAIN_VERSION ?? CompactCompiler.DEFAULT_COMPACT_VERSION; + } + return new CompactCompiler(flags.join(' '), targetDir, version); } From e06d0488d481edb4aec47911b477ca2c6bed60ee Mon Sep 17 00:00:00 2001 From: 0xisk Date: Mon, 3 Nov 2025 14:18:35 +0100 Subject: [PATCH 29/40] fix: ci issues --- .github/actions/setup/action.yml | 35 ++++++++++++++++++++++++-- contracts/src/utils/test/utils.test.ts | 2 +- packages/compact/src/Compiler.ts | 5 ++-- packages/compact/src/versions.ts | 2 ++ packages/compact/test/Compiler.test.ts | 3 ++- 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 packages/compact/src/versions.ts diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 2f9e5e07..144a4f55 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -41,7 +41,8 @@ runs: uses: actions/cache@v4 id: compact-cache with: - path: ~/compactc + path: | + ~/.local/bin/compact key: compact-compiler-${{ env.COMPILER_VERSION }}-${{ runner.os }} - name: Setup Node.js @@ -78,6 +79,9 @@ runs: echo "🔧 Installing Compact compiler from $COMPACT_INSTALLER_URL ..." curl --proto '=https' --tlsv1.2 -LsSf "$COMPACT_INSTALLER_URL" | sh + echo "🔧 Updating Compact compiler to $COMPILER_VERSION..." + "$COMPACT_HOME/compact" update "$COMPILER_VERSION" + echo "✅ Compact compiler installed" - name: Setup Compact environment @@ -101,5 +105,32 @@ runs: id: compact-outputs shell: bash run: | - echo "compact-home=$HOME/compact" >> $GITHUB_OUTPUT + echo "compact-home=$HOME/.local/bin" >> $GITHUB_OUTPUT echo "version=$COMPILER_VERSION" >> $GITHUB_OUTPUT + + - name: Check compiler and language version + if: inputs.skip-compact != 'true' + shell: bash + run: | + set -euo pipefail + + echo "🔍 Checking Compact compiler version..." + COMPILER_OUTPUT=$("$COMPACT_HOME/compact" compile --version) + COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1) + + if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then + echo "::error::❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION" + exit 1 + fi + echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION" + + echo "🔍 Checking Compact language version..." + LANGUAGE_OUTPUT=$("$COMPACT_HOME/compact" compile --language-version) + COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1) + + if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then + echo "::error::❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION" + exit 1 + fi + echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION" + \ No newline at end of file diff --git a/contracts/src/utils/test/utils.test.ts b/contracts/src/utils/test/utils.test.ts index 17f573cc..339d41c4 100644 --- a/contracts/src/utils/test/utils.test.ts +++ b/contracts/src/utils/test/utils.test.ts @@ -27,7 +27,7 @@ describe('Utils', () => { }); it('should not return zero for a zero contract address', () => { - expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe(false); + expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe(true); }); }); diff --git a/packages/compact/src/Compiler.ts b/packages/compact/src/Compiler.ts index a95d20dd..d58cd9fc 100755 --- a/packages/compact/src/Compiler.ts +++ b/packages/compact/src/Compiler.ts @@ -13,6 +13,7 @@ import { DirectoryNotFoundError, isPromisifiedChildProcessError, } from './types/errors.ts'; +import { COMPACT_VERSION } from './versions.ts'; /** Source directory containing .compact files */ const SRC_DIR: string = 'src'; @@ -433,8 +434,6 @@ export const UIService = { * ``` */ export class CompactCompiler { - /** Default Compact version used when none is explicitly provided */ - private static readonly DEFAULT_COMPACT_VERSION = '0.25.0'; /** Environment validation service */ private readonly environmentValidator: EnvironmentValidator; /** File discovery service */ @@ -553,7 +552,7 @@ export class CompactCompiler { // Apply default toolchain version if none provided; allow env to override if (!version) { - version = env.COMPACT_TOOLCHAIN_VERSION ?? CompactCompiler.DEFAULT_COMPACT_VERSION; + version = env.COMPACT_TOOLCHAIN_VERSION ?? COMPACT_VERSION; } return new CompactCompiler(flags.join(' '), targetDir, version); diff --git a/packages/compact/src/versions.ts b/packages/compact/src/versions.ts new file mode 100644 index 00000000..dca487bb --- /dev/null +++ b/packages/compact/src/versions.ts @@ -0,0 +1,2 @@ +export const COMPACT_VERSION = '0.25.0'; +export const LANGUAGE_VERSION = '0.17.0'; diff --git a/packages/compact/test/Compiler.test.ts b/packages/compact/test/Compiler.test.ts index 8dcc4dd1..f6b71c87 100644 --- a/packages/compact/test/Compiler.test.ts +++ b/packages/compact/test/Compiler.test.ts @@ -21,6 +21,7 @@ import { CompilationError, DirectoryNotFoundError, } from '../src/types/errors.js'; +import { COMPACT_VERSION } from '../src/versions.js'; // Mock Node.js modules vi.mock('node:fs'); @@ -479,7 +480,7 @@ describe('CompactCompiler', () => { expect(compiler.testFlags).toBe(''); expect(compiler.testTargetDir).toBeUndefined(); - expect(compiler.testVersion).toBeUndefined(); + expect(compiler.testVersion).toBe(COMPACT_VERSION); }); it('should handle SKIP_ZK environment variable', () => { From 0028e186a5fcc1c02e262728977ea57982fd6e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 18:48:19 -0500 Subject: [PATCH 30/40] Updates codeql-action to latest version --- .github/workflows/codeql.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 42145c4e..992ea100 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,13 +35,13 @@ jobs: uses: ./.github/actions/setup - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # We can add custom queries later when needed # queries: security-extended - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{ matrix.language }}" From 83b8129193fbddf050a9f633bc424e7dd9e873c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 18:50:37 -0500 Subject: [PATCH 31/40] Updates setup-node to v6 --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 144a4f55..d8727c7b 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -46,7 +46,7 @@ runs: key: compact-compiler-${{ env.COMPILER_VERSION }}-${{ runner.os }} - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: ".nvmrc" cache: "yarn" From 006522e8a827c9bf61d3a4a8f3251d04f0d82c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:28:00 -0500 Subject: [PATCH 32/40] Update compact version and setup-node action version --- .github/workflows/release.yml | 4 ++-- packages/compact/src/versions.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 445a734d..135a261b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,9 +35,9 @@ jobs: echo "✅ Version consistency validated: $RELEASE_VERSION" - name: Setup npm registry - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - registry-url: 'https://registry.npmjs.org' + registry-url: "https://registry.npmjs.org" - name: Pack tarball id: pack diff --git a/packages/compact/src/versions.ts b/packages/compact/src/versions.ts index dca487bb..efb582eb 100644 --- a/packages/compact/src/versions.ts +++ b/packages/compact/src/versions.ts @@ -1,2 +1,2 @@ -export const COMPACT_VERSION = '0.25.0'; -export const LANGUAGE_VERSION = '0.17.0'; +export const COMPACT_VERSION = '0.26.0'; +export const LANGUAGE_VERSION = '0.18.0'; From a279b5a5b18e922aff8a5fc50197ca285914f96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:37:40 -0500 Subject: [PATCH 33/40] Updates Compact version in various file docs, tooling, etc --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 4 +- .github/ISSUE_TEMPLATE/01_bug_report.yml | 2 +- .github/actions/setup/action.yml | 4 +- README.md | 6 +- docs/modules/ROOT/pages/index.adoc | 4 +- packages/compact/src/Builder.ts | 6 +- packages/compact/src/Compiler.ts | 26 +++---- packages/compact/src/runBuilder.ts | 2 +- packages/compact/src/runCompiler.ts | 6 +- packages/compact/test/Compiler.test.ts | 86 +++++++++++------------ packages/compact/test/runCompiler.test.ts | 16 ++--- 12 files changed, 82 insertions(+), 82 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index bd886029..89ac308b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/devcontainers/javascript-node # Midnight binaries and tools download URLs # Source: https://docs.midnight.network/relnotes/overview -ARG COMPACT_TOOLCHAIN_VERSION=0.25.0 +ARG COMPACT_TOOLCHAIN_VERSION=0.26.0 ARG COMPACT_VSCODE_VERSION=0.2.13 ARG COMPACT_VSCODE_URL="https://raw.githubusercontent.com/midnight-ntwrk/releases/gh-pages/artifacts/vscode-extension/compact-${COMPACT_VSCODE_VERSION}/compact-${COMPACT_VSCODE_VERSION}.vsix" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1f7a77a7..ff1b8f1b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,5 +3,5 @@ "build": { "dockerfile": "Dockerfile" }, - "postCreateCommand": "code --install-extension /tmp/compact.vsix && compact update 0.25.0" -} + "postCreateCommand": "code --install-extension /tmp/compact.vsix && compact update 0.26.0" +} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/01_bug_report.yml b/.github/ISSUE_TEMPLATE/01_bug_report.yml index fd3dd963..5e38c0e1 100644 --- a/.github/ISSUE_TEMPLATE/01_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/01_bug_report.yml @@ -93,7 +93,7 @@ body: label: Version description: What version of Compact are you running? options: - - 0.25.0 (Default) + - 0.26.0 (Default) default: 0 validations: required: true diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index d8727c7b..1a0d29dd 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,8 +21,8 @@ runs: - name: Set shared environment variables shell: bash run: | - echo "COMPILER_VERSION=0.25.0" >> $GITHUB_ENV - echo "LANGUAGE_VERSION=0.17.0" >> $GITHUB_ENV + echo "COMPILER_VERSION=0.26.0" >> $GITHUB_ENV + echo "LANGUAGE_VERSION=0.18.0" >> $GITHUB_ENV - name: Get yarn cache directory path shell: bash diff --git a/README.md b/README.md index 81cfdb86..67e75d6a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Generic badge](https://img.shields.io/badge/Compact%20Compiler-0.25.0-1abc9c.svg)](https://docs.midnight.network/relnotes/compact) +[![Generic badge](https://img.shields.io/badge/Compact%20Compiler-0.26.0-1abc9c.svg)](https://docs.midnight.network/relnotes/compact) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) # OpenZeppelin Contracts for Compact @@ -20,8 +20,8 @@ Follow Midnight's [Compact Developer Tools installation guide](https://docs.midn ```bash $ compact compile --version -Compactc version: 0.25.0 -0.25.0 +Compactc version: 0.26.0 +0.26.0 ``` ### Installation diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index 2c426b70..9598f2d5 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -20,8 +20,8 @@ Follow Midnight's {compact-dev-tools} installation guide and confirm that `compa ```bash $ compact compile --version -Compactc version: 0.25.0 -0.25.0 +Compactc version: 0.26.0 +0.26.0 ``` === Installation diff --git a/packages/compact/src/Builder.ts b/packages/compact/src/Builder.ts index 128f26d3..57fc3e27 100755 --- a/packages/compact/src/Builder.ts +++ b/packages/compact/src/Builder.ts @@ -30,9 +30,9 @@ const execAsync = promisify(exec); * ``` * ℹ [COMPILE] Found 2 .compact file(s) to compile * ✔ [COMPILE] [1/2] Compiled AccessControl.compact - * Compactc version: 0.25.0 + * Compactc version: 0.26.0 * ✔ [COMPILE] [2/2] Compiled MockAccessControl.compact - * Compactc version: 0.25.0 + * Compactc version: 0.26.0 * ✔ [BUILD] [1/3] Compiling TypeScript * ✔ [BUILD] [2/3] Copying artifacts * ✔ [BUILD] [3/3] Copying and cleaning .compact files @@ -42,7 +42,7 @@ const execAsync = promisify(exec); * ``` * ℹ [COMPILE] Found 2 .compact file(s) to compile * ✖ [COMPILE] [1/2] Failed AccessControl.compact - * Compactc version: 0.25.0 + * Compactc version: 0.26.0 * Error: Expected ';' at line 5 in AccessControl.compact * ``` * diff --git a/packages/compact/src/Compiler.ts b/packages/compact/src/Compiler.ts index d58cd9fc..29b91528 100755 --- a/packages/compact/src/Compiler.ts +++ b/packages/compact/src/Compiler.ts @@ -40,7 +40,7 @@ export type ExecFunction = ( * @example * ```typescript * const validator = new EnvironmentValidator(); - * await validator.validate('0.25.0'); + * await validator.validate('0.26.0'); * const version = await validator.getDevToolsVersion(); * ``` */ @@ -101,7 +101,7 @@ export class EnvironmentValidator { * @throws {Error} If the CLI is not available or command fails * @example * ```typescript - * const toolchainVersion = await validator.getToolchainVersion('0.25.0'); + * const toolchainVersion = await validator.getToolchainVersion('0.26.0'); * console.log(`Toolchain: ${toolchainVersion}`); * ``` */ @@ -123,7 +123,7 @@ export class EnvironmentValidator { * @example * ```typescript * try { - * await validator.validate('0.25.0'); + * await validator.validate('0.26.0'); * console.log('Environment validated successfully'); * } catch (error) { * if (error instanceof CompactCliNotFoundError) { @@ -216,7 +216,7 @@ export class FileDiscovery { * const result = await compiler.compileFile( * 'contracts/Token.compact', * '--skip-zk --verbose', - * '0.25.0' + * '0.26.0' * ); * console.log('Compilation output:', result.stdout); * ``` @@ -248,7 +248,7 @@ export class CompilerService { * const result = await compiler.compileFile( * 'security/AccessControl.compact', * '--skip-zk', - * '0.25.0' + * '0.26.0' * ); * console.log('Success:', result.stdout); * } catch (error) { @@ -297,7 +297,7 @@ export class CompilerService { * @class UIService * @example * ```typescript - * UIService.displayEnvInfo('compact 0.1.0', 'Compactc 0.25.0', 'security'); + * UIService.displayEnvInfo('compact 0.1.0', 'Compactc 0.26.0', 'security'); * UIService.printOutput('Compilation successful', chalk.green); * ``` */ @@ -334,9 +334,9 @@ export const UIService = { * ```typescript * UIService.displayEnvInfo( * 'compact 0.1.0', - * 'Compactc version: 0.25.0', + * 'Compactc version: 0.26.0', * 'security', - * '0.25.0' + * '0.26.0' * ); * ``` */ @@ -420,7 +420,7 @@ export const UIService = { * @example * ```typescript * // Basic usage - * const compiler = new CompactCompiler('--skip-zk', 'security', '0.25.0'); + * const compiler = new CompactCompiler('--skip-zk', 'security', '0.26.0'); * await compiler.compile(); * * // Factory method usage @@ -453,7 +453,7 @@ export class CompactCompiler { * * @param flags - Space-separated compiler flags (e.g., '--skip-zk --verbose') * @param targetDir - Optional subdirectory within src/ to compile (e.g., 'security', 'token') - * @param version - Optional toolchain version to use (e.g., '0.25.0') + * @param version - Optional toolchain version to use (e.g., '0.26.0') * @param execFn - Optional custom exec function for dependency injection * @example * ```typescript @@ -464,7 +464,7 @@ export class CompactCompiler { * const compiler = new CompactCompiler('', 'security'); * * // Compile with specific version - * const compiler = new CompactCompiler('--skip-zk', undefined, '0.25.0'); + * const compiler = new CompactCompiler('--skip-zk', undefined, '0.26.0'); * * // For testing with custom exec function * const mockExec = vi.fn(); @@ -501,11 +501,11 @@ export class CompactCompiler { * @throws {Error} If --dir flag is provided without a directory name * @example * ```typescript - * // Parse command line: compact-compiler --dir security --skip-zk +0.25.0 + * // Parse command line: compact-compiler --dir security --skip-zk +0.26.0 * const compiler = CompactCompiler.fromArgs([ * '--dir', 'security', * '--skip-zk', - * '+0.25.0' + * '+0.26.0' * ]); * * // With environment variable diff --git a/packages/compact/src/runBuilder.ts b/packages/compact/src/runBuilder.ts index ac2659b7..8a9391d2 100644 --- a/packages/compact/src/runBuilder.ts +++ b/packages/compact/src/runBuilder.ts @@ -19,7 +19,7 @@ import { CompactBuilder } from './Builder.js'; * ℹ [COMPILE] COMPACTC_PATH: /path/to/compactc/compactc * ℹ [COMPILE] Found 1 .compact file(s) to compile * ✔ [COMPILE] [1/1] Compiled Foo.compact - * Compactc version: 0.25.0 + * Compactc version: 0.26.0 * ✔ [BUILD] [1/3] Compiling TypeScript * ✔ [BUILD] [2/3] Copying artifacts * ✔ [BUILD] [3/3] Copying and cleaning .compact files diff --git a/packages/compact/src/runCompiler.ts b/packages/compact/src/runCompiler.ts index 93cbe1b2..eebd491c 100644 --- a/packages/compact/src/runCompiler.ts +++ b/packages/compact/src/runCompiler.ts @@ -40,7 +40,7 @@ import { * * @example Version specification * ```bash - * npx compact-compiler --dir security --skip-zk +0.25.0 + * npx compact-compiler --dir security --skip-zk +0.26.0 * ``` */ async function runCompiler(): Promise { @@ -179,7 +179,7 @@ function showUsageHelp(): void { ); console.log( chalk.yellow( - ' + Use specific toolchain version (e.g., +0.25.0)', + ' + Use specific toolchain version (e.g., +0.26.0)', ), ); console.log(chalk.yellow('\nExamples:')); @@ -205,7 +205,7 @@ function showUsageHelp(): void { ); console.log( chalk.yellow( - ' compact-compiler --skip-zk +0.25.0 # Use specific version', + ' compact-compiler --skip-zk +0.26.0 # Use specific version', ), ); console.log(chalk.yellow('\nTurbo integration:')); diff --git a/packages/compact/test/Compiler.test.ts b/packages/compact/test/Compiler.test.ts index f6b71c87..1a7cbdc0 100644 --- a/packages/compact/test/Compiler.test.ts +++ b/packages/compact/test/Compiler.test.ts @@ -105,27 +105,27 @@ describe('EnvironmentValidator', () => { describe('getToolchainVersion', () => { it('should get version without specific version flag', async () => { mockExec.mockResolvedValue({ - stdout: 'Compactc version: 0.25.0', + stdout: 'Compactc version: 0.26.0', stderr: '', }); const version = await validator.getToolchainVersion(); - expect(version).toBe('Compactc version: 0.25.0'); + expect(version).toBe('Compactc version: 0.26.0'); expect(mockExec).toHaveBeenCalledWith('compact compile --version'); }); it('should get version with specific version flag', async () => { mockExec.mockResolvedValue({ - stdout: 'Compactc version: 0.25.0', + stdout: 'Compactc version: 0.26.0', stderr: '', }); - const version = await validator.getToolchainVersion('0.25.0'); + const version = await validator.getToolchainVersion('0.26.0'); - expect(version).toBe('Compactc version: 0.25.0'); + expect(version).toBe('Compactc version: 0.26.0'); expect(mockExec).toHaveBeenCalledWith( - 'compact compile +0.25.0 --version', + 'compact compile +0.26.0 --version', ); }); }); @@ -202,7 +202,7 @@ describe('FileDiscovery', () => { it('should handle directory read errors gracefully', async () => { const consoleSpy = vi .spyOn(console, 'error') - .mockImplementation(() => {}); + .mockImplementation(() => { }); mockReaddir.mockRejectedValueOnce(new Error('Permission denied')); @@ -275,12 +275,12 @@ describe('CompilerService', () => { const result = await service.compileFile( 'MyToken.compact', '--skip-zk', - '0.25.0', + '0.26.0', ); expect(result).toEqual({ stdout: 'Compilation successful', stderr: '' }); expect(mockExec).toHaveBeenCalledWith( - 'compact compile +0.25.0 --skip-zk "src/MyToken.compact" "artifacts/MyToken"', + 'compact compile +0.26.0 --skip-zk "src/MyToken.compact" "artifacts/MyToken"', ); }); @@ -334,7 +334,7 @@ describe('CompilerService', () => { describe('UIService', () => { beforeEach(() => { vi.clearAllMocks(); - vi.spyOn(console, 'log').mockImplementation(() => {}); + vi.spyOn(console, 'log').mockImplementation(() => { }); }); describe('printOutput', () => { @@ -365,9 +365,9 @@ describe('UIService', () => { it('should display environment information with all parameters', () => { UIService.displayEnvInfo( 'compact 0.1.0', - 'Compactc 0.25.0', + 'Compactc 0.26.0', 'security', - '0.25.0', + '0.26.0', ); expect(mockSpinner.info).toHaveBeenCalledWith( @@ -377,21 +377,21 @@ describe('UIService', () => { '[COMPILE] Compact developer tools: compact 0.1.0', ); expect(mockSpinner.info).toHaveBeenCalledWith( - '[COMPILE] Compact toolchain: Compactc 0.25.0', + '[COMPILE] Compact toolchain: Compactc 0.26.0', ); expect(mockSpinner.info).toHaveBeenCalledWith( - '[COMPILE] Using toolchain version: 0.25.0', + '[COMPILE] Using toolchain version: 0.26.0', ); }); it('should display environment information without optional parameters', () => { - UIService.displayEnvInfo('compact 0.1.0', 'Compactc 0.25.0'); + UIService.displayEnvInfo('compact 0.1.0', 'Compactc 0.26.0'); expect(mockSpinner.info).toHaveBeenCalledWith( '[COMPILE] Compact developer tools: compact 0.1.0', ); expect(mockSpinner.info).toHaveBeenCalledWith( - '[COMPILE] Compact toolchain: Compactc 0.25.0', + '[COMPILE] Compact toolchain: Compactc 0.26.0', ); expect(mockSpinner.info).not.toHaveBeenCalledWith( expect.stringContaining('TARGET_DIR'), @@ -461,7 +461,7 @@ describe('CompactCompiler', () => { compiler = new CompactCompiler( '--skip-zk', 'security', - '0.25.0', + '0.26.0', mockExec, ); @@ -515,9 +515,9 @@ describe('CompactCompiler', () => { }); it('should parse version flag', () => { - compiler = CompactCompiler.fromArgs(['+0.25.0']); + compiler = CompactCompiler.fromArgs(['+0.26.0']); - expect(compiler.testVersion).toBe('0.25.0'); + expect(compiler.testVersion).toBe('0.26.0'); expect(compiler.testFlags).toBe(''); }); @@ -527,12 +527,12 @@ describe('CompactCompiler', () => { 'security', '--skip-zk', '--verbose', - '+0.25.0', + '+0.26.0', ]); expect(compiler.testTargetDir).toBe('security'); expect(compiler.testFlags).toBe('--skip-zk --verbose'); - expect(compiler.testVersion).toBe('0.25.0'); + expect(compiler.testVersion).toBe('0.26.0'); }); it('should combine environment variables with CLI flags', () => { @@ -571,19 +571,19 @@ describe('CompactCompiler', () => { .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) // checkCompactAvailable .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) // getDevToolsVersion .mockResolvedValueOnce({ - stdout: 'Compactc version: 0.25.0', + stdout: 'Compactc version: 0.26.0', stderr: '', }); // getToolchainVersion compiler = new CompactCompiler( '--skip-zk', 'security', - '0.25.0', + '0.26.0', mockExec, ); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => {}); + .mockImplementation(() => { }); await expect(compiler.validateEnvironment()).resolves.not.toThrow(); @@ -593,15 +593,15 @@ describe('CompactCompiler', () => { expect(mockExec).toHaveBeenNthCalledWith(2, 'compact --version'); // getDevToolsVersion() expect(mockExec).toHaveBeenNthCalledWith( 3, - 'compact compile +0.25.0 --version', + 'compact compile +0.26.0 --version', ); // getToolchainVersion() // Verify passed args expect(displaySpy).toHaveBeenCalledWith( 'compact 0.1.0', - 'Compactc version: 0.25.0', + 'Compactc version: 0.26.0', 'security', - '0.25.0', + '0.26.0', ); displaySpy.mockRestore(); @@ -655,27 +655,27 @@ describe('CompactCompiler', () => { .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) .mockResolvedValueOnce({ - stdout: 'Compactc version: 0.25.0', + stdout: 'Compactc version: 0.26.0', stderr: '', }); - compiler = new CompactCompiler('', undefined, '0.25.0', mockExec); + compiler = new CompactCompiler('', undefined, '0.26.0', mockExec); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => {}); + .mockImplementation(() => { }); await compiler.validateEnvironment(); // Verify version-specific toolchain call expect(mockExec).toHaveBeenNthCalledWith( 3, - 'compact compile +0.25.0 --version', + 'compact compile +0.26.0 --version', ); expect(displaySpy).toHaveBeenCalledWith( 'compact 0.1.0', - 'Compactc version: 0.25.0', + 'Compactc version: 0.26.0', undefined, // no targetDir - '0.25.0', + '0.26.0', ); displaySpy.mockRestore(); @@ -686,14 +686,14 @@ describe('CompactCompiler', () => { .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) .mockResolvedValueOnce({ - stdout: 'Compactc version: 0.25.0', + stdout: 'Compactc version: 0.26.0', stderr: '', }); compiler = new CompactCompiler('', undefined, undefined, mockExec); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => {}); + .mockImplementation(() => { }); await compiler.validateEnvironment(); @@ -701,7 +701,7 @@ describe('CompactCompiler', () => { expect(mockExec).toHaveBeenNthCalledWith(3, 'compact compile --version'); expect(displaySpy).toHaveBeenCalledWith( 'compact 0.1.0', - 'Compactc version: 0.25.0', + 'Compactc version: 0.26.0', undefined, undefined, ); @@ -768,7 +768,7 @@ describe('CompactCompiler', () => { .fn() .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) // checkCompactAvailable .mockResolvedValueOnce({ stdout: 'compact 0.1.0', stderr: '' }) // getDevToolsVersion - .mockResolvedValueOnce({ stdout: 'Compactc 0.25.0', stderr: '' }) // getToolchainVersion + .mockResolvedValueOnce({ stdout: 'Compactc 0.26.0', stderr: '' }) // getToolchainVersion .mockRejectedValueOnce(new Error('Compilation failed')); // compileFile execution compiler = new CompactCompiler('', undefined, undefined, testMockExec); @@ -830,9 +830,9 @@ describe('CompactCompiler', () => { }); it('should handle version specification', () => { - compiler = CompactCompiler.fromArgs(['+0.25.0']); + compiler = CompactCompiler.fromArgs(['+0.26.0']); - expect(compiler.testVersion).toBe('0.25.0'); + expect(compiler.testVersion).toBe('0.26.0'); }); it.each([ @@ -842,7 +842,7 @@ describe('CompactCompiler', () => { '--dir', 'security', '--no-communications-commitment', - '+0.25.0', + '+0.26.0', ], env: { SKIP_ZK: 'true' }, }, @@ -853,7 +853,7 @@ describe('CompactCompiler', () => { 'security', '--skip-zk', '--no-communications-commitment', - '+0.25.0', + '+0.26.0', ], env: { SKIP_ZK: 'false' }, }, @@ -864,7 +864,7 @@ describe('CompactCompiler', () => { 'security', '--skip-zk', '--no-communications-commitment', - '+0.25.0', + '+0.26.0', ], env: { SKIP_ZK: 'true' }, }, @@ -875,7 +875,7 @@ describe('CompactCompiler', () => { '--skip-zk --no-communications-commitment', ); expect(compiler.testTargetDir).toBe('security'); - expect(compiler.testVersion).toBe('0.25.0'); + expect(compiler.testVersion).toBe('0.26.0'); }); }); }); diff --git a/packages/compact/test/runCompiler.test.ts b/packages/compact/test/runCompiler.test.ts index 35ea17c2..83213964 100644 --- a/packages/compact/test/runCompiler.test.ts +++ b/packages/compact/test/runCompiler.test.ts @@ -50,7 +50,7 @@ const mockExit = vi .mockImplementation(() => undefined as never); // Mock console methods -const mockConsoleLog = vi.spyOn(console, 'log').mockImplementation(() => {}); +const mockConsoleLog = vi.spyOn(console, 'log').mockImplementation(() => { }); describe('runCompiler CLI', () => { let mockCompile: ReturnType; @@ -329,7 +329,7 @@ describe('runCompiler CLI', () => { ' --skip-zk Skip zero-knowledge proof generation', ); expect(mockConsoleLog).toHaveBeenCalledWith( - ' + Use specific toolchain version (e.g., +0.25.0)', + ' + Use specific toolchain version (e.g., +0.26.0)', ); expect(mockConsoleLog).toHaveBeenCalledWith('\nExamples:'); expect(mockConsoleLog).toHaveBeenCalledWith( @@ -345,7 +345,7 @@ describe('runCompiler CLI', () => { ' SKIP_ZK=true compact-compiler --dir token # Use environment variable', ); expect(mockConsoleLog).toHaveBeenCalledWith( - ' compact-compiler --skip-zk +0.25.0 # Use specific version', + ' compact-compiler --skip-zk +0.26.0 # Use specific version', ); expect(mockConsoleLog).toHaveBeenCalledWith('\nTurbo integration:'); expect(mockConsoleLog).toHaveBeenCalledWith( @@ -423,11 +423,11 @@ describe('runCompiler CLI', () => { }); it('should handle version specification', async () => { - process.argv = ['node', 'runCompiler.js', '+0.25.0', '--skip-zk']; + process.argv = ['node', 'runCompiler.js', '+0.26.0', '--skip-zk']; await import('../src/runCompiler.js'); - expect(mockFromArgs).toHaveBeenCalledWith(['+0.25.0', '--skip-zk']); + expect(mockFromArgs).toHaveBeenCalledWith(['+0.26.0', '--skip-zk']); }); it('should handle complex command', async () => { @@ -438,7 +438,7 @@ describe('runCompiler CLI', () => { 'security', '--skip-zk', '--verbose', - '+0.25.0', + '+0.26.0', ]; await import('../src/runCompiler.js'); @@ -448,14 +448,14 @@ describe('runCompiler CLI', () => { 'security', '--skip-zk', '--verbose', - '+0.25.0', + '+0.26.0', ]); }); }); describe('integration with CompactCompiler', () => { it('should pass arguments correctly to CompactCompiler.fromArgs', async () => { - const args = ['--dir', 'token', '--skip-zk', '+0.25.0']; + const args = ['--dir', 'token', '--skip-zk', '+0.26.0']; process.argv = ['node', 'runCompiler.js', ...args]; mockCompile.mockResolvedValue(undefined); From 35dfd69809d69d6c4a0b210a59728cf21702e24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 20:04:41 -0500 Subject: [PATCH 34/40] Use pinned OS version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 135a261b..4e1a335b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: publish: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: contents: read id-token: write From 98a2dbae2c9afd244ae67152436f612ddb45f051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 20:05:07 -0500 Subject: [PATCH 35/40] Use latest setup-node version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> --- .github/workflows/prepare-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index c625b617..b411c655 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v5 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: ".nvmrc" cache: "yarn" From 11755b8dfdb659accec9ebaa417918325497f84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 20:05:39 -0500 Subject: [PATCH 36/40] Use pinned OS runner version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> --- .github/workflows/prepare-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index b411c655..71689248 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -10,7 +10,7 @@ permissions: jobs: update_version: if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/release-v') - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout repository From 42b2b9edd04b3e3d93f219c343f84a70d1d67bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 20:21:43 -0500 Subject: [PATCH 37/40] biome lint fix --- .devcontainer/devcontainer.json | 2 +- contracts/src/utils/test/utils.test.ts | 4 +++- packages/compact/src/Builder.ts | 2 ++ packages/compact/test/Compiler.test.ts | 10 +++++----- packages/compact/test/runCompiler.test.ts | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ff1b8f1b..eeb0dff2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,4 +4,4 @@ "dockerfile": "Dockerfile" }, "postCreateCommand": "code --install-extension /tmp/compact.vsix && compact update 0.26.0" -} \ No newline at end of file +} diff --git a/contracts/src/utils/test/utils.test.ts b/contracts/src/utils/test/utils.test.ts index 339d41c4..0d768441 100644 --- a/contracts/src/utils/test/utils.test.ts +++ b/contracts/src/utils/test/utils.test.ts @@ -27,7 +27,9 @@ describe('Utils', () => { }); it('should not return zero for a zero contract address', () => { - expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe(true); + expect(contract.isKeyOrAddressZero(contractUtils.ZERO_ADDRESS)).toBe( + true, + ); }); }); diff --git a/packages/compact/src/Builder.ts b/packages/compact/src/Builder.ts index 57fc3e27..d6150a2c 100755 --- a/packages/compact/src/Builder.ts +++ b/packages/compact/src/Builder.ts @@ -75,6 +75,7 @@ export class CompactBuilder { // Step 3: Copy .compact files preserving structure (excludes Mock* files and archive/) { + // biome-ignore-start lint/suspicious/noUselessEscapeInString: Needed inside JS template literal cmd: ` find src -type f -name "*.compact" ! -name "Mock*" ! -path "*/archive/*" | while read file; do # Remove src/ prefix from path @@ -83,6 +84,7 @@ export class CompactBuilder { cp "\$file" "dist/\$rel_path" done `, + // biome-ignore-end lint/suspicious/noUselessEscapeInString: Needed inside JS template literal msg: 'Copying .compact files (excluding mocks and archive)', shell: '/bin/bash', }, diff --git a/packages/compact/test/Compiler.test.ts b/packages/compact/test/Compiler.test.ts index 1a7cbdc0..300da37a 100644 --- a/packages/compact/test/Compiler.test.ts +++ b/packages/compact/test/Compiler.test.ts @@ -202,7 +202,7 @@ describe('FileDiscovery', () => { it('should handle directory read errors gracefully', async () => { const consoleSpy = vi .spyOn(console, 'error') - .mockImplementation(() => { }); + .mockImplementation(() => {}); mockReaddir.mockRejectedValueOnce(new Error('Permission denied')); @@ -334,7 +334,7 @@ describe('CompilerService', () => { describe('UIService', () => { beforeEach(() => { vi.clearAllMocks(); - vi.spyOn(console, 'log').mockImplementation(() => { }); + vi.spyOn(console, 'log').mockImplementation(() => {}); }); describe('printOutput', () => { @@ -583,7 +583,7 @@ describe('CompactCompiler', () => { ); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => { }); + .mockImplementation(() => {}); await expect(compiler.validateEnvironment()).resolves.not.toThrow(); @@ -662,7 +662,7 @@ describe('CompactCompiler', () => { compiler = new CompactCompiler('', undefined, '0.26.0', mockExec); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => { }); + .mockImplementation(() => {}); await compiler.validateEnvironment(); @@ -693,7 +693,7 @@ describe('CompactCompiler', () => { compiler = new CompactCompiler('', undefined, undefined, mockExec); const displaySpy = vi .spyOn(UIService, 'displayEnvInfo') - .mockImplementation(() => { }); + .mockImplementation(() => {}); await compiler.validateEnvironment(); diff --git a/packages/compact/test/runCompiler.test.ts b/packages/compact/test/runCompiler.test.ts index 83213964..3110f436 100644 --- a/packages/compact/test/runCompiler.test.ts +++ b/packages/compact/test/runCompiler.test.ts @@ -50,7 +50,7 @@ const mockExit = vi .mockImplementation(() => undefined as never); // Mock console methods -const mockConsoleLog = vi.spyOn(console, 'log').mockImplementation(() => { }); +const mockConsoleLog = vi.spyOn(console, 'log').mockImplementation(() => {}); describe('runCompiler CLI', () => { let mockCompile: ReturnType; From d11542f7b3ed8e6a52a27dc032a5ad05b8ce8a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9F=A3=20=E2=82=AC=E2=82=A5=E2=84=B5=E2=88=AA=E2=84=93?= =?UTF-8?q?=20=E2=9F=A2?= <34749913+emnul@users.noreply.github.com> Date: Mon, 3 Nov 2025 21:46:12 -0500 Subject: [PATCH 38/40] Ensure default compiler version is set --- .github/actions/setup/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 1a0d29dd..08af71c2 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -114,6 +114,9 @@ runs: run: | set -euo pipefail + echo "🔧 Updating Compact compiler to $COMPILER_VERSION..." + "$COMPACT_HOME/compact" update "$COMPILER_VERSION" + echo "🔍 Checking Compact compiler version..." COMPILER_OUTPUT=$("$COMPACT_HOME/compact" compile --version) COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1) From 9072d975f9f46fe0eaa6041d4bbba865cf8aebdc Mon Sep 17 00:00:00 2001 From: 0xisk Date: Fri, 7 Nov 2025 09:14:39 +0100 Subject: [PATCH 39/40] fix: .github/workflows/prepare-release.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> Signed-off-by: 0xisk <0xisk@proton.me> --- .github/workflows/prepare-release.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 71689248..bf381393 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -63,15 +63,7 @@ jobs: echo "New version: $NEW_VERSION" # Update package.json version field manually - cd contracts - node -e " - const fs = require('fs'); - const newVersion = process.env.NEW_VERSION; - const pkg = require('./package.json'); - pkg.version = newVersion; - fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n'); - console.log('Updated package.json to version ' + newVersion); - " + yarn workspace @openzeppelin-compact/contracts version "$NEW_VERSION" # Update yarn.lock to reflect the new version yarn install cd .. From 3bab84ac0a607136805a20a0f0abfd99e9683773 Mon Sep 17 00:00:00 2001 From: 0xisk Date: Fri, 7 Nov 2025 09:14:53 +0100 Subject: [PATCH 40/40] fix: .github/workflows/prepare-release.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com> Signed-off-by: 0xisk <0xisk@proton.me> --- .github/workflows/prepare-release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index bf381393..5d187507 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -64,9 +64,6 @@ jobs: # Update package.json version field manually yarn workspace @openzeppelin-compact/contracts version "$NEW_VERSION" - # Update yarn.lock to reflect the new version - yarn install - cd .. # Escape special characters for sed ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g')