Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed May 23, 2024
1 parent d07e1f5 commit 7e572f0
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 61 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,34 @@ jobs:
- name: Typecheck
run: nr typecheck

test:
runs-on: ${{ matrix.os }}
# test:
# runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [lts/*]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
# strategy:
# matrix:
# node: [lts/*]
# os: [ubuntu-latest, windows-latest, macos-latest]
# fail-fast: false

steps:
- uses: actions/checkout@v4
# steps:
# - uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3
# - name: Install pnpm
# uses: pnpm/action-setup@v3

- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# - name: Set node ${{ matrix.node }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node }}

- name: Setup
run: npm i -g @antfu/ni
# - name: Setup
# run: npm i -g @antfu/ni

- name: Install
run: nci
# - name: Install
# run: nci

- name: Build
run: nr build
# - name: Build
# run: nr build

- name: Test
run: nr test
# - name: Test
# run: nr test
4 changes: 2 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const validatorDetail = computed(() => !!route.params.address)
<template>
<div flex="~ col gap-64" mx-auto size-screen max-h-screen max-w-1200 px-32 py-20>
<header flex="~ gap-32 row items-center">
<div i-nimiq:logos-nimiq-horizontal ml-16 h-24 w-90 dark:i-nimiq:logos-nimiq-white-horizontal />
<NuxtLink to="/" i-nimiq:logos-nimiq-horizontal ml-16 h-24 w-90 dark:i-nimiq:logos-nimiq-white-horizontal />
<NuxtLink v-if="validatorDetail" to="/" block w-max arrow-back ghost-btn>
Go Back
</NuxtLink>
Expand All @@ -26,7 +26,7 @@ const validatorDetail = computed(() => !!route.params.address)
</main>

