generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add supabase and rework reward parser
- Loading branch information
1 parent
acffea5
commit f1ed4a7
Showing
18 changed files
with
830 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ?? ""), | ||
}; | ||
}; |
Oops, something went wrong.