Skip to content
Open
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 @@ -43,4 +43,4 @@ runs:
if: ${{ inputs.skip-compact != 'true' }}
uses: midnightntwrk/setup-compact-action@836895c8fffbbea6bd986af2b17e8941ff29d1f8 # v1
with:
compact-version: "0.29.0"
compact-version: "0.30.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Import modules through `node_modules` rather than directly to avoid state confli
```typescript
// MyContract.compact

pragma language_version >= 0.18.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;
import "./compact-contracts/node_modules/@openzeppelin/compact-contracts/src/access/Ownable"
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.0.1-alpha.1 (access/AccessControl.compact)

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @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.0.1-alpha.1 (access/Ownable.compact)

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module Ownable
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.0.1-alpha.1 (access/ZOwnablePK.compact)

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module ZOwnablePK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.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
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.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
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.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.0.1-alpha.1 (archive/ShieldedToken.compact)

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module ShieldedToken (archived until further notice, DO NOT USE IN PRODUCTION)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

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

const PREFIX_ADDRESS = '0200';
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/security/Initializable.compact
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Compact Contracts v0.0.1-alpha.1 (security/Initializable.compact)

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

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

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module Pausable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;
import "../../Initializable" prefix Initializable_;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/security/test/mocks/MockPausable.compact
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

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

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

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

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

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

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module NonFungibleToken
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/test/mocks/MockFungibleToken.compact
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/test/mocks/MockMultiToken.compact
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;
import "../../MultiToken" prefix MultiToken_;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;

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

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

/**
* @module Utils.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/test/mocks/MockUtils.compact
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import CompactStandardLibrary;

Expand Down
8 changes: 4 additions & 4 deletions contracts/test-utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
encodeCoinPublicKey,
isContractAddress,
} from '@midnight-ntwrk/compact-runtime';
import { encodeContractAddress } from '@midnight-ntwrk/ledger-v7';
import { encodeContractAddress } from '@midnight-ntwrk/ledger-v8';

type ZswapCoinPublicKey = { bytes: Uint8Array };

Expand Down Expand Up @@ -78,9 +78,9 @@ const baseGeneratePubKeyPair = (
str: string,
asEither: boolean,
): [
string,
ZswapCoinPublicKey | Either<ZswapCoinPublicKey, ContractAddress>,
] => {
string,
ZswapCoinPublicKey | Either<ZswapCoinPublicKey, ContractAddress>,
] => {
const pk = toHexPadded(str);
const zpk = asEither ? createEitherTestUser(str) : encodeToPK(str);
return [pk, zpk];
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openzeppelin-compact",
"description": "Secure Smart Contract library written in Compact for Midnight",
"private": true,
"packageManager": "yarn@4.12.0",
"packageManager": "yarn@4.13.0",
"workspaces": [
"contracts/",
"packages/*"
Expand All @@ -22,11 +22,11 @@
"glob": "~10.5.0"
},
"dependencies": {
"@midnight-ntwrk/compact-runtime": "0.14.0"
"@midnight-ntwrk/compact-runtime": "0.15.0"
},
"devDependencies": {
"@biomejs/biome": "^2.4.7",
"@midnight-ntwrk/ledger-v7": "7.0.0",
"@midnight-ntwrk/ledger-v8": "8.0.2",
"@midnight-ntwrk/zswap": "^4.0.0",
"@types/node": "24.10.0",
"ts-node": "^10.9.2",
Expand Down
45 changes: 45 additions & 0 deletions packages/compact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,51 @@ yarn test
yarn clean
```

### Testing unreleased versions of the Compact compiler

These steps assume the `compact` cli is already installed.

Clone the Compact repo and `cd` into the new directory
```bash
git clone https://github.com/LFDT-Minokawa/compact.git
```

