Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Koral Protocol #88

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1594872
docs: add GPL v3 LICENSE
cmdlucas Sep 23, 2022
e27ae30
docs: add project readme
cmdlucas Sep 23, 2022
a06d095
initial project dev setup
cmdlucas Oct 12, 2022
379b429
feat: setup foundation for colony smart contract
cmdlucas Oct 14, 2022
4d66c9d
feat: add contract deployer using proxy pattern
cmdlucas Oct 14, 2022
e5d4656
feat: push to ethernal after contract deployment
cmdlucas Oct 15, 2022
ebf6182
feat: setup ability to add or deactivate colony entities
cmdlucas Oct 17, 2022
7a0bda9
feat: untangle stop from resume function
cmdlucas Oct 18, 2022
5178226
docs: add comment about colony protocol status
cmdlucas Oct 18, 2022
220916b
docs: update project readme
cmdlucas Oct 18, 2022
df642f4
refactor: update app initial setup
cmdlucas Oct 18, 2022
aa78331
refactor: introduce core frontend dir
cmdlucas Oct 18, 2022
c8f58e8
chore: initial linting setup
cmdlucas Oct 18, 2022
5403e4c
chore: improve typing and formatting
cmdlucas Oct 18, 2022
6db75d5
feat: tco2 market view setup
cmdlucas Oct 19, 2022
257f721
feat: setup topbar
cmdlucas Oct 19, 2022
c4ebb3e
feat: setup market to read static toucan projects datas
cmdlucas Oct 20, 2022
6d417e8
refactor: remove unnecessary FC
cmdlucas Oct 20, 2022
e51947d
feat: introduced paginated view for projects in market
cmdlucas Oct 20, 2022
39f8a57
docs: add note about toucan projects source
cmdlucas Oct 20, 2022
a87610f
feat: update colony contract name
cmdlucas Oct 25, 2022
f71edd0
feat: introduce celo wallet connection
cmdlucas Oct 25, 2022
79e9fc6
refactor: introduce market repo and entity
cmdlucas Oct 25, 2022
0f3e32e
feat: update repo to directly query toucan subgraph
cmdlucas Oct 25, 2022
cb3d592
feat: update carbon button text
cmdlucas Oct 25, 2022
7711f52
feat: improve market projects item content
cmdlucas Oct 25, 2022
55b22c1
feat: fetch projects through tokens
cmdlucas Oct 26, 2022
6431cd7
feat: introduce offset page
cmdlucas Oct 28, 2022
50d3720
feat: switch from ethers to web3js cos of celo
cmdlucas Oct 29, 2022
067d14c
feat: introduce reward fetching
cmdlucas Oct 29, 2022
5d72b9a
feat: add reward claiming to colony
cmdlucas Oct 31, 2022
a8d3abe
feat: add reward claiming to client app
cmdlucas Oct 31, 2022
aff5027
feat: introduce means to fetch claimed rewards
cmdlucas Oct 31, 2022
a722f7c
feat: introduce fetching user rewards
cmdlucas Oct 31, 2022
dc41af6
feat: improve logic for no claimed rewards message
cmdlucas Oct 31, 2022
b9696a7
refactor: use constant route definition in nav
cmdlucas Nov 1, 2022
187743e
feat: improve reward claiming modal messages
cmdlucas Nov 1, 2022
8830302
feat: introduce nprogress in client app
cmdlucas Nov 1, 2022
3ea7999
feat: improve offset payment notes
cmdlucas Nov 1, 2022
4611afa
feat: introduce offset contribution to colony contract
cmdlucas Nov 1, 2022
6aea485
feat: add ability to pay for offset
cmdlucas Nov 1, 2022
f37f7f4
feat: prevent claiming rewards for non-supporting projects
cmdlucas Nov 1, 2022
38ec471
feat: rename user rewards header
cmdlucas Nov 1, 2022
d7dc093
feat: add ability to set min contribution amount
cmdlucas Nov 1, 2022
5f6f965
chore: remove unnecessary contracts from frontend app
cmdlucas Nov 2, 2022
cdf5e75
refactor: update project queries naming convention
cmdlucas Nov 2, 2022
715c52c
feat: introduce blockchain network segregation
cmdlucas Nov 2, 2022
669061c
feat: stop logging process env
cmdlucas Nov 2, 2022
6a7c2d4
feat: do not fail when env var is not defined
cmdlucas Nov 2, 2022
67b43fe
feat: add typechain dir
cmdlucas Nov 2, 2022
33d1d33
refactor: make app independent of hardhat
cmdlucas Nov 2, 2022
1672c5e
refactor: update rewards file name
cmdlucas Nov 2, 2022
bc69b3b
chore: only include core app dir in tsconfig
cmdlucas Nov 2, 2022
b75626d
feat: support vcu projects
cmdlucas Nov 2, 2022
dd8a6e5
chore: remove typechain setup from root install
cmdlucas Nov 2, 2022
575b23d
feat: make web3 available in app project
cmdlucas Nov 2, 2022
7f8b191
fix: use correct default network for celo
cmdlucas Nov 2, 2022
6bca460
feat: deploy colony to alfajores
cmdlucas Nov 2, 2022
2791d6c
docs: update project description
cmdlucas Nov 3, 2022
ac4a4dc
test: add tests for colony smart contract
cmdlucas Nov 5, 2022
3e6da77
docs: add usage guide to readme
cmdlucas Nov 5, 2022
c45d347
docs: update readme
cmdlucas Nov 9, 2022
4b37444
docs: add loom video to docs
cmdlucas Nov 10, 2022
a490ad1
fix: ensure appropriate render on mobile
cmdlucas Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
initial project dev setup
cmdlucas committed Oct 12, 2022
commit a06d0956ac331599f1415c52c94da14ffd0d9479
3 changes: 3 additions & 0 deletions koral-earth/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ACCOUNT_PATH=
CELOSCAN_API_KEY=
MNEMONIC=
11 changes: 11 additions & 0 deletions koral-earth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

