From 7bf774153cac5c6e1bcfef7d46e50b16718a66d4 Mon Sep 17 00:00:00 2001 From: Pablo Alayeto <55535804+Pabl0cks@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:26:14 +0100 Subject: [PATCH 1/4] Delete askAmount from eip712 sign --- packages/nextjs/app/api/grants/new/route.ts | 2 +- packages/nextjs/app/apply/_component/Form.tsx | 1 - packages/nextjs/utils/eip712.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/nextjs/app/api/grants/new/route.ts b/packages/nextjs/app/api/grants/new/route.ts index 31dbb8cc..caf55c2a 100644 --- a/packages/nextjs/app/api/grants/new/route.ts +++ b/packages/nextjs/app/api/grants/new/route.ts @@ -36,7 +36,7 @@ export async function POST(req: Request) { domain: EIP_712_DOMAIN, types: EIP_712_TYPES__APPLY_FOR_GRANT, primaryType: "Message", - message: { title, description, askAmount }, + message: { title, description }, signature: signature, }); diff --git a/packages/nextjs/app/apply/_component/Form.tsx b/packages/nextjs/app/apply/_component/Form.tsx index cce4e2d9..686ace21 100644 --- a/packages/nextjs/app/apply/_component/Form.tsx +++ b/packages/nextjs/app/apply/_component/Form.tsx @@ -45,7 +45,6 @@ const Form = () => { message: { title: title, description: description, - askAmount: askAmount, }, }); diff --git a/packages/nextjs/utils/eip712.ts b/packages/nextjs/utils/eip712.ts index 7d03877c..e80261a5 100644 --- a/packages/nextjs/utils/eip712.ts +++ b/packages/nextjs/utils/eip712.ts @@ -10,7 +10,6 @@ export const EIP_712_TYPES__APPLY_FOR_GRANT = { Message: [ { name: "title", type: "string" }, { name: "description", type: "string" }, - { name: "askAmount", type: "string" }, ], } as const; From 7acbafff65c8bcf55cbb6d426d11956a425d97c3 Mon Sep 17 00:00:00 2001 From: Pablo Alayeto <55535804+Pabl0cks@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:30:11 +0100 Subject: [PATCH 2/4] Remove chainId so it can be signed from any chain --- packages/nextjs/utils/eip712.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/nextjs/utils/eip712.ts b/packages/nextjs/utils/eip712.ts index e80261a5..86f1e3df 100644 --- a/packages/nextjs/utils/eip712.ts +++ b/packages/nextjs/utils/eip712.ts @@ -1,9 +1,6 @@ -import scaffoldConfig from "~~/scaffold.config"; - export const EIP_712_DOMAIN = { name: "BuidlGuidl Grants", version: "1", - chainId: scaffoldConfig.targetNetworks[0].id, } as const; export const EIP_712_TYPES__APPLY_FOR_GRANT = { From 97cf56498081e42ff9ca1be9f5594e2ab480d55b Mon Sep 17 00:00:00 2001 From: Pablo Alayeto <55535804+Pabl0cks@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:35:32 +0100 Subject: [PATCH 3/4] Hide ETH amount if grant status is Proposed --- packages/nextjs/app/my-grants/page.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/app/my-grants/page.tsx b/packages/nextjs/app/my-grants/page.tsx index 19565aad..070a5f44 100644 --- a/packages/nextjs/app/my-grants/page.tsx +++ b/packages/nextjs/app/my-grants/page.tsx @@ -40,12 +40,14 @@ const MyGrants: NextPage = () => { {grant.title} ({grant.id}) -
- ETH Icon - - {grant.askAmount} ETH - -
+ {grant.status !== PROPOSAL_STATUS.PROPOSED && ( +
+ ETH Icon + + {grant.askAmount} ETH + +
+ )}

{grant.description}

{grant.status}

{grant.status === PROPOSAL_STATUS.APPROVED && ( From 346ad39a2906e5ef90f6107eb8ba19107a9b0388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez?= Date: Fri, 22 Mar 2024 17:02:42 +0100 Subject: [PATCH 4/4] Hardcode askAmount in the backend --- packages/nextjs/app/api/grants/new/route.ts | 15 ++++++--------- packages/nextjs/app/apply/_component/Form.tsx | 6 ++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/nextjs/app/api/grants/new/route.ts b/packages/nextjs/app/api/grants/new/route.ts index caf55c2a..3cdd18f1 100644 --- a/packages/nextjs/app/api/grants/new/route.ts +++ b/packages/nextjs/app/api/grants/new/route.ts @@ -12,20 +12,17 @@ type ReqBody = { signer?: string; }; -// TODO: We could also add extra validtion of nonce +// Hardcoded default ask amount +const askAmount = 0.25; +// TODO: We could also add extra validation of nonce export async function POST(req: Request) { try { - const { title, description, askAmount, signature, signer } = (await req.json()) as ReqBody; + const { title, description, signature, signer } = (await req.json()) as ReqBody; - if (!title || !description || !askAmount || isNaN(Number(askAmount)) || !signature || !signer) { + if (!title || !description || !signature || !signer) { return NextResponse.json({ error: "Invalid form details submited" }, { status: 400 }); } - // Check to see if the askAmount === 0.25 - if (Number(askAmount) !== 0.25) { - return NextResponse.json({ error: "Invalid askAmount" }, { status: 400 }); - } - // Verif if the builder is present const builder = await findUserByAddress(signer); if (!builder.exists) { @@ -47,7 +44,7 @@ export async function POST(req: Request) { const grant = await createGrant({ title: title, description: description, - askAmount: Number(askAmount), + askAmount: askAmount, builder: signer, }); diff --git a/packages/nextjs/app/apply/_component/Form.tsx b/packages/nextjs/app/apply/_component/Form.tsx index 686ace21..2205abf8 100644 --- a/packages/nextjs/app/apply/_component/Form.tsx +++ b/packages/nextjs/app/apply/_component/Form.tsx @@ -12,7 +12,6 @@ import { postMutationFetcher } from "~~/utils/swr"; type ReqBody = { title?: string; description?: string; - askAmount?: string; signature?: `0x${string}`; signer?: string; }; @@ -32,8 +31,7 @@ const Form = () => { try { const title = formData.get("title") as string; const description = formData.get("description") as string; - const askAmount = "0.25"; - if (!title || !description || !askAmount) { + if (!title || !description) { notification.error("Please fill all the fields"); return; } @@ -48,7 +46,7 @@ const Form = () => { }, }); - await postNewGrant({ title, description, askAmount, signature, signer: connectedAddress }); + await postNewGrant({ title, description, signature, signer: connectedAddress }); notification.success("Proposal submitted successfully!"); router.push("/");