Skip to content

Commit b799786

Browse files
committed
refactor(web): account abstraction for verifymessage
1 parent bdc9403 commit b799786

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

web/netlify/functions/update-settings.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { verifyMessage } from "viem";
1+
import { createPublicClient, http } from "viem";
22
import { createClient } from "@supabase/supabase-js";
3+
import { arbitrumGoerli } from "viem/chains";
4+
5+
const publicClient = createPublicClient({
6+
chain: arbitrumGoerli,
7+
transport: http(),
8+
});
39

410
const SUPABASE_KEY = process.env.SUPABASE_CLIENT_API_KEY;
511
const SUPABASE_URL = process.env.SUPABASE_URL;
612
const supabase = createClient(SUPABASE_URL!, SUPABASE_KEY!);
13+
714
export const uploadSettingsToSupabase = async function (event: any, context: any) {
815
try {
916
const { message, address, signature } = JSON.parse(event.body);
1017
const email = message.split("Email:").pop().split(",Nonce:")[0].trim();
1118
const nonce = message.split("Nonce:").pop().trim();
12-
const isValid = await verifyMessage({ address, message: message, signature });
19+
const isValid = await publicClient.verifyMessage({ address, message: message, signature });
1320
// If the recovered address does not match the provided address, return an error
1421
if (!isValid) {
1522
throw new Error("Signature verification failed");

0 commit comments

Comments
 (0)