Skip to content
Closed
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: 2 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export GITHUB_TOKEN=ghp_
export LONG_TESTS=true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ web_modules/
.yarn-integrity

# dotenv environment variable files
.envrc
.env
.env.development.local
.env.test.local
Expand Down Expand Up @@ -151,4 +152,4 @@ dist


# Compact
artifacts/
artifacts/
11 changes: 11 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Use npmjs.org by default
registry=https://registry.npmjs.org/

# Tell npm to pull any @midnight-ntwrk/* package from GitHub Packages:
@midnight-ntwrk:registry=https://npm.pkg.github.com/

# Token to auth yourself (make sure the env‐var matches below)
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

# Always send auth on every request to GitHub’s registry
//npm.pkg.github.com/:always-auth=true
157 changes: 146 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,82 @@
A collection of starter-dapps on the Midnight Network

## Overview
This monorepo contains experimental sample projects built on top of the Midnight Network using Compact. It includes contracts, utilities, and application.
This monorepo contains experimental sample projects built on top of the Midnight Network using Compact. It includes contracts, utilities, and applications showcasing the capabilities of privacy-preserving blockchain development.

## Smart Contracts

### 🌑 Lunarswap V2
**A decentralized exchange (DEX) protocol with privacy-preserving features**

- **Location**: `contracts/lunarswap-v2/`
- **Documentation**: [📖 Lunarswap V2 README](contracts/lunarswap-v2/README.md)

Lunarswap V2 is a next-generation DEX that combines automated market making with privacy features. Based on Uniswap V2 architecture, it's adapted for the Midnight Network with UTXO-based token management and shielded transactions.

**Key Features:**
- Automated market making with constant product formula
- Privacy-preserving UTXO-based token model
- LP token system for liquidity providers
- VWAP price oracle functionality
- Factory pattern for efficient pair management

### 🔐 Access Control
**Smart contract access control patterns**

- **Location**: `contracts/access/`

Demonstrates access control patterns for Compact smart contracts, including role-based permissions and administrative functions.

### 📊 Math Contracts
**Mathematical utilities and safe arithmetic operations**

- **Location**: `contracts/math/`

Provides safe mathematical operations, overflow protection, and utility functions for Compact smart contracts.

### 🏗️ Structs
**Common data structures and patterns**

- **Location**: `contracts/structs/`

Reusable data structures and patterns for Compact smart contract development.

## Applications

### 🌑 Lunarswap UI
**User interface for the Lunarswap V2 protocol**

- **Location**: `apps/lunarswap-ui/`
- **Technology**: React/TypeScript frontend
- **Purpose**: Web interface for interacting with Lunarswap V2

A modern web application that provides a user-friendly interface for:
- Adding and removing liquidity
- Viewing trading pairs and reserves
- Managing LP tokens
- Monitoring protocol statistics

## Packages & Utilities

### 📦 Compact Language Utilities
- **Location**: `packages/compact/`
- **Purpose**: Core Compact language utilities and tooling

### 📚 Compact Standard Library
- **Location**: `packages/compact-std/`
- **Purpose**: Standard library functions for Compact development

### 🛠️ Lunarswap SDK
- **Location**: `packages/lunarswap-sdk/`
- **Purpose**: JavaScript/TypeScript SDK for Lunarswap V2 integration


## Development Flow

### Prerequisites
- **Node.js**: Version 22.14.0 (see `.nvmrc` and `package.json` `engines`).
- **pnpm**: Version 10.4.1 (specified in `packageManager`).


Install Node.js 22.x using `nvm`:
```bash
nvm install 22.14.0
Expand All @@ -30,14 +97,7 @@ nvm use 22.14.0
```
- This installs all workspace dependencies and runs the `prepare` script, which sets up Husky and builds `@midnight-dapps/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`).

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

4. **Build Contracts Packages**:
3. **Build Contracts Packages**:
```bash
pnpm build:contracts
```
Expand Down Expand Up @@ -71,7 +131,71 @@ Turbo manages tasks across the monorepo, defined in `turbo.json`. Key tasks:
- Formats and lints code with Biome.
- Run: `pnpm fmt`, `pnpm lint`, `pnpm lint:fix`.

### Commit Workflow
## Quick Start

### Working with Smart Contracts
```bash
# Build all contracts
pnpm build:contracts

# Compile Compact files
pnpm compact

# Run contract tests
pnpm test

# Build specific contract
cd contracts/lunarswap-v2
pnpm build
```

### Running Applications
```bash
# Build all applications
pnpm build:apps

# Start Lunarswap UI
cd apps/lunarswap-ui
pnpm dev
```

### Using Packages
```bash
# Build all packages
pnpm build

# Use Lunarswap SDK
cd packages/lunarswap-sdk
pnpm build
```

## Contributing

### Development Workflow
1. **Fork the Repository**
2. **Create Feature Branch**: `git checkout -b feature/amazing-feature`
3. **Make Changes**: Follow coding standards and add tests
4. **Commit Changes**: Use conventional commit format
5. **Push Changes**: `git push origin feature/amazing-feature`
6. **Create Pull Request**: Provide detailed description

### Code Standards
- **Compact Code**: Follow Compact language best practices
- **Documentation**: Add comprehensive JSDoc comments
- **Testing**: Maintain high test coverage
- **Linting**: Ensure code passes all linting rules

### Commit Convention
Use conventional commit format:
```
type(scope): description

feat(lunarswap): add deadline support for transactions
fix(access): resolve permission check bug
docs(ui): update component documentation
```

## Commit Workflow
Commits are linted with `commitlint` and staged files are processed with `lint-staged` and Biome.

1. **Conventional Commits**:
Expand Down Expand Up @@ -117,3 +241,14 @@ husky - commit-msg hook
⧺ Commit message does not follow Conventional Commits format.
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Built on the Midnight Network
- Lunarswap V2 based on Uniswap V2 architecture
- Developed using Compact programming language
- Community-driven development and feedback

Loading