Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #63

Open
wants to merge 129 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
f8cef40
add backend packages
alireza-sharifpour Oct 7, 2024
0c0df50
add base schema
alireza-sharifpour Oct 8, 2024
9a10a3b
update schema and add cascade
alireza-sharifpour Oct 9, 2024
683dff0
add migrate script
alireza-sharifpour Oct 9, 2024
84dc303
add deployment script
alireza-sharifpour Oct 10, 2024
7c36e80
update migrate and schema location
alireza-sharifpour Oct 10, 2024
3d40706
update gitignore
alireza-sharifpour Oct 10, 2024
e68a03e
add drizzle.config.ts file
alireza-sharifpour Oct 10, 2024
6930abb
add scripts and packages
alireza-sharifpour Oct 13, 2024
d18bd13
write start-database.sh file for creating docker container for the pr…
alireza-sharifpour Oct 13, 2024
acdf0e0
update layour with TRPC configs
alireza-sharifpour Oct 13, 2024
f1a57e5
validation for env files
alireza-sharifpour Oct 13, 2024
66f821e
add validation
alireza-sharifpour Oct 13, 2024
b3cacf8
add route.ts for handling trpc in FE
alireza-sharifpour Oct 13, 2024
ab87e8b
add root.ts for combining trpc routers
alireza-sharifpour Oct 13, 2024
eb0fe16
update root.ts
alireza-sharifpour Oct 13, 2024
a0ab721
add server.ts to handle ssr
alireza-sharifpour Oct 13, 2024
b0a87db
add hydrate to hydrate state
alireza-sharifpour Oct 13, 2024
295d8c4
add trpc.ts
alireza-sharifpour Oct 13, 2024
86dd3a0
add graph.ts to handle graph CRUD operation
alireza-sharifpour Oct 13, 2024
ac52bdc
add db configs
alireza-sharifpour Oct 13, 2024
ce2ea39
add react query configs
alireza-sharifpour Oct 13, 2024
74b4abf
add react.tsx file
alireza-sharifpour Oct 13, 2024
c0ca09b
add populate_db.ts file
alireza-sharifpour Oct 14, 2024
6655aa2
update populate file
alireza-sharifpour Oct 14, 2024
172891b
fix tec_holder error
alireza-sharifpour Oct 14, 2024
a906ae5
add specialNodes and LowerCase
alireza-sharifpour Oct 14, 2024
c096b94
fix types
alireza-sharifpour Oct 14, 2024
cb42532
add populate script and ts-node configs
alireza-sharifpour Oct 14, 2024
1727456
update tsconfig file
alireza-sharifpour Oct 14, 2024
365ac04
update types
alireza-sharifpour Oct 14, 2024
2ddfcca
update migrate db
alireza-sharifpour Oct 16, 2024
e40bb99
fix some of populate_db errors
alireza-sharifpour Oct 16, 2024
e71fdd5
add isSpecial field and remove some references.
alireza-sharifpour Oct 16, 2024
63a209c
add isSpecial and fix type
alireza-sharifpour Oct 16, 2024
c3ab65f
add test route
alireza-sharifpour Oct 16, 2024
b34e187
handle duplicate in adding TEC Holder Links
alireza-sharifpour Oct 16, 2024
1998059
add removeDuplicateTecHolderLinks script
alireza-sharifpour Oct 16, 2024
3d68cd2
add inserting regenscore
alireza-sharifpour Oct 16, 2024
4483c1c
add removeDuplicateRegenScoreLinks fn
alireza-sharifpour Oct 16, 2024
bdbeed8
checking for duplicate links for regenScore links
alireza-sharifpour Oct 16, 2024
5099fbf
add trustedSeed data
alireza-sharifpour Oct 16, 2024
f1a8f56
remove reference from trustedSeeds
alireza-sharifpour Oct 16, 2024
55c70fb
fix not adding trusted_seeds data
alireza-sharifpour Oct 16, 2024
f3bcba3
add check for trusted_seeds nodes
alireza-sharifpour Oct 16, 2024
504a6d6
update schema
alireza-sharifpour Oct 16, 2024
5bb8d79
check for duplicates on farcaster connections
alireza-sharifpour Oct 16, 2024
e7539b8
fix badgeHolders error
alireza-sharifpour Oct 16, 2024
89a90a9
fix adding regen poap duplicates
alireza-sharifpour Oct 16, 2024
b1b39d4
check for duplicate transactions and don't add them
alireza-sharifpour Oct 16, 2024
56cd6c6
generalize removing duplicates
alireza-sharifpour Oct 16, 2024
ea4c70f
remove unused file
alireza-sharifpour Oct 20, 2024
f77d8df
update type
alireza-sharifpour Oct 21, 2024
21cca57
update tsconfig for dom
alireza-sharifpour Oct 21, 2024
6e0232d
read graphdata from trpc BE
alireza-sharifpour Oct 21, 2024
72a0fb8
add rq devtools
alireza-sharifpour Oct 22, 2024
9881e1d
add nodeId state
alireza-sharifpour Oct 22, 2024
5bae3aa
update RightSidebar to read data from BE.
alireza-sharifpour Oct 22, 2024
91fe059
update BadgeHolderReferralInfo type
alireza-sharifpour Oct 22, 2024
9f84cb3
update useFarcasterData to use backend
alireza-sharifpour Oct 22, 2024
8b568c7
add new routers
alireza-sharifpour Oct 22, 2024
14214bb
add trpc badgeHolder router
alireza-sharifpour Oct 22, 2024
f174bc9
add farcasterRouter
alireza-sharifpour Oct 22, 2024
ff5b069
add nodeRouter
alireza-sharifpour Oct 22, 2024
2614765
add react query devtools
alireza-sharifpour Oct 22, 2024
f957662
fix special nodes not showing issue
alireza-sharifpour Oct 22, 2024
9bca6a1
remove unused
alireza-sharifpour Oct 26, 2024
360f097
add scripts and packages
alireza-sharifpour Oct 26, 2024
c5d4c7d
update env
alireza-sharifpour Oct 26, 2024
24efc62
comment useGraph
alireza-sharifpour Oct 26, 2024
cb9101f
add updateFarcasterData script
alireza-sharifpour Oct 26, 2024
429b966
add airstackService.ts
alireza-sharifpour Oct 26, 2024
ce7d0dd
handle adding followings data
alireza-sharifpour Oct 26, 2024
2218092
add remove duplicate script to scripts
alireza-sharifpour Oct 26, 2024
e0c2806
update drizzle config
alireza-sharifpour Oct 27, 2024
97d183c
update scripts
alireza-sharifpour Oct 28, 2024
46198e3
add db related drizzle metadata
alireza-sharifpour Oct 28, 2024
e4288f2
add fixNodeTypes script
alireza-sharifpour Oct 28, 2024
bde9127
add migrate.ts
alireza-sharifpour Oct 28, 2024
d749c02
add migrateDelegates script
alireza-sharifpour Oct 28, 2024
006890d
move to scripts folder
alireza-sharifpour Oct 28, 2024
c2838ef
add removeDuplicateLinks.ts
alireza-sharifpour Oct 28, 2024
5172672
add removeDuplicates.ts
alireza-sharifpour Oct 28, 2024
4f59761
update graphPage.tsx
alireza-sharifpour Oct 28, 2024
eb2da43
add new types
alireza-sharifpour Oct 28, 2024
b14cb3a
update schema with new data
alireza-sharifpour Oct 28, 2024
962958b
update airstackService to include delegates nodes
alireza-sharifpour Oct 28, 2024
a034ed8
comment importing env.js
alireza-sharifpour Oct 28, 2024
a8ec2b6
update git ignore
alireza-sharifpour Oct 29, 2024
67fe2fb
update drizzle config
alireza-sharifpour Oct 29, 2024
19f555b
add vercel postgres
alireza-sharifpour Oct 29, 2024
8471654
update env.js
alireza-sharifpour Oct 29, 2024
e05c7e4
add connection for production db
alireza-sharifpour Oct 29, 2024
5ff74a3
conditionally do ssl for db
alireza-sharifpour Oct 30, 2024
eaf1dc5
Merge pull request #61 from GeneralMagicio/add-backend-db
alireza-sharifpour Oct 30, 2024
6a9573e
add remove duplicate badge holders script
alireza-sharifpour Oct 30, 2024
d8da696
update git ignore
alireza-sharifpour Oct 31, 2024
56db882
add remove badgeHolders script and json
alireza-sharifpour Oct 31, 2024
5971d0d
filter using types
alireza-sharifpour Oct 31, 2024
018481a
filter types in backend
alireza-sharifpour Oct 31, 2024
bb092ab
update graphSidebar and add new filters
alireza-sharifpour Oct 31, 2024
96cb38d
remove test
alireza-sharifpour Oct 31, 2024
a78e32e
remove log
alireza-sharifpour Nov 3, 2024
d48620b
feat(Migrate data to BE): Add community roles section and reorganize …
alireza-sharifpour Nov 3, 2024
e6142df
feat(Migrate data to BE): update types
alireza-sharifpour Nov 3, 2024
4048c3e
add AGORA_API_KEY
alireza-sharifpour Nov 19, 2024
b9a70e9
update git ignore
alireza-sharifpour Nov 19, 2024
e799620
add backup scripts
alireza-sharifpour Nov 19, 2024
7cc0293
remove nodeType
alireza-sharifpour Nov 19, 2024
8d98564
update search fn
alireza-sharifpour Nov 19, 2024
ed33165
update graph
alireza-sharifpour Nov 19, 2024
f65f217
remove type field
alireza-sharifpour Nov 19, 2024
da90d17
add delegates script
alireza-sharifpour Nov 20, 2024
bc18d87
add migration data
alireza-sharifpour Nov 20, 2024
424cd45
export DelegateData type
alireza-sharifpour Nov 20, 2024
f2671fe
add migrateDelegatesAgora
alireza-sharifpour Nov 20, 2024
257ee3d
add delegates type
alireza-sharifpour Nov 20, 2024
ccb4a79
update type
alireza-sharifpour Nov 20, 2024
c9d0fc8
update schema
alireza-sharifpour Nov 20, 2024
01468a1
add delegateService
alireza-sharifpour Nov 20, 2024
c5bc35e
update where condition
alireza-sharifpour Nov 20, 2024
ace3373
add updateNodesEns.ts file
alireza-sharifpour Nov 21, 2024
48a1a2f
fix graph label issue
alireza-sharifpour Nov 21, 2024
dc77714
add env and update package
alireza-sharifpour Nov 21, 2024
7146fcc
update type
alireza-sharifpour Nov 22, 2024
dff11af
feat delegates: improve nodeRadious
alireza-sharifpour Nov 22, 2024
0bb53b9
Merge pull request #67 from GeneralMagicio/feat-add-delegates
alireza-sharifpour Nov 23, 2024
0282e3f
update git ignore
alireza-sharifpour Nov 24, 2024
c3fba8d
add script to show Delegate with highest and lowest voting power
alireza-sharifpour Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ yarn-error.log*

