diff --git a/web/netlify/functions/authUser.ts b/web/netlify/functions/authUser.ts index c6faeea..2c6a3f6 100644 --- a/web/netlify/functions/authUser.ts +++ b/web/netlify/functions/authUser.ts @@ -9,6 +9,8 @@ import { ETH_SIGNATURE_REGEX } from "consts/index"; import { netlifyUri, netlifyDeployUri, netlifyDeployPrimeUri } from "src/generatedNetlifyInfo.json"; import { Database } from "src/types/supabase-notification"; +import { ethers } from "ethers"; +import { isProductionDeployment } from "consts/processEnvConst"; const authUser = async (event) => { try { @@ -74,9 +76,14 @@ const authUser = async (event) => { } try { - await siweMessage.verify({ signature, nonce: nonceData.nonce, time: new Date().toISOString() }); + // If the main Alchemy API key is permissioned, it won't work in a Netlify Function so we use a dedicated API key + const alchemyApiKey = process.env.ALCHEMY_FUNCTIONS_API_KEY ?? process.env.ALCHEMY_API_KEY; + const alchemyChain = isProductionDeployment() ? "arb-mainnet" : "arb-sepolia"; + const alchemyRpcURL = `https://${alchemyChain}.g.alchemy.com/v2/${alchemyApiKey}`; + const provider = new ethers.providers.JsonRpcProvider(alchemyRpcURL); + await siweMessage.verify({ signature, nonce: nonceData.nonce, time: new Date().toISOString() }, { provider }); } catch (err) { - throw new Error("Invalid signer"); + throw new Error("Invalid signer: " + JSON.stringify(err)); } const { error } = await supabase.from("user-nonce").delete().match({ address: lowerCaseAddress }); diff --git a/web/package.json b/web/package.json index be211dc..96bda6a 100644 --- a/web/package.json +++ b/web/package.json @@ -58,7 +58,7 @@ "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "@typescript-eslint/utils": "^5.62.0", - "@wagmi/cli": "^1.5.2", + "@wagmi/cli": "^2.1.15", "eslint": "^8.56.0", "eslint-config-prettier": "^8.10.0", "eslint-plugin-react": "^7.33.2", @@ -83,6 +83,7 @@ "@tanstack/react-query": "^4.28.0", "@web3modal/ethereum": "^2.7.1", "@web3modal/react": "^2.2.2", + "@web3modal/wagmi": "^5.1.6", "@yornaath/batshit": "^0.9.0", "amqplib": "^0.10.3", "chart.js": "^3.9.1", @@ -112,7 +113,7 @@ "siwe": "^2.3.2", "styled-components": "^5.3.11", "subgraph-status": "^1.2.3", - "viem": "^1.21.4", - "wagmi": "^1.4.13" + "viem": "^2.21.2", + "wagmi": "^2.12.8" } } diff --git a/web/src/app.tsx b/web/src/app.tsx index 84c48f8..5209134 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -7,7 +7,6 @@ import Web3Provider from "context/Web3Provider"; import IsListViewProvider from "context/IsListViewProvider"; import QueryClientProvider from "context/QueryClientProvider"; import StyledComponentsProvider from "context/StyledComponentsProvider"; -import RefetchOnBlock from "context/RefetchOnBlock"; import Layout from "layout/index"; import Home from "./pages/Home"; import AllLists from "./pages/AllLists"; @@ -21,10 +20,9 @@ import { SubmitListProvider } from "./context/SubmitListContext"; const App: React.FC = () => { return ( - - + - + @@ -47,9 +45,9 @@ const App: React.FC = () => { - + - + ); }; diff --git a/web/src/components/ActionButton/ExecuteButton.tsx b/web/src/components/ActionButton/ExecuteButton.tsx index b9464e0..3110621 100644 --- a/web/src/components/ActionButton/ExecuteButton.tsx +++ b/web/src/components/ActionButton/ExecuteButton.tsx @@ -2,9 +2,9 @@ import { Button } from "@kleros/ui-components-library"; import React, { useState } from "react"; import { Address } from "viem"; import { usePublicClient } from "wagmi"; -import { useCurateV2ExecuteRequest, usePrepareCurateV2ExecuteRequest } from "hooks/contracts/generated"; import { wrapWithToast } from "utils/wrapWithToast"; import { EnsureChain } from "../EnsureChain"; +import { useSimulateCurateV2ExecuteRequest, useWriteCurateV2ExecuteRequest } from "hooks/useContract"; interface IExecuteButton { registryAddress: Address; @@ -17,12 +17,11 @@ const ExecuteButton: React.FC = ({ registryAddress, itemId, refe const [isExecuting, setIsExecuting] = useState(false); const { - config, + data: config, isError, isLoading: isPreparingConfig, - //@ts-ignore - } = usePrepareCurateV2ExecuteRequest({ address: registryAddress, args: [itemId as `0x${string}`] }); - const { writeAsync: executeRequest, isLoading } = useCurateV2ExecuteRequest(config); + } = useSimulateCurateV2ExecuteRequest({ address: registryAddress, args: [itemId as `0x${string}`] }); + const { writeContractAsync: executeRequest, isLoading } = useWriteCurateV2ExecuteRequest(); return (