Skip to content

Commit

Permalink
Merge pull request #14 from ubq-testing/development
Browse files Browse the repository at this point in the history
chore: purge rewards and format
  • Loading branch information
gitcoindev authored Apr 23, 2024
2 parents b63bb3b + b6456f2 commit 902ff2b
Show file tree
Hide file tree
Showing 50 changed files with 64 additions and 2,833 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"WXDAI",
"XDAI",
"xmark",
"SUPABASE"
"SUPABASE",
"Knip"
],
"dictionaries": ["typescript", "node", "software-terms", "html"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Knip

on:
pull_request_target:
types: [ opened, synchronize ]
types: [opened, synchronize]

permissions: write-all

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
.env
static/dist
metamask
static/out
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `@ubiquity/onboard.ubq.fi`

Generates the configuration for organizations, by creating a default configuration and creating a repository under the
Generates the configuration for organizations, by creating a default configuration and creating a repository under the
given Organization.

## Requirements
Expand All @@ -12,24 +12,29 @@ Copy the `env.example` to `.env` and fill the required variables.
```shell
yarn start
```

Should make the front-end page available at [http://localhost:8080](http://localhost:8080).

### Required fields

- `CHAIN_ID`: the id of the network you want to use for the transactions
- `WALLET_PRIVATE_KEY`: the [64 digits](https://www.browserling.com/tools/random-hex) crypto wallet key that will be used for transactions
- `GITHUB_PAT`: a [GitHub Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)
- `ORG_NAME`: the name of the [organization](https://github.com/settings/organizations) where you want to add the bot

## Testing

To test with Cypress Studio UI, run

```shell
yarn cy:open
```

Otherwise to simply run the tests through the console, run

```shell
yarn cy:run
```

To test in a real-world scenario, you will need to create an Organization under your GitHub account, and use it as a
To test in a real-world scenario, you will need to create an Organization under your GitHub account, and use it as a
dummy. If the operation is successful, you will see a new repository appear with the Ubiquibot configuration.
13 changes: 1 addition & 12 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { execSync } from "child_process";
import { config } from "dotenv";
import esbuild from "esbuild";
import extraRpcs from "../lib/chainlist/constants/extraRpcs";

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

const allNetworkUrls: Record<string, string[]> = {};
// this flattens all the rpcs into a single object, with key names that match the networkIds. The arrays are just of URLs per network ID.

Object.keys(extraRpcs).forEach((networkId) => {
const officialUrls = extraRpcs[networkId].rpcs.filter((rpc) => typeof rpc === "string");
const extraUrls: string[] = extraRpcs[networkId].rpcs.filter((rpc) => rpc.url !== undefined).map((rpc) => rpc.url);
allNetworkUrls[networkId] = [...officialUrls, ...extraUrls];
});

export const esBuildContext: esbuild.BuildOptions = {
sourcemap: true,
entryPoints: entries,
Expand All @@ -31,7 +21,6 @@ export const esBuildContext: esbuild.BuildOptions = {
},
outdir: "static/out",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY", "FRONTEND_URL"], {
extraRpcs: allNetworkUrls,
commitHash: execSync(`git rev-parse --short HEAD`).toString().trim(),
}),
};
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/main.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("Homepage tests", () => {
statusCode: 200,
});
// Simulate login token
// cspell:ignore wfzpewmlyiozupulbuur
// cSpell: ignore wfzpewmlyiozupulbuur
window.localStorage.setItem("sb-wfzpewmlyiozupulbuur-auth-token", JSON.stringify(loginToken));
}).as("githubLogin");
cy.get("#github-login-button").click();
Expand Down
4 changes: 1 addition & 3 deletions cypress/fixtures/get-installation-repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@
"allow_forking": false,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [

],
"topics": [],
"visibility": "private",
"forks": 0,
"open_issues": 0,
Expand Down
16 changes: 4 additions & 12 deletions cypress/fixtures/get-installations.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
"updated_at": "2024-02-13T19:37:31.000+09:00",
"single_file_name": null,
"has_multiple_single_files": false,
"single_file_paths": [

],
"single_file_paths": [],
"suspended_by": null,
"suspended_at": null
},
Expand Down Expand Up @@ -110,19 +108,13 @@
"app_slug": "ubi",
"target_id": 159901852,
"target_type": "Organization",
"permissions": {

},
"events": [

],
"permissions": {},
"events": [],
"created_at": "2024-02-13T21:12:10.000+09:00",
"updated_at": "2024-02-13T21:12:10.000+09:00",
"single_file_name": null,
"has_multiple_single_files": false,
"single_file_paths": [

],
"single_file_paths": [],
"suspended_by": null,
"suspended_at": null
}
Expand Down
4 changes: 1 addition & 3 deletions cypress/fixtures/get-org-installations.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
"updated_at": "2024-03-11T20:40:33.000+09:00",
"single_file_name": null,
"has_multiple_single_files": false,
"single_file_paths": [

],
"single_file_paths": [],
"suspended_by": null,
"suspended_at": null
}
Expand Down
8 changes: 2 additions & 6 deletions cypress/fixtures/get-repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@
"allow_forking": false,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [

],
"topics": [],
"visibility": "private",
"forks": 0,
"open_issues": 0,
Expand All @@ -117,9 +115,7 @@
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"merge_commit_message": "PR_TITLE",
"merge_commit_title": "MERGE_MESSAGE",
"custom_properties": {

},
"custom_properties": {},
"organization": {
"login": "Ubiquity",
"id": 159901852,
Expand Down
4 changes: 1 addition & 3 deletions cypress/fixtures/get-search.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@
"allow_forking": false,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [

],
"topics": [],
"visibility": "private",
"forks": 0,
"open_issues": 0,
Expand Down
8 changes: 2 additions & 6 deletions cypress/fixtures/get-ubiquibot-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [

],
"topics": [],
"visibility": "private",
"forks": 0,
"open_issues": 0,
Expand All @@ -118,9 +116,7 @@
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"merge_commit_message": "PR_TITLE",
"merge_commit_title": "MERGE_MESSAGE",
"custom_properties": {

},
"custom_properties": {},
"organization": {
"login": "ubiquity",
"id": 76412717,
Expand Down
4 changes: 1 addition & 3 deletions cypress/fixtures/put-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
"updated_at": "2024-03-11T20:40:33.000+09:00",
"single_file_name": null,
"has_multiple_single_files": false,
"single_file_paths": [

],
"single_file_paths": [],
"suspended_by": null,
"suspended_at": null
}
Expand Down
2 changes: 1 addition & 1 deletion knip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["static/scripts/onboarding/onboarding.ts", "static/scripts/rewards/index.ts"],
entry: ["static/scripts/onboarding/onboarding.ts"],
project: ["static/**/*.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@octokit/core"],
Expand Down
1 change: 0 additions & 1 deletion lib/chainlist
Submodule chainlist deleted from 805928
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
"@octokit/core": "^5.1.0",
"@octokit/plugin-create-or-update-text-file": "^4.0.1",
"@octokit/rest": "^20.0.2",
"@sinclair/typebox": "^0.32.15",
"@supabase/supabase-js": "2.39.7",
"@types/libsodium-wrappers": "^0.7.13",
"@ubiquibot/configuration": "1.1.0",
"@uniswap/permit2-sdk": "^1.2.0",
"axios": "^1.6.8",
"dotenv": "^16.4.4",
"ethers": "^5.7.2",
"libsodium-wrappers": "^0.7.13",
Expand Down
6 changes: 2 additions & 4 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ <h1 class="title">Onboarding</h1>
</div>
<div id="step1" class="step-container">
<div class="overlay" id="overlay">
<div id="overlay-item-container">
</div>
<div id="overlay-item-container"> </div>
</div>
<div class="mb-3">
<label for="chainId" class="form-label">CHAIN_ID</label>
Expand All @@ -39,8 +38,7 @@ <h1 class="title">Onboarding</h1>
</div>
<div class="mb-3">
<label for="orgName" class="form-label">ORG_NAME</label>
<select class="form-control" id="orgName" disabled>
</select>
<select class="form-control" id="orgName" disabled> </select>
<span class="status-log"></span>
</div>
<div class="mb-3 pos-rel">
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions static/scripts/onboarding/abis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./erc20Abi";
29 changes: 29 additions & 0 deletions static/scripts/onboarding/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export enum NetworkIds {
Mainnet = 1,
Goerli = 5,
Gnosis = 100,
Anvil = 31337,
}

export enum Tokens {
DAI = "0x6b175474e89094c44da98b954eedeac495271d0f",
WXDAI = "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
}

export const networkNames = {
[NetworkIds.Mainnet]: "Ethereum Mainnet",
[NetworkIds.Goerli]: "Goerli Testnet",
[NetworkIds.Gnosis]: "Gnosis Chain",
[NetworkIds.Anvil]: "http://127.0.0.1:8545",
};

export function getNetworkName(networkId?: number) {
const networkName = networkNames[networkId as keyof typeof networkNames];
if (!networkName) {
console.error(`Unknown network ID: ${networkId}`);
}
return networkName ?? "Unknown Network";
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const nftAddress = "0xAa1bfC0e51969415d64d6dE74f27CDa0587e645b";
2 changes: 1 addition & 1 deletion static/scripts/onboarding/github-login-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getNewSessionToken() {
}

function getSessionToken() {
// cspell:ignore wfzpewmlyiozupulbuur
// cSpell: ignore wfzpewmlyiozupulbuur
const cachedSessionToken = getLocalStore<OAuthToken>("sb-wfzpewmlyiozupulbuur-auth-token");
if (cachedSessionToken) {
return cachedSessionToken.provider_token;
Expand Down
4 changes: 2 additions & 2 deletions static/scripts/onboarding/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { ethers } from "ethers";
import { parseUnits } from "ethers/lib/utils";
import _sodium from "libsodium-wrappers";
import YAML from "yaml";
import { erc20Abi } from "../rewards/abis";
import { getNetworkName, NetworkIds, Tokens } from "../rewards/constants";
import { erc20Abi } from "./abis";
import { getNetworkName, NetworkIds, Tokens } from "./constants";
import { getSessionToken, renderGitHubLoginButton } from "./github-login-button";

const classes = ["error", "warn", "success"];
Expand Down
2 changes: 0 additions & 2 deletions static/scripts/rewards/abis/index.ts

This file was deleted.

Loading

0 comments on commit 902ff2b

Please sign in to comment.