From 52c6718c23870eb2bc6797b8c44587ca7ac1c31c Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 2 Jan 2025 12:38:13 +0000 Subject: [PATCH] setup drizzle --- db/index.ts | 3 + db/relations.ts | 2 + db/schema.ts | 502 ++++++++ drizzle.config.ts | 11 + drizzle/0000_boring_hannibal_king.sql | 246 ++++ drizzle/meta/0000_snapshot.json | 1503 ++++++++++++++++++++++++ drizzle/meta/_journal.json | 13 + package.json | 5 +- pnpm-lock.yaml | 13 +- src/app/(dashboard)/[slug].js/page.tsx | 88 ++ src/server/db/index.ts | 2 + 11 files changed, 2384 insertions(+), 4 deletions(-) create mode 100644 db/index.ts create mode 100644 db/relations.ts create mode 100644 db/schema.ts create mode 100644 drizzle.config.ts create mode 100644 drizzle/0000_boring_hannibal_king.sql create mode 100644 drizzle/meta/0000_snapshot.json create mode 100644 drizzle/meta/_journal.json create mode 100644 src/app/(dashboard)/[slug].js/page.tsx diff --git a/db/index.ts b/db/index.ts new file mode 100644 index 0000000..ea16b32 --- /dev/null +++ b/db/index.ts @@ -0,0 +1,3 @@ +import * as envioSchema from "./schema"; + +export default envioSchema; diff --git a/db/relations.ts b/db/relations.ts new file mode 100644 index 0000000..0ed80c7 --- /dev/null +++ b/db/relations.ts @@ -0,0 +1,2 @@ +import { relations } from "drizzle-orm/relations"; +import {} from "./schema"; diff --git a/db/schema.ts b/db/schema.ts new file mode 100644 index 0000000..d24e1b0 --- /dev/null +++ b/db/schema.ts @@ -0,0 +1,502 @@ +import { + pgTable, + index, + text, + numeric, + timestamp, + integer, + boolean, + varchar, + serial, + primaryKey, + date, + jsonb, + pgEnum, +} from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; + +export const contractType = pgEnum("contract_type", [ + "EntryPointV06", + "EntryPointV07", +]); +export const entityType = pgEnum("entity_type", [ + "EntryPoint_AccountDeployed", + "EntryPoint_UserOperationEvent", +]); + +export const entryPointAccountDeployed = pgTable( + "EntryPoint_AccountDeployed", + { + blockHash: text("blockHash").notNull(), + blockNumber: numeric("blockNumber").notNull(), + blockTimestamp: timestamp("blockTimestamp", { + withTimezone: true, + mode: "date", + }).notNull(), + chainId: integer("chainId").notNull(), + factory: text("factory").notNull(), + id: text("id").primaryKey().notNull(), + paymaster: text("paymaster").notNull(), + sender: text("sender").notNull(), + transactionHash: text("transactionHash").notNull(), + dbWriteTimestamp: timestamp("db_write_timestamp", { + mode: "date", + }).default(sql`CURRENT_TIMESTAMP`), + }, + (table) => { + return { + blockTimestamp: index("EntryPoint_AccountDeployed_blockTimestamp").using( + "btree", + table.blockTimestamp.asc().nullsLast(), + ), + chainId: index("EntryPoint_AccountDeployed_chainId").using( + "btree", + table.chainId.asc().nullsLast(), + ), + factory: index("EntryPoint_AccountDeployed_factory").using( + "btree", + table.factory.asc().nullsLast(), + ), + paymaster: index("EntryPoint_AccountDeployed_paymaster").using( + "btree", + table.paymaster.asc().nullsLast(), + ), + transactionHash: index( + "EntryPoint_AccountDeployed_transactionHash", + ).using("btree", table.transactionHash.asc().nullsLast()), + idxAccountdeployedSenderChainid: index( + "idx_accountdeployed_sender_chainid", + ).using( + "btree", + table.sender.asc().nullsLast(), + table.chainId.asc().nullsLast(), + table.factory.asc().nullsLast(), + ), + }; + }, +); + +export const entryPointUserOperationEvent = pgTable( + "EntryPoint_UserOperationEvent", + { + actualGasCost: numeric("actualGasCost").notNull(), + actualGasUsed: numeric("actualGasUsed").notNull(), + blockHash: text("blockHash").notNull(), + blockNumber: numeric("blockNumber").notNull(), + blockTimestamp: timestamp("blockTimestamp", { + withTimezone: true, + mode: "date", + }).notNull(), + chainId: integer("chainId").notNull(), + entryPoint: text("entryPoint").notNull(), + id: text("id").primaryKey().notNull(), + logIndex: integer("logIndex").notNull(), + nonce: numeric("nonce").notNull(), + paymaster: text("paymaster").notNull(), + sender: text("sender").notNull(), + success: boolean("success").notNull(), + transactionFrom: text("transactionFrom").notNull(), + transactionHash: text("transactionHash").notNull(), + transactionIndex: integer("transactionIndex").notNull(), + dbWriteTimestamp: timestamp("db_write_timestamp", { + mode: "date", + }).default(sql`CURRENT_TIMESTAMP`), + }, + (table) => { + return { + blockTimestamp: index( + "EntryPoint_UserOperationEvent_blockTimestamp", + ).using("btree", table.blockTimestamp.asc().nullsLast()), + chainId: index("EntryPoint_UserOperationEvent_chainId").using( + "btree", + table.chainId.asc().nullsLast(), + ), + entryPoint: index("EntryPoint_UserOperationEvent_entryPoint").using( + "btree", + table.entryPoint.asc().nullsLast(), + ), + paymaster: index("EntryPoint_UserOperationEvent_paymaster").using( + "btree", + table.paymaster.asc().nullsLast(), + ), + sender: index("EntryPoint_UserOperationEvent_sender").using( + "btree", + table.sender.asc().nullsLast(), + ), + success: index("EntryPoint_UserOperationEvent_success").using( + "btree", + table.success.asc().nullsLast(), + ), + transactionFrom: index( + "EntryPoint_UserOperationEvent_transactionFrom", + ).using("btree", table.transactionFrom.asc().nullsLast()), + transactionHash: index( + "EntryPoint_UserOperationEvent_transactionHash", + ).using("btree", table.transactionHash.asc().nullsLast()), + idxEupBlocktimestamp: index("idx_eup_blocktimestamp").using( + "btree", + table.blockTimestamp.asc().nullsLast(), + ), + idxEupTransactionfromChainid: index( + "idx_eup_transactionfrom_chainid", + ).using( + "btree", + table.transactionFrom.asc().nullsLast(), + table.chainId.asc().nullsLast(), + ), + }; + }, +); + +export const aggregateTracking = pgTable("aggregate_tracking", { + aggregateName: varchar("aggregate_name", { length: 100 }) + .primaryKey() + .notNull(), + lastProcessedTimestamp: timestamp("last_processed_timestamp", { + withTimezone: true, + mode: "date", + }) + .default(new Date("2023-01-01T00:00:00.000Z")) + .notNull(), +}); + +export const bundlers = pgTable("bundlers", { + name: varchar("name", { length: 50 }).notNull(), + address: varchar("address", { length: 42 }).primaryKey().notNull(), +}); + +export const chainMetadata = pgTable("chain_metadata", { + chainId: integer("chain_id").primaryKey().notNull(), + startBlock: integer("start_block").notNull(), + endBlock: integer("end_block"), + blockHeight: integer("block_height").notNull(), + firstEventBlockNumber: integer("first_event_block_number"), + latestProcessedBlock: integer("latest_processed_block"), + numEventsProcessed: integer("num_events_processed"), + isHyperSync: boolean("is_hyper_sync").notNull(), + numBatchesFetched: integer("num_batches_fetched").notNull(), + latestFetchedBlockNumber: integer("latest_fetched_block_number").notNull(), + timestampCaughtUpToHeadOrEndblock: timestamp( + "timestamp_caught_up_to_head_or_endblock", + { withTimezone: true, mode: "date" }, + ), +}); + +export const eventSyncState = pgTable("event_sync_state", { + chainId: integer("chain_id").primaryKey().notNull(), + blockNumber: integer("block_number").notNull(), + logIndex: integer("log_index").notNull(), + blockTimestamp: integer("block_timestamp").notNull(), + isPreRegisteringDynamicContracts: boolean( + "is_pre_registering_dynamic_contracts", + ).notNull(), +}); + +export const factories = pgTable("factories", { + name: varchar("name", { length: 50 }).notNull(), + address: varchar("address", { length: 42 }).primaryKey().notNull(), +}); + +export const paymasters = pgTable("paymasters", { + name: varchar("name", { length: 50 }).notNull(), + address: varchar("address", { length: 42 }).primaryKey().notNull(), + type: varchar("type").notNull(), +}); + +export const persistedState = pgTable("persisted_state", { + id: serial("id").primaryKey().notNull(), + envioVersion: text("envio_version").notNull(), + configHash: text("config_hash").notNull(), + schemaHash: text("schema_hash").notNull(), + handlerFilesHash: text("handler_files_hash").notNull(), + abiFilesHash: text("abi_files_hash").notNull(), +}); + +export const activeAccountsDailyMetrics = pgTable( + "active_accounts_daily_metrics", + { + date: date("date").notNull(), + chainId: integer("chain_id").notNull(), + uniqueActiveSenders: integer("unique_active_senders").notNull(), + }, + (table) => { + return { + activeAccountsDailyMetricsPkey: primaryKey({ + columns: [table.date, table.chainId], + name: "active_accounts_daily_metrics_pkey", + }), + }; + }, +); + +export const activeAccountsMonthlyMetrics = pgTable( + "active_accounts_monthly_metrics", + { + month: date("month").notNull(), + chainId: integer("chain_id").notNull(), + uniqueActiveSenders: integer("unique_active_senders").notNull(), + }, + (table) => { + return { + activeAccountsMonthlyMetricsPkey: primaryKey({ + columns: [table.month, table.chainId], + name: "active_accounts_monthly_metrics_pkey", + }), + }; + }, +); + +export const endOfBlockRangeScannedData = pgTable( + "end_of_block_range_scanned_data", + { + chainId: integer("chain_id").notNull(), + blockTimestamp: integer("block_timestamp").notNull(), + blockNumber: integer("block_number").notNull(), + blockHash: text("block_hash").notNull(), + }, + (table) => { + return { + endOfBlockRangeScannedDataPkey: primaryKey({ + columns: [table.chainId, table.blockNumber], + name: "end_of_block_range_scanned_data_pkey", + }), + }; + }, +); + +export const factoryHourlyMetrics = pgTable( + "factory_hourly_metrics", + { + hour: timestamp("hour", { withTimezone: true, mode: "date" }).notNull(), + factoryAddress: varchar("factory_address").notNull(), + chainId: integer("chain_id").notNull(), + totalAccountsDeployed: numeric("total_accounts_deployed").notNull(), + }, + (table) => { + return { + factoryHourlyMetricsPkey: primaryKey({ + columns: [table.hour, table.factoryAddress, table.chainId], + name: "factory_hourly_metrics_pkey", + }), + }; + }, +); + +export const bundlerHourlyMetrics = pgTable( + "bundler_hourly_metrics", + { + hour: timestamp("hour", { withTimezone: true, mode: "date" }).notNull(), + bundlerName: varchar("bundler_name").notNull(), + chainId: integer("chain_id").notNull(), + totalOperationCount: integer("total_operation_count").notNull(), + totalActualGasCost: numeric("total_actual_gas_cost").notNull(), + }, + (table) => { + return { + bundlerHourlyMetricsPkey: primaryKey({ + columns: [table.hour, table.bundlerName, table.chainId], + name: "bundler_hourly_metrics_pkey", + }), + }; + }, +); + +export const paymasterHourlyMetrics = pgTable( + "paymaster_hourly_metrics", + { + hour: timestamp("hour", { withTimezone: true, mode: "date" }).notNull(), + paymasterName: varchar("paymaster_name").notNull(), + chainId: integer("chain_id").notNull(), + totalSponsoredOperationCount: integer( + "total_sponsored_operation_count", + ).notNull(), + totalActualGasCost: numeric("total_actual_gas_cost").notNull(), + }, + (table) => { + return { + paymasterHourlyMetricsPkey: primaryKey({ + columns: [table.hour, table.paymasterName, table.chainId], + name: "paymaster_hourly_metrics_pkey", + }), + }; + }, +); + +export const paymasterHourlyMetricsNew = pgTable( + "paymaster_hourly_metrics_new", + { + hour: timestamp("hour", { withTimezone: true, mode: "date" }).notNull(), + paymasterAddress: varchar("paymaster_address").notNull(), + chainId: integer("chain_id").notNull(), + totalSponsoredOperationCount: integer( + "total_sponsored_operation_count", + ).notNull(), + totalActualGasCost: numeric("total_actual_gas_cost").notNull(), + }, + (table) => { + return { + paymasterHourlyMetricsNewPkey: primaryKey({ + columns: [table.hour, table.paymasterAddress, table.chainId], + name: "paymaster_hourly_metrics_new_pkey", + }), + }; + }, +); + +export const globalHourlyMetrics = pgTable( + "global_hourly_metrics", + { + hour: timestamp("hour", { withTimezone: true, mode: "date" }).notNull(), + chainId: integer("chain_id").notNull(), + entryPointAddress: varchar("entry_point_address").notNull(), + sponsored: boolean("sponsored").notNull(), + success: boolean("success").notNull(), + totalOperationCount: integer("total_operation_count").notNull(), + totalActualGasUsed: numeric("total_actual_gas_used").notNull(), + totalActualGasCost: numeric("total_actual_gas_cost").notNull(), + }, + (table) => { + return { + globalHourlyMetricsPkey: primaryKey({ + columns: [ + table.hour, + table.chainId, + table.entryPointAddress, + table.sponsored, + table.success, + ], + name: "global_hourly_metrics_pkey", + }), + }; + }, +); + +export const dynamicContractRegistry = pgTable( + "dynamic_contract_registry", + { + chainId: integer("chain_id").notNull(), + registeringEventBlockNumber: integer( + "registering_event_block_number", + ).notNull(), + registeringEventLogIndex: integer("registering_event_log_index").notNull(), + registeringEventBlockTimestamp: integer( + "registering_event_block_timestamp", + ).notNull(), + registeringEventContractName: text( + "registering_event_contract_name", + ).notNull(), + registeringEventName: text("registering_event_name").notNull(), + registeringEventSrcAddress: text("registering_event_src_address").notNull(), + contractAddress: text("contract_address").notNull(), + contractType: contractType("contract_type").notNull(), + }, + (table) => { + return { + dynamicContractRegistryPkey: primaryKey({ + columns: [table.chainId, table.contractAddress], + name: "dynamic_contract_registry_pkey", + }), + }; + }, +); + +export const entityHistoryFilter = pgTable( + "entity_history_filter", + { + entityId: text("entity_id").notNull(), + chainId: integer("chain_id").notNull(), + oldVal: jsonb("old_val"), + newVal: jsonb("new_val"), + blockNumber: integer("block_number").notNull(), + blockTimestamp: integer("block_timestamp").notNull(), + previousBlockNumber: integer("previous_block_number"), + logIndex: integer("log_index").notNull(), + previousLogIndex: integer("previous_log_index").notNull(), + entityType: entityType("entity_type").notNull(), + }, + (table) => { + return { + entityHistoryFilterPkey: primaryKey({ + columns: [ + table.entityId, + table.chainId, + table.blockNumber, + table.blockTimestamp, + table.logIndex, + table.previousLogIndex, + table.entityType, + ], + name: "entity_history_filter_pkey", + }), + }; + }, +); + +export const entityHistory = pgTable( + "entity_history", + { + entityId: text("entity_id").notNull(), + blockTimestamp: integer("block_timestamp").notNull(), + chainId: integer("chain_id").notNull(), + blockNumber: integer("block_number").notNull(), + logIndex: integer("log_index").notNull(), + entityType: entityType("entity_type").notNull(), + params: jsonb("params"), + previousBlockTimestamp: integer("previous_block_timestamp"), + previousChainId: integer("previous_chain_id"), + previousBlockNumber: integer("previous_block_number"), + previousLogIndex: integer("previous_log_index"), + }, + (table) => { + return { + entityTypeEntityIdBlockTimestamp: index( + "entity_history_entity_type_entity_id_block_timestamp", + ).using( + "btree", + table.entityType.asc().nullsLast(), + table.entityId.asc().nullsLast(), + table.blockTimestamp.asc().nullsLast(), + ), + entityHistoryPkey: primaryKey({ + columns: [ + table.entityId, + table.blockTimestamp, + table.chainId, + table.blockNumber, + table.logIndex, + table.entityType, + ], + name: "entity_history_pkey", + }), + }; + }, +); + +export const rawEvents = pgTable( + "raw_events", + { + chainId: integer("chain_id").notNull(), + eventId: numeric("event_id").notNull(), + eventName: text("event_name").notNull(), + contractName: text("contract_name").notNull(), + blockNumber: integer("block_number").notNull(), + logIndex: integer("log_index").notNull(), + srcAddress: text("src_address").notNull(), + blockHash: text("block_hash").notNull(), + blockTimestamp: integer("block_timestamp").notNull(), + blockFields: jsonb("block_fields").notNull(), + transactionFields: jsonb("transaction_fields").notNull(), + params: jsonb("params").notNull(), + dbWriteTimestamp: timestamp("db_write_timestamp", { + mode: "date", + }).default(sql`CURRENT_TIMESTAMP`), + }, + (table) => { + return { + rawEventsPkey: primaryKey({ + columns: [table.chainId, table.eventId], + name: "raw_events_pkey", + }), + }; + }, +); diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..3be0e40 --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,11 @@ +import "dotenv/config"; +import { defineConfig } from "drizzle-kit"; + +export default defineConfig({ + out: "./drizzle", + schema: "./db/schema.ts", + dialect: "postgresql", + dbCredentials: { + url: process.env.ENVIO_URL!, + }, +}); diff --git a/drizzle/0000_boring_hannibal_king.sql b/drizzle/0000_boring_hannibal_king.sql new file mode 100644 index 0000000..1cc0e03 --- /dev/null +++ b/drizzle/0000_boring_hannibal_king.sql @@ -0,0 +1,246 @@ +-- Current sql file was generated after introspecting the database +-- If you want to run this migration please uncomment this code before executing migrations +/* +DO $$ BEGIN + CREATE TYPE "public"."contract_type" AS ENUM('EntryPointV06', 'EntryPointV07'); +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + CREATE TYPE "public"."entity_type" AS ENUM('EntryPoint_AccountDeployed', 'EntryPoint_UserOperationEvent'); +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "EntryPoint_AccountDeployed" ( + "blockHash" text NOT NULL, + "blockNumber" numeric NOT NULL, + "blockTimestamp" timestamp with time zone NOT NULL, + "chainId" integer NOT NULL, + "factory" text NOT NULL, + "id" text PRIMARY KEY NOT NULL, + "paymaster" text NOT NULL, + "sender" text NOT NULL, + "transactionHash" text NOT NULL, + "db_write_timestamp" timestamp DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "EntryPoint_UserOperationEvent" ( + "actualGasCost" numeric NOT NULL, + "actualGasUsed" numeric NOT NULL, + "blockHash" text NOT NULL, + "blockNumber" numeric NOT NULL, + "blockTimestamp" timestamp with time zone NOT NULL, + "chainId" integer NOT NULL, + "entryPoint" text NOT NULL, + "id" text PRIMARY KEY NOT NULL, + "logIndex" integer NOT NULL, + "nonce" numeric NOT NULL, + "paymaster" text NOT NULL, + "sender" text NOT NULL, + "success" boolean NOT NULL, + "transactionFrom" text NOT NULL, + "transactionHash" text NOT NULL, + "transactionIndex" integer NOT NULL, + "db_write_timestamp" timestamp DEFAULT CURRENT_TIMESTAMP +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "aggregate_tracking" ( + "aggregate_name" varchar(100) PRIMARY KEY NOT NULL, + "last_processed_timestamp" timestamp with time zone DEFAULT '2023-01-01 00:00:00+00' NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "bundlers" ( + "name" varchar(50) NOT NULL, + "address" varchar(42) PRIMARY KEY NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "chain_metadata" ( + "chain_id" integer PRIMARY KEY NOT NULL, + "start_block" integer NOT NULL, + "end_block" integer, + "block_height" integer NOT NULL, + "first_event_block_number" integer, + "latest_processed_block" integer, + "num_events_processed" integer, + "is_hyper_sync" boolean NOT NULL, + "num_batches_fetched" integer NOT NULL, + "latest_fetched_block_number" integer NOT NULL, + "timestamp_caught_up_to_head_or_endblock" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "event_sync_state" ( + "chain_id" integer PRIMARY KEY NOT NULL, + "block_number" integer NOT NULL, + "log_index" integer NOT NULL, + "block_timestamp" integer NOT NULL, + "is_pre_registering_dynamic_contracts" boolean NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "factories" ( + "name" varchar(50) NOT NULL, + "address" varchar(42) PRIMARY KEY NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "paymasters" ( + "name" varchar(50) NOT NULL, + "address" varchar(42) PRIMARY KEY NOT NULL, + "type" varchar NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "persisted_state" ( + "id" serial PRIMARY KEY NOT NULL, + "envio_version" text NOT NULL, + "config_hash" text NOT NULL, + "schema_hash" text NOT NULL, + "handler_files_hash" text NOT NULL, + "abi_files_hash" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "active_accounts_daily_metrics" ( + "date" date NOT NULL, + "chain_id" integer NOT NULL, + "unique_active_senders" integer NOT NULL, + CONSTRAINT "active_accounts_daily_metrics_pkey" PRIMARY KEY("date","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "active_accounts_monthly_metrics" ( + "month" date NOT NULL, + "chain_id" integer NOT NULL, + "unique_active_senders" integer NOT NULL, + CONSTRAINT "active_accounts_monthly_metrics_pkey" PRIMARY KEY("month","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "end_of_block_range_scanned_data" ( + "chain_id" integer NOT NULL, + "block_timestamp" integer NOT NULL, + "block_number" integer NOT NULL, + "block_hash" text NOT NULL, + CONSTRAINT "end_of_block_range_scanned_data_pkey" PRIMARY KEY("chain_id","block_number") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "factory_hourly_metrics" ( + "hour" timestamp with time zone NOT NULL, + "factory_address" varchar NOT NULL, + "chain_id" integer NOT NULL, + "total_accounts_deployed" numeric NOT NULL, + CONSTRAINT "factory_hourly_metrics_pkey" PRIMARY KEY("hour","factory_address","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "bundler_hourly_metrics" ( + "hour" timestamp with time zone NOT NULL, + "bundler_name" varchar NOT NULL, + "chain_id" integer NOT NULL, + "total_operation_count" integer NOT NULL, + "total_actual_gas_cost" numeric NOT NULL, + CONSTRAINT "bundler_hourly_metrics_pkey" PRIMARY KEY("hour","bundler_name","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "paymaster_hourly_metrics" ( + "hour" timestamp with time zone NOT NULL, + "paymaster_name" varchar NOT NULL, + "chain_id" integer NOT NULL, + "total_sponsored_operation_count" integer NOT NULL, + "total_actual_gas_cost" numeric NOT NULL, + CONSTRAINT "paymaster_hourly_metrics_pkey" PRIMARY KEY("hour","paymaster_name","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "paymaster_hourly_metrics_new" ( + "hour" timestamp with time zone NOT NULL, + "paymaster_address" varchar NOT NULL, + "chain_id" integer NOT NULL, + "total_sponsored_operation_count" integer NOT NULL, + "total_actual_gas_cost" numeric NOT NULL, + CONSTRAINT "paymaster_hourly_metrics_new_pkey" PRIMARY KEY("hour","paymaster_address","chain_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "global_hourly_metrics" ( + "hour" timestamp with time zone NOT NULL, + "chain_id" integer NOT NULL, + "entry_point_address" varchar NOT NULL, + "sponsored" boolean NOT NULL, + "success" boolean NOT NULL, + "total_operation_count" integer NOT NULL, + "total_actual_gas_used" numeric NOT NULL, + "total_actual_gas_cost" numeric NOT NULL, + CONSTRAINT "global_hourly_metrics_pkey" PRIMARY KEY("hour","chain_id","entry_point_address","sponsored","success") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "dynamic_contract_registry" ( + "chain_id" integer NOT NULL, + "registering_event_block_number" integer NOT NULL, + "registering_event_log_index" integer NOT NULL, + "registering_event_block_timestamp" integer NOT NULL, + "registering_event_contract_name" text NOT NULL, + "registering_event_name" text NOT NULL, + "registering_event_src_address" text NOT NULL, + "contract_address" text NOT NULL, + "contract_type" "contract_type" NOT NULL, + CONSTRAINT "dynamic_contract_registry_pkey" PRIMARY KEY("chain_id","contract_address") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "entity_history_filter" ( + "entity_id" text NOT NULL, + "chain_id" integer NOT NULL, + "old_val" jsonb, + "new_val" jsonb, + "block_number" integer NOT NULL, + "block_timestamp" integer NOT NULL, + "previous_block_number" integer, + "log_index" integer NOT NULL, + "previous_log_index" integer NOT NULL, + "entity_type" "entity_type" NOT NULL, + CONSTRAINT "entity_history_filter_pkey" PRIMARY KEY("entity_id","chain_id","block_number","block_timestamp","log_index","previous_log_index","entity_type") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "entity_history" ( + "entity_id" text NOT NULL, + "block_timestamp" integer NOT NULL, + "chain_id" integer NOT NULL, + "block_number" integer NOT NULL, + "log_index" integer NOT NULL, + "entity_type" "entity_type" NOT NULL, + "params" jsonb, + "previous_block_timestamp" integer, + "previous_chain_id" integer, + "previous_block_number" integer, + "previous_log_index" integer, + CONSTRAINT "entity_history_pkey" PRIMARY KEY("entity_id","block_timestamp","chain_id","block_number","log_index","entity_type") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "raw_events" ( + "chain_id" integer NOT NULL, + "event_id" numeric NOT NULL, + "event_name" text NOT NULL, + "contract_name" text NOT NULL, + "block_number" integer NOT NULL, + "log_index" integer NOT NULL, + "src_address" text NOT NULL, + "block_hash" text NOT NULL, + "block_timestamp" integer NOT NULL, + "block_fields" jsonb NOT NULL, + "transaction_fields" jsonb NOT NULL, + "params" jsonb NOT NULL, + "db_write_timestamp" timestamp DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "raw_events_pkey" PRIMARY KEY("chain_id","event_id") +); +--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_AccountDeployed_blockTimestamp" ON "EntryPoint_AccountDeployed" USING btree ("blockTimestamp");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_AccountDeployed_chainId" ON "EntryPoint_AccountDeployed" USING btree ("chainId");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_AccountDeployed_factory" ON "EntryPoint_AccountDeployed" USING btree ("factory");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_AccountDeployed_paymaster" ON "EntryPoint_AccountDeployed" USING btree ("paymaster");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_AccountDeployed_transactionHash" ON "EntryPoint_AccountDeployed" USING btree ("transactionHash");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "idx_accountdeployed_sender_chainid" ON "EntryPoint_AccountDeployed" USING btree ("sender","chainId","factory");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_blockTimestamp" ON "EntryPoint_UserOperationEvent" USING btree ("blockTimestamp");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_chainId" ON "EntryPoint_UserOperationEvent" USING btree ("chainId");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_entryPoint" ON "EntryPoint_UserOperationEvent" USING btree ("entryPoint");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_paymaster" ON "EntryPoint_UserOperationEvent" USING btree ("paymaster");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_sender" ON "EntryPoint_UserOperationEvent" USING btree ("sender");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_success" ON "EntryPoint_UserOperationEvent" USING btree ("success");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_transactionFrom" ON "EntryPoint_UserOperationEvent" USING btree ("transactionFrom");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "EntryPoint_UserOperationEvent_transactionHash" ON "EntryPoint_UserOperationEvent" USING btree ("transactionHash");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "idx_eup_blocktimestamp" ON "EntryPoint_UserOperationEvent" USING btree ("blockTimestamp");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "idx_eup_transactionfrom_chainid" ON "EntryPoint_UserOperationEvent" USING btree ("transactionFrom","chainId");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "entity_history_entity_type_entity_id_block_timestamp" ON "entity_history" USING btree ("entity_type","entity_id","block_timestamp"); +*/ \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..737a47a --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,1503 @@ +{ + "id": "00000000-0000-0000-0000-000000000000", + "prevId": "", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.EntryPoint_AccountDeployed": { + "name": "EntryPoint_AccountDeployed", + "schema": "", + "columns": { + "blockHash": { + "name": "blockHash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blockNumber": { + "name": "blockNumber", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "blockTimestamp": { + "name": "blockTimestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "chainId": { + "name": "chainId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "factory": { + "name": "factory", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "paymaster": { + "name": "paymaster", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sender": { + "name": "sender", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transactionHash": { + "name": "transactionHash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "db_write_timestamp": { + "name": "db_write_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "EntryPoint_AccountDeployed_blockTimestamp": { + "name": "EntryPoint_AccountDeployed_blockTimestamp", + "columns": [ + { + "expression": "blockTimestamp", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_AccountDeployed_chainId": { + "name": "EntryPoint_AccountDeployed_chainId", + "columns": [ + { + "expression": "chainId", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_AccountDeployed_factory": { + "name": "EntryPoint_AccountDeployed_factory", + "columns": [ + { + "expression": "factory", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_AccountDeployed_paymaster": { + "name": "EntryPoint_AccountDeployed_paymaster", + "columns": [ + { + "expression": "paymaster", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_AccountDeployed_transactionHash": { + "name": "EntryPoint_AccountDeployed_transactionHash", + "columns": [ + { + "expression": "transactionHash", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_accountdeployed_sender_chainid": { + "name": "idx_accountdeployed_sender_chainid", + "columns": [ + { + "expression": "sender", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "chainId", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "factory", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.EntryPoint_UserOperationEvent": { + "name": "EntryPoint_UserOperationEvent", + "schema": "", + "columns": { + "actualGasCost": { + "name": "actualGasCost", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "actualGasUsed": { + "name": "actualGasUsed", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "blockHash": { + "name": "blockHash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blockNumber": { + "name": "blockNumber", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "blockTimestamp": { + "name": "blockTimestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "chainId": { + "name": "chainId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entryPoint": { + "name": "entryPoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "logIndex": { + "name": "logIndex", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "nonce": { + "name": "nonce", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "paymaster": { + "name": "paymaster", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sender": { + "name": "sender", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "transactionFrom": { + "name": "transactionFrom", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transactionHash": { + "name": "transactionHash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "transactionIndex": { + "name": "transactionIndex", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "db_write_timestamp": { + "name": "db_write_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "EntryPoint_UserOperationEvent_blockTimestamp": { + "name": "EntryPoint_UserOperationEvent_blockTimestamp", + "columns": [ + { + "expression": "blockTimestamp", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_chainId": { + "name": "EntryPoint_UserOperationEvent_chainId", + "columns": [ + { + "expression": "chainId", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_entryPoint": { + "name": "EntryPoint_UserOperationEvent_entryPoint", + "columns": [ + { + "expression": "entryPoint", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_paymaster": { + "name": "EntryPoint_UserOperationEvent_paymaster", + "columns": [ + { + "expression": "paymaster", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_sender": { + "name": "EntryPoint_UserOperationEvent_sender", + "columns": [ + { + "expression": "sender", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_success": { + "name": "EntryPoint_UserOperationEvent_success", + "columns": [ + { + "expression": "success", + "asc": true, + "nulls": "last", + "opclass": "bool_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_transactionFrom": { + "name": "EntryPoint_UserOperationEvent_transactionFrom", + "columns": [ + { + "expression": "transactionFrom", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "EntryPoint_UserOperationEvent_transactionHash": { + "name": "EntryPoint_UserOperationEvent_transactionHash", + "columns": [ + { + "expression": "transactionHash", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_eup_blocktimestamp": { + "name": "idx_eup_blocktimestamp", + "columns": [ + { + "expression": "blockTimestamp", + "asc": true, + "nulls": "last", + "opclass": "timestamptz_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_eup_transactionfrom_chainid": { + "name": "idx_eup_transactionfrom_chainid", + "columns": [ + { + "expression": "transactionFrom", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "chainId", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.aggregate_tracking": { + "name": "aggregate_tracking", + "schema": "", + "columns": { + "aggregate_name": { + "name": "aggregate_name", + "type": "varchar(100)", + "primaryKey": true, + "notNull": true + }, + "last_processed_timestamp": { + "name": "last_processed_timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "'2023-01-01 00:00:00+00'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.bundlers": { + "name": "bundlers", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(42)", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.chain_metadata": { + "name": "chain_metadata", + "schema": "", + "columns": { + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "start_block": { + "name": "start_block", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_block": { + "name": "end_block", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "block_height": { + "name": "block_height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "first_event_block_number": { + "name": "first_event_block_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "latest_processed_block": { + "name": "latest_processed_block", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "num_events_processed": { + "name": "num_events_processed", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_hyper_sync": { + "name": "is_hyper_sync", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "num_batches_fetched": { + "name": "num_batches_fetched", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "latest_fetched_block_number": { + "name": "latest_fetched_block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "timestamp_caught_up_to_head_or_endblock": { + "name": "timestamp_caught_up_to_head_or_endblock", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.event_sync_state": { + "name": "event_sync_state", + "schema": "", + "columns": { + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "block_number": { + "name": "block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "log_index": { + "name": "log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_timestamp": { + "name": "block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_pre_registering_dynamic_contracts": { + "name": "is_pre_registering_dynamic_contracts", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.factories": { + "name": "factories", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(42)", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.paymasters": { + "name": "paymasters", + "schema": "", + "columns": { + "name": { + "name": "name", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(42)", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.persisted_state": { + "name": "persisted_state", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "envio_version": { + "name": "envio_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "config_hash": { + "name": "config_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema_hash": { + "name": "schema_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handler_files_hash": { + "name": "handler_files_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "abi_files_hash": { + "name": "abi_files_hash", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.active_accounts_daily_metrics": { + "name": "active_accounts_daily_metrics", + "schema": "", + "columns": { + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "unique_active_senders": { + "name": "unique_active_senders", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "active_accounts_daily_metrics_pkey": { + "name": "active_accounts_daily_metrics_pkey", + "columns": [ + "date", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.active_accounts_monthly_metrics": { + "name": "active_accounts_monthly_metrics", + "schema": "", + "columns": { + "month": { + "name": "month", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "unique_active_senders": { + "name": "unique_active_senders", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "active_accounts_monthly_metrics_pkey": { + "name": "active_accounts_monthly_metrics_pkey", + "columns": [ + "month", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.end_of_block_range_scanned_data": { + "name": "end_of_block_range_scanned_data", + "schema": "", + "columns": { + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_timestamp": { + "name": "block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_number": { + "name": "block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_hash": { + "name": "block_hash", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "end_of_block_range_scanned_data_pkey": { + "name": "end_of_block_range_scanned_data_pkey", + "columns": [ + "chain_id", + "block_number" + ] + } + }, + "uniqueConstraints": {} + }, + "public.factory_hourly_metrics": { + "name": "factory_hourly_metrics", + "schema": "", + "columns": { + "hour": { + "name": "hour", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "factory_address": { + "name": "factory_address", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_accounts_deployed": { + "name": "total_accounts_deployed", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "factory_hourly_metrics_pkey": { + "name": "factory_hourly_metrics_pkey", + "columns": [ + "hour", + "factory_address", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.bundler_hourly_metrics": { + "name": "bundler_hourly_metrics", + "schema": "", + "columns": { + "hour": { + "name": "hour", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "bundler_name": { + "name": "bundler_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_operation_count": { + "name": "total_operation_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_actual_gas_cost": { + "name": "total_actual_gas_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "bundler_hourly_metrics_pkey": { + "name": "bundler_hourly_metrics_pkey", + "columns": [ + "hour", + "bundler_name", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.paymaster_hourly_metrics": { + "name": "paymaster_hourly_metrics", + "schema": "", + "columns": { + "hour": { + "name": "hour", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "paymaster_name": { + "name": "paymaster_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_sponsored_operation_count": { + "name": "total_sponsored_operation_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_actual_gas_cost": { + "name": "total_actual_gas_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "paymaster_hourly_metrics_pkey": { + "name": "paymaster_hourly_metrics_pkey", + "columns": [ + "hour", + "paymaster_name", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.paymaster_hourly_metrics_new": { + "name": "paymaster_hourly_metrics_new", + "schema": "", + "columns": { + "hour": { + "name": "hour", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "paymaster_address": { + "name": "paymaster_address", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_sponsored_operation_count": { + "name": "total_sponsored_operation_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_actual_gas_cost": { + "name": "total_actual_gas_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "paymaster_hourly_metrics_new_pkey": { + "name": "paymaster_hourly_metrics_new_pkey", + "columns": [ + "hour", + "paymaster_address", + "chain_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.global_hourly_metrics": { + "name": "global_hourly_metrics", + "schema": "", + "columns": { + "hour": { + "name": "hour", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entry_point_address": { + "name": "entry_point_address", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "sponsored": { + "name": "sponsored", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "total_operation_count": { + "name": "total_operation_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_actual_gas_used": { + "name": "total_actual_gas_used", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "total_actual_gas_cost": { + "name": "total_actual_gas_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "global_hourly_metrics_pkey": { + "name": "global_hourly_metrics_pkey", + "columns": [ + "hour", + "chain_id", + "entry_point_address", + "sponsored", + "success" + ] + } + }, + "uniqueConstraints": {} + }, + "public.dynamic_contract_registry": { + "name": "dynamic_contract_registry", + "schema": "", + "columns": { + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "registering_event_block_number": { + "name": "registering_event_block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "registering_event_log_index": { + "name": "registering_event_log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "registering_event_block_timestamp": { + "name": "registering_event_block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "registering_event_contract_name": { + "name": "registering_event_contract_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registering_event_name": { + "name": "registering_event_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "registering_event_src_address": { + "name": "registering_event_src_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_address": { + "name": "contract_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_type": { + "name": "contract_type", + "type": "contract_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "dynamic_contract_registry_pkey": { + "name": "dynamic_contract_registry_pkey", + "columns": [ + "chain_id", + "contract_address" + ] + } + }, + "uniqueConstraints": {} + }, + "public.entity_history_filter": { + "name": "entity_history_filter", + "schema": "", + "columns": { + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "old_val": { + "name": "old_val", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_val": { + "name": "new_val", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "block_number": { + "name": "block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_timestamp": { + "name": "block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "previous_block_number": { + "name": "previous_block_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "log_index": { + "name": "log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "previous_log_index": { + "name": "previous_log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "entity_history_filter_pkey": { + "name": "entity_history_filter_pkey", + "columns": [ + "entity_id", + "chain_id", + "block_number", + "block_timestamp", + "log_index", + "previous_log_index", + "entity_type" + ] + } + }, + "uniqueConstraints": {} + }, + "public.entity_history": { + "name": "entity_history", + "schema": "", + "columns": { + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_timestamp": { + "name": "block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_number": { + "name": "block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "log_index": { + "name": "log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "previous_block_timestamp": { + "name": "previous_block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "previous_chain_id": { + "name": "previous_chain_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "previous_block_number": { + "name": "previous_block_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "previous_log_index": { + "name": "previous_log_index", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "entity_history_entity_type_entity_id_block_timestamp": { + "name": "entity_history_entity_type_entity_id_block_timestamp", + "columns": [ + { + "expression": "entity_type", + "asc": true, + "nulls": "last", + "opclass": "text_ops", + "isExpression": false + }, + { + "expression": "entity_id", + "asc": true, + "nulls": "last", + "opclass": "enum_ops", + "isExpression": false + }, + { + "expression": "block_timestamp", + "asc": true, + "nulls": "last", + "opclass": "int4_ops", + "isExpression": false + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "entity_history_pkey": { + "name": "entity_history_pkey", + "columns": [ + "entity_id", + "block_timestamp", + "chain_id", + "block_number", + "log_index", + "entity_type" + ] + } + }, + "uniqueConstraints": {} + }, + "public.raw_events": { + "name": "raw_events", + "schema": "", + "columns": { + "chain_id": { + "name": "chain_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "event_name": { + "name": "event_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contract_name": { + "name": "contract_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_number": { + "name": "block_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "log_index": { + "name": "log_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "src_address": { + "name": "src_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_hash": { + "name": "block_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_timestamp": { + "name": "block_timestamp", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "block_fields": { + "name": "block_fields", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "transaction_fields": { + "name": "transaction_fields", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "params": { + "name": "params", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "db_write_timestamp": { + "name": "db_write_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "raw_events_pkey": { + "name": "raw_events_pkey", + "columns": [ + "chain_id", + "event_id" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": { + "public.contract_type": { + "name": "contract_type", + "values": [ + "EntryPointV06", + "EntryPointV07" + ], + "schema": "public" + }, + "public.entity_type": { + "name": "entity_type", + "values": [ + "EntryPoint_AccountDeployed", + "EntryPoint_UserOperationEvent" + ], + "schema": "public" + } + }, + "schemas": {}, + "sequences": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..d1db15a --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1735752959178, + "tag": "0000_boring_hannibal_king", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 3c3ad87..b1bb10e 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,12 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "date-fns": "^4.1.0", + "dotenv": "^16.4.7", "drizzle-orm": "^0.33.0", "geist": "^1.3.0", "lucide-react": "^0.460.0", "next": "^15.0.1", - "postgres": "^3.4.4", + "postgres": "^3.4.5", "react": "^18.3.1", "react-dom": "^18.3.1", "recharts": "^2.13.3", @@ -61,7 +62,7 @@ "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^8.1.0", "@typescript-eslint/parser": "^8.1.0", - "drizzle-kit": "^0.24.0", + "drizzle-kit": "^0.24.2", "eslint": "^8.57.0", "eslint-config-next": "^15.0.1", "eslint-plugin-drizzle": "^0.2.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6a9f5a0..a392005 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ importers: date-fns: specifier: ^4.1.0 version: 4.1.0 + dotenv: + specifier: ^16.4.7 + version: 16.4.7 drizzle-orm: specifier: ^0.33.0 version: 0.33.0(@types/react@18.3.12)(postgres@3.4.5)(react@18.3.1) @@ -75,7 +78,7 @@ importers: specifier: ^15.0.1 version: 15.0.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) postgres: - specifier: ^3.4.4 + specifier: ^3.4.5 version: 3.4.5 react: specifier: ^18.3.1 @@ -124,7 +127,7 @@ importers: specifier: ^8.1.0 version: 8.15.0(eslint@8.57.1)(typescript@5.7.2) drizzle-kit: - specifier: ^0.24.0 + specifier: ^0.24.2 version: 0.24.2 eslint: specifier: ^8.57.0 @@ -1614,6 +1617,10 @@ packages: dom-helpers@5.2.1: resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==} + dotenv@16.4.7: + resolution: {integrity: sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==} + engines: {node: '>=12'} + drizzle-kit@0.24.2: resolution: {integrity: sha512-nXOaTSFiuIaTMhS8WJC2d4EBeIcN9OSt2A2cyFbQYBAZbi7lRsVGJNqDpEwPqYfJz38yxbY/UtbvBBahBfnExQ==} hasBin: true @@ -4240,6 +4247,8 @@ snapshots: '@babel/runtime': 7.26.0 csstype: 3.1.3 + dotenv@16.4.7: {} + drizzle-kit@0.24.2: dependencies: '@drizzle-team/brocli': 0.10.2 diff --git a/src/app/(dashboard)/[slug].js/page.tsx b/src/app/(dashboard)/[slug].js/page.tsx new file mode 100644 index 0000000..629195b --- /dev/null +++ b/src/app/(dashboard)/[slug].js/page.tsx @@ -0,0 +1,88 @@ +"use client"; + +import { api } from "@/trpc/react"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; + +export default function AddressBookPage() { + const bundlers = api.addressBook.getBundlers.useQuery(); + const paymasters = api.addressBook.getPaymasters.useQuery(); + const factories = api.addressBook.getFactories.useQuery(); + + return ( +
+

Address Book

+
+

Factories

+ + + + Address + Factory + + + + {factories.data?.map((factory) => ( + + + {factory.address} + + {factory.name} + + ))} + +
+
+
+

Paymasters

+ + + + Address + Provider + Type + + + + {paymasters.data?.map((paymaster) => ( + + + {paymaster.address} + + {paymaster.name} + {paymaster.type} + + ))} + +
+
+
+

Bundlers

+ + + + Address + Provider + + + + {bundlers.data?.map((bundler) => ( + + + {bundler.address} + + {bundler.name} + + ))} + +
+
+
+ ); +} diff --git a/src/server/db/index.ts b/src/server/db/index.ts index 323580f..c894b14 100644 --- a/src/server/db/index.ts +++ b/src/server/db/index.ts @@ -1,3 +1,4 @@ +import envioSchema from "../../../db"; import { drizzle } from "drizzle-orm/postgres-js"; import { env } from "@/env"; @@ -7,4 +8,5 @@ const envioClient = postgres(env.ENVIO_URL, { prepare: false }); export const envioDb = drizzle(envioClient, { logger: process.env.NODE_ENV === "development", + schema: { ...envioSchema }, });