From 2355995484378e0c478805258917b28cb6bb7293 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 20 Nov 2025 01:44:35 -0300 Subject: [PATCH 1/3] fix contracts package name --- contracts/package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/package.json b/contracts/package.json index 269ff8e0..1eda62fb 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,5 +1,5 @@ { - "name": "@openzeppelin-compact/contracts", + "name": "@openzeppelin/compact-contracts", "version": "0.0.1", "description": "OpenZeppelin Compact contract library", "keywords": [ diff --git a/yarn.lock b/yarn.lock index 06ca70b1..622856f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -427,9 +427,9 @@ __metadata: languageName: unknown linkType: soft -"@openzeppelin-compact/contracts@workspace:contracts": +"@openzeppelin/compact-contracts@workspace:contracts": version: 0.0.0-use.local - resolution: "@openzeppelin-compact/contracts@workspace:contracts" + resolution: "@openzeppelin/compact-contracts@workspace:contracts" dependencies: "@openzeppelin-compact/compact": "workspace:^" "@openzeppelin-compact/contracts-simulator": "workspace:^" From f179f2aaee8ca40e8b2f30633e68241cea7032d3 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 20 Nov 2025 01:44:53 -0300 Subject: [PATCH 2/3] update contracts package name --- .github/workflows/prepare-release.yml | 2 +- .github/workflows/test.yml | 2 +- README.md | 10 +++++----- package.json | 4 ++-- turbo.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 5d187507..b1a1e7c7 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -63,7 +63,7 @@ jobs: echo "New version: $NEW_VERSION" # Update package.json version field manually - yarn workspace @openzeppelin-compact/contracts version "$NEW_VERSION" + yarn workspace @openzeppelin/compact-contracts version "$NEW_VERSION" # Escape special characters for sed ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d02dc73..8846b1fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: uses: ./.github/actions/setup - name: Compile contracts (with retry) - run: turbo compact --filter=@openzeppelin-compact/contracts --concurrency=1 + run: turbo compact --filter=@openzeppelin/compact-contracts --concurrency=1 - name: Run type checks run: turbo types diff --git a/README.md b/README.md index 48295370..47885b61 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ SKIP_ZK=true yarn compact ### Write a custom contract using library modules In the root of `my-project`, create a custom contract using OpenZeppelin Compact modules. -Import the modules through `compact-contracts/node_modules/@openzeppelin-compact/contracts/...`. +Import the modules through `compact-contracts/node_modules/@openzeppelin/compact-contracts/...`. Import modules through `node_modules` rather than directly to avoid state conflicts between shared dependencies. > NOTE: Installing the library will be easier once it's available as an NPM package. @@ -68,11 +68,11 @@ Import modules through `node_modules` rather than directly to avoid state confli pragma language_version >= 0.18.0; import CompactStandardLibrary; -import "./compact-contracts/node_modules/@openzeppelin-compact/contracts/src/access/Ownable" +import "./compact-contracts/node_modules/@openzeppelin/compact-contracts/src/access/Ownable" prefix Ownable_; -import "./compact-contracts/node_modules/@openzeppelin-compact/contracts/src/security/Pausable" +import "./compact-contracts/node_modules/@openzeppelin/compact-contracts/src/security/Pausable" prefix Pausable_; -import "./compact-contracts/node_modules/@openzeppelin-compact/contracts/src/token/FungibleToken" +import "./compact-contracts/node_modules/@openzeppelin/compact-contracts/src/token/FungibleToken" prefix FungibleToken_; constructor( @@ -180,7 +180,7 @@ ZK key generation is slow and usually unnecessary during development. ```bash # Individual module compilation (recommended for development) -turbo compact:token --filter=@openzeppelin-compact/contracts -- --skip-zk +turbo compact:token --filter=@openzeppelin/compact-contracts -- --skip-zk # Full compilation with skip-zk (use environment variable) SKIP_ZK=true turbo compact diff --git a/package.json b/package.json index 1ba3a61e..8979aba2 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ "scripts": { "docs": "turbo run docs --filter=docs", "docs:watch": "turbo run docs:watch --filter=docs", - "compact": "turbo run compact --filter=@openzeppelin-compact/contracts --log-prefix=none", + "compact": "turbo run compact --filter=@openzeppelin/compact-contracts --log-prefix=none", "build": "turbo run build --filter=!'docs' --log-prefix=none", - "test": "turbo run test --filter=@openzeppelin-compact/contracts --log-prefix=none", + "test": "turbo run test --filter=@openzeppelin/compact-contracts --log-prefix=none", "fmt-and-lint": "biome check . --changed", "fmt-and-lint:fix": "biome check . --changed --write", "fmt-and-lint:ci": "biome ci . --changed --no-errors-on-unmatched", diff --git a/turbo.json b/turbo.json index b52c9c45..c1c1ccf3 100644 --- a/turbo.json +++ b/turbo.json @@ -76,7 +76,7 @@ "types": { "dependsOn": [ "@openzeppelin-compact/compact#build", - "@openzeppelin-compact/contracts#compact" + "@openzeppelin/compact-contracts#compact" ], "outputs": [], "cache": false From 1dcced244ccdcdd9476f430d6227a335237a8623 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 20 Nov 2025 02:53:56 -0300 Subject: [PATCH 3/3] fix fmt --- contracts/src/access/test/AccessControl.test.ts | 12 ++++++------ contracts/src/access/test/ZOwnablePK.test.ts | 4 ++-- contracts/src/access/test/utils/address.ts | 14 +++++++------- contracts/src/archive/test/utils/address.ts | 4 ++-- contracts/src/security/test/utils/address.ts | 4 ++-- contracts/src/token/test/utils/address.ts | 2 +- contracts/src/utils/test/utils/address.ts | 4 ++-- packages/compact/test/Compiler.test.ts | 10 +++++----- packages/compact/test/runCompiler.test.ts | 2 +- packages/simulator/src/index.ts | 2 +- packages/simulator/test/fixtures/utils/address.ts | 14 +++++++------- .../test/integration/SampleZOwnable.test.ts | 4 ++-- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/contracts/src/access/test/AccessControl.test.ts b/contracts/src/access/test/AccessControl.test.ts index 0557388a..8a291b9f 100644 --- a/contracts/src/access/test/AccessControl.test.ts +++ b/contracts/src/access/test/AccessControl.test.ts @@ -1,6 +1,6 @@ import { - convertFieldToBytes, type CoinPublicKey, + convertFieldToBytes, } from '@midnight-ntwrk/compact-runtime'; import { beforeEach, describe, expect, it } from 'vitest'; import { AccessControlSimulator } from './simulators/AccessControlSimulator.js'; @@ -24,11 +24,11 @@ const Z_OPERATOR_CONTRACT = // Roles const DEFAULT_ADMIN_ROLE = utils.zeroUint8Array(); -const OPERATOR_ROLE_1 = convertFieldToBytes(32, 1n, ""); -const OPERATOR_ROLE_2 = convertFieldToBytes(32, 2n, ""); -const OPERATOR_ROLE_3 = convertFieldToBytes(32, 3n, ""); -const CUSTOM_ADMIN_ROLE = convertFieldToBytes(32, 4n, ""); -const UNINITIALIZED_ROLE = convertFieldToBytes(32, 5n, ""); +const OPERATOR_ROLE_1 = convertFieldToBytes(32, 1n, ''); +const OPERATOR_ROLE_2 = convertFieldToBytes(32, 2n, ''); +const OPERATOR_ROLE_3 = convertFieldToBytes(32, 3n, ''); +const CUSTOM_ADMIN_ROLE = convertFieldToBytes(32, 4n, ''); +const UNINITIALIZED_ROLE = convertFieldToBytes(32, 5n, ''); let accessControl: AccessControlSimulator; let caller: CoinPublicKey; diff --git a/contracts/src/access/test/ZOwnablePK.test.ts b/contracts/src/access/test/ZOwnablePK.test.ts index 84ef6281..ec156f9e 100644 --- a/contracts/src/access/test/ZOwnablePK.test.ts +++ b/contracts/src/access/test/ZOwnablePK.test.ts @@ -41,7 +41,7 @@ const buildCommitmentFromId = ( counter: bigint, ): Uint8Array => { const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32)); - const bCounter = convertFieldToBytes(32, counter, ""); + const bCounter = convertFieldToBytes(32, counter, ''); const bDomain = new TextEncoder().encode(DOMAIN); const commitment = persistentHash(rt_type, [ @@ -63,7 +63,7 @@ const buildCommitment = ( const id = createIdHash(pk, nonce); const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32)); - const bCounter = convertFieldToBytes(32, counter, ""); + const bCounter = convertFieldToBytes(32, counter, ''); const bDomain = new TextEncoder().encode(domain); const commitment = persistentHash(rt_type, [ diff --git a/contracts/src/access/test/utils/address.ts b/contracts/src/access/test/utils/address.ts index 30ebeba3..3c9f2a52 100644 --- a/contracts/src/access/test/utils/address.ts +++ b/contracts/src/access/test/utils/address.ts @@ -65,12 +65,12 @@ const baseGeneratePubKeyPair = ( str: string, asEither: boolean, ): [ - string, - ( - | Compact.ZswapCoinPublicKey - | Compact.Either - ), - ] => { + string, + ( + | Compact.ZswapCoinPublicKey + | Compact.Either + ), +] => { const pk = toHexPadded(str); const zpk = asEither ? createEitherTestUser(str) : encodeToPK(str); return [pk, zpk]; @@ -86,7 +86,7 @@ export const generateEitherPubKeyPair = (str: string) => ]; export const zeroUint8Array = (length = 32) => - convertFieldToBytes(length, 0n, ""); + convertFieldToBytes(length, 0n, ''); export const ZERO_KEY = { is_left: true, diff --git a/contracts/src/archive/test/utils/address.ts b/contracts/src/archive/test/utils/address.ts index ea3675ce..441f9c93 100644 --- a/contracts/src/archive/test/utils/address.ts +++ b/contracts/src/archive/test/utils/address.ts @@ -70,12 +70,12 @@ export const createEitherTestContractAddress = (str: string) => { export const ZERO_KEY = { is_left: true, - left: { bytes: convertFieldToBytes(32, 0n, "") }, + left: { bytes: convertFieldToBytes(32, 0n, '') }, right: encodeToAddress(''), }; export const ZERO_ADDRESS = { is_left: false, left: encodeToPK(''), - right: { bytes: convertFieldToBytes(32, 0n, "") }, + right: { bytes: convertFieldToBytes(32, 0n, '') }, }; diff --git a/contracts/src/security/test/utils/address.ts b/contracts/src/security/test/utils/address.ts index d34fc03e..ae55f943 100644 --- a/contracts/src/security/test/utils/address.ts +++ b/contracts/src/security/test/utils/address.ts @@ -70,12 +70,12 @@ export const createEitherTestContractAddress = (str: string) => { export const ZERO_KEY = { is_left: true, - left: { bytes: convertFieldToBytes(32, 0n, "") }, + left: { bytes: convertFieldToBytes(32, 0n, '') }, right: encodeToAddress(''), }; export const ZERO_ADDRESS = { is_left: false, left: encodeToPK(''), - right: { bytes: convertFieldToBytes(32, 0n, "") }, + right: { bytes: convertFieldToBytes(32, 0n, '') }, }; diff --git a/contracts/src/token/test/utils/address.ts b/contracts/src/token/test/utils/address.ts index f3f5935d..a2bcd69c 100644 --- a/contracts/src/token/test/utils/address.ts +++ b/contracts/src/token/test/utils/address.ts @@ -62,7 +62,7 @@ export const createEitherTestContractAddress = (str: string) => ({ }); export const zeroUint8Array = (length = 32) => - convertFieldToBytes(length, 0n, ""); + convertFieldToBytes(length, 0n, ''); export const ZERO_KEY = { is_left: true, diff --git a/contracts/src/utils/test/utils/address.ts b/contracts/src/utils/test/utils/address.ts index d34fc03e..ae55f943 100644 --- a/contracts/src/utils/test/utils/address.ts +++ b/contracts/src/utils/test/utils/address.ts @@ -70,12 +70,12 @@ export const createEitherTestContractAddress = (str: string) => { export const ZERO_KEY = { is_left: true, - left: { bytes: convertFieldToBytes(32, 0n, "") }, + left: { bytes: convertFieldToBytes(32, 0n, '') }, right: encodeToAddress(''), }; export const ZERO_ADDRESS = { is_left: false, left: encodeToPK(''), - right: { bytes: convertFieldToBytes(32, 0n, "") }, + right: { bytes: convertFieldToBytes(32, 0n, '') }, }; 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; diff --git a/packages/simulator/src/index.ts b/packages/simulator/src/index.ts index 9785188d..59523ed5 100644 --- a/packages/simulator/src/index.ts +++ b/packages/simulator/src/index.ts @@ -9,6 +9,6 @@ export type { ExtractImpureCircuits, ExtractPureCircuits, IContractSimulator, - IMinimalContract + IMinimalContract, } from './types/index.js'; export type { BaseSimulatorOptions } from './types/Options.js'; diff --git a/packages/simulator/test/fixtures/utils/address.ts b/packages/simulator/test/fixtures/utils/address.ts index 344f6d5b..da7578d6 100644 --- a/packages/simulator/test/fixtures/utils/address.ts +++ b/packages/simulator/test/fixtures/utils/address.ts @@ -65,12 +65,12 @@ const baseGeneratePubKeyPair = ( str: string, asEither: boolean, ): [ - string, - ( - | Compact.ZswapCoinPublicKey - | Compact.Either - ), - ] => { + string, + ( + | Compact.ZswapCoinPublicKey + | Compact.Either + ), +] => { const pk = toHexPadded(str); const zpk = asEither ? createEitherTestUser(str) : encodeToPK(str); return [pk, zpk]; @@ -86,7 +86,7 @@ export const generateEitherPubKeyPair = (str: string) => ]; export const zeroUint8Array = (length = 32) => - convertFieldToBytes(length, 0n, ""); + convertFieldToBytes(length, 0n, ''); export const ZERO_KEY = { is_left: true, diff --git a/packages/simulator/test/integration/SampleZOwnable.test.ts b/packages/simulator/test/integration/SampleZOwnable.test.ts index cc459e95..f5152c52 100644 --- a/packages/simulator/test/integration/SampleZOwnable.test.ts +++ b/packages/simulator/test/integration/SampleZOwnable.test.ts @@ -53,7 +53,7 @@ const buildCommitmentFromId = ( counter: bigint, ): Uint8Array => { const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32)); - const bCounter = convertFieldToBytes(32, counter, ""); + const bCounter = convertFieldToBytes(32, counter, ''); const bDomain = new TextEncoder().encode(DOMAIN); const commitment = persistentHash(rt_type, [ @@ -84,7 +84,7 @@ const buildCommitment = ( const id = createIdHash(pk, nonce); const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32)); - const bCounter = convertFieldToBytes(32, counter, ""); + const bCounter = convertFieldToBytes(32, counter, ''); const bDomain = new TextEncoder().encode(domain); const commitment = persistentHash(rt_type, [