|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Build and Test |
| 8 | +- `cargo build --release` - Build production binary |
| 9 | +- `cargo test` - Run all tests including Redis integration tests |
| 10 | +- `cargo nextest run -p twmq --profile ci` - Run specific component tests |
| 11 | +- `RUST_LOG=debug cargo run` - Run server with debug logging |
| 12 | + |
| 13 | +### Development Setup |
| 14 | +Redis is required for development: |
| 15 | +```bash |
| 16 | +docker run -d --name redis -p 6379:6379 redis:7-alpine |
| 17 | +``` |
| 18 | + |
| 19 | +Required environment variables: |
| 20 | +```bash |
| 21 | +export APP__THIRDWEB__SECRET="your_secret_key" |
| 22 | +export APP__THIRDWEB__CLIENT_ID="your_client_id" |
| 23 | +``` |
| 24 | + |
| 25 | +## Architecture Overview |
| 26 | + |
| 27 | +This is a **Rust workspace** with 7 crates providing blockchain transaction infrastructure: |
| 28 | + |
| 29 | +- **`server/`** - Main HTTP API server (Axum-based REST API with OpenAPI docs) |
| 30 | +- **`core/`** - Core blockchain functionality (chain management, transactions, UserOps) |
| 31 | +- **`aa-core/`** - Account Abstraction engine (ERC-4337 v0.6/v0.7 support) |
| 32 | +- **`aa-types/`** - Account Abstraction type definitions |
| 33 | +- **`executors/`** - Background job handlers (webhooks, transaction confirmation) |
| 34 | +- **`twmq/`** - Thirdweb Message Queue (Redis-backed job queue with lease-based concurrency) |
| 35 | +- **`thirdweb-core/`** - Thirdweb service integrations (Vault SDK, IAW) |
| 36 | + |
| 37 | +### Key Technologies |
| 38 | +- **Axum** for HTTP server |
| 39 | +- **Alloy** for Ethereum interactions |
| 40 | +- **Redis** for job queue and state |
| 41 | +- **Tokio** for async runtime |
| 42 | +- **Vault SDK** for secure key management |
| 43 | + |
| 44 | +## Configuration System |
| 45 | + |
| 46 | +Hierarchical configuration priority: |
| 47 | +1. Environment variables (`APP__` prefix) |
| 48 | +2. Environment-specific YAML (`server_development.yaml`, `server_production.yaml`) |
| 49 | +3. Base YAML (`server_base.yaml`) |
| 50 | + |
| 51 | +Configuration files located in `server/configuration/` |
| 52 | + |
| 53 | +## Transaction Types Supported |
| 54 | + |
| 55 | +- **EOA transactions** - Traditional wallet transactions |
| 56 | +- **Account Abstraction** - ERC-4337 smart accounts with gas sponsorship |
| 57 | +- **EIP-7702** - Delegated transaction execution |
| 58 | + |
| 59 | +## Key Development Areas |
| 60 | + |
| 61 | +### API Routes |
| 62 | +Located in `server/src/http/routes/` - follows RESTful patterns with OpenAPI documentation |
| 63 | + |
| 64 | +### Background Jobs |
| 65 | +Implemented in `executors/src/` - uses TWMQ for reliable job processing with Redis persistence |
| 66 | + |
| 67 | +### Blockchain Core |
| 68 | +`core/src/` contains chain management, transaction building, and UserOperation support |
| 69 | + |
| 70 | +### Account Abstraction |
| 71 | +`aa-core/src/` implements complete ERC-4337 flow including bundler integration |
| 72 | + |
| 73 | +## Error Handling |
| 74 | + |
| 75 | +Uses comprehensive error types with context. All errors are structured and logged with tracing spans. |
| 76 | + |
| 77 | +## Testing |
| 78 | + |
| 79 | +Integration tests require Redis. Tests cover job queue operations, transaction building, and API endpoints. |
| 80 | + |
| 81 | +## Production Features |
| 82 | + |
| 83 | +- Horizontal scaling via shared Redis backend |
| 84 | +- Graceful shutdown with job completion guarantees |
| 85 | +- Vault-backed private key management |
| 86 | +- Comprehensive metrics and health checks |
| 87 | +- Docker support with multi-stage builds |
0 commit comments