Skip to content

Commit fb87437

Browse files
authored
Merge pull request #102 from api3dao/revert-97-dcroote/94-lint
Revert "Fixes, lints, prettier, and upgrades"
2 parents 89ab2b3 + 4a58127 commit fb87437

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

+1376
-3306
lines changed

.eslintrc.json

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
11
{
2-
"extends": [
3-
"plugin:@api3/eslint-plugin-commons/universal",
4-
"next/core-web-vitals"
5-
],
6-
"parserOptions": {
7-
"project": ["./tsconfig.json"]
8-
},
9-
"rules": {
10-
// Some of these can be removed with effort (not addressed by --fix)
11-
"@typescript-eslint/ban-ts-comment": "off",
12-
"@typescript-eslint/no-unsafe-function-type": "off",
13-
"@typescript-eslint/prefer-namespace-keyword": "off",
14-
"@typescript-eslint/prefer-nullish-coalescing": "off",
15-
"eqeqeq": "off",
16-
"functional/no-classes": "off",
17-
"import/no-default-export": "off",
18-
"no-console": "off",
19-
"prefer-named-capture-group": "off",
20-
"prefer-template": "off",
21-
"radix": "off",
22-
"unicorn/filename-case": "off",
23-
"unicorn/no-array-callback-reference": "off",
24-
"unicorn/no-array-push-push": "off",
25-
"unicorn/no-await-expression-member": "off",
26-
"unicorn/number-literal-case": "off",
27-
"unicorn/prefer-code-point": "off",
28-
"unicorn/prefer-string-slice": "off",
29-
"unicorn/prefer-switch": "off"
30-
}
2+
"extends": "next/core-web-vitals"
313
}

.github/ISSUE_TEMPLATE/community-bug-bounty.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
name: Community bug bounty
33
about: Submissions for the community bug bounty
4-
title: ""
4+
title: ''
55
labels: cbb
6-
assignees: ""
6+
assignees: ''
7+
78
---
89

910
## Steps to reproduce

