Skip to content

Commit bbfdc3b

Browse files
committed
Initial commit of BountyPool project with real-time yield calculation
1 parent 8fc7c33 commit bbfdc3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+20431
-102
lines changed

.gitignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,25 @@ out/
1010
# Docs
1111
docs/
1212

13-
# Dotenv file
13+
# Node.js files
14+
node_modules/
15+
16+
# Environment variables
1417
.env
18+
.env.local
19+
.env.development.local
20+
.env.test.local
21+
.env.production.local
22+
frontend/public/env.js
23+
24+
# Build directories
25+
build/
26+
dist/
27+
28+
# IDE files
29+
.idea/
30+
.vscode/
31+
32+
# OS files
33+
.DS_Store
34+
Thumbs.db

.gitmodules

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/openzeppelin/openzeppelin-contracts
7+
[submodule "lib/openzeppelin-contracts-upgradeable"]
8+
path = lib/openzeppelin-contracts-upgradeable
9+
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
10+
[submodule "contracts/lib/forge-std"]
11+
path = contracts/lib/forge-std
12+
url = https://github.com/foundry-rs/forge-std
13+
[submodule "contracts/lib/openzeppelin-contracts"]
14+
path = contracts/lib/openzeppelin-contracts
15+
url = https://github.com/openzeppelin/openzeppelin-contracts
16+
[submodule "contracts/lib/openzeppelin-contracts-upgradeable"]
17+
path = contracts/lib/openzeppelin-contracts-upgradeable
18+
url = https://github.com/openzeppelin/openzeppelin-contracts-upgradeable
19+
[submodule "contracts/lib/aave-address-book"]
20+
path = contracts/lib/aave-address-book
21+
url = https://github.com/bgd-labs/aave-address-book

README.md

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,94 @@
1-
## Foundry
1+
# BountyPool
22

3-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
3+
BountyPool is a decentralized platform for incentivizing open-source development through bounty pools. This dApp allows repository owners to create token pools, where contributors can deposit funds to support the development of features and bug fixes. When issues are resolved, the contributor who solved the issue receives a bounty reward.
44

5-
Foundry consists of:
5+
## Features
66

7-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
7+
- **GitHub Integration**: Authenticate with GitHub to verify repository ownership
8+
- **Create Bounty Pools**: Repository owners can create pools tied to their GitHub repositories
9+
- **Deposit Funds**: Contributors can deposit tokens to support development
10+
- **Real-time Yield Calculation**: See up-to-date yield information without requiring transactions
11+
- **Issue Management**: Create, assign, and resolve GitHub issues with bounties attached
12+
- **Smart Contract Infrastructure**: Secure and transparent bounty distribution
1113

12-
## Documentation
14+
## Project Structure
1315

14-
https://book.getfoundry.sh/
16+
- `/contracts`: Solidity smart contracts (Foundry/Forge)
17+
- `/backend`: Express server for GitHub OAuth
18+
- `/frontend`: React frontend application (Vite)
1519

16-
## Usage
20+
## Prerequisites
1721

