Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes from Austin's test feedback on apply process #90

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions packages/nextjs/app/api/grants/new/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -36,7 +33,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,
});

Expand All @@ -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,
});

Expand Down
7 changes: 2 additions & 5 deletions packages/nextjs/app/apply/_component/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { postMutationFetcher } from "~~/utils/swr";
type ReqBody = {
title?: string;
description?: string;
askAmount?: string;
signature?: `0x${string}`;
signer?: string;
};
Expand All @@ -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;
}
Expand All @@ -45,11 +43,10 @@ const Form = () => {
message: {
title: title,
description: description,
askAmount: askAmount,
},
});

await postNewGrant({ title, description, askAmount, signature, signer: connectedAddress });
await postNewGrant({ title, description, signature, signer: connectedAddress });

notification.success("Proposal submitted successfully!");
router.push("/");
Expand Down
14 changes: 8 additions & 6 deletions packages/nextjs/app/my-grants/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ const MyGrants: NextPage = () => {
{grant.title}
<span className="text-sm text-gray-500 ml-2">({grant.id})</span>
</h3>
<div className="flex mb-2 items-center">
<Image src="/assets/eth-completed-grant.png" alt="ETH Icon" width={10} height={10} />
<span className="ml-1 tooltip" data-tip="Total amount of the grant">
{grant.askAmount} ETH
</span>
</div>
{grant.status !== PROPOSAL_STATUS.PROPOSED && (
<div className="flex mb-2 items-center">
<Image src="/assets/eth-completed-grant.png" alt="ETH Icon" width={10} height={10} />
<span className="ml-1 tooltip" data-tip="Total amount of the grant">
{grant.askAmount} ETH
</span>
</div>
)}
<p className="m-0">{grant.description}</p>
<p className={`badge ${badgeBgColor[grant.status]}`}>{grant.status}</p>
{grant.status === PROPOSAL_STATUS.APPROVED && (
Expand Down
4 changes: 0 additions & 4 deletions packages/nextjs/utils/eip712.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
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 = {
Message: [
{ name: "title", type: "string" },
{ name: "description", type: "string" },
{ name: "askAmount", type: "string" },
],
} as const;

Expand Down
Loading