diff --git a/packages/nextjs/app/submit-grant/_actions/index.ts b/packages/nextjs/app/submit-grant/_actions/index.ts index 4a1da3c..434020a 100644 --- a/packages/nextjs/app/submit-grant/_actions/index.ts +++ b/packages/nextjs/app/submit-grant/_actions/index.ts @@ -4,23 +4,24 @@ import { verifyMessage } from "viem"; import { createGrant } from "~~/services/database/grants"; import { findUserByAddress } from "~~/services/database/users"; -type SignedMessage = { - message?: string; +type SignatureAndSigner = { signature?: `0x${string}`; address?: string; }; -export const submitGrantAction = async ({ message, signature, address }: SignedMessage, form: FormData) => { +export const submitGrantAction = async ({ signature, address }: SignatureAndSigner, form: FormData) => { try { const formData = Object.fromEntries(form.entries()); if (!formData.title || !formData.description || !formData.askAmount) { throw new Error("Invalid form data"); } - if (!message || !signature || !address) { - throw new Error("Invalid message, signature, or address."); + + if (!signature || !address) { + throw new Error("Signature and address are required to submit grant"); } - const isMessageValid = await verifyMessage({ message, signature, address }); + const constructedMessage = JSON.stringify(formData); + const isMessageValid = await verifyMessage({ message: constructedMessage, signature, address }); if (!isMessageValid) { throw new Error("Invalid signature"); } diff --git a/packages/nextjs/app/submit-grant/_component/Form.tsx b/packages/nextjs/app/submit-grant/_component/Form.tsx index 1f58798..6ca879f 100644 --- a/packages/nextjs/app/submit-grant/_component/Form.tsx +++ b/packages/nextjs/app/submit-grant/_component/Form.tsx @@ -25,7 +25,6 @@ const Form = () => { const signedMessageObject = { signature: signature, address: connectedAddress, - message: JSON.stringify(formState), }; // server action