<footer self-center pb-40>
Learn about the <NuxtLink to="/validator-trust-score" text-blue arrow>
Learn about the <NuxtLink :to="`/vts`" text-blue arrow>
Validator Trust Score
</NuxtLink>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { defineConfig } from 'drizzle-kit'
export default defineConfig({
schema: './server/database/schema.ts',
out: './server/database/migrations',
dialect: 'sqlite'
dialect: 'sqlite',
})
2 changes: 1 addition & 1 deletion public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions server/database/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "e0c818d9-d1cc-4bab-8acb-3da68fdbdb69",
"id": "c24187fc-4b2a-49ec-ab03-673a037430e2",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"activity": {
Expand Down Expand Up @@ -227,4 +227,4 @@
"tables": {},
"columns": {}
}
}
}
6 changes: 3 additions & 3 deletions server/database/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"idx": 0,
"version": "6",
"when": 1716452825470,
"tag": "0000_rare_the_enforcers",
"when": 1716471061910,
"tag": "0000_old_spectrum",
"breakpoints": true
}
]
}
}
3 changes: 1 addition & 2 deletions server/database/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sql } from 'drizzle-orm'
import { sqliteTable, text, integer, real, primaryKey } from 'drizzle-orm/sqlite-core'
import { integer, primaryKey, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'

export const validators = sqliteTable('validators', {
id: integer('id').primaryKey({ autoIncrement: true, onConflict: 'replace' }),
Expand Down
12 changes: 2 additions & 10 deletions server/database/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,68 @@ export async function seedDatabase() {
}
}

const validators: NewValidator[] = [
type InitialValidator = Omit<NewValidator, 'icon'> & Partial<Pick<NewValidator, 'icon'>>
const validators: InitialValidator[] = [
{
name: 'Pooly McPoolface',
address: 'NQ24 DJE3 KX3U HG5X 1BXP 8XQ3 SK7S X364 N7G7',
fee: 0.09,
icon: '',
payoutType: PayoutType.Restake,
tag: ValidatorTag.Nimiq
},
{
name: 'Cool Pool',
address: 'NQ87 FEGQ 01TF M29N T03J 3YCB JB5M X5VM XP8Q',
fee: 0.09,
icon: '',
payoutType: PayoutType.Direct,
tag: ValidatorTag.Nimiq
},
{
name: 'Puddle',
address: 'NQ82 BHPS UR9K 07X1 X6QH 3DY3 J325 UCSP UHV3',
fee: 0.095,
icon: '',
payoutType: PayoutType.Direct,
tag: ValidatorTag.Nimiq
},
{
name: 'Swimming Pool',
address: 'NQ38 YX2J GTMX 5XAU LKFU H0GS A4AA U26L MDA3',
fee: 0.1,
icon: '',
payoutType: PayoutType.Restake,
tag: ValidatorTag.Nimiq
},
{
name: 'Kiddie Pool',
address: 'NQ57 UQJL 5A3H N45M 1FHS 2454 C7L5 BTE6 KEU1',
fee: 0.1,
icon: '',
payoutType: PayoutType.Restake,
tag: ValidatorTag.Nimiq
},
{
name: 'Pool Billard',
address: 'NQ57 2F6C X3GB Y9B7 04U5 2BVA 4BVC M2T0 ELRL',
fee: 0.105,
icon: '',
payoutType: PayoutType.Restake,
tag: ValidatorTag.Nimiq
},
{
name: 'Monopooly',
address: 'NQ71 CK94 3V7U H62Y 4L0F GUUK DPA4 6SA6 DKKM',
fee: 0.11,
icon: '',
payoutType: PayoutType.Direct,
tag: ValidatorTag.Nimiq
},
{
name: 'Not-A-Pool',
address: 'NQ08 N4RH FQDL TE7S 8C66 65LT KYDU Q382 YG7U',
fee: 0.11,
icon: '',
payoutType: PayoutType.Restake,
tag: ValidatorTag.Nimiq
},
{
name: 'AceStaking',
address: 'NQ65 DHN8 4BSR 5YSX FC3V BB5J GKM2 GB2L H17C',
fee: 0.1,
icon: '',
payoutType: PayoutType.Direct,
description: 'The Ace in staking',
tag: ValidatorTag.Community
Expand Down
2 changes: 1 addition & 1 deletion server/database/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function storeValidator(address: string, rest: Omit<NewValidator, '
}

const icon = await Identicons.default.toDataUrl(address) as string
const newValidator = await useDrizzle().insert(tables.validators).values({ address, icon, ...rest }).returning().get()
const newValidator = await useDrizzle().insert(tables.validators).values({ ...rest, address, icon }).returning().get()
validators.set(address, newValidator.id)
return newValidator.id
}
Expand Down
3 changes: 2 additions & 1 deletion server/plugins/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { consola } from 'consola'
import { migrate } from 'drizzle-orm/d1/migrator'

export default defineNitroPlugin(async () => {
if (!import.meta.dev) return
if (!import.meta.dev)
return

onHubReady(async () => {
await migrate(useDrizzle(), { migrationsFolder: 'server/database/migrations' })
Expand Down
3 changes: 2 additions & 1 deletion server/plugins/seed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { seedDatabase } from '../database/seed'

export default defineNitroPlugin(async () => {
if (!import.meta.dev) return
if (!import.meta.dev)
return
let seeded = false
onHubReady(async () => {
await seedDatabase()
Expand Down
13 changes: 7 additions & 6 deletions server/tasks/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Client } from 'nimiq-rpc-client-ts'
import { fetchEpochsActivity, getRange } from 'nimiq-vts'
import { getMissingEpochs, storeActivities } from '../database/utils'
import { consola } from 'consola'
import { getMissingEpochs, storeActivities } from '../database/utils'

export default defineTask({
meta: {
name: "fetch",
description: "Fetches the necessary data from the blockchain",
name: 'fetch',
description: 'Fetches the necessary data from the blockchain',
},
async run() {
consola.info("Running fetch task...")
consola.info('Running fetch task...')

const client = new Client(new URL(useRuntimeConfig().rpcUrl))

Expand All @@ -20,7 +20,8 @@ export default defineTask({
// Only fetch the missing epochs that are not in the database
const epochBlockNumbers = await getMissingEpochs(range)
consola.info(`Fetching data for epochs: ${JSON.stringify(epochBlockNumbers)}`)
if (epochBlockNumbers.length === 0) return { success: "No epochs to fetch. Database is up to date" }
if (epochBlockNumbers.length === 0)
return { success: 'No epochs to fetch. Database is up to date' }

// Fetch the activity for the given epochs
const activities = await fetchEpochsActivity(client, epochBlockNumbers)
Expand All @@ -29,6 +30,6 @@ export default defineTask({
await storeActivities(activities)
consola.success(`Stored data for ${epochBlockNumbers.length} epochs.`)

return { result: "success" }
return { result: 'success' }
},
})
6 changes: 3 additions & 3 deletions server/tasks/reset.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default defineTask({
meta: {
name: "db:reset",
description: "Deletes all data from the database",
name: 'db:reset',
description: 'Deletes all data from the database',
},
async run() {
console.log("deleting DB...")
console.log('deleting DB...')
const events = await useDrizzle().delete(tables.activity).get()
const scores = await useDrizzle().delete(tables.scores).get()
const validators = await useDrizzle().delete(tables.validators).get()
Expand Down
10 changes: 5 additions & 5 deletions server/tasks/seed.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { seedDatabase } from "../database/seed"
import { consola } from 'consola'
import { seedDatabase } from '../database/seed'

export default defineTask({
meta: {
name: "db:seed",
description: "Deletes all data from the database",
name: 'db:seed',
description: 'Deletes all data from the database',
},
async run() {
consola.info("Seeding validators table...")
consola.info('Seeding validators table...')
await seedDatabase()
return { result: "Database seeded" }
return { result: 'Database seeded' }
},
})

0 comments on commit 7e572f0

Please sign in to comment.