|
| 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 | +- `npm run dev` - Start development server with hot reload (runs on http://localhost:5173) |
| 8 | +- `npm run build` - Build for production (outputs to `build/` directory) |
| 9 | +- `npm start` - Start production server |
| 10 | +- `npm run typecheck` - Run TypeScript type checking |
| 11 | + |
| 12 | +## Architecture Overview |
| 13 | + |
| 14 | +This is a React Router v7 SPA application for smart contract verification using the Sourcify service. The app operates in SPA mode (SSR disabled in react-router.config.ts). |
| 15 | + |
| 16 | +### Key Directories |
| 17 | + |
| 18 | +- `app/` - Main application code |
| 19 | + - `components/` - Reusable UI components, with verification-specific components in `verification/` |
| 20 | + - `contexts/` - React contexts for global state (ServerConfig, CompilerVersions, Chains) |
| 21 | + - `hooks/` - Custom React hooks for form validation and verification state |
| 22 | + - `routes/` - Route components (home page, job status) |
| 23 | + - `types/` - TypeScript type definitions |
| 24 | + - `utils/` - Utility functions for API calls, storage, and business logic |
| 25 | + |
| 26 | +### Core Architecture |
| 27 | + |
| 28 | +**Verification Flow**: The app supports multiple verification methods (single-file, multiple-files, std-json, metadata-json) for both Solidity and Vyper contracts. All methods eventually convert to standard JSON format before submission to Sourcify's v2 API. |
| 29 | + |
| 30 | +**API Integration**: |
| 31 | +- `sourcifyApi.ts` - Main Sourcify API client with custom headers for client identification |
| 32 | +- `etherscanApi.ts` - Etherscan integration for importing contract data |
| 33 | +- All API calls use custom `sourcifyFetch()` with client identification headers |
| 34 | + |
| 35 | +**State Management**: Uses React Context for global state: |
| 36 | +- `ServerConfigContext` - Manages Sourcify server URLs (default, custom, localStorage sync) |
| 37 | +- `CompilerVersionsContext` - Fetches and caches compiler versions |
| 38 | +- `ChainsContext` - Manages blockchain network data |
| 39 | + |
| 40 | +**Job Tracking**: Verification jobs are tracked via localStorage and polling the `/v2/verify/{verificationId}` endpoint. |
| 41 | + |
| 42 | +### Environment Variables |
| 43 | + |
| 44 | +- `VITE_SOURCIFY_SERVER_URL` - Default Sourcify server URL |
| 45 | +- `VITE_SOURCIFY_REPO_URL` - Sourcify repository URL |
| 46 | +- `VITE_GIT_COMMIT` - Git commit hash for client version tracking |
| 47 | +- `VITE_ENV` - Environment (development/production) |
| 48 | + |
| 49 | +### Build Configuration |
| 50 | + |
| 51 | +- React Router v7 with Vite |
| 52 | +- TailwindCSS v4 for styling |
| 53 | +- TypeScript with strict mode |
| 54 | +- Path alias: `~/*` maps to `./app/*` |
| 55 | +- Web Workers used for bytecode diff calculations (`public/diffWorker.js`) |
0 commit comments