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
58 changes: 44 additions & 14 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,31 @@ runs:
with:
fetch-depth: 1

- name: Set Compact environment variables
shell: bash
run: |
COMPACT_HOME="$HOME/compactc"
echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV"
echo "$COMPACT_HOME" >> "$GITHUB_PATH"

- name: Cache Compact compiler
id: cache-compact
uses: actions/cache@v4
with:
path: ${{ env.COMPACT_HOME }}
key: compact-compiler-0.23.0
restore-keys: |
compact-compiler-

- name: Install Compact compiler
id: setup
if: steps.cache-compact.outputs.cache-hit != 'true'
shell: bash
env:
COMPILER_VERSION: "0.23.0"
LANGUAGE_VERSION: "0.15.0"
run: |
set -euo pipefail
# Create directory for compiler
COMPACT_HOME="$HOME/compactc"
mkdir -p "$COMPACT_HOME"

# Create URL
Expand All @@ -38,10 +53,9 @@ runs:
unzip -qo "$COMPACT_HOME/compactc.zip" -d "$COMPACT_HOME"
chmod +x "$COMPACT_HOME"/{compactc,compactc.bin,zkir}

echo "📁 Setting environment variables..."
echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV"
echo "$COMPACT_HOME" >> "$GITHUB_PATH"

- name: Verify Compact compiler installation
shell: bash
run: |
echo "✅ Verifying installation..."
if [ ! -f "$COMPACT_HOME/compactc" ]; then
echo "::error::❌ compactc not found in $COMPACT_HOME"
Expand All @@ -51,14 +65,6 @@ runs:
echo "🤖 Testing installation..."
"$COMPACT_HOME/compactc" --version

- name: Cache Compact compiler
uses: actions/cache@v4
with:
path: ${{ env.COMPACT_HOME }}
key: compact-compiler-0.23.0
restore-keys: |
compact-compiler-

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
Expand Down Expand Up @@ -95,3 +101,27 @@ runs:
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --prefer-offline

- name: Build contract packages (with retry on hash mismatch)
if: inputs.skip-compile != 'true'
shell: bash
run: |
set -euo pipefail

build_contracts() {
echo "⚙️ Building contract packages..."
if ! pnpm build:contracts; then
echo "❌ Build failed."
if [ -d "$HOME/.cache/midnight/zk-params" ]; then
echo "⚠️ zk-params exists. Removing cache and retrying..."
rm -rf "$HOME/.cache/midnight/zk-params"
echo "::notice::♻️ Retrying build after clearing zk-params..."
pnpm build:contracts || { echo "::error::❌ Retry also failed."; exit 1; }
else
echo "🚫 Build failed and zk-params missing. No retry."
exit 1
fi
fi
}

build_contracts
3 changes: 3 additions & 0 deletions .github/workflows/apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
run: pnpm test:apps
timeout-minutes: 10

- name: Check types for apps and packages
run: pnpm types:apps && pnpm types:packages

- name: Upload build artifacts
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@v4
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 1
fetch-depth: 0

- name: Setup Environment
uses: ./.github/actions/setup

- name: Lint
run: pnpm lint
- name: Lint and Format
run: pnpm lint && pnpm fmt
timeout-minutes: 10

- name: Format
run: pnpm fmt
timeout-minutes: 10
- name: Commitlint
run: pnpm commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.event.pull_request.head.sha }}

- name: Type check
run: pnpm types
timeout-minutes: 10
- name: Spell Check with Typos
uses: crate-ci/typos@v1.36.2
with:
config: .github/workflows/config/typos.toml

- name: Cleanup on failure
if: failure()
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/commitlint.yml

This file was deleted.

26 changes: 3 additions & 23 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,8 @@ jobs:

echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION"

- name: Compile contracts (with retry on hash mismatch)
shell: bash
run: |
set -euo pipefail

compile() {
echo "⚙️ Running Compact compilation..."
if ! pnpm compact; then
echo "❌ Compilation failed."
if [ -d "$HOME/.cache/midnight/zk-params" ]; then
echo "⚠️ zk-params exists. Removing cache and retrying..."
rm -rf "$HOME/.cache/midnight/zk-params"
echo "::notice::♻️ Retrying compilation after clearing zk-params..."
pnpm compact || { echo "::error::❌ Retry also failed."; exit 1; }
else
echo "🚫 Compilation failed and zk-params missing. No retry."
exit 1
fi
fi
}

compile

- name: Run tests
run: pnpm test:contracts

- name: Check types
run: pnpm types:contracts
22 changes: 0 additions & 22 deletions .github/workflows/typos.yml

This file was deleted.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ nvm use 22.14.0
1. **Clone the Repository**:
```bash
git clone <repository-url>
cd midnight-dapps
cd midnight-apps
```

2. **Install Dependencies**:
```bash
pnpm install
```
- This installs all workspace dependencies and runs the `prepare` script, which sets up Husky and builds `@midnight-dapps/compact`.
- This installs all workspace dependencies and runs the `prepare` script, which sets up Husky and builds `@openzeppelin-midnight-apps/compact`.

3. **Workspace Structure**:
- `contracts/*`: Compact Smart contract projects (e.g., `@midnight-dapps/access-contract`).
- `packages/*`: Utility packages (e.g., `@midnight-dapps/compact`).
- `apps/*`: Frontend applications (e.g., `@midnight-dapps/lunarswap-ui`).
- `contracts/*`: Compact Smart contract projects (e.g., `@openzeppelin-midnight-apps/access-contract`).
- `packages/*`: Utility packages (e.g., `@openzeppelin-midnight-apps/compact`).
- `apps/*`: Frontend applications (e.g., `@openzeppelin-midnight-apps/lunarswap-ui`).