# local env files
.env*.local
.env
.env.production

# vercel
.vercel
Expand All @@ -35,4 +37,12 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

.cursorrules
.cursorrules
instructions.md

# Database backups
*.sql
backup-*.sql
backup-*.sql.gz
backups/
commands.md
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instructions.md
19 changes: 19 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Config } from "drizzle-kit";
import { env } from "@/env";

export default {
schema: "./src/server/db/schema.ts",
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
url: env.DATABASE_URL,
// ssl: true,
// password: env.POSTGRES_PASSWORD,
// user: env.POSTGRES_USER,
// host: env.POSTGRES_HOST,
// database: env.POSTGRES_DATABASE,
// port: env.POSTGRES_PORT
},
verbose: true,
strict: true
} satisfies Config;
211 changes: 211 additions & 0 deletions drizzle/0000_safe_ken_ellis.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
DO $$ BEGIN
CREATE TYPE "public"."link_type" AS ENUM('FarcasterConnection', 'BadgeHolderReferral', 'RegenPOAP', 'RegenScore', 'TrustedSeed', 'CitizenTransaction', 'TECHolder');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
CREATE TYPE "public"."node_type" AS ENUM('Citizen', 'TECHolder', 'RegenScore', 'TrustedSeed', 'RegenPOAP', 'Delegate');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "badge_holders" (
"id" serial PRIMARY KEY NOT NULL,
"attester" text NOT NULL,
"recipient" text NOT NULL,
"rpgf_round" text NOT NULL,
"referred_by" text,
"referred_method" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "farcaster_connections" (
"id" serial PRIMARY KEY NOT NULL,
"source_id" text,
"target_id" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "links" (
"id" serial PRIMARY KEY NOT NULL,
"source_id" text,
"target_id" text,
"type" "link_type" NOT NULL,
"data" jsonb,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "networks" (
"id" serial PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"description" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "networks_name_unique" UNIQUE("name")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "nodes" (
"id" text PRIMARY KEY NOT NULL,
"network_id" integer,
"type" "node_type" NOT NULL,
"node_types" text[] DEFAULT '{}' NOT NULL,
"ens" text,
"user_id" text,
"identity" text,
"profile_image" text,
"profile_name" text,
"profile_display_name" text,
"profile_bio" text,
"user_address" text,
"chain_id" text,
"tec_balance" text,
"regen_score" integer,
"trusted_seed" boolean,
"regen_poap" boolean,
"has_farcaster" boolean,
"is_special" boolean,
"ens_address" text,
"farcaster_url" text,
"twitter_url" text,
"roles" text,
"ambassador_of" text,
"op_rewards_earned" text,
"is_delegate" boolean DEFAULT false,
"description" text,
"data" jsonb,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "regen_poaps" (
"id" serial PRIMARY KEY NOT NULL,
"node_id" text,
"collection" text NOT NULL,
"count" integer NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "regen_scores" (
"id" text PRIMARY KEY NOT NULL,
"score" integer NOT NULL,
"address" text NOT NULL,
"meta" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "tec_holders" (
"id" text PRIMARY KEY NOT NULL,
"balance" text NOT NULL,
"pending_balance_update" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "transactions" (
"id" serial PRIMARY KEY NOT NULL,
"network_id" integer,
"date" timestamp NOT NULL,
"from_id" text,
"to_id" text,
"token_name" text NOT NULL,
"token_symbol" text NOT NULL,
"value" text NOT NULL,
"hash" varchar(66) NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "trusted_seeds" (
"id" text PRIMARY KEY NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "badge_holders" ADD CONSTRAINT "badge_holders_recipient_nodes_id_fk" FOREIGN KEY ("recipient") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "badge_holders" ADD CONSTRAINT "badge_holders_referred_by_nodes_id_fk" FOREIGN KEY ("referred_by") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "farcaster_connections" ADD CONSTRAINT "farcaster_connections_source_id_nodes_id_fk" FOREIGN KEY ("source_id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "farcaster_connections" ADD CONSTRAINT "farcaster_connections_target_id_nodes_id_fk" FOREIGN KEY ("target_id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "links" ADD CONSTRAINT "links_source_id_nodes_id_fk" FOREIGN KEY ("source_id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "links" ADD CONSTRAINT "links_target_id_nodes_id_fk" FOREIGN KEY ("target_id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "nodes" ADD CONSTRAINT "nodes_network_id_networks_id_fk" FOREIGN KEY ("network_id") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "regen_poaps" ADD CONSTRAINT "regen_poaps_node_id_nodes_id_fk" FOREIGN KEY ("node_id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_network_id_networks_id_fk" FOREIGN KEY ("network_id") REFERENCES "public"."networks"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_from_id_nodes_id_fk" FOREIGN KEY ("from_id") REFERENCES "public"."nodes"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "transactions" ADD CONSTRAINT "transactions_to_id_nodes_id_fk" FOREIGN KEY ("to_id") REFERENCES "public"."nodes"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "trusted_seeds" ADD CONSTRAINT "trusted_seeds_id_nodes_id_fk" FOREIGN KEY ("id") REFERENCES "public"."nodes"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "farcaster_source_idx" ON "farcaster_connections" USING btree ("source_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "farcaster_target_idx" ON "farcaster_connections" USING btree ("target_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "link_source_idx" ON "links" USING btree ("source_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "link_target_idx" ON "links" USING btree ("target_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "link_type_idx" ON "links" USING btree ("type");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "node_network_idx" ON "nodes" USING btree ("network_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "node_type_idx" ON "nodes" USING btree ("type");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "transaction_network_idx" ON "transactions" USING btree ("network_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "transaction_from_idx" ON "transactions" USING btree ("from_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "transaction_to_idx" ON "transactions" USING btree ("to_id");
Loading