|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Development Commands |
| 6 | + |
| 7 | +### Installation |
| 8 | +```bash |
| 9 | +yarn install |
| 10 | +``` |
| 11 | + |
| 12 | +### Development |
| 13 | +```bash |
| 14 | +# Watch mode for development (compiles all TypeScript packages and watches for changes) |
| 15 | +yarn dev |
| 16 | + |
| 17 | +# Single build of all packages |
| 18 | +yarn |
| 19 | +``` |
| 20 | + |
| 21 | +### Linting |
| 22 | +```bash |
| 23 | +# Lint all packages |
| 24 | +yarn lint |
| 25 | + |
| 26 | +# Lint only changed files |
| 27 | +yarn lint-changed |
| 28 | + |
| 29 | +# Fix linting issues |
| 30 | +yarn lint-fix |
| 31 | +``` |
| 32 | + |
| 33 | +### Testing |
| 34 | +```bash |
| 35 | +# Run all unit tests |
| 36 | +yarn unit-test |
| 37 | + |
| 38 | +# Run unit tests for a specific module |
| 39 | +yarn run unit-test --scope bitgo |
| 40 | + |
| 41 | +# Run unit tests for files containing specific string |
| 42 | +yarn run unit-test -- -- --grep "keyword" |
| 43 | + |
| 44 | +# Run unit tests only for changed modules since master |
| 45 | +yarn unit-test-changed |
| 46 | + |
| 47 | +# Run integration tests |
| 48 | +yarn integration-test |
| 49 | + |
| 50 | +# Generate test coverage |
| 51 | +yarn coverage |
| 52 | +``` |
| 53 | + |
| 54 | +### Browser Compatibility |
| 55 | +```bash |
| 56 | +# Run browser tests |
| 57 | +yarn browser-tests |
| 58 | + |
| 59 | +# Build for production |
| 60 | +yarn compile |
| 61 | + |
| 62 | +# Build for development |
| 63 | +yarn compile-dbg |
| 64 | +``` |
| 65 | + |
| 66 | +## Code Architecture |
| 67 | + |
| 68 | +BitGoJS is a monorepo composed of multiple modules, each implementing specific functionality: |
| 69 | + |
| 70 | +### Core Modules |
| 71 | +- `bitgo`: Main module providing authentication, wallet management, cryptographic primitives, and coin interfaces |
| 72 | +- `@bitgo/sdk-core`: Core SDK functionality, base classes, and interfaces |
| 73 | +- `@bitgo/sdk-api`: API client utilities |
| 74 | +- `@bitgo/statics`: Static configuration values used across the platform |
| 75 | + |
| 76 | +### Coin Implementation Modules |
| 77 | +- `@bitgo/sdk-coin-*`: Individual cryptocurrency implementations (e.g., btc, eth, sol, etc.) |
| 78 | +- `@bitgo/abstract-eth`, `@bitgo/abstract-utxo`, etc.: Abstract base classes for similar coin families |
| 79 | + |
| 80 | +### Transaction Building and Signing |
| 81 | +- `@bitgo/account-lib`: Build and sign transactions for account-based coins |
| 82 | +- `@bitgo/utxo-lib`: Build and sign transactions for UTXO-based coins |
| 83 | + |
| 84 | +### Other Utility Modules |
| 85 | +- `@bitgo/blockapis`: Access public block explorer APIs for various coins |
| 86 | +- `@bitgo/express`: Local BitGo transaction signing server and proxy |
| 87 | +- `@bitgo/unspents`: Utilities for UTXO chains |
| 88 | + |
| 89 | +## Architecture Overview |
| 90 | + |
| 91 | +The BitGoJS SDK follows a modular architecture: |
| 92 | + |
| 93 | +1. **Coin Factory Pattern**: The `CoinFactory` allows dynamic registration and instantiation of different cryptocurrency implementations |
| 94 | + |
| 95 | +2. **Multi-signature Wallets**: Core functionality revolves around creating and managing multi-signature wallets across various blockchains |
| 96 | + |
| 97 | +3. **Transaction Building**: Each coin type has builders for constructing, signing, and broadcasting transactions |
| 98 | + |
| 99 | +4. **Abstraction Layers**: Common functionality shared across similar blockchains is abstracted into base classes (e.g., `abstractEthLikeCoin`, `abstractUtxoCoin`) |
| 100 | + |
| 101 | +5. **TSS (Threshold Signature Scheme)**: Support for advanced cryptographic operations, including MPC (Multi-Party Computation) for secure key management |
| 102 | + |
| 103 | +6. **Module Independence**: Each cryptocurrency module can be used independently, allowing users to include only the functionality they need |
| 104 | + |
| 105 | +## Adding New Coins |
| 106 | + |
| 107 | +To implement a new coin: |
| 108 | +```bash |
| 109 | +yarn sdk-coin:new |
| 110 | +``` |
| 111 | + |
| 112 | +This will generate the necessary boilerplate for a new coin implementation. |
| 113 | + |
| 114 | +## Node.js Version Support |
| 115 | + |
| 116 | +BitGoJS supports Node.js versions >=18 and <23, with NPM >=3.10.10. |
0 commit comments