I am following this https://docs.moralis.io/docs/how-to-sign-in-with-metamask tutorial and have run into some issues. First I think that making an entire sign in page is unnecessary so I’m creating a button instead that will be nested in my navbar component. I’m using ESLint as my linter and it is throwing a couple of errors
import { useAuthRequestChallengeEvm } from "@moralisweb3/next";
import { useAccount, useConnect, useDisconnect, useSignMessage } from "wagmi";
import { MetaMaskConnector } from "wagmi/connectors/metaMask";
function MetamaskButton() {
const { connectAsync } = useConnect();
const { disconnectAsync } = useDisconnect();
const { isConnected } = useAccount();
const { signMessageAsync } = useSignMessage();
const { requestChallengeAsync } = useAuthRequestChallengeEvm();
const handleAuth = async () => {
if (isConnected) {
await disconnectAsync();
}
const { account, chain } = await connectAsync({
connector: new MetaMaskConnector(),
});
const { message } = await requestChallengeAsync({
address: account,
chainId: chain.id,
});
const signature = await signMessageAsync({ message });
const { url } = await MetamaskButton("moralis-auth", {
message,
signature,
redirect: false,
callbackUrl: "/user",
});
/**
* instead of using signIn(..., redirect: "/user")
* we get the url from callback and push it to the router to avoid page refreshing
*/
push(url);
};
return (
<div>
<h3>Web3 Authentication</h3>
<button onClick={handleAuth}>Authenticate via Metamask</button>
</div>
);
}
export default MetamaskButton;
It is telling me that push(url) is an undefined variable.
Second issue is that my Moralis.ts file is also throwing type errors. I changed it to a js file which helped but I’m still getting this error
uri: process.env.http://localhost:3000,
It is highlighting the http and giving this message Parsing error: Unexpected token, expected “,” (7:25)eslint
Also, this is what happens when I start my dev server.
Thank you for any help