Skip to content

Commit

Permalink
[Backend] USDC balance indexer + endpoint (#84)
Browse files Browse the repository at this point in the history
* support a fake USDC on sepolia

* fix balances indexer

* remove decimals support

* small refactoring

* activate entity mode on balances indexor

* configure balacnes db update

* fix balances indexor entity key

* fix entity mode config

* small drizzle refactor

* add drizzle migrations

* fix apibara insert/update on balances

* rename db url variable name

* remove useless config files

* remove more useless config files

* replace postgres-js by node-postgres

* removed balances indexer entity mode

* generate drizzle migration on build
  • Loading branch information
0xChqrles authored Jun 12, 2024
1 parent 48ce11b commit 7831367
Show file tree
Hide file tree
Showing 41 changed files with 136 additions and 2,709 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches
# Caches

.cache

Expand Down
11 changes: 7 additions & 4 deletions backend/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable import/no-unused-modules */

import type { Config } from 'drizzle-kit'
import { defineConfig } from 'drizzle-kit'

export default {
export default defineConfig({
schema: './src/db/schema.ts',
out: './src/db/migrations',
out: './drizzle',
driver: 'pg',
} satisfies Config
dbCredentials: {
connectionString: process.env.DATABASE_URL ?? '',
},
})
1 change: 1 addition & 0 deletions backend/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"5","dialect":"pg","entries":[]}
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"typecheck": "tsc --noEmit",
"drizzle:generate": "drizzle-kit generate:pg",
"test": "vitest",
"prepare": "pnpm drizzle:generate",
"coverage": "vitest run --coverage",
"lint": "eslint . --max-warnings=0",
"fix": "eslint . --fix"
Expand Down
3 changes: 2 additions & 1 deletion backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Fastify from 'fastify'
import { Account } from 'starknet'

import { fastifyDrizzle } from '@/db/plugin'
import { declareRoutes } from '@/routes'

import { declareRoutes } from './routes'

export type AppConfiguration = {
database: {
Expand Down
4 changes: 1 addition & 3 deletions backend/src/db/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ export function drizzle(client: postgres.Sql, config: DrizzleConfig = {}) {

export async function migrate(client: postgres.Sql, config: DrizzleConfig = {}) {
// Notice that the path must be relative to the application root.
return await ogMigrate(drizzle(client, config), {
migrationsFolder: './src/db/migrations',
})
return await ogMigrate(drizzle(client, config), { migrationsFolder: './drizzle' })
}
13 changes: 0 additions & 13 deletions backend/src/db/migrations/0000_dry_silver_centurion.sql

This file was deleted.

8 changes: 0 additions & 8 deletions backend/src/db/migrations/0001_flawless_nehzno.sql

This file was deleted.

8 changes: 0 additions & 8 deletions backend/src/db/migrations/0002_medical_darwin.sql

This file was deleted.

6 changes: 0 additions & 6 deletions backend/src/db/migrations/0003_giant_thaddeus_ross.sql

This file was deleted.

6 changes: 0 additions & 6 deletions backend/src/db/migrations/0004_thin_gorgon.sql

This file was deleted.

5 changes: 0 additions & 5 deletions backend/src/db/migrations/0005_first_madripoor.sql

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/db/migrations/0006_light_rocket_raccoon.sql

This file was deleted.

4 changes: 0 additions & 4 deletions backend/src/db/migrations/0006_outgoing_roxanne_simpson.sql

This file was deleted.

2 changes: 0 additions & 2 deletions backend/src/db/migrations/0007_breezy_zarek.sql

This file was deleted.

4 changes: 0 additions & 4 deletions backend/src/db/migrations/0008_fearless_angel.sql

This file was deleted.

3 changes: 0 additions & 3 deletions backend/src/db/migrations/0009_gray_whizzer.sql

This file was deleted.

91 changes: 0 additions & 91 deletions backend/src/db/migrations/meta/0000_snapshot.json

This file was deleted.

137 changes: 0 additions & 137 deletions backend/src/db/migrations/meta/0001_snapshot.json

This file was deleted.

Loading

0 comments on commit 7831367

Please sign in to comment.