See `pnpm-workspace.yaml` for the full list.

Expand Down Expand Up @@ -86,7 +86,7 @@ Commits are linted with `commitlint` and staged files are processed with `lint-s

2. **Pre-Commit Hook**:
- Runs `turbo run precommit` via `.husky/pre-commit`.
- For `@midnight-dapps/access-contract`:
- For `@openzeppelin-midnight-apps/access-contract`:
- `lint-staged`: Formats and lints staged files (see `.lintstagedrc.json`).
- `pnpm run types`: Checks TypeScript types.

Expand All @@ -104,7 +104,7 @@ Output:
husky - pre-commit hook
> turbo run precommit
• Running precommit in X packages
• @midnight-dapps/access-contract:precommit
• @openzeppelin-midnight-apps/access-contract:precommit
Tasks: 1 successful, 1 total
Time: 500ms

Expand Down
2 changes: 1 addition & 1 deletion apps/lunarswap-ui/biome.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": ["@midnight-dapps/biome-config"]
"extends": ["@openzeppelin-midnight-apps/biome-config"]
}
4 changes: 2 additions & 2 deletions apps/lunarswap-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@midnight-dapps/lunarswap-ui",
"name": "@openzeppelin-midnight-apps/lunarswap-ui",
"version": "1.0.0-alpha.1",
"private": true,
"scripts": {
Expand Down Expand Up @@ -69,7 +69,7 @@
"zod": "^3.25.67"
},
"devDependencies": {
"@midnight-dapps/biome-config": "workspace:^",
"@openzeppelin-midnight-apps/biome-config": "workspace:^",
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/biome.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": ["@midnight-dapps/biome-config"]
"extends": ["@openzeppelin-midnight-apps/biome-config"]
}
8 changes: 4 additions & 4 deletions contracts/access/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@midnight-dapps/access-contract",
"name": "@openzeppelin-midnight-apps/access-control",
"version": "1.0.0-alpha.1",
"private": true,
"description": "Compacts for implementing LunarSwap DEX",
Expand All @@ -26,9 +26,9 @@
"vitest": "^3.1.4"
},
"dependencies": {
"@midnight-dapps/biome-config": "workspace:^",
"@midnight-dapps/compact": "workspace:^",
"@midnight-dapps/compact-std": "workspace:^",
"@openzeppelin-midnight-apps/biome-config": "workspace:^",
"@openzeppelin-midnight-apps/compact": "workspace:^",
"@openzeppelin-midnight-apps/compact-std": "workspace:^",
"@midnight-ntwrk/compact-runtime": "^0.8.1",
"@midnight-ntwrk/midnight-js-network-id": "^2.0.1",
"@midnight-ntwrk/zswap": "^4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module @midnight-dapps/access-contract
* @module @openzeppelin-midnight-apps/access-contract
* @description Main entry point for the AccessControl contract package, exporting private state utilities, witness implementations, and type definitions.
* @remarks This module serves as the primary export point for TypeScript consumers of the AccessControl contract.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ZswapCoinPublicKey } from '@midnight-dapps/compact-std';
import {
type CircuitContext,
type CoinPublicKey,
Expand All @@ -9,6 +8,7 @@ import {
encodeCoinPublicKey,
} from '@midnight-ntwrk/compact-runtime';
import { sampleContractAddress } from '@midnight-ntwrk/zswap';
import type { ZswapCoinPublicKey } from '@openzeppelin-midnight-apps/compact-std';
import type { AccessControl_Role } from '../artifacts/Index/contract/index.cjs';
import {
type Ledger,
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/src/types/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module @midnight-dapps/access-contract/types/ledger
* @module @openzeppelin-midnight-apps/access-contract/types/ledger
* @description Re-exports ledger-related types from the AccessControl contract’s Index artifact.
* @remarks Renames AccessControl_Role to AccessControlRole to follow TypeScript naming conventions (camelCase over snake_case).
*/
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/src/types/role.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { MerkleTreePath } from '@midnight-dapps/compact-std';
import type { MerkleTreePath } from '@openzeppelin-midnight-apps/compact-std';
import type { AccessControlRole } from './ledger';

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/src/utils/compactHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Maybe } from '@midnight-dapps/compact-std';
import type { Maybe } from '@openzeppelin-midnight-apps/compact-std';

/**
* @description Converts a nullable value into a Maybe type, providing a default empty value if null or undefined.
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/src/witnesses/AccessControlWitnesses.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getRandomValues } from 'node:crypto';
import type { WitnessContext } from '@midnight-ntwrk/compact-runtime';
import type {
Maybe,
MerkleTreePath,
ZswapCoinPublicKey,
} from '@midnight-dapps/compact-std';
import type { WitnessContext } from '@midnight-ntwrk/compact-runtime';
} from '@openzeppelin-midnight-apps/compact-std';
import {
AccessControl_Role,
type Ledger,
Expand Down
5 changes: 4 additions & 1 deletion contracts/access/src/witnesses/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Maybe, MerkleTreePath } from '@midnight-dapps/compact-std';
import type { WitnessContext } from '@midnight-ntwrk/compact-runtime';
import type {
Maybe,
MerkleTreePath,
} from '@openzeppelin-midnight-apps/compact-std';
import type {
AccessControl_Role,
Ledger,
Expand Down
Loading
Loading