#Hardhat files
cache
artifacts

17 changes: 17 additions & 0 deletions koral-earth/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.singleQuote": true,
}
3 changes: 3 additions & 0 deletions koral-earth/client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions koral-earth/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
34 changes: 34 additions & 0 deletions koral-earth/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
7 changes: 7 additions & 0 deletions koral-earth/client/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
}

module.exports = nextConfig
5,229 changes: 5,229 additions & 0 deletions koral-earth/client/package-lock.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions koral-earth/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "koral-earth",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "12.3.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.8.4",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"eslint": "8.25.0",
"eslint-config-next": "12.3.1",
"typescript": "4.8.4"
}
}
8 changes: 8 additions & 0 deletions koral-earth/client/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import '../styles/globals.css'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

export default MyApp
13 changes: 13 additions & 0 deletions koral-earth/client/pages/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'

type Data = {
name: string
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}
72 changes: 72 additions & 0 deletions koral-earth/client/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import type { NextPage } from 'next'
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'

const Home: NextPage = () => {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>

<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>

<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.tsx</code>
</p>

<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
<h2>Documentation &rarr;</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>

<a href="https://nextjs.org/learn" className={styles.card}>
<h2>Learn &rarr;</h2>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>

<a
href="https://github.com/vercel/next.js/tree/canary/examples"
className={styles.card}
>
<h2>Examples &rarr;</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h2>Deploy &rarr;</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<span className={styles.logo}>
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</span>
</a>
</footer>
</div>
)
}

export default Home
Binary file added koral-earth/client/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions koral-earth/client/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions koral-earth/client/styles/Home.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
.container {
padding: 0 2rem;
}

.main {
min-height: 100vh;
padding: 4rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.footer {
display: flex;
flex: 1;
padding: 2rem 0;
border-top: 1px solid #eaeaea;
justify-content: center;
align-items: center;
}

.footer a {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
}

.title a {
color: #0070f3;
text-decoration: none;
}

.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}

.title {
margin: 0;
line-height: 1.15;
font-size: 4rem;
}

.title,
.description {
text-align: center;
}