18-
### Build
22+
- [Node.js](https://nodejs.org/) (v16+)
23+
- [Foundry](https://getfoundry.sh/) for smart contract development
1924

20-
```shell
21-
$ forge build
22-
```
25+
## Setup Instructions
2326

24-
### Test
27+
### 1. Clone the Repository
2528

26-
```shell
27-
$ forge test
29+
```bash
30+
git clone <your-repo-url>
31+
cd BountyPool
2832
```
2933

30-
### Format
34+
### 3. Install Dependencies
35+
36+
```bash
37+
# Install backend dependencies
38+
cd backend
39+
npm install
40+
cd ..
3141

32-
```shell
33-
$ forge fmt
42+
# Install frontend dependencies
43+
cd frontend
44+
npm install
45+
cd ..
3446
```
3547

36-
### Gas Snapshots
48+
### 4. Start Local Blockchain
49+
50+
In a terminal window:
3751

38-
```shell
39-
$ forge snapshot
52+
```bash
53+
cd contracts
54+
forge anvil
4055
```
4156

42-
### Anvil
57+
### 5. Deploy Contracts
4358

44-
```shell
45-
$ anvil
59+
In a second terminal:
60+
61+
```bash
62+
cd contracts
63+
forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast -vvv
4664
```
4765

48-
### Deploy
66+
### 6. Start Backend Server
67+
68+
In a third terminal:
4969

50-
```shell
51-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
70+
```bash
71+
cd backend
72+
npm run dev
5273
```
5374

54-
### Cast
75+
### 7. Start Frontend
5576

56-
```shell
57-
$ cast <subcommand>
77+
In a fourth terminal:
78+
79+
```bash
80+
cd frontend
81+
npm run dev
5882
```
5983

60-
### Help
84+
Once all services are running, you can access the application at http://localhost:5173
6185

62-
```shell
63-
$ forge --help
64-
$ anvil --help
65-
$ cast --help
66-
```
86+
## License
87+
88+
This project is licensed under the MIT License - see the LICENSE file for details.
89+
90+
## Acknowledgments
91+
92+
- Built with [Foundry](https://getfoundry.sh/)
93+
- Frontend powered by [React](https://reactjs.org/) and [Vite](https://vitejs.dev/)
94+
- GitHub integration via [Octokit](https://github.com/octokit/octokit.js)

aderyn.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Aderyn Configuration File
2+
# Help Aderyn work with more granular control
3+
4+
# DO NOT CHANGE version below. As of now, only 1 is supported
5+
version = 1
6+
7+
# Read the description carefully and uncomment the examples in each paragraph should you consider using them.
8+
9+
# Base path for resolving remappings and compiling smart contracts, relative to workspace-root (directory in which the editor is open)
10+
# Most of the time, you want to point it to the directory containing foundry.toml or hardhat.config.js/ts.
11+
root = "."
12+
13+
# Path of source directory containing the contracts, relative to root (above)
14+
# Aderyn will traverse all the nested files inside to scan and report vulnerabilities found inside.
15+
# - If not specified, Aderyn will try to extract it from the framework that is being used. (Foundry / Hardhat).
16+
# That would be "contracts/" in case of Hardhat and in case of Foundry, it depends on foundry.toml and
17+
# many other factors like FOUNDRY_PROFILE environment variable, etc.
18+
# - If specified, Aderyn will override the above found `src`.
19+
# Example:
20+
# src = "src/"
21+
22+
# Path segments of contract files to include in the analysis.
23+
# - It can be a partial match like "/interfaces/", which will include all files with "/interfaces/" in the file path.
24+
# Or it can be a full match like "src/counters/Counter.sol", which will include only the file with the exact path.
25+
# - If not specified, all contract files in the source directory will be included.
26+
# Examples:
27+
# include = ["src/counters/Counter.sol", "src/others/"]
28+
# include = ["/interfaces/"]
29+
30+
# Path segments of contract files to exclude in the analysis.
31+
# - It can be a partial match like "/interfaces/", which will exclude all files with "/interfaces/" in the file path.
32+
# Or it can be a full match like "src/counters/Counter.sol", which will exclude only the file with the exact path.
33+
# - If not specified, no contract files will be excluded.
34+
# Examples:
35+
# exclude = ["src/counters/Counter.sol", "src/others/"]
36+
# exclude = ["/interfaces/"]
37+
38+
# For advanced use cases, leverage the following
39+
40+
# Remappings
41+
# - It can be specified in `remappings.txt` within the root folder of the project.
42+
# - If not specified, Aderyn will try to derive the values from foundry.toml (if present.)
43+
44+
# Environment
45+
# - These are usually all the FOUNDRY_, DAPP_ environment variables that are used during development.
46+
# - For example, if different profiles have different `src` declaration in `foundry.toml`, FOUNDRY_PROFILE can dictate the correct `src` value.
47+
# Env variables and their values can be specified below.
48+
49+
[env]
50+
# Example:
51+
# FOUNDRY_PROFILE = "default"

backend/.env.example

Whitespace-only changes.

backend/index.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
require('dotenv').config();
2+
const express = require('express');
3+
const cors = require('cors');
4+
const axios = require('axios');
5+
6+
const app = express();
7+
const PORT = process.env.PORT || 3000;
8+
9+
// Middleware
10+
app.use(express.json());
11+
app.use(cors({
12+
origin: 'http://localhost:5173', // Vite's default dev server port
13+
methods: ['GET', 'POST'],
14+
credentials: true
15+
}));
16+
17+
// GitHub OAuth exchange endpoint
18+
app.post('/api/github/exchange-code', async (req, res) => {
19+
try {
20+
const { code, state } = req.body;
21+
22+
if (!code) {
23+
return res.status(400).json({ error: 'Code is required' });
24+
}
25+
26+
console.log('Received GitHub code:', code.substring(0, 10) + '...');
27+
console.log('Using GitHub Client ID:', process.env.GITHUB_CLIENT_ID);
28+
29+
if (!process.env.GITHUB_CLIENT_SECRET || process.env.GITHUB_CLIENT_SECRET === 'your_github_client_secret') {
30+
console.error('ERROR: GitHub client secret is not properly configured');
31+
return res.status(500).json({ error: 'GitHub client secret is not configured' });
32+
}
33+
34+
// Exchange code for token with GitHub
35+
const requestData = {
36+
client_id: process.env.GITHUB_CLIENT_ID,
37+
client_secret: process.env.GITHUB_CLIENT_SECRET,
38+
code
39+
};
40+
41+
// Add state if provided
42+
if (state) {
43+
requestData.state = state;
44+
}
45+
46+
console.log('Sending token exchange request to GitHub');
47+
48+
const response = await axios.post(
49+
'https://github.com/login/oauth/access_token',
50+
requestData,
51+
{
52+
headers: {
53+
'Accept': 'application/json',
54+
'Content-Type': 'application/json'
55+
}
56+
}
57+
);
58+
59+
console.log('GitHub response status:', response.status);
60+
61+
if (response.data && response.data.access_token) {
62+
console.log('Received access token from GitHub');
63+
// Return the token response to the client
64+
return res.json(response.data);
65+
} else if (response.data && response.data.error) {
66+
console.error('GitHub OAuth error:', response.data);
67+
return res.status(400).json({
68+
error: 'GitHub OAuth error',
69+
details: response.data
70+
});
71+
} else {
72+
console.error('Unexpected GitHub response:', response.data);
73+
return res.status(500).json({
74+
error: 'Invalid response from GitHub',
75+
details: response.data
76+
});
77+
}
78+
} catch (error) {
79+
console.error('Error exchanging GitHub code for token:', error.message);
80+
if (error.response) {
81+
console.error('GitHub error response:', error.response.data);
82+
console.error('GitHub error status:', error.response.status);
83+
}
84+
return res.status(500).json({
85+
error: 'Failed to exchange code for token',
86+
details: error.response?.data || error.message
87+
});
88+
}
89+
});
90+
91+
// Health check endpoint
92+
app.get('/api/health', (req, res) => {
93+
res.json({ status: 'ok', message: 'GitHub OAuth server is running' });
94+
});
95+
96+
// Start the server
97+
app.listen(PORT, () => {
98+
console.log(`Server running on http://localhost:${PORT}`);
99+
console.log(`GitHub OAuth endpoint: http://localhost:${PORT}/api/github/exchange-code`);
100+
});

0 commit comments

Comments
 (0)