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

Refactor/v2 #112

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b867b36
chore: include ubiquibot org
Keyrxng Apr 30, 2024
093540f
chore: commit leaderboard and unspent data
Keyrxng Apr 30, 2024
7f9bbba
feat: data via dune
Keyrxng May 17, 2024
e078163
feat: dune data parser
Keyrxng May 27, 2024
8b65537
feat: paid issue parser
Keyrxng May 27, 2024
53f86bd
feat: user tx parser
Keyrxng May 27, 2024
b25cc32
chore: eslint settings, write wallet map json
Keyrxng May 27, 2024
387a6fd
chore: update tx hashes
Keyrxng Jun 3, 2024
4281599
chore: update dune parser
Keyrxng Jun 3, 2024
93693de
chore: update issue parser
Keyrxng Jun 3, 2024
53a65f3
chore: update user tx parser
Keyrxng Jun 3, 2024
35a72ef
feat: data controller
Keyrxng Jun 3, 2024
a2f29c6
refactor: controller code split
Keyrxng Jun 4, 2024
de9a170
refactor: issue parser
Keyrxng Jun 4, 2024
2123648
refactor: dune parser
Keyrxng Jun 4, 2024
f83ff23
refactor: user tx history
Keyrxng Jun 4, 2024
36b64eb
refactor: split methods
Keyrxng Jun 4, 2024
8828c04
refactor: optimizing
Keyrxng Jun 4, 2024
43cb6de
refactor: clean up
Keyrxng Jun 4, 2024
d9b8c6b
refactor: remove v1 and unused template
Keyrxng Jun 4, 2024
8e84977
refactor: eslint, cspell
Keyrxng Jun 4, 2024
6f2ab88
refactor: knip
Keyrxng Jun 4, 2024
c1c1978
chore: final clean up and comments
Keyrxng Jun 5, 2024
7b3431a
fix: remove workflow
Keyrxng Jun 5, 2024
76ef918
chore: add unspent filtering back
Keyrxng Jun 7, 2024
bdc61b1
chore: tweak for db push
Keyrxng Jun 27, 2024
ae37fc4
chore: final tweaks
Keyrxng Jun 27, 2024
c8956b9
chore: non-parsed amount
Keyrxng Jun 27, 2024
93c029f
chore: rebuild unspent permit urls
Keyrxng Jun 28, 2024
6772e03
fix: rate limit workaround
Keyrxng Jun 28, 2024
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
36 changes: 0 additions & 36 deletions .github/workflows/tallyRepo.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eslint.workingDirectories": [
"./airdrop-cli",
]
}
27 changes: 26 additions & 1 deletion airdrop-cli/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"words": [
"dataurl",
"devpool",
"outdir",
"servedir",
"TYPEHASH",
"PAIDOUT",
"Supabase",
"SUPABASE",
"viem",
"WXDAI",
"Populator",
"leaderboard",
"Leaderboard",
"publicnode",
"txhashes",
"gtxs",
"etxs",
"gnosisscan",
"txreceipt",
"ubiquibar",
"blockscan",
"ubiquibot",
"pavlovcik",
"sonarjs"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
3 changes: 1 addition & 2 deletions airdrop-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ node_modules
static/dist
.env
dist
*.csv
debug/repos/*
/src/scripts/data/*
2 changes: 1 addition & 1 deletion airdrop-cli/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodeLinker: node-modules
nodeLinker: node-modules
124 changes: 29 additions & 95 deletions airdrop-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,46 @@
# UBQ Airdrop Tally Tool

## Overview
This CLI tool tallies UBQ airdrop amounts for contributors. It does this by parsing issue comments for payout links from the UBQ bot using the GitHub GraphQL API.

## Setup
1. **GitHub Token**
- Add the token to ``.env`` as `GITHUB_TOKEN`.
2. **Install Dependencies**
- Install the required dependencies using `npm` or `yarn`.
This tool is designed to tally up Ubiquity contributor permits from across all issues and create a verifiable leaderboard based on earnings from completed tasks, ensuring a high level of data integrity and transparency.

```bash
# npm install
```
3. **Build the CLI**
- Build the CLI using the available commands.
A huge improvement from the first iteration of the airdrop tally tool, this is expected to store the underlying data into the `Permits` table in the database, which would render the need for future use of this tool obsolete.

```bash
# npm run cli:build
```
## Usage

4. **Run the CLI**
- Run the CLI using the available commands.
1. Install dependencies

```bash
# npm run cli:start
```
```bash
yarn install
```

## Commands
1. **start**
- Display information about the available commands and their usage.
2. Open three terminals and run one parser in each terminal

```bash
# yarn cli:start
```
```bash
yarn dune
```

2. **single**
- Tally UBQ airdrop for a specific repository or shortcode from the beginning of 2023.
```bash
yarn issue
```

```bash
# yarn cli:single [shortcode/repo-name]
```
```bash
yarn userTx
```

3. **tally**
- Tally UBQ airdrop for all indexable repositories since the start of 2023.
##### Note: This will take around 10-15 minutes to complete the process.

```bash
# yarn cli:tally
```
3. Close all but one terminal and run the following command

4. **tally-from**
- Tally UBQ airdrop for all indexable repositories since a specified date (YYYY-MM-DD).
```bash
yarn all
```

```bash
# yarn cli:tally-from [date]
```
## Changes Made

5. **tally-multi-csv**
- Tally UBQ airdrop for all indexable repositories since the start of 2023 and output repository-specific CSV files.

```bash
# yarn cli:tally-multi-csv
```

6. **help**
- Display a list of indexable repositories and their shortcodes.

```bash
# yarn run cli:help
```

## Output
The CLI outputs three CSV files:

1. [**All Payments**](all_repos_all_payments.csv)
- Includes payments with or without an assignee. Manual checking required for entries without an assignee which is often due to issues having been reopened or manual payouts because of issues with the bot.

2. [**Contributors**](all_repos_contributors.csv)
- Provides a username-to-UBQ mapping for total UBQ earned from all payments across all repositories since the chosen time.

3. [**No Payments**](all_repos_no_payments.csv)
- Lists repositories that have been indexed as having no payments released, including archived and inactive repositories. Manual checking may be required.


## Usage Examples
1. Tally UBQ airdrop for a specific repository or shortcode:

```bash
# npm run cli:single dollar || npm single ubiquity-dollar
```

2. Tally UBQ airdrop for all indexable repositories since the start of 2023:

```bash
# npm run cli:tally
```

3. Tally UBQ airdrop for all indexable repositories since a specified date:

```bash
# npm run cli:tally-from 2023-01-01
```
4. Tally UBQ airdrop for all indexable repositories since the start of 2023 and output repository-specific CSV files:

```bash
# npm run cli:tally-multi-csv
```
5. Display a list of indexable repositories and their shortcodes:

```bash
# npm run cli:help
```
- Optimized and refactored the core `tally` function into a far more readable codebase.
- Created a parser for both blockscan APIs and Dune Analytics.
- Improved data integrity and cohesion of data from all sources as opposed to the previous version, through multiple parsers, checks and rechecks as well as outputting debug data/verification data that is much more workable.
- Combined all data available for a given permit into a single source of truth, handy for attributing permits to the respective issues (should the DB be extended to support that)
- Geared the tool towards seeding the database as opposed to outputting CSV files.
- Removed the unnecessary CLIME and CLI code, as it was never used in the first place.
33 changes: 0 additions & 33 deletions airdrop-cli/build/esbuild-build.ts

This file was deleted.

18 changes: 0 additions & 18 deletions airdrop-cli/build/esbuild-server.ts

This file was deleted.

4 changes: 0 additions & 4 deletions airdrop-cli/build/index.ts

This file was deleted.

16 changes: 7 additions & 9 deletions airdrop-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
"format:prettier": "prettier --write .",
"format:cspell": "cspell **/*",
"prepare": "husky install",
"cli:debug": "npx tsx src/debug/cli-entry.ts",
"cli:tally": "npx tsx src/tally/cli-entry.ts",
"cli:single": "npx tsx src/single/cli-entry.ts",
"cli:unspent": "npx tsx src/unspent/cli-entry.ts",
"cli:help": "npx tsx src/help/cli-entry.ts",
"dune": "npx tsx src/scripts/dune-data-parser.ts",
"issue": "npx tsx src/scripts/paid-issue-parser.ts",
"userTx": "npx tsx src/scripts/user-tx-parser.ts",
"all": "npx tsx src/scripts/data-controller.ts",
"test": "npx jest"
},
"keywords": [
Expand All @@ -31,8 +30,8 @@
"open-source"
],
"dependencies": {
"axios": "^1.6.7",
"clime": "^0.5.16",
"@octokit/rest": "^20.1.1",
"@supabase/supabase-js": "^2.43.2",
"dotenv": "^16.4.2",
"ethers": "^5.7.2",
"graphql": "^16.8.1",
Expand All @@ -50,7 +49,6 @@
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"cspell": "^8.3.2",
"esbuild": "^0.19.8",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
Expand Down Expand Up @@ -80,4 +78,4 @@
"@commitlint/config-conventional"
]
}
}
}
Loading