Skip to content

refactor: upgrade contracts to 0.30#388

Open
emnul wants to merge 16 commits intomainfrom
refactor/upgrade-contracts-to-0.30
Open

refactor: upgrade contracts to 0.30#388
emnul wants to merge 16 commits intomainfrom
refactor/upgrade-contracts-to-0.30

Conversation

@emnul
Copy link
Contributor

@emnul emnul commented Mar 13, 2026

Bumps yarn version, pragma versions in contracts dir, bumps compact-runtime and ledger packages to latest

Summary by CodeRabbit

  • Chores

    • Updated compiler and language versions to 0.30.0 and 0.22.0 respectively.
    • Updated package manager to Yarn 4.13.0.
    • Bumped runtime dependency and ledger library versions.
  • Documentation

    • Added comprehensive guide for testing unreleased compiler versions locally.
    • Added shell script utility for installing local compiler binaries.
    • Updated example code in documentation.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f8bd0f5-9cc8-452b-b39f-930c9275f1e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR systematically upgrades the Compact language version from 0.21.0 to 0.22.0 across all contract files, updates dependencies (compact-runtime 0.14.0→0.15.0, ledger-v7→ledger-v8, yarn 4.12.0→4.13.0), updates version constants, refreshes import paths in test utilities, and adds documentation for testing unreleased compiler versions.

Changes

