11import { NextResponse } from "next/server" ;
2+ // APPLICATIONS DISABLED - These imports are kept for when applications re-open
3+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24import { recoverTypedDataAddress } from "viem" ;
5+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36import { createGrant } from "~~/services/database/grants" ;
7+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48import { EIP_712_DOMAIN , EIP_712_TYPES__APPLY_FOR_GRANT } from "~~/utils/eip712" ;
9+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
510import { REQUIRED_CHALLENGE_COUNT , fetchAcceptedChallengeCount } from "~~/utils/eligibility-criteria" ;
611
12+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
713type ReqBody = {
814 title ?: string ;
915 description ?: string ;
@@ -13,49 +19,55 @@ type ReqBody = {
1319} ;
1420
1521// Hardcoded default ask amount
22+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1623const askAmount = 0.08 ;
1724// TODO: We could also add extra validation of nonce
25+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1826export async function POST ( req : Request ) {
19- try {
20- const { title , description , signature , signer } = ( await req . json ( ) ) as ReqBody ;
27+ // APPLICATIONS DISABLED - Remove this return to re-enable grant submissions
28+ return NextResponse . json ( { error : "Grant applications are currently closed" } , { status : 403 } ) ;
2129
22- if ( ! title || ! description || ! signature || ! signer || description . length > 750 || title . length > 75 ) {
23- return NextResponse . json ( { error : "Invalid form details submitted" } , { status : 400 } ) ;
24- }
25-
26- // Legacy BG builder presence check removed. All eligibility is now based on the new SpeedRunEthereum system. If needed we could try do some kind of ROLE validation and make sure OG BuidlGuidl members that that certain ROLE in new SRE database.
27- const completed = await fetchAcceptedChallengeCount ( signer ) ;
28- if ( completed < REQUIRED_CHALLENGE_COUNT ) {
29- return NextResponse . json (
30- {
31- error : `Only builders with at least ${ REQUIRED_CHALLENGE_COUNT } accepted SpeedRun Ethereum challenges can submit for grants` ,
32- } ,
33- { status : 401 } ,
34- ) ;
35- }
36-
37- const recoveredAddress = await recoverTypedDataAddress ( {
38- domain : EIP_712_DOMAIN ,
39- types : EIP_712_TYPES__APPLY_FOR_GRANT ,
40- primaryType : "Message" ,
41- message : { title, description } ,
42- signature : signature ,
43- } ) ;
44-
45- if ( recoveredAddress !== signer ) {
46- return NextResponse . json ( { error : "Recovered address did not match signer" } , { status : 401 } ) ;
47- }
48-
49- const grant = await createGrant ( {
50- title : title ,
51- description : description ,
52- askAmount : askAmount ,
53- builder : signer ,
54- } ) ;
55-
56- return NextResponse . json ( { grant } , { status : 201 } ) ;
57- } catch ( e ) {
58- console . error ( e ) ;
59- return NextResponse . json ( { error : "Error processing form" } , { status : 500 } ) ;
60- }
30+ // ORIGINAL CODE - Uncomment below and remove the return above to re-enable:
31+ // try {
32+ // const { title, description, signature, signer } = (await req.json()) as ReqBody;
33+ //
34+ // if (!title || !description || !signature || !signer || description.length > 750 || title.length > 75) {
35+ // return NextResponse.json({ error: "Invalid form details submitted" }, { status: 400 });
36+ // }
37+ //
38+ // // Legacy BG builder presence check removed. All eligibility is now based on the new SpeedRunEthereum system. If needed we could try do some kind of ROLE validation and make sure OG BuidlGuidl members that that certain ROLE in new SRE database.
39+ // const completed = await fetchAcceptedChallengeCount(signer);
40+ // if (completed < REQUIRED_CHALLENGE_COUNT) {
41+ // return NextResponse.json(
42+ // {
43+ // error: `Only builders with at least ${REQUIRED_CHALLENGE_COUNT} accepted SpeedRun Ethereum challenges can submit for grants`,
44+ // },
45+ // { status: 401 },
46+ // );
47+ // }
48+ //
49+ // const recoveredAddress = await recoverTypedDataAddress({
50+ // domain: EIP_712_DOMAIN,
51+ // types: EIP_712_TYPES__APPLY_FOR_GRANT,
52+ // primaryType: "Message",
53+ // message: { title, description },
54+ // signature: signature,
55+ // });
56+ //
57+ // if (recoveredAddress !== signer) {
58+ // return NextResponse.json({ error: "Recovered address did not match signer" }, { status: 401 });
59+ // }
60+ //
61+ // const grant = await createGrant({
62+ // title: title,
63+ // description: description,
64+ // askAmount: askAmount,
65+ // builder: signer,
66+ // });
67+ //
68+ // return NextResponse.json({ grant }, { status: 201 });
69+ // } catch (e) {
70+ // console.error(e);
71+ // return NextResponse.json({ error: "Error processing form" }, { status: 500 });
72+ // }
6173}
0 commit comments