Skip to content

Commit aa2984a

Browse files
author
sven-hash
committed
add: readme+customize color
1 parent 0364c3c commit aa2984a

4 files changed

Lines changed: 132 additions & 0 deletions

File tree

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Delegation Hub
2+
3+
A simple web application for delegating AAVE, stkAAVE, and aAAVE voting power to a specified delegate address. Users can connect their wallet and delegate their voting power with a single click.
4+
5+
## What It Does
6+
7+
This website allows AAVE token holders to delegate their voting power (both VOTING and PROPOSITION) to a trusted delegate. It supports:
8+
- **AAVE** token delegation
9+
- **stkAAVE** token delegation
10+
- **aAAVE** token delegation
11+
- Delegation of all tokens at once
12+
13+
Users connect their wallet, view their token balances, and can delegate or remove delegation with a simple interface.
14+
15+
## How to Create Your Own Page
16+
17+
### Prerequisites
18+
19+
- [Bun](https://bun.sh) (or Node.js/npm)
20+
- An Ethereum wallet for testing
21+
22+
### Setup
23+
24+
1. **Clone or fork this repository**
25+
26+
2. **Install dependencies**
27+
```bash
28+
bun install
29+
```
30+
31+
3. **Create a `.env` file** in the root directory:
32+
```env
33+
VITE_DELEGATE_ADDRESS=0xYourDelegateAddressHere
34+
VITE_DELEGATE_NAME=Your Delegate Name
35+
VITE_LOGO_NAME=Your Logo Text
36+
37+
# Optional: Customize colors
38+
VITE_MAIN_COLOR=#e8f8a6
39+
VITE_MAIN_COLOR_DARK=#0d1208
40+
41+
# Optional: WalletConnect Project ID (for better wallet connection)
42+
VITE_WALLETCONNECT_PROJECT_ID=your-project-id
43+
```
44+
45+
4. **Update the configuration**
46+
- Set `VITE_DELEGATE_ADDRESS` to the Ethereum address you want users to delegate to
47+
- Set `VITE_DELEGATE_NAME` to the display name (e.g., "No Trust Verify")
48+
- Set `VITE_LOGO_NAME` to the text shown in the header (defaults to delegate name)
49+
50+
5. **Run the development server**
51+
```bash
52+
bun run dev
53+
```
54+
55+
6. **Build for production**
56+
```bash
57+
bun run build
58+
```
59+
60+
### Configuration Options
61+
62+
- **`VITE_DELEGATE_ADDRESS`** (required): The Ethereum address to delegate voting power to
63+
- **`VITE_DELEGATE_NAME`** (required): Display name for the delegate
64+
- **`VITE_LOGO_NAME`** (optional): Logo text in header (defaults to delegate name)
65+
- **`VITE_MAIN_COLOR`** (optional): Light theme background color (default: `#e8f8a6`)
66+
- **`VITE_MAIN_COLOR_DARK`** (optional): Dark theme background color (default: `#0d1208`)
67+
- **`VITE_WALLETCONNECT_PROJECT_ID`** (optional): WalletConnect project ID for better wallet support
68+
69+
### Deployment
70+
71+
The project includes a GitHub Actions workflow for automatic deployment to GitHub Pages. Just push to the `main` branch and it will deploy automatically.
72+
73+
For manual deployment, build the project and serve the `dist` folder:
74+
```bash
75+
bun run build
76+
# Serve the dist folder with your preferred static hosting service
77+
```
78+
79+
## How It Works
80+
81+
The app interacts with AAVE governance contracts:
82+
- **AAVE Token**: `0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9`
83+
- **stkAAVE Token**: `0x4da27a545c0c5b758a6ba100e3a049001de870f5`
84+
- **aAAVE Token**: `0xa700b4eb416be35b2911fd5dee80678ff64ff6c9`
85+
86+
It calls the `delegateByType(address, powerType)` function where:
87+
- `address`: The delegate address (or user's own address to remove delegation)
88+
- `powerType`: `0` for VOTING, `1` for PROPOSITION
89+
90+
### Inspired By
91+
92+
This project is inspired by [AaveChan's delegation interface](https://apps.aavechan.com/delegate).
93+

src/App.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ function App() {
3131
useEffect(() => {
3232
document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light');
3333
localStorage.setItem('theme', isDark ? 'dark' : 'light');
34+
35+
// Update CSS variable for the current theme
36+
document.documentElement.style.setProperty(
37+
'--bg-primary',
38+
isDark ? config.mainColorDark : config.mainColor
39+
);
40+
41+
// Update theme-color meta tag when theme changes
42+
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
43+
if (themeColorMeta) {
44+
themeColorMeta.setAttribute('content', isDark ? config.mainColorDark : config.mainColor);
45+
}
3446
}, [isDark]);
3547

3648
const toggleTheme = () => {

src/config/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export const config = {
33
delegateAddress: import.meta.env.VITE_DELEGATE_ADDRESS,
44
delegateName: import.meta.env.VITE_DELEGATE_NAME,
55
logoName: import.meta.env.VITE_LOGO_NAME || import.meta.env.VITE_DELEGATE_NAME,
6+
mainColor: import.meta.env.VITE_MAIN_COLOR || '#e8f8a6',
7+
mainColorDark: import.meta.env.VITE_MAIN_COLOR_DARK || '#0d1208',
68
} as const;
79

810
// Helper to check if string is an Ethereum address (not ENS)

src/main.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,33 @@ import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
33
import { WalletProvider } from './components/WalletProvider'
44
import App from './App'
5+
import { config } from './config/env'
56
import './index.css'
67

8+
// Set the main color from environment variable for light theme
9+
document.documentElement.style.setProperty('--bg-primary', config.mainColor);
10+
11+
// Create a style element to set dark theme color
12+
// The inline style in App.tsx will override this when theme changes
13+
const darkThemeStyle = document.createElement('style');
14+
darkThemeStyle.id = 'custom-dark-theme-color';
15+
darkThemeStyle.textContent = `
16+
[data-theme="dark"] {
17+
--bg-primary: ${config.mainColorDark};
18+
}
19+
`;
20+
document.head.appendChild(darkThemeStyle);
21+
22+
// Update theme-color meta tag (will be updated dynamically when theme changes)
23+
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
24+
if (themeColorMeta) {
25+
// Set initial theme color based on current theme
26+
const isDark = document.documentElement.getAttribute('data-theme') === 'dark' ||
27+
(!document.documentElement.getAttribute('data-theme') &&
28+
window.matchMedia('(prefers-color-scheme: dark)').matches);
29+
themeColorMeta.setAttribute('content', isDark ? config.mainColorDark : config.mainColor);
30+
}
31+
732
createRoot(document.getElementById('root')!).render(
833
<StrictMode>
934
<WalletProvider>

0 commit comments

Comments
 (0)