.description {
margin: 4rem 0;
line-height: 1.5;
font-size: 1.5rem;
}

.code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}

.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
}

.card {
margin: 1rem;
padding: 1.5rem;
text-align: left;
color: inherit;
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease;
max-width: 300px;
}

.card:hover,
.card:focus,
.card:active {
color: #0070f3;
border-color: #0070f3;
}

.card h2 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}

.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}

.logo {
height: 1em;
margin-left: 0.5rem;
}

@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}

@media (prefers-color-scheme: dark) {
.card,
.footer {
border-color: #222;
}
.code {
background: #111;
}
.logo img {
filter: invert(1);
}
}
26 changes: 26 additions & 0 deletions koral-earth/client/styles/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}

a {
color: inherit;
text-decoration: none;
}

* {
box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
body {
color: white;
background: black;
}
}
20 changes: 20 additions & 0 deletions koral-earth/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
9 changes: 9 additions & 0 deletions koral-earth/deploy/001_deploy_colony.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { HardhatRuntimeEnvironment } from 'hardhat/types';

async function deployer(_hre: HardhatRuntimeEnvironment) {
console.log(`Deployed all contracts successfully`);
}

deployer.tags = ['Colony'];

export default deployer;
91 changes: 91 additions & 0 deletions koral-earth/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'dotenv/config';
import 'hardhat-celo';
import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
import type { HardhatUserConfig } from 'hardhat/config';
import type { NetworkUserConfig } from 'hardhat/types';

function getEnvVar(key: EnvVarName): string {
const val = process.env[key];
if (!val) {
throw new Error(`Requested env var not defined. Please provide a ${key} in the process environment`)
}
return val;
}

const chainIds = {
ganache: 1337,
mainnet: 42220,
alfajores: 44787,
};

function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
let jsonRpcUrl = 'http://127.0.0.1:7545';

if (chain === 'alfajores') {
jsonRpcUrl = 'https://alfajores-forno.celo-testnet.org';
}

if (chain === 'mainnet') {
jsonRpcUrl = 'https://forno.celo.org';
}

return {
accounts: {
count: 10,
mnemonic: getEnvVar("MNEMONIC"),
path: getEnvVar("ACCOUNT_PATH"),
},
chainId: chainIds[chain],
url: jsonRpcUrl,
};
}

const config: HardhatUserConfig = {
defaultNetwork: 'ganache',
etherscan: {
apiKey: {
mainnet: getEnvVar("CELOSCAN_API_KEY"),
alfajores: getEnvVar("CELOSCAN_API_KEY"),
},
},
gasReporter: {
currency: 'USD',
enabled: true,
excludeContracts: [],
src: './contracts',
},
networks: {
ganache: getChainConfig('ganache'),
mainnet: getChainConfig('mainnet'),
alfajores: getChainConfig('alfajores'),
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
solidity: {
version: '0.8.17',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 800,
},
},
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
};

export default config;
21,098 changes: 21,098 additions & 0 deletions koral-earth/package-lock.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions koral-earth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "koral-earth-demo",
"version": "0.0.1-SNAPSHOT",
"description": "A demo that uses a basic PoC of Koral's Reward Protocol",
"author": "koral.earth",
"scripts": {
"test": "jest"
},
"devDependencies": {
"@openzeppelin/hardhat-upgrades": "^1.21.0",
"dotenv": "^16.0.3",
"ethers": "^5.7.1",
"hardhat": "^2.12.0",
"hardhat-celo": "^0.0.3",
"hardhat-deploy": "^0.11.18",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
}
}
7 changes: 7 additions & 0 deletions koral-earth/test/fake.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect } from 'chai';

describe("fake", function () {
it("should be truthy", () => {
expect("value").to.not.be.equal(undefined)
})
});
10 changes: 10 additions & 0 deletions koral-earth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
}
7 changes: 7 additions & 0 deletions koral-earth/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare type EnvVar = {
ACCOUNT_PATH: string;
CELOSCAN_API_KEY: string;
MNEMONIC: string;
};

declare type EnvVarName = keyof EnvVar;