.github/workflows/docker-image.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main", "i/**", "f/**" ]
6+
pull_request:
7+
branches: [ "dependabot/**" ]
8+
9+
jobs:
10+
only_build:
11+
runs-on: ubuntu-latest
12+
if: github.ref != 'refs/heads/main'
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Build the Docker image
16+
run: docker build . --file Dockerfile --tag api3tracker:latest
17+
build_deploy:
18+
runs-on: ubuntu-latest
19+
if: github.ref == 'refs/heads/main'
20+
env:
21+
SSH_HOST: ${{ secrets.SSH_HOST }}
22+
SSH_REMOTE_PATH: /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod
23+
24+
steps:
25+
- name: Install SSH Key
26+
uses: shimataro/ssh-key-action@v2
27+
with:
28+
key: ${{ secrets.SSH_PRIVATE_KEY }}
29+
known_hosts: /dev/null
30+
- uses: actions/checkout@v3
31+
- name: Build the Docker image
32+
run: docker build . --file Dockerfile --tag api3tracker:latest
33+
- name: Push main Docker image
34+
run: docker save api3tracker:latest | bzip2 | ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null $SSH_HOST 'bunzip2 -d | docker load'
35+
- name: Apply Terraform plan
36+
run: |
37+
echo "::add-mask::$TF_VAR_API3TRACKER_ENDPOINT"
38+
echo "::add-mask::$TF_VAR_API3TRACKER_ARCHIVE_ENDPOINT"
39+
export REMOTE_CMD="cd $SSH_REMOTE_PATH && terraform init && terraform apply -auto-approve && docker system prune -af"
40+
ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null $SSH_HOST bash -c '"'$REMOTE_CMD'"'
41+

.github/workflows/main.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
FROM node:20.18-alpine3.19 AS dependencies
1+
FROM node:16.16-alpine3.15 AS dependencies
22
WORKDIR /app
33
COPY package.json yarn.lock ./
44
RUN yarn install --frozen-lockfile
55

6-
FROM node:20.18-alpine3.19 AS builder
6+
FROM node:16.16-alpine3.15 AS builder
77
WORKDIR /app
88
COPY . .
99
COPY --from=dependencies /app/node_modules ./node_modules
1010
RUN yarn prisma generate
1111
RUN yarn build
1212
RUN yarn next telemetry disable
1313

14-
FROM node:20.18-alpine3.19
14+
FROM node:16.16-alpine3.15
1515
WORKDIR /app
1616
ENV NODE_ENV=production
1717

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ The services are:
2020
```
2121

2222
Containers:
23-
2423
- api3tracker: The FE and BE-service
2524
- postgres: The database the FE and BE rely on
2625
- traefik: A load balancer that encrypts HTTP responses (using the CF origin server key pair)
2726
- postgres-exporter: a service that exports the database as a backup on an interval
2827

2928
Host services:
3029
The host OS also runs some cron services, these are:
31-
3230
```bash
3331
*/10 * * * * root cd /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod && ./bin/job_logs_download.sh >> /var/log/api3-logs-download.log 2>&1
3432
15,45 * * * * root cd /home/ubuntu/src/github.com/api3dao/api3-tracker/terraform/workspaces/api3tracker-prod && ./bin/job_supply_download.sh >> /var/log/api3-supply-download.log 2>&1
@@ -39,45 +37,36 @@ The host OS also runs some cron services, these are:
3937
```
4038

4139
## Local developement using Docker
42-
4340
Developers can run some or all services locally using Docker Swarm, or even bare-bones, without containerisation.
4441

4542
One combination is running just postgres locally using Docker, eg:
46-
4743
```bash
4844
docker run --rm -ti -p 5432:5432 postgres:15
4945
```
50-
5146
and then running the FE and BE services directly (refer to Cron jobs below and `yarn next dev` in `package.json`).
5247

5348
Alternatively, one can run services using Docker Swarm, but this lacks hot-reloading.
5449

5550
### Local development using Docker Swarm
56-
5751
If you haven't already enabled Swarm mode on your Docker instance, do so now (only has to be done once):
58-
5952
```bash
6053
docker swarm init
6154
```
62-
6355
The result of the above command can be ignored.
6456

6557
Build the FE/BE image:
66-
6758
```bash
6859
docker build -t api3dao/api3-tracker:latest .
6960
```
7061

7162
Run the stack:
72-
7363
```bash
7464
docker stack deploy -c dev-tools/docker-compose.yml tracker-stack
7565
```
7666

7767
If all goes well the application will be served at http://localhost:3000
7868

7969
Some commands for visualising the services:
80-
8170
```bash
8271
docker ps # all docker containers
8372
docker service ls # all swarm services
@@ -86,13 +75,11 @@ docker stack rm tracker-stack # tear down the stack
8675
```
8776

8877
Initialise the DB:
89-
9078
```bash
9179
DATABASE_URL="postgres://postgres:[email protected]:5432/postgres?sslmode=disable" yarn prisma migrate deploy
9280
```
9381

9482
Cron jobs (unwrapped versions of cronjobs):
95-
9683
```bash
9784
DATABASE_URL="postgres://postgres:[email protected]:5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts logs download
9885
DATABASE_URL="postgres://postgres:[email protected]:5432/postgres?sslmode=disable" TS_NODE_PROJECT=./tsconfig.cli.json yarn ts-node cli.ts supply download

cli.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { hideBin } from "yargs/helpers";
21
import yargs from "yargs/yargs";
3-
4-
import { ENS } from "./services/ens";
2+
import { hideBin } from "yargs/helpers";
53
import { EthereumPrice } from "./services/price";
6-
import { Shares } from "./services/shares";
7-
import { Supply } from "./services/supply";
84
import { Events } from "./services/sync";
95
import { Treasuries } from "./services/treasuries";
6+
import { Supply } from "./services/supply";
7+
import { Shares } from "./services/shares";
8+
import { ENS } from "./services/ens";
109

