Skip to content

Commit 645f6e6

Browse files
committed
feat: implement quadratic voting for governance
closes ceejaylaboratory#69 - Add voting credits system for quadratic voting - Implement quorum requirements for proposals - Add quadratic cost tracking per user and proposal - Add max votes calculation using integer square root - Add comprehensive mathematical accuracy tests - Add vote record storage with full vote details - Add voter count tracking - Optimize gas usage with efficient storage patterns - Add tests for quadratic voting efficiency comparison
1 parent 49d98e8 commit 645f6e6

109 files changed

Lines changed: 21264 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/rust.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Rust Contracts CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: dtolnay/rust-toolchain@stable
15+
with:
16+
targets: wasm32-unknown-unknown
17+
- uses: Swatinem/rust-cache@v2
18+
- name: Test sep41-token
19+
run: cargo test -p sep41-token
20+
- name: Test upgradeable
21+
run: cargo test -p upgradeable

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
/target
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
27+
# Env
28+
.env
29+
.env.local
30+
.env.development.local
31+
.env.test.local
32+
.env.production.local
33+
target
34+
Cargo.lock

Cargo.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[workspace]
2+
members = ["src/upgradeable", "src/token", "src/escrow_multisig", "src/governance", "src/auth", "src/amm", "src/oracle_consumer", "src/batch", "src/utils"]
3+
members = [
4+
"src/upgradeable",
5+
"src/token",
6+
"src/escrow_multisig",
7+
"src/governance",
8+
"src/flash_loan"
9+
]
10+
members = ["src/upgradeable", "src/token", "src/escrow_multisig", "src/governance", "src/auth", "src/amm", "src/oracle_consumer", "src/batch"]
11+
resolver = "2"
12+
13+
[package]
14+
name = "anchorpoint"
15+
version = "0.1.0"
16+
edition = "2021"
17+
18+
[lib]
19+
path = "src/vesting/lib.rs"
20+
21+
[[test]]
22+
name = "vesting"
23+
path = "src/vesting/lib.rs"
24+
25+
[profile.release]
26+
opt-level = "z"
27+
overflow-checks = true
28+
debug = 0
29+
strip = "symbols"
30+
debug-assertions = false
31+
panic = "abort"
32+
codegen-units = 1
33+
lto = true

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# AnchorPoint: Standardized Stellar Anchor Dashboard
2+
3+
AnchorPoint is a premium, developer-first dashboard template designed for Stellar Anchors. It provides a standardized UI for implementing Stellar Ecosystem Proposals (SEPs), specifically focusing on SEP-24 (Interactive Self-Contained Deposits and Withdrawals).
4+
5+
## Project Structure
6+
7+
This is a monorepo containing:
8+
- `/dashboard`: A React/Vite frontend built with TypeScript, Tailwind CSS, and Framer Motion.
9+
- `/demo`: A mock anchor server to simulate SEP responses for local development and testing.
10+
11+
## Key Features
12+
13+
- **SEP-24 Wizard**: A multi-step UI flow for handling deposits and withdrawals.
14+
- **Transaction Management**: A detailed view of pending and historical transactions.
15+
- **Interactive KYC**: Placeholder integration for SEP-12 interactive flows.
16+
- **Institutional Branding**: Easily customizable via CSS variables.
17+
18+
## Implementation Guide: Stellar Ecosystem Proposals (SEPs)
19+
20+
### 1. SEP-1: stellar.toml
21+
The entry point for any anchor. It defines the supported assets and the URLs for other SEPs.
22+
- Place your `stellar.toml` in `/.well-known/stellar.toml`.
23+
- Ensure CORS is enabled on your server.
24+
25+
### 2. SEP-10: Stellar Web Authentication
26+
Before initiating transactions, the dashboard must authenticate the user's wallet.
27+
- The dashboard requests a challenge transaction from the anchor.
28+
- The user signs it with their wallet (e.g., Freight, Albedo, or Rabe).
29+
- The dashboard submits the signed transaction to get a JWT.
30+
31+
### 3. SEP-24: Interactive Flows
32+
The core of AnchorPoint.
33+
- **Deposit**: Request `/transactions/deposit/interactive`. The anchor returns a URL to a webview.
34+
- **Withdraw**: Request `/transactions/withdraw/interactive`. Similar to deposit, but requires a subsequent transaction to the anchor's distribution account.
35+
36+
### 4. SEP-12: KYC
37+
Standardized way to collect user information.
38+
- Interactive KYC (supported by AnchorPoint) allows the anchor to provide a URL for complex data collection (documents, biometrics).
39+
40+
## Customization
41+
42+
instituciones can change the branding by modifying `/dashboard/src/index.css`:
43+
44+
```css
45+
:root {
46+
--primary: #0052FF;
47+
--primary-foreground: #FFFFFF;
48+
--accent: #7928CA;
49+
--background: #000000;
50+
--card: #111111;
51+
}
52+
```
53+
54+
## Getting Started
55+
56+
1. **Install dependencies**:
57+
```bash
58+
npm run install:all
59+
```
60+
61+
2. **Run the project**:
62+
```bash
63+
npm run dev
64+
```
65+
66+
3. **Explore the Demo**:
67+
The dashboard is pre-configured to point to the local mock anchor server running on port 3001.
68+
69+
## Docker Setup
70+
71+
Quickly deploy the backend with all dependencies using Docker Compose.
72+
73+
### Prerequisites
74+
- Docker (v20+)
75+
- Docker Compose (v2.0+)
76+
77+
### Quick Start
78+
79+
```bash
80+
# Start all services (backend, Redis, SQLite)
81+
docker-compose up -d
82+
83+
# View logs
84+
docker-compose logs -f
85+
86+
# Stop services
87+
docker-compose down
88+
```
89+
90+
### Services
91+
92+
| Service | Port | Description |
93+
|-----------|------|--------------------------------|
94+
| Backend | 3002 | Node.js/TypeScript API server |
95+
| Redis | 6379 | Cache and session store |
96+
97+
### Health Check
98+
99+
Verify the backend is running:
100+
101+
```bash
102+
curl http://localhost:3002/health
103+
```
104+
105+
### Data Persistence
106+
107+
Data is stored in Docker volumes:
108+
- `backend-data`: SQLite database
109+
- `redis-data`: Redis data
110+
111+
To remove volumes along with containers:
112+
113+
```bash
114+
docker-compose down -v
115+
```
116+
117+
### Development
118+
119+
For local development without Docker, see the [Backend README](./backend/README.md).

