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/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ runs:
if: ${{ inputs.skip-compact != 'true' }}
uses: midnightntwrk/setup-compact-action@836895c8fffbbea6bd986af2b17e8941ff29d1f8 # v1
with:
compact-version: "0.31.0"
compact-version: "0.34.0"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Setup Compact Compiler
uses: midnightntwrk/setup-compact-action@836895c8fffbbea6bd986af2b17e8941ff29d1f8 # v1
with:
compact-version: "0.31.0"
compact-version: "0.34.0"

- name: Build contracts
run: yarn build
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- Upgrade the Compact toolchain and Midnight dependencies: compiler `0.31.0` → `0.34.0`, `@midnight-ntwrk/compact-runtime` `0.16.0` → `0.19.0`, `@midnight-ntwrk/ledger-v8` `8.1.0` → `@midnightntwrk/ledger-v9` `1.0.0-rc.3`, `@midnight-ntwrk/compact-js` `2.5.1` → `2.5.5-rc.8`, the `midnight-js` packages `4.1.1` → `5.0.0-beta.7`, and `@openzeppelin/compact-simulator` `^0.3.1` → `^0.4.0`. Contract `pragma language_version` raised `>= 0.23.0` → `>= 0.26.0` (the language version shipped with compiler 0.34.0). (#841)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth defining what should go in the changelog at some point. To me, dev dep changes aren't important for users, they only matter for development. The important things to note are bumping the compiler and language version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be seen in the PR so it's not worth restating so much. That's my style on this though. If we did want to include every major detail like this, I suggest trying to make it more organized and readable e.g.


Upgrade the Compact toolchain and Midnight deps

  • compiler 0.31.00.34.0
  • @midnight-ntwrk/compact-runtime 0.16.00.19.0
  • etc


## 0.3.0-alpha.2 (2026-08-11)

### Changed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Generic badge](https://img.shields.io/badge/Compact%20Compiler-0.31.0-1abc9c.svg)](https://docs.midnight.network/relnotes/compact/minokawa-0-18-26-0)
[![Generic badge](https://img.shields.io/badge/Compact%20Compiler-0.34.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)

This project is built on the Midnight Network.
Expand Down Expand Up @@ -37,8 +37,8 @@ Follow Midnight's [Compact Developer Tools installation guide](https://docs.midn
```bash
$ compact compile --version

Compactc version: 0.31.0
0.31.0
Compactc version: 0.34.0
0.34.0
```

### Installation
Expand All @@ -64,7 +64,7 @@ Import the modules through `./node_modules/@openzeppelin/compact-contracts/...`.
```typescript
// MyContract.compact

pragma language_version >= 0.21.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;
import "./node_modules/@openzeppelin/compact-contracts/access/Ownable"
Expand Down
27 changes: 14 additions & 13 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,22 @@
"node": ">=22"
},
"dependencies": {
"@openzeppelin/compact-cli": "^0.0.2"
"@openzeppelin/compact-cli": "^0.0.3"
},
"devDependencies": {
"@midnight-ntwrk/compact-js": "2.5.1",
"@midnight-ntwrk/compact-runtime": "0.16.0",
"@midnight-ntwrk/ledger-v8": "8.1.0",
"@midnight-ntwrk/midnight-js-contracts": "4.1.1",
"@midnight-ntwrk/midnight-js-http-client-proof-provider": "4.1.1",
"@midnight-ntwrk/midnight-js-indexer-public-data-provider": "4.1.1",
"@midnight-ntwrk/midnight-js-network-id": "4.1.1",
"@midnight-ntwrk/midnight-js-node-zk-config-provider": "4.1.1",
"@midnight-ntwrk/midnight-js-protocol": "4.1.1",
"@midnight-ntwrk/midnight-js-types": "4.1.1",
"@midnight-ntwrk/testkit-js": "4.1.1",
"@openzeppelin/compact-simulator": "^0.3.1",
"@midnight-ntwrk/compact-js": "2.5.5-rc.8",
"@midnight-ntwrk/compact-runtime": "0.19.0",
"@midnight-ntwrk/midnight-js-contracts": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-http-client-proof-provider": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-indexer-public-data-provider": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-network-id": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-node-zk-config-provider": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-protocol": "5.0.0-beta.7",
"@midnight-ntwrk/midnight-js-types": "5.0.0-beta.7",
"@midnight-ntwrk/testkit-js": "5.0.0-beta.7",
"@midnightntwrk/ledger-v9": "1.0.0-rc.3",
"@midnightntwrk/wallet-sdk-address-format": "4.0.0-beta.2",
"@openzeppelin/compact-simulator": "^0.4.0",
"@tsconfig/node24": "^24.0.5",
"@types/node": "26.2.0",
"@vitest/coverage-v8": "^4.1.11",
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/AccessControl.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/AccessControl.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not in the diff so I can't highlight it, but most, if not all, of the constraints are incorrect from the bump. Yet another reason to consider #829

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^Addressed on #869


/**
* @module AccessControl
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/Ownable.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/Ownable.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

/**
* @module Ownable
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/ShieldedAccessControl.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/ShieldedAccessControl.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

/**
* @module ShieldedAccessControl
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/ZOwnablePK.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/ZOwnablePK.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

/**
* @module ZOwnablePK
Expand Down
14 changes: 7 additions & 7 deletions contracts/src/access/test/AccessControl.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CompactTypeBytes,
CompactTypeVector,
convertFieldToBytes,
convertBigintToBytes,
persistentHash,
} from '@midnight-ntwrk/compact-runtime';
import { beforeEach, describe, expect, it } from 'vitest';
Expand Down Expand Up @@ -59,11 +59,11 @@ const OP1_CONTRACT = eitherContract('CONTRACT_ADDRESS');

// 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 = convertBigintToBytes(32, 1n, '');
const OPERATOR_ROLE_2 = convertBigintToBytes(32, 2n, '');
const OPERATOR_ROLE_3 = convertBigintToBytes(32, 3n, '');
const CUSTOM_ADMIN_ROLE = convertBigintToBytes(32, 4n, '');
const UNINITIALIZED_ROLE = convertBigintToBytes(32, 5n, '');

// Lists
const operatorRolesList = [OPERATOR_ROLE_1, OPERATOR_ROLE_2];
Expand Down Expand Up @@ -567,7 +567,7 @@ describe('AccessControl', () => {
});

it('should allow overwriting admin role and transfer authority', async () => {
const NEW_ADMIN_ROLE = convertFieldToBytes(32, 99n, '');
const NEW_ADMIN_ROLE = convertBigintToBytes(32, 99n, '');
const NEW_ADMIN = makeUser('NEW_ADMIN');

await accessControl._grantRole(CUSTOM_ADMIN_ROLE, CUSTOM_ADMIN.either);
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/access/test/ShieldedAccessControl.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CompactTypeBytes,
CompactTypeVector,
convertFieldToBytes,
convertBigintToBytes,
type MerkleTreePath,
persistentHash,
type WitnessContext,
Expand Down Expand Up @@ -84,11 +84,11 @@ const UNAUTHORIZED_SK = Buffer.alloc(32, 'UNAUTHORIZED_SECRET_KEY');
const BAD_SK = Buffer.alloc(32, 'BAD_SECRET_KEY');

// Roles
const ROLE_ADMIN = Buffer.from(convertFieldToBytes(32, 0n, ''));
const ROLE_OP1 = Buffer.from(convertFieldToBytes(32, 1n, ''));
const ROLE_OP2 = Buffer.from(convertFieldToBytes(32, 2n, ''));
const ROLE_OP3 = Buffer.from(convertFieldToBytes(32, 3n, ''));
const ROLE_NONEXISTENT = Buffer.from(convertFieldToBytes(32, 555n, ''));
const ROLE_ADMIN = Buffer.from(convertBigintToBytes(32, 0n, ''));
const ROLE_OP1 = Buffer.from(convertBigintToBytes(32, 1n, ''));
const ROLE_OP2 = Buffer.from(convertBigintToBytes(32, 2n, ''));
const ROLE_OP3 = Buffer.from(convertBigintToBytes(32, 3n, ''));
const ROLE_NONEXISTENT = Buffer.from(convertBigintToBytes(32, 555n, ''));

// Derived ids
const ADMIN_ACCOUNT_ID = buildAccountIdHash(ADMIN_SK);
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/access/test/ZOwnablePK.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CompactTypeBytes,
CompactTypeVector,
convertFieldToBytes,
convertBigintToBytes,
persistentHash,
} from '@midnight-ntwrk/compact-runtime';
import { beforeEach, describe, expect, it } from 'vitest';
Expand Down Expand Up @@ -59,7 +59,7 @@ const buildCommitmentFromId = (
counter: bigint,
): Uint8Array => {
const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32));
const bCounter = convertFieldToBytes(32, counter, '');
const bCounter = convertBigintToBytes(32, counter, '');
const bDomain = new TextEncoder().encode(DOMAIN);

const commitment = persistentHash(rt_type, [
Expand All @@ -81,7 +81,7 @@ const buildCommitment = (
const id = createIdHash(pk, nonce);

const rt_type = new CompactTypeVector(4, new CompactTypeBytes(32));
const bCounter = convertFieldToBytes(32, counter, '');
const bCounter = convertBigintToBytes(32, counter, '');
const bDomain = new TextEncoder().encode(domain);

const commitment = persistentHash(rt_type, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// corresponding production contract relies on. DO NOT deploy or use this
// contract in any production application.

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/test/mocks/MockOwnable.compact
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// corresponding production contract relies on. DO NOT deploy or use this
// contract in any production application.

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// corresponding production contract relies on. DO NOT deploy or use this
// contract in any production application.

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/access/test/mocks/MockZOwnablePK.compact
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// corresponding production contract relies on. DO NOT deploy or use this
// contract in any production application.

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;
import "../../ZOwnablePK" prefix ZOwnablePK_;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/archive/ShieldedToken.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (archive/ShieldedToken.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

/**
* @module ShieldedToken (archived until further notice, DO NOT USE IN PRODUCTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// corresponding production contract relies on. DO NOT deploy or use this
// contract in any production application.

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

import CompactStandardLibrary;
import "../../ShieldedToken" prefix ShieldedToken_;
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/archive/test/utils/address.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
convertFieldToBytes,
convertBigintToBytes,
encodeCoinPublicKey,
} from '@midnight-ntwrk/compact-runtime';
import { encodeContractAddress } from '@midnight-ntwrk/ledger-v8';
import { encodeContractAddress } from '@midnightntwrk/ledger-v9';
import type * as Compact from '../../../../artifacts/MockShieldedToken/contract/index.js';

const PREFIX_ADDRESS = '0200';
Expand Down 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: convertBigintToBytes(32, 0n, '') },
right: encodeToAddress(''),
};

export const ZERO_ADDRESS = {
is_left: false,
left: encodeToPK(''),
right: { bytes: convertFieldToBytes(32, 0n, '') },
right: { bytes: convertBigintToBytes(32, 0n, '') },
};
8 changes: 4 additions & 4 deletions contracts/src/crypto/EcdhMask.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.3.0-alpha.2 (crypto/EcdhMask.compact)

pragma language_version >= 0.23.0;
pragma language_version >= 0.26.0;

/**
* @module EcdhMask
Expand Down Expand Up @@ -142,10 +142,10 @@ module EcdhMask {
export pure circuit encrypt(
recipientPk: JubjubPoint,
value: Uint<128>,
e: Field,
e: JubjubScalar,
domain: Bytes<32>
): Ciphertext {
const identity = ecMulGenerator(0 as Field);
const identity = ecMulGenerator(0 as JubjubScalar);
assert(recipientPk != identity, "EcdhMask: identity pk");
const ephemeralPk = ecMulGenerator(e);
// Guard the ephemeral POINT, not the scalar: `ephemeralPk == identity`
Expand All @@ -169,7 +169,7 @@ module EcdhMask {
* @return The recovered value as a `Field` (equal to the original `value`,
* which is `< 2^128`).
*/
export pure circuit decrypt(ciphertext: Ciphertext, ekScalar: Field, domain: Bytes<32>): Field {
export pure circuit decrypt(ciphertext: Ciphertext, ekScalar: JubjubScalar, domain: Bytes<32>): Field {
const sShared = ecMul(ciphertext.ephemeralPk, ekScalar);
const mask = kdf(sShared, domain);
return ciphertext.ct - mask;
Expand Down
Loading