feat: multi-wallet architecture with localStorage state, EIP-712 verification, cross-tab WS leadership
- wallets.js: WalletManager state management with chain validation - verifier.js: WalletVerifier EIP-712 signing via window.ethereum - stream.js: WalletStreamManager with BroadcastChannel leader election, backoff + jitter - AGENTS.md: updated with coding guidelines
This commit is contained in:
58
AGENTS.md
Normal file
58
AGENTS.md
Normal file
@ -0,0 +1,58 @@
|
||||
# cbBTC Treasury Dashboard
|
||||
|
||||
**What it is:** A single-page HTML dashboard tracking cbBTC acquisition across wallets. No build step, no JS framework, no tests — just one `index.html` served by nginx.
|
||||
|
||||
## How to run
|
||||
|
||||
```bash
|
||||
docker build -t cbBTC-dashboard . && docker run -p 8080:80 cbBTC-dashboard
|
||||
```
|
||||
|
||||
Or just open `index.html` in a browser (without the `/api/` proxy, only the Kraken BTC price chart will work).
|
||||
|
||||
## File layout
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `index.html` | Everything. Frontend, embedded chart data, inline JS logic. Edit here. |
|
||||
| `Dockerfile` | 4 lines. Copies `index.html` and `default.conf` into `nginx:alpine`. |
|
||||
| `default.conf` | Reverse proxy: `/api/` → `http://192.168.1.102:8000/api/`. |
|
||||
| `aave_portfolio.md` / `wallet_portfolio.md` | Reference data dumps. NOT consumed by the app. |
|
||||
|
||||
## Key facts for editing `index.html`
|
||||
|
||||
- **Data is embedded as JS constants** near the top of the `<script>` block:
|
||||
- `walletCumulData` — time-series of cumulative BTC per wallet
|
||||
- `dailySatsData` — rolling sats/day with price info
|
||||
- `walletsMetadata` — wallet id → address, name, color, chain
|
||||
- `walletCosts` / `walletBuys` — cost basis per wallet
|
||||
- **API endpoints** (proxied through nginx):
|
||||
- `GET /api/v1/prices/{symbol}/history?range=N` — price history
|
||||
- `GET /api/v1/portfolio/{address}/base/aave` — Aave portfolio snapshots
|
||||
- **BTC price** fetched directly from Kraken: `https://api.kraken.com/0/public/OHLC?pair=XBTUSD&interval=1440`
|
||||
- **Polling:** `setInterval` every 30s with a 60s throttle on the Aave endpoint
|
||||
- **Tracked wallet:** `0x0c1a4a060e119f981412e323104d1c134d413dba` ("penguin", Base)
|
||||
- **Token decimals:** cbBTC=8, WETH=18, USDC=6
|
||||
|
||||
## Gotchas
|
||||
|
||||
- `apiBase = window.location.origin` — the dashboard relies on nginx proxy to reach the backend at `192.168.1.102:8000`. Running without Docker/proxy means the Aave table and price charts fail silently.
|
||||
- No linting, no type-checking, no CI. Validate changes by opening the HTML in a browser.
|
||||
- Adding chart data? Update the embedded arrays (`walletCumulData`, etc.) — they are plain JS arrays of `[timestampMs, value]` pairs.
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
You are an expert senior Web3 frontend engineer specializing in high-scale performance and stateless cryptographic security.
|
||||
|
||||
We are building the client-side code for an anonymous multi-wallet tracker. The application handles up to 100k concurrent connections, so code efficiency, memory management, and avoiding redundant network overhead are paramount.
|
||||
|
||||
1. **Modern TypeScript/JavaScript** — clean, modular, and well-commented.
|
||||
2. **No bloated third-party UI frameworks** — stick to vanilla methods or standard state hooks.
|
||||
3. **Production-ready error handling** — bulletproof handling for wallet rejections and network drops.
|
||||
|
||||
## After every `index.html` edit
|
||||
|
||||
Always rebuild and restart the Docker container so changes take effect:
|
||||
```bash
|
||||
docker build -t cbbtc-dashboard . && docker stop dione-dashboard && docker rm dione-dashboard && docker run -d --name dione-dashboard -p 8080:80 cbbtc-dashboard
|
||||
```
|
||||
Reference in New Issue
Block a user