Skip to content

Commit

Permalink
feat: add supabase and rework reward parser
Browse files Browse the repository at this point in the history
  • Loading branch information
EtherealGlow committed Jan 18, 2024
1 parent acffea5 commit f1ed4a7
Show file tree
Hide file tree
Showing 18 changed files with 830 additions and 56 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"dependencies": {
"@octokit/types": "^12.4.0",
"@sinclair/typebox": "^0.32.3",
"@supabase/supabase-js": "^2.39.3",
"dotenv": "^16.3.1",
"json": "^11.0.0",
"json2csv": "^6.0.0-alpha.2",
"octokit": "^3.1.2",
"supabase": "^1.131.5",
"xlsx": "^0.18.5"
},
"devDependencies": {
Expand Down
20 changes: 20 additions & 0 deletions src/adapters/supabase/helpers/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createClient, SupabaseClient } from "@supabase/supabase-js";
import { getAdapters } from ".";
import { Database } from "../types";

/**
* @dev Creates a typescript client which will be used to interact with supabase platform
*
* @param url - The supabase project url
* @param key - The supabase project key
* @returns - The supabase client
*/
export const supabase = (url: string, key: string): SupabaseClient => {
return createClient<Database>(url, key, { auth: { persistSession: false } });
};

export const getUserFromWalletAddr = async (wallet: string): Promise<string | undefined> => {
const { supabase } = getAdapters();
const { data } = await supabase.from("wallets").select("user_name").eq("wallet_address", wallet).single();
return data?.user_name;
};
10 changes: 10 additions & 0 deletions src/adapters/supabase/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export * from "./client";
import { supabase } from "./client";
import { config } from "dotenv";
config();

export const getAdapters = () => {
return {
supabase: supabase(process.env.SUPABASE_URL ?? "", process.env.SUPABASE_KEY ?? ""),
};
};
Loading

0 comments on commit f1ed4a7

Please sign in to comment.