diff --git a/frontend/pages/api/auth/[...nextauth].ts b/frontend/pages/api/auth/[...nextauth].ts deleted file mode 100644 index 90df93dd..00000000 --- a/frontend/pages/api/auth/[...nextauth].ts +++ /dev/null @@ -1,69 +0,0 @@ -/*import NextAuth, { NextAuthOptions, Session } from 'next-auth' -import DiscordProvider from 'next-auth/providers/discord' -import { hashDiscordUserId } from 'utils/hashDiscord' - -const DISCORD_HASH_SALT = Buffer.from( - new Uint8Array(JSON.parse(process.env.DISCORD_HASH_SALT!)) -) - -export const authOptions: NextAuthOptions = { - // Configure one or more authentication providers - providers: [ - DiscordProvider({ - // @ts-ignore this should not be undefined - clientId: process.env.DISCORD_ID, - // @ts-ignore this should not be undefined - clientSecret: process.env.DISCORD_SECRET, - authorization: 'https://discord.com/api/oauth2/authorize?scope=identify', - profile(profile) { - if (profile.avatar === null) { - const defaultAvatarNumber = parseInt(profile.discriminator) % 5 - profile.image_url = `https://cdn.discordapp.com/embed/avatars/${defaultAvatarNumber}.png` - } else { - const format = profile.avatar.startsWith('a_') ? 'gif' : 'png' - profile.image_url = `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.${format}` - } - return { - id: profile.id, - name: profile.username, - image: profile.image_url, - hashedUserId: hashDiscordUserId(DISCORD_HASH_SALT, profile.id), - } - }, - httpOptions: { - // Receiving error on Discord when the default timeout - 3500ms is used - timeout: 5000, - }, - }), - // ...add more providers here - ], - callbacks: { - async jwt({ token, user }) { - // as per next auth docs - // The arguments user, account, profile and isNewUser are only passed the first time this - // callback is called on a new session, after the user signs in. In subsequent calls, only token will be available. - if (user !== undefined) { - token.hashedUserId = user.hashedUserId - } - return token - }, - async session({ - session, - token, - }: { - session: Session - token: any - }): Promise { - return { - user: { - ...session.user, - hashedUserId: token.hashedUserId, - }, - expires: session.expires, - } - }, - }, -} - -export default NextAuth(authOptions) -*/ \ No newline at end of file diff --git a/frontend/pages/api/grant/v1/amount_and_proof.ts b/frontend/pages/api/grant/v1/amount_and_proof.ts deleted file mode 100644 index 991468fc..00000000 --- a/frontend/pages/api/grant/v1/amount_and_proof.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -import type { NextApiRequest, NextApiResponse } from 'next' -import { Pool } from 'pg' - -// NOTE: This uses the PG* environment variables by default to configure the connection. -const pool = new Pool() - -/** - * This endpoint returns the amount of tokens allocated to a specific identity - */ -/* -export default async function handlerAmountAndProof( - req: NextApiRequest, - res: NextApiResponse -) { - const { ecosystem, identity } = req.query - if ( - ecosystem === undefined || - identity === undefined || - identity instanceof Array || - ecosystem instanceof Array - ) { - res.status(400).json({ - error: "Must provide the 'ecosystem' and 'identity' query parameters", - }) - return - } - - try { - const result = await pool.query( - 'SELECT amount, proof_of_inclusion FROM claims WHERE ecosystem = $1 AND identity = $2', - [ecosystem, lowerCapIfEvm(identity, ecosystem)] - ) - if (result.rows.length == 0) { - res.status(404).json({ - error: `No result found for ${ecosystem} identity ${identity}`, - }) - } else { - res.status(200).json({ - amount: result.rows[0].amount, - proof: (result.rows[0].proof_of_inclusion as Buffer).toString('hex'), - }) - } - } catch (error) { - res.status(500).json({ - error: `An unexpected error occurred`, - }) - } -} - -function lowerCapIfEvm(identity: string, ecosystem: string): string { - if (ecosystem === 'evm') { - return identity.toLowerCase() - } - return identity -} -*/ \ No newline at end of file diff --git a/frontend/pages/api/grant/v1/discord_signed_message.ts b/frontend/pages/api/grant/v1/discord_signed_message.ts deleted file mode 100644 index 80b18854..00000000 --- a/frontend/pages/api/grant/v1/discord_signed_message.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -import type { NextApiRequest, NextApiResponse } from 'next' -import { getServerSession } from 'next-auth/next' -import { authOptions } from '../../auth/[...nextauth]' -import { Keypair, PublicKey } from '@solana/web3.js' -import { signDiscordMessage } from '../../../../claim_sdk/ecosystems/solana' - -const dispenserGuard = Keypair.fromSecretKey( - Uint8Array.from(JSON.parse(process.env.DISPENSER_GUARD!)) -) - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - if (typeof req.query.publicKey !== 'string') { - res.status(400).json({ - error: "Must provide the 'publicKey' query parameter", - }) - return - } - - try { - new PublicKey(req.query.publicKey) - } catch { - res.status(400).json({ - error: "Invalid 'publicKey' query parameter", - }) - return - } - - const claimant = new PublicKey(req.query.publicKey) // The claimant's public key, it will receive the tokens - const session = await getServerSession(req, res, authOptions) - - if (session && session.user && session.user.hashedUserId) { - const signedMessage = signDiscordMessage( - session.user.hashedUserId, - claimant, - dispenserGuard - ) - - res.status(200).json({ - signature: Buffer.from(signedMessage.signature).toString('hex'), - publicKey: Buffer.from(signedMessage.publicKey).toString('hex'), // The dispenser guard's public key - fullMessage: Buffer.from(signedMessage.fullMessage).toString('hex'), - }) - } else { - res.status(403).json({ - error: 'You must be logged in with Discord to access this endpoint', - }) - } -} -*/ diff --git a/frontend/pages/api/grant/v1/evm_breakdown.ts b/frontend/pages/api/grant/v1/evm_breakdown.ts deleted file mode 100644 index 37e5a9e6..00000000 --- a/frontend/pages/api/grant/v1/evm_breakdown.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -import type { NextApiRequest, NextApiResponse } from 'next' -import { Pool } from 'pg' - -// NOTE: This uses the PG* environment variables by default to configure the connection. -const pool = new Pool() - -/** - * This endpoint returns the breakdown by chain for the evm allocation of a given evm identity. - */ -/* -export default async function handlerEvmBreakdown( - req: NextApiRequest, - res: NextApiResponse -) { - const { identity } = req.query - if (identity === undefined || identity instanceof Array) { - res.status(400).json({ - error: "Must provide the 'identity' query parameter", - }) - return - } - - try { - const result = await pool.query( - 'SELECT chain, amount FROM evm_breakdowns WHERE identity = $1', - [identity.toLowerCase()] - ) - if (result.rows.length == 0) { - res.status(404).json({ - error: `No result found for identity ${identity}`, - }) - } else { - res.status(200).json(result.rows) - } - } catch (error) { - res.status(500).json({ - error: `An unexpected error occurred.`, - }) - } -} -*/ diff --git a/frontend/pages/api/grant/v1/fund_transaction.ts b/frontend/pages/api/grant/v1/fund_transaction.ts deleted file mode 100644 index dd57dd7b..00000000 --- a/frontend/pages/api/grant/v1/fund_transaction.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* -import NodeWallet from '@coral-xyz/anchor/dist/cjs/nodewallet' -import { loadFunderWallet } from '../../../../claim_sdk/testWallets' -import { - ComputeBudgetProgram, - Ed25519Program, - Keypair, - PublicKey, - Secp256k1Program, - VersionedTransaction, -} from '@solana/web3.js' -import type { NextApiRequest, NextApiResponse } from 'next' -import { checkTransactions } from '../../../../utils/verifyTransaction' - -const wallet = process.env.FUNDER_KEYPAIR - ? new NodeWallet( - Keypair.fromSecretKey( - Uint8Array.from(JSON.parse(process.env.FUNDER_KEYPAIR)) - ) - ) - : loadFunderWallet() - -const PROGRAM_ID = new PublicKey(process.env.PROGRAM_ID!) - -const WHITELISTED_PROGRAMS: PublicKey[] = [ - PROGRAM_ID, - Secp256k1Program.programId, - Ed25519Program.programId, - ComputeBudgetProgram.programId, -] - -export default async function handlerFundTransaction( - req: NextApiRequest, - res: NextApiResponse -) { - if (req.method !== 'POST') { - return res.status(405).end() - } - - const data = req.body - let transactions: VersionedTransaction[] = [] - let signedTransactions: VersionedTransaction[] = [] - - if (data.length >= 10) { - return res.status(400).json({ - error: 'Too many transactions', - }) - } - - try { - transactions = data.map((serializedTx: any) => { - return VersionedTransaction.deserialize(Buffer.from(serializedTx)) - }) - } catch { - return res.status(400).json({ - error: 'Failed to deserialize transactions', - }) - } - - if (checkTransactions(transactions, PROGRAM_ID, WHITELISTED_PROGRAMS)) { - try { - signedTransactions = await wallet.signAllTransactions(transactions) - } catch { - return res.status(400).json({ - error: - 'Failed to sign transactions, make sure the transactions have the right funder', - }) - } - - return res.status(200).json( - signedTransactions.map((tx) => { - return Buffer.from(tx.serialize()) - }) - ) - } else { - return res.status(403).json({ error: 'Unauthorized transaction' }) - } -} -*/ \ No newline at end of file diff --git a/frontend/pages/api/grant/v1/solana_breakdown.ts b/frontend/pages/api/grant/v1/solana_breakdown.ts deleted file mode 100644 index 9d4d478d..00000000 --- a/frontend/pages/api/grant/v1/solana_breakdown.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -import type { NextApiRequest, NextApiResponse } from 'next' -import { Pool } from 'pg' - -// NOTE: This uses the PG* environment variables by default to configure the connection. -const pool = new Pool() - -/** - * This endpoint returns the breakdown for the solana allocation of a given solana identity. - */ -/* -export default async function handlerSolanaBreakdown( - req: NextApiRequest, - res: NextApiResponse -) { - const { identity } = req.query - if (identity === undefined) { - res.status(400).json({ - error: "Must provide the 'identity' query parameter", - }) - return - } - - try { - const result = await pool.query( - 'SELECT source, amount FROM solana_breakdowns WHERE identity = $1', - [identity] - ) - if (result.rows.length == 0) { - res.status(404).json({ - error: `No result found for identity ${identity}`, - }) - } else { - res.status(200).json(result.rows) - } - } catch (error) { - res.status(500).json({ - error: `An unexpected error occurred.`, - }) - } -} -*/ \ No newline at end of file