Fetch tags (if local repo hasn't been updated in awhile)
```bash
git fetch -t
```

Checkout tagged commit
```bash
git checkout v0.30.0-rc.1
```

Build the compactc-binary package locally.

> **Note:** The default `nix build` target does not output all required binary files. Use the `compactc-binary` attribute explicitly as shown below to ensure the full set of binaries is produced.

```bash
nix build .#compactc-binary
```

Run `install-local.sh`

The script installs a locally built version of the Compact toolchain into a subdirectory of the Compact devtool's artifact directory

**Usage**: ./install-local.sh <repo-path> [platform]

**Steps**:
1. Validates that the provided repo path exists and is a directory
2. Reads the git tag at HEAD from that repo (strips the leading v) — fails if HEAD isn't tagged
3. Detects the current platform (aarch64-darwin, x86_64-linux, etc.) from uname, or accepts one as the second argument — fails if unsupported
4. Creates ~/.compact/versions/<version>/<platform>/ and copies the built binaries from <repo-path>/result/bin/ into it
5. Runs compact update <version> to register the newly installed version with the toolchain manager

Update `packages/compact/src/versions.ts` with the current compact and language version (eg `compact compile --language-version`)

Rebuild compact package
`yarn build`

## Output Example

```bash
Expand Down
51 changes: 51 additions & 0 deletions packages/compact/install-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -euo pipefail

REPO_PATH="${1:?Error: path to compact repo is required as the first argument}"

if [[ ! -d "$REPO_PATH" ]]; then
echo "Error: '$REPO_PATH' is not a directory" >&2
exit 1
fi

GIT_TAG=$(git -C "$REPO_PATH" describe --tags --exact-match 2>/dev/null | sed 's/^v//')

if [[ -z "$GIT_TAG" ]]; then
echo "Error: no git tag found at HEAD in '$REPO_PATH'" >&2
exit 1
fi

detect_platform() {
local arch os
arch=$(uname -m)
os=$(uname -s)

case "$arch" in
arm64|aarch64) arch="aarch64" ;;
x86_64) arch="x86_64" ;;
*) echo "Error: unsupported architecture: $arch" >&2; exit 1 ;;
esac

case "$os" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
*) echo "Error: unsupported OS: $os" >&2; exit 1 ;;
esac

echo "${arch}-${os}"
}

PLATFORM="${2:-$(detect_platform)}"

case "$PLATFORM" in
aarch64-linux|aarch64-darwin|x86_64-linux|x86_64-darwin) ;;
*) echo "Error: unsupported platform '$PLATFORM'. Must be one of: aarch64-linux, aarch64-darwin, x86_64-linux, x86_64-darwin" >&2; exit 1 ;;
esac

# compact-compiler tool requires the destination path version to match the reported compact version from the binary
REPORTED_COMPACT_VERSION=$("$REPO_PATH/result/bin/compactc" --version | tail -n1)
DEST="$HOME/.compact/versions/$REPORTED_COMPACT_VERSION/$PLATFORM"
mkdir -p "$DEST"
cp -r "$REPO_PATH/result/bin/." "$DEST/"
echo "Installed $GIT_TAG ($PLATFORM) to $DEST"
compact update $REPORTED_COMPACT_VERSION
4 changes: 2 additions & 2 deletions packages/compact/src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const COMPACT_VERSION = '0.29.0';
export const LANGUAGE_VERSION = '0.21.0';
export const COMPACT_VERSION = '0.30.0';
export const LANGUAGE_VERSION = '0.22.0';
4 changes: 2 additions & 2 deletions packages/simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"clean": "git clean -fXd"
},
"devDependencies": {
"@midnight-ntwrk/ledger-v7": "7.0.0",
"@midnight-ntwrk/ledger-v8": "8.0.2",
"@midnight-ntwrk/zswap": "^4.0.0",
"@tsconfig/node24": "^24.0.4",
"@types/node": "24.10.0",
Expand All @@ -38,6 +38,6 @@
"vitest": "^4.0.16"
},
"dependencies": {
"@midnight-ntwrk/compact-runtime": "0.14.0"
"@midnight-ntwrk/compact-runtime": "0.15.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Sample contract for testing
// DO NOT USE IN PRODUCTION!!!

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import {
Either,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Sample contract for testing
// DO NOT USE IN PRODUCTION!!!

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import { ZswapCoinPublicKey, ContractAddress, Either, Maybe } from CompactStandardLibrary;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Sample contract for testing
// DO NOT USE IN PRODUCTION!!!

pragma language_version >= 0.21.0;
pragma language_version >= 0.22.0;

import { ZswapCoinPublicKey, ContractAddress, Either, Maybe } from CompactStandardLibrary;

Expand Down
Loading
Loading