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: initial stage audit.ubq.fi #1

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 37 additions & 3 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "/lib"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"dictionaries": ["typescript", "node", "software-terms"],
"words": [
"binkey",
"binsec",
"chainlist",
"cirip",
"dataurl",
"devpool",
"ethersproject",
"fract",
"gnosisscan",
"godb",
"greyscale",
"IERC",
"keccak",
"keypair",
"libsodium",
"Numberish",
"outdir",
"Rpcs",
"scalarmult",
"servedir",
"solmate",
"sonarjs",
"typebox",
"TYPEHASH",
"ubiquibot",
"UBIQUIBOT",
"URLSAFE",
"WXDAI",
"XDAI",
"xmark",
"supabase",
"SUPABASE"

],
"dictionaries": ["typescript", "node", "software-terms", "html"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
}
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
run: |
yarn
yarn build
# env: # Set environment variables for the build
# SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co"
# SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs"
env: # Set environment variables for the build
SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co"
SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs"

- name: Deploy to Cloudflare
uses: ubiquity/cloudflare-deploy-action@main
Expand Down
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# `@ubiquity/ts-template`
# `@ubiquity/audit.ubq.fi`

This template repository includes support for the following:
#### Install Dependencies
- yarn

- TypeScript
- Environment Variables
- Conventional Commits
- Automatic deployment to Cloudflare Pages
#### Build
- yarn build

### Start UI

- yarn start

Test Uses:

```json
{
"WALLET": "0xrandomwallet",
"REPO": "https://github.com/repo/repo",
"PAT": "YOUR_PAT"
}
28 changes: 21 additions & 7 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import esbuild from "esbuild";
const typescriptEntries = ["static/main.ts"];
// const cssEntries = ["static/style.css"];
const entries = [
...typescriptEntries,
// ...cssEntries
];
import * as dotenv from "dotenv";

const typescriptEntries = ["static/scripts/rewards/index.ts", "static/scripts/audit-report/audit.ts"];
const cssEntries = ["static/styles/rewards/rewards.css", "static/styles/audit-report/audit.css"];
export const entries = [...typescriptEntries, ...cssEntries];

export const esBuildContext: esbuild.BuildOptions = {
sourcemap: true,
Expand All @@ -19,7 +18,8 @@ export const esBuildContext: esbuild.BuildOptions = {
".ttf": "dataurl",
".svg": "dataurl",
},
outdir: "static/dist",
outdir: "static/out",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY"]),
};

esbuild
Expand All @@ -31,3 +31,17 @@ esbuild
console.error(err);
process.exit(1);
});

function createEnvDefines(envVarNames: string[]): Record<string, string> {
const defines: Record<string, string> = {};
dotenv.config();
for (const name of envVarNames) {
const envVar = process.env[name];
if (envVar !== undefined) {
defines[name] = JSON.stringify(envVar);
} else {
throw new Error(`Missing environment variable: ${name}`);
}
}
return defines;
}
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ts-template",
"version": "1.0.0",
"description": "Template repository with TypeScript support.",
"description": "audit.ubq.fi",
"main": "build/index.ts",
"author": "Ubiquity DAO",
"license": "MIT",
Expand All @@ -27,7 +27,14 @@
"open-source"
],
"dependencies": {
"dotenv": "^16.4.4"
"@octokit/plugin-throttling": "^8.1.3",
"@octokit/rest": "^20.0.2",
"@sinclair/typebox": "^0.32.14",
"@supabase/supabase-js": "2.39.7",
"axios": "^1.6.7",
"dotenv": "^16.4.4",
"ethers": "^5.7.2",
"godb": "^0.6.2"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
Expand Down
74 changes: 67 additions & 7 deletions static/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,73 @@
<!doctype html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ubiquity TypeScript Template</title>
<link rel="stylesheet" href="style.css" />
<title>Audit report</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="out/styles/audit-report/audit.css" rel="stylesheet" />
</head>

<body>
<h1>Ubiquity TypeScript Template</h1>
<script type="module" src="dist/main.js"></script>
<div class="container">
<h1 class="audit-tag">Audit report</h1>
<!-- params -->
<div class="mb-3">
<label for="botWalletAddress" class="form-label">Bot wallet address</label>
<input type="text" class="form-control" id="botWalletAddress" />
</div>
<div class="mb-3">
<label for="repoURLs" class="form-label">Repository URLs</label>
<input type="text" class="form-control" id="repoURLs" />
</div>
<div class="mb-3">
<label for="githubPAT" class="form-label">Github Personal Access Token</label>
<input type="text" class="form-control" id="githubPAT" />
</div>
<div class="mb-3">
<label for="quickName" class="form-label">Quick Import</label>
<textarea
type="text"
class="form-control"
id="quickName"
placeholder='
{
"WALLET": "",
"REPO": "",
"PAT": ""
}'
></textarea>
</div>
<div class="btn-container">
<button type="button" class="btn btn-primary mb-3" id="getReport">
<span class="btn-loader" id="report-loader"></span>
<span>Get report</span>
</button>
<div class="tg-list-item">
<input class="tgl tgl-flat" id="cb4" type="checkbox" />
<label class="tgl-btn" for="cb4"></label>
<div class="cache-title">⚡Cache</div>
</div>
</div>
<!-- result table -->
<div class="resultContainer">
<input type="text" id="searchInput" placeholder="Filter Result" />
<table id="resultTable" class="table" style="display: none">
<thead>
<tr>
<th scope="col">Organization/Repo Name</th>
<th scope="col">Issue URL</th>
<th scope="col">Bounty Hunter</th>
<th scope="col" id="amountHeader">Amount <span id="sortArrow">&#8595;</span></th>
<th scope="col">TX URL</th>
</tr>
</thead>
<tbody>
<!-- table content -->
</tbody>
</table>
</div>
</div>
<ul class="notifications"></ul>
<script src="out/scripts/audit-report/audit.js" type="application/javascript"></script>
</body>
</html>
Loading
Loading