Cohort / File(s) Summary
Compact Language Version Bumps
contracts/src/access/*.compact, contracts/src/access/test/mocks/*.compact, contracts/src/security/*.compact, contracts/src/security/test/mocks/*.compact, contracts/src/token/*.compact, contracts/src/token/test/mocks/*.compact, contracts/src/archive/*.compact, contracts/src/archive/test/mocks/*.compact, contracts/src/utils/*.compact, contracts/src/utils/test/mocks/*.compact, packages/simulator/test/fixtures/sample-contracts/*.compact
Updated language\_version pragma from 0.21.0/≥0.21.0 to 0.22.0/≥0.22.0 across 21 contract files; no functional changes.
Package Manager & Dependencies
package.json, packages/simulator/package.json
Bumped yarn from 4.12.0 to 4.13.0, upgraded @midnight-ntwrk/compact-runtime from 0.14.0 to 0.15.0, replaced @midnight-ntwrk/ledger-v7 (7.0.0) with @midnight-ntwrk/ledger-v8 (8.0.2).
Version Constants
packages/compact/src/versions.ts
Updated COMPACT\_VERSION from '0.29.0' to '0.30.0' and LANGUAGE\_VERSION from '0.21.0' to '0.22.0'.
Test Utility Import Updates
contracts/test-utils/address.ts, contracts/src/archive/test/utils/address.ts, packages/simulator/test/fixtures/utils/address.ts
Updated imports from @midnight-ntwrk/ledger-v7 to @midnight-ntwrk/ledger-v8 for encodeContractAddress; minor formatting adjustments to type annotations.
Documentation & Build Tooling
README.md, packages/compact/README.md, packages/compact/install-local.sh
Updated example pragma version in README; added comprehensive "Testing unreleased versions" section; introduced new install-local.sh shell script for managing local Compact binary builds with platform detection and version management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • andrew-fleming
  • 0xisk

Poem

🐰 Hopping through pragmas with Compact's new way,
Version 0.22 brightens the day!
Ledger v8 replaces v7's old hop,
Our contracts and tests in sync—won't stop!
From 0.21 to 0.22, we spring ahead true! 🌱✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: upgrading contracts and tooling to version 0.30, which is the primary focus of this changeset across multiple files and dependencies.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/upgrade-contracts-to-0.30
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@emnul emnul added the blocked Issues blocked on other issues. label Mar 17, 2026
@emnul emnul moved this from Backlog to In progress in OZ Development for Midnight Mar 17, 2026
@emnul emnul self-assigned this Mar 17, 2026
@emnul emnul linked an issue Mar 17, 2026 that may be closed by this pull request
@emnul emnul marked this pull request as ready for review March 17, 2026 20:27
@emnul emnul requested review from a team as code owners March 17, 2026 20:27
@emnul emnul moved this from In progress to Needs Review in OZ Development for Midnight Mar 17, 2026
@emnul emnul removed the blocked Issues blocked on other issues. label Mar 17, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/compact/README.md (1)

113-115: ⚠️ Potential issue | 🟡 Minor

Unclosed code block.

Line 113 opens a code block section but there's no closing ``` before the next section header on line 115. This will cause rendering issues.

Proposed fix
 # Build specific directory and skip proving key generation
 compact-builder --dir token --skip-zk
+```

 ## Programmatic API
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/compact/README.md` around lines 113 - 115, Close the unclosed fenced
code block that starts with the line containing "compact-builder --dir token
--skip-zk" by adding a closing triple backtick (```) immediately before the "##
Programmatic API" header so the code block is terminated properly; locate the
open block by searching for that command string and ensure the README's sections
render correctly by inserting the closing fence just above the "## Programmatic
API" heading.
🧹 Nitpick comments (3)
packages/compact/install-local.sh (2)

51-51: Quote version variable and add trailing newline.

The $REPORTED_COMPACT_VERSION variable should be quoted in case the version string contains unexpected characters. Also, the file is missing a trailing newline.

Proposed fix
-compact update $REPORTED_COMPACT_VERSION
+compact update "$REPORTED_COMPACT_VERSION"
+
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/compact/install-local.sh` at line 51, Quote the version variable in
the compact update invocation and ensure the script ends with a trailing
newline: change the command that calls compact update to use the quoted variable
"$REPORTED_COMPACT_VERSION" (so the compact update invocation handles any
special chars or whitespace) and add a final newline at the end of the
install-local.sh file.

46-51: Consider adding validation before executing compactc binary.

The script assumes $REPO_PATH/result/bin/compactc exists without checking. If the build step failed or the binary is missing, the error message won't be clear.

Proposed improvement
 # compact-compiler tool requires the destination path version to match the reported compact version from the binary
+COMPACTC_BIN="$REPO_PATH/result/bin/compactc"
+if [[ ! -x "$COMPACTC_BIN" ]]; then
+  echo "Error: compactc binary not found or not executable at '$COMPACTC_BIN'" >&2
+  echo "Did you run 'nix build .#compactc-binary' first?" >&2
+  exit 1
+fi
+
-REPORTED_COMPACT_VERSION=$("$REPO_PATH/result/bin/compactc" --version | tail -n1)
+REPORTED_COMPACT_VERSION=$("$COMPACTC_BIN" --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
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/compact/install-local.sh` around lines 46 - 51, Add validation to
ensure the built compactc binary exists and is executable before invoking it:
check the file referenced by "$REPO_PATH/result/bin/compactc" (used to compute
REPORTED_COMPACT_VERSION) and if missing or not executable, print a clear error
referencing the path and suggested action (e.g., build step failed), then exit
non‑zero; only proceed to compute REPORTED_COMPACT_VERSION, create DEST, copy
files, and run compact update if the check passes.
packages/compact/src/versions.ts (1)

1-2: Version constants updated, but README examples remain at 0.29.0.

The version constants are correctly bumped to 0.30.0 and 0.22.0. However, packages/compact/README.md still shows 0.29.0 in multiple example outputs and CLI usage (e.g., lines 14, 40, 77, 125, 134, 235, 238, 239). Consider updating those examples to reflect the new version for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/compact/src/versions.ts` around lines 1 - 2, The README examples
still show the old version strings; update the example outputs and CLI usage in
the README.md to match the bumped constants COMPACT_VERSION ('0.30.0') and
LANGUAGE_VERSION ('0.22.0'). Locate occurrences of the old '0.29.0' examples in
packages/compact README.md (example outputs and CLI snippets) and replace them
with the new version strings, ensuring any inline examples, sample command
outputs, and help text consistently reflect COMPACT_VERSION and
LANGUAGE_VERSION.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/compact/README.md`:
- Around line 113-115: Close the unclosed fenced code block that starts with the
line containing "compact-builder --dir token --skip-zk" by adding a closing
triple backtick (```) immediately before the "## Programmatic API" header so the
code block is terminated properly; locate the open block by searching for that
command string and ensure the README's sections render correctly by inserting
the closing fence just above the "## Programmatic API" heading.

---

Nitpick comments:
In `@packages/compact/install-local.sh`:
- Line 51: Quote the version variable in the compact update invocation and
ensure the script ends with a trailing newline: change the command that calls
compact update to use the quoted variable "$REPORTED_COMPACT_VERSION" (so the
compact update invocation handles any special chars or whitespace) and add a
final newline at the end of the install-local.sh file.
- Around line 46-51: Add validation to ensure the built compactc binary exists
and is executable before invoking it: check the file referenced by
"$REPO_PATH/result/bin/compactc" (used to compute REPORTED_COMPACT_VERSION) and
if missing or not executable, print a clear error referencing the path and
suggested action (e.g., build step failed), then exit non‑zero; only proceed to
compute REPORTED_COMPACT_VERSION, create DEST, copy files, and run compact
update if the check passes.

In `@packages/compact/src/versions.ts`:
- Around line 1-2: The README examples still show the old version strings;
update the example outputs and CLI usage in the README.md to match the bumped
constants COMPACT_VERSION ('0.30.0') and LANGUAGE_VERSION ('0.22.0'). Locate
occurrences of the old '0.29.0' examples in packages/compact README.md (example
outputs and CLI snippets) and replace them with the new version strings,
ensuring any inline examples, sample command outputs, and help text consistently
reflect COMPACT_VERSION and LANGUAGE_VERSION.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ba0c4e3-e6b8-4eec-b48c-74d02415b8c4

📥 Commits

Reviewing files that changed from the base of the PR and between 80f1ad8 and f6be0ef.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (32)
  • README.md
  • contracts/src/access/AccessControl.compact
  • contracts/src/access/Ownable.compact
  • contracts/src/access/ZOwnablePK.compact
  • contracts/src/access/test/mocks/MockAccessControl.compact
  • contracts/src/access/test/mocks/MockOwnable.compact
  • contracts/src/access/test/mocks/MockZOwnablePK.compact
  • contracts/src/archive/ShieldedToken.compact
  • contracts/src/archive/test/mocks/MockShieldedToken.compact
  • contracts/src/archive/test/utils/address.ts
  • contracts/src/security/Initializable.compact
  • contracts/src/security/Pausable.compact
  • contracts/src/security/test/mocks/MockInitializable.compact
  • contracts/src/security/test/mocks/MockPausable.compact
  • contracts/src/token/FungibleToken.compact
  • contracts/src/token/MultiToken.compact
  • contracts/src/token/NonFungibleToken.compact
  • contracts/src/token/test/mocks/MockFungibleToken.compact
  • contracts/src/token/test/mocks/MockMultiToken.compact
  • contracts/src/token/test/mocks/MockNonFungibleToken.compact
  • contracts/src/utils/Utils.compact
  • contracts/src/utils/test/mocks/MockUtils.compact
  • contracts/test-utils/address.ts
  • package.json
  • packages/compact/README.md
  • packages/compact/install-local.sh
  • packages/compact/src/versions.ts
  • packages/simulator/package.json
  • packages/simulator/test/fixtures/sample-contracts/SampleZOwnable.compact
  • packages/simulator/test/fixtures/sample-contracts/Simple.compact
  • packages/simulator/test/fixtures/sample-contracts/Witness.compact
  • packages/simulator/test/fixtures/utils/address.ts

@emnul emnul requested review from 0xisk and andrew-fleming March 18, 2026 01:47
@0xisk 0xisk changed the title Refactor/upgrade contracts to 0.30 refactor: upgrade contracts to 0.30 Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Upgrade Contracts / Packages to 0.30.0

1 participant