Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@openzeppelin-compact/contracts",
"name": "@openzeppelin/compact-contracts",
"version": "0.0.1",
"description": "OpenZeppelin Compact contract library",
"keywords": [
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/access/test/AccessControl.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/access/test/ZOwnablePK.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand All @@ -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, [
Expand Down
14 changes: 7 additions & 7 deletions contracts/src/access/test/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ const baseGeneratePubKeyPair = (
str: string,
asEither: boolean,
): [
string,
(
| Compact.ZswapCoinPublicKey
| Compact.Either<Compact.ZswapCoinPublicKey, Compact.ContractAddress>
),
] => {
string,
(
| Compact.ZswapCoinPublicKey
| Compact.Either<Compact.ZswapCoinPublicKey, Compact.ContractAddress>
),
] => {
const pk = toHexPadded(str);
const zpk = asEither ? createEitherTestUser(str) : encodeToPK(str);
return [pk, zpk];
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/archive/test/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '') },
};
4 changes: 2 additions & 2 deletions contracts/src/security/test/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '') },
};
2 changes: 1 addition & 1 deletion contracts/src/token/test/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/utils/test/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '') },
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/compact/test/Compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -334,7 +334,7 @@ describe('CompilerService', () => {
describe('UIService', () => {
beforeEach(() => {
vi.clearAllMocks();
vi.spyOn(console, 'log').mockImplementation(() => { });
vi.spyOn(console, 'log').mockImplementation(() => {});
});

describe('printOutput', () => {
Expand Down Expand Up @@ -583,7 +583,7 @@ describe('CompactCompiler', () => {
);
const displaySpy = vi
.spyOn(UIService, 'displayEnvInfo')
.mockImplementation(() => { });
.mockImplementation(() => {});

await expect(compiler.validateEnvironment()).resolves.not.toThrow();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -693,7 +693,7 @@ describe('CompactCompiler', () => {
compiler = new CompactCompiler('', undefined, undefined, mockExec);
const displaySpy = vi
.spyOn(UIService, 'displayEnvInfo')
.mockImplementation(() => { });
.mockImplementation(() => {});

await compiler.validateEnvironment();

Expand Down
2 changes: 1 addition & 1 deletion packages/compact/test/runCompiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof vi.fn>;
Expand Down
2 changes: 1 addition & 1 deletion packages/simulator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type {
ExtractImpureCircuits,
ExtractPureCircuits,
IContractSimulator,
IMinimalContract
IMinimalContract,
} from './types/index.js';
export type { BaseSimulatorOptions } from './types/Options.js';
14 changes: 7 additions & 7 deletions packages/simulator/test/fixtures/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ const baseGeneratePubKeyPair = (
str: string,
asEither: boolean,
): [
string,
(
| Compact.ZswapCoinPublicKey
| Compact.Either<Compact.ZswapCoinPublicKey, Compact.ContractAddress>
),
] => {
string,
(
| Compact.ZswapCoinPublicKey
| Compact.Either<Compact.ZswapCoinPublicKey, Compact.ContractAddress>
),
] => {
const pk = toHexPadded(str);
const zpk = asEither ? createEitherTestUser(str) : encodeToPK(str);
return [pk, zpk];
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/simulator/test/integration/SampleZOwnable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down Expand Up @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"types": {
"dependsOn": [
"@openzeppelin-compact/compact#build",
"@openzeppelin-compact/contracts#compact"
"@openzeppelin/compact-contracts#compact"
],
"outputs": [],
"cache": false
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:^"
Expand Down
Loading