|
| 1 | +# Contributing |
| 2 | + |
| 3 | +This repo contains the Aavegotchi contracts (Diamonds/facets/libraries) and supporting Hardhat tasks/scripts used for upgrades and operations. |
| 4 | + |
| 5 | +## Local Setup |
| 6 | + |
| 7 | +1. Initialize submodules (forge-std): |
| 8 | + |
| 9 | +```bash |
| 10 | +git submodule update --init --recursive |
| 11 | +``` |
| 12 | + |
| 13 | +2. Install JS dependencies: |
| 14 | + |
| 15 | +```bash |
| 16 | +npm ci |
| 17 | +``` |
| 18 | + |
| 19 | +3. Install Foundry (forge/anvil/cast): |
| 20 | + |
| 21 | +- https://book.getfoundry.sh/getting-started/installation |
| 22 | + |
| 23 | +## Common Commands |
| 24 | + |
| 25 | +### Format |
| 26 | + |
| 27 | +```bash |
| 28 | +forge fmt |
| 29 | +npm run prettier |
| 30 | +``` |
| 31 | + |
| 32 | +### Build / Compile |
| 33 | + |
| 34 | +This repo compiles with multiple Solidity compiler versions (see `hardhat.config.ts`). |
| 35 | + |
| 36 | +```bash |
| 37 | +forge build --sizes |
| 38 | +npx hardhat compile |
| 39 | +``` |
| 40 | + |
| 41 | +### Tests |
| 42 | + |
| 43 | +```bash |
| 44 | +forge test |
| 45 | +npm test |
| 46 | +``` |
| 47 | + |
| 48 | +Some tests use a local fork (Hardhat `hardhat` network). For fork-based tests you will need an RPC URL in `.env` (for example `BASE_RPC_URL`). |
| 49 | + |
| 50 | +## Diamond-Specific Guidelines |
| 51 | + |
| 52 | +### Storage Safety (Critical) |
| 53 | + |
| 54 | +The diamond’s state is a single `AppStorage` struct stored at slot 0: |
| 55 | +- `contracts/Aavegotchi/libraries/LibAppStorage.sol` |
| 56 | + |
| 57 | +Rules of thumb: |
| 58 | +- Treat `AppStorage` as a database schema migration. |
| 59 | +- Append-only: do not reorder/remove existing fields or change field types. |
| 60 | +- If you need new state, add it at the end and consider backfills/init if required. |
| 61 | + |
| 62 | +### msg.sender vs Meta-Transactions |
| 63 | + |
| 64 | +Many auth checks use `LibMeta.msgSender()` (meta-tx aware). If you add new permissioned functions in facets, be deliberate about whether you should use: |
| 65 | +- `msg.sender` (direct call only) |
| 66 | +- `LibMeta.msgSender()` (supports meta-tx flows) |
| 67 | + |
| 68 | +References: |
| 69 | +- `contracts/shared/libraries/LibMeta.sol` |
| 70 | +- `contracts/Aavegotchi/facets/MetaTransactionsFacet.sol` |
| 71 | + |
| 72 | +## PR Expectations |
| 73 | + |
| 74 | +- Keep PRs focused and small when possible. |
| 75 | +- Include tests (or explain why tests aren’t feasible). |
| 76 | +- Don’t commit secrets (`.env`, private keys, API keys). |
| 77 | +- Prefer changes that keep local dev flows safe by default (forks/simulations; no accidental broadcasts). |
| 78 | + |
0 commit comments