1110
yargs(hideBin(process.argv))
1211
.env("API3TRACKER")
@@ -27,13 +26,13 @@ yargs(hideBin(process.argv))
2726
});
2827
},
2928
handler: async ({ endpoint, sub }) => {
30-
if (sub === "reset") {
29+
if (sub == "reset") {
3130
await ENS.resetAll();
3231
console.log("ENS cache was deleted");
33-
} else if (sub === "import") {
32+
} else if (sub == "import") {
3433
const total = await ENS.importLocal("./.cache");
3534
console.log(`saved ${total} new ENS records`);
36-
} else if (sub === "download") {
35+
} else if (sub == "download") {
3736
const total = await ENS.download(endpoint);
3837
console.log(`saved ${total} new ENS records`);
3938
} else {
@@ -53,8 +52,7 @@ yargs(hideBin(process.argv))
5352
describe: `logs subcommand - reset or download new`,
5453
})
5554
.option("coingecko_host", {
56-
default:
57-
process.env.API3TRACKER_COINGECKO_HOST || "api.coingecko.com",
55+
default: process.env.API3TRACKER_COINGECKO_HOST || "api.coingecko.com",
5856
type: "string",
5957
description: "Host to use for CoinGecko API",
6058
})
@@ -64,12 +62,11 @@ yargs(hideBin(process.argv))
6462
description: "API KEY to be used for CoinGecko-compatible API",
6563
});
6664
},
67-
// eslint-disable-next-line camelcase
6865
handler: async ({ endpoint, sub, coingecko_host, coingecko_api_key }) => {
69-
if (sub === "reset") {
66+
if (sub == "reset") {
7067
await Events.resetAll();
7168
console.log("events were deleted");
72-
} else if (sub === "download") {
69+
} else if (sub == "download") {
7370
const priceReader = EthereumPrice(coingecko_host, coingecko_api_key);
7471
const total = await Events.download(endpoint, priceReader);
7572
console.log(`downloaded ${total} new events`);
@@ -106,21 +103,21 @@ yargs(hideBin(process.argv))
106103
});
107104
},
108105
handler: async ({ endpoint, sub, member, tag, rpsLimit }) => {
109-
if (sub === "reset") {
106+
if (sub == "reset") {
110107
await Shares.resetAll();
111108
console.log("shares cache records were deleted");
112-
} else if (sub === "votings") {
113-
const total = await Shares.downloadVotings();
109+
} else if (sub == "votings") {
110+
const total = await Shares.downloadVotings(endpoint);
114111
console.log(`updated ${total} new records`);
115-
} else if (sub === "totals") {
112+
} else if (sub == "totals") {
116113
await Shares.recalculateTotals();
117-
} else if (sub === "download") {
118-
if (tag) {
119-
const total = await Shares.downloadMembers(endpoint, tag, rpsLimit);
120-
console.log(`scanned ${total} members`);
121-
} else {
114+
} else if (sub == "download") {
115+
if (!tag) {
122116
const total = await Shares.download(endpoint, member, rpsLimit);
123117
console.log(`downloaded ${total} new records`);
118+
} else {
119+
const total = await Shares.downloadMembers(endpoint, tag, rpsLimit);
120+
console.log(`scanned ${total} members`);
124121
}
125122
} else {
126123
console.error("ERROR: Unknown sub-command");
@@ -179,10 +176,10 @@ yargs(hideBin(process.argv))
179176
stopBlock,
180177
useArchive,
181178
}) => {
182-
if (sub === "reset") {
179+
if (sub == "reset") {
183180
await Events.resetState();
184181
console.log("Events state was reset");
185-
} else if (sub === "next") {
182+
} else if (sub == "next") {
186183
const verbose = {
187184
blocks: verboseBlocks || false,
188185
epochs: verboseEpochs || false,
@@ -197,10 +194,10 @@ yargs(hideBin(process.argv))
197194
endpoint,
198195
verbose,
199196
termination,
200-
useArchive,
197+
useArchive
201198
);
202199
console.log(`${blocks} blocks were processed`);
203-
} else if (sub === "update") {
200+
} else if (sub == "update") {
204201
const verbose = {
205202
blocks: verboseBlocks || false,
206203
epochs: verboseEpochs || false,
@@ -215,7 +212,7 @@ yargs(hideBin(process.argv))
215212
endpoint,
216213
verbose,
217214
termination,
218-
useArchive,
215+
useArchive
219216
);
220217
console.log(`${blocks} blocks were processed`);
221218
} else {
@@ -235,10 +232,10 @@ yargs(hideBin(process.argv))
235232
});
236233
},
237234
handler: async ({ endpoint, sub }) => {
238-
if (sub === "reset") {
235+
if (sub == "reset") {
239236
await Supply.resetAll();
240237
console.log("Supply history was reset");
241-
} else if (sub === "download") {
238+
} else if (sub == "download") {
242239
await Supply.download(endpoint);
243240
console.log("Supply history was updated");
244241
} else {
@@ -258,10 +255,10 @@ yargs(hideBin(process.argv))
258255
});
259256
},
260257
handler: async ({ endpoint, sub }) => {
261-
if (sub === "reset") {
258+
if (sub == "reset") {
262259
await Treasuries.resetAll();
263260
console.log("Treasuries state was reset");
264-
} else if (sub === "download") {
261+
} else if (sub == "download") {
265262
const total = await Treasuries.download(endpoint);
266263
console.log(`downloaded state of ${total} balances`);
267264
} else {

components/ContractsList.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from "react";
2-
3-
import { type IContract } from "../services/types";
4-
2+
import { IContract } from "../services/types";
53
import { BorderedPanel } from "./BorderedPanel";
64
import { Address } from "./Ethscan";
75

0 commit comments

Comments
 (0)