backend/.dockerignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log
4+
5+
# Build output
6+
dist
7+
build
8+
9+
# Prisma
10+
prisma/migrations
11+
prisma/dev.db
12+
13+
# Environment files
14+
.env
15+
.env.local
16+
.env.*.local
17+
18+
# IDE
19+
.vscode
20+
.idea
21+
*.swp
22+
*.swo
23+
24+
# OS
25+
.DS_Store
26+
Thumbs.db
27+
28+
# Test
29+
coverage
30+
.nyc_output
31+
32+
# Docker
33+
Dockerfile
34+
docker-compose*.yml
35+
.dockerignore
36+
37+
# Git
38+
.git
39+
.gitignore
40+
41+
# Documentation
42+
README.md
43+
44+
# Logs
45+
logs
46+
*.log

backend/.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended"
8+
],
9+
"rules": {
10+
"@typescript-eslint/no-unused-vars": "error",
11+
"@typescript-eslint/no-explicit-any": "warn"
12+
},
13+
"env": {
14+
"node": true,
15+
"jest": true
16+
}
17+
}

backend/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
coverage
4+
.env
5+
*.log
6+
7+
/src/generated/prisma

backend/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Stage 1: Build
2+
FROM node:20-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Copy package files
7+
COPY package*.json ./
8+
9+
# Install dependencies
10+
RUN npm ci
11+
12+
# Copy source code
13+
COPY . .
14+
15+
# Build TypeScript
16+
RUN npm run build
17+
18+
# Stage 2: Production
19+
FROM node:20-alpine AS production
20+
21+
WORKDIR /app
22+
23+
# Copy package files
24+
COPY package*.json ./
25+
26+
# Install production dependencies only
27+
RUN npm ci --only=production
28+
29+
# Copy built files from builder
30+
COPY --from=builder /app/dist ./dist
31+
COPY --from=builder /app/prisma ./prisma
32+
33+
# Generate Prisma client
34+
RUN npx prisma generate
35+
36+
# Expose port
37+
EXPOSE 3002
38+
39+
# Health check
40+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
41+
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/health || exit 1
42+
43+
# Start the application
44+
CMD ["npm", "start"]

backend/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# AnchorPoint Backend
2+
3+
The backend service for AnchorPoint, providing API endpoints for Stellar Anchor operations as per SEPs 1, 10, 12, and 24.
4+
5+
## Tech Stack
6+
- **Node.js**: Runtime environment.
7+
- **TypeScript**: Typed JavaScript for robustness.
8+
- **Express**: Fast, unopinionated, minimalist web framework.
9+
- **Jest & Supertest**: Testing framework and HTTP assertion library.
10+
- **ESLint**: Linter for identifying and reporting on patterns in JavaScript/TypeScript.
11+
12+
## Getting Started
13+
14+
### Prerequisites
15+
- Node.js (v18 or higher)
16+
- npm
17+
18+
### Installation
19+
From the monorepo root:
20+
```bash
21+
npm run install:all
22+
```
23+
24+
Or from the `/backend` directory:
25+
```bash
26+
npm install
27+
```
28+
29+
### Development
30+
To start the development server with auto-reload:
31+
```bash
32+
npm run dev
33+
```
34+
35+
### Building
36+
To compile TypeScript to JavaScript:
37+
```bash
38+
npm run build
39+
```
40+
41+
### Testing
42+
To run tests:
43+
```bash
44+
npm test
45+
```
46+
47+
To run tests with coverage report:
48+
```bash
49+
npm run test:coverage
50+
```
51+
52+
Current coverage threshold is set to **95%** for branches, functions, lines, and statements.
53+
54+
### Quality Control
55+
To run the linter:
56+
```bash
57+
npm run lint
58+
```

0 commit comments

Comments
 (0)