Skip to content

Commit 0d2b47e

Browse files
committed
ci: commented unnused code, removed domain for sign in siwe
1 parent 098eb33 commit 0d2b47e

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

src/components/Topbar.tsx

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
Flex,
44
Text,
55
IconButton,
6-
Button,
6+
// Button,
77
Stack,
88
Collapse,
99
Icon,
@@ -24,19 +24,19 @@ import {
2424
import NextLink from "next/link";
2525
import SchoolOfCodeLogo from "./SchoolOfCodeLogo";
2626
import { useRouter } from "next/router";
27-
import { getCsrfToken, signIn, signOut, useSession } from "next-auth/react";
27+
// import { getCsrfToken, signIn, signOut, useSession } from "next-auth/react";
2828
// import { api } from '@/utils/api'
2929
// SIWE Integration
30-
import { SiweMessage } from "siwe";
31-
import {
32-
useAccount,
33-
useConnect,
34-
useDisconnect,
35-
useSignMessage,
36-
useNetwork,
37-
} from "wagmi";
38-
import { InjectedConnector } from "wagmi/connectors/injected";
39-
import { useEffect, useState } from "react";
30+
// import { SiweMessage } from "siwe";
31+
// import {
32+
// useAccount,
33+
// useConnect,
34+
// useDisconnect,
35+
// useSignMessage,
36+
// useNetwork,
37+
// } from "wagmi";
38+
// import { InjectedConnector } from "wagmi/connectors/injected";
39+
// import { useEffect, useState } from "react";
4040
import { ConnectButton } from "@rainbow-me/rainbowkit";
4141

4242
interface NavItem {
@@ -66,67 +66,67 @@ export default function Topbar() {
6666
const router = useRouter();
6767

6868
// Hooks
69-
const { data: sessionData } = useSession();
69+
// const { data: sessionData } = useSession();
7070
// const { data: secretMessage } = api.example.getSecretMessage.useQuery(
7171
// undefined, // no input
7272
// { enabled: sessionData?.user !== undefined }
7373
// );
7474
// State
75-
const [showConnection, setShowConnection] = useState(false);
75+
// const [showConnection, setShowConnection] = useState(false);
7676

7777
// Wagmi Hooks
78-
const { signMessageAsync } = useSignMessage();
79-
const { address, isConnected } = useAccount();
80-
const { connect } = useConnect({
81-
connector: new InjectedConnector(),
82-
});
83-
const { disconnect } = useDisconnect();
84-
const { chain } = useNetwork();
78+
// const { signMessageAsync } = useSignMessage();
79+
// const { address, isConnected } = useAccount();
80+
// const { connect } = useConnect({
81+
// connector: new InjectedConnector(),
82+
// });
83+
// const { disconnect } = useDisconnect();
84+
// const { chain } = useNetwork();
8585

8686
// Functions
8787
/**
8888
* Attempts SIWE and establish session
8989
*/
90-
const onClickSignIn = async () => {
91-
try {
92-
const message = new SiweMessage({
93-
domain: window.location.host,
94-
address: address,
95-
statement: "Sign in with Ethereum to the app.",
96-
uri: window.location.origin,
97-
version: "1",
98-
chainId: chain?.id,
99-
// nonce is used from CSRF token
100-
nonce: await getCsrfToken(),
101-
});
102-
const signature = await signMessageAsync({
103-
message: message.prepareMessage(),
104-
});
105-
await signIn("credentials", {
106-
message: JSON.stringify(message),
107-
redirect: false,
108-
signature,
109-
});
110-
} catch (error) {
111-
window.alert(error);
112-
}
113-
};
90+
// const onClickSignIn = async () => {
91+
// try {
92+
// const message = new SiweMessage({
93+
// domain: window.location.host,
94+
// address: address,
95+
// statement: "Sign in with Ethereum to the app.",
96+
// uri: window.location.origin,
97+
// version: "1",
98+
// chainId: chain?.id,
99+
// // nonce is used from CSRF token
100+
// nonce: await getCsrfToken(),
101+
// });
102+
// const signature = await signMessageAsync({
103+
// message: message.prepareMessage(),
104+
// });
105+
// await signIn("credentials", {
106+
// message: JSON.stringify(message),
107+
// redirect: false,
108+
// signature,
109+
// });
110+
// } catch (error) {
111+
// window.alert(error);
112+
// }
113+
// };
114114

115115
/**
116116
* Sign user out
117117
*/
118-
const onClickSignOut = async () => {
119-
await signOut();
120-
};
118+
// const onClickSignOut = async () => {
119+
// await signOut();
120+
// };
121121

122122
// Hooks
123123
/**
124124
* Handles hydration issue
125125
* only show after the window has finished loading
126126
*/
127-
useEffect(() => {
128-
setShowConnection(true);
129-
}, []);
127+
// useEffect(() => {
128+
// setShowConnection(true);
129+
// }, []);
130130

131131
return (
132132
<Box

src/server/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { SiweMessage } from "siwe";
1414
import { getCsrfToken } from "next-auth/react";
1515
import type { Session } from "next-auth";
1616
import { PrismaAdapter } from "@next-auth/prisma-adapter";
17-
import { env } from "@/env.mjs";
17+
// import { env } from "@/env.mjs";
1818

1919
// Types
2020
// ========================================================
@@ -169,11 +169,11 @@ export const authOptions: (ctxReq: CtxOrReq) => NextAuthOptions = ({
169169
const nonce = await getCsrfToken({ req: { headers: req?.headers } });
170170
// const nonce = await getCsrfToken({ req });
171171

172-
const nextAuthUrl = new URL(env.NEXTAUTH_URL);
172+
// const nextAuthUrl = new URL(env.NEXTAUTH_URL);
173173

174174
const verified = await siwe.verify({
175175
signature: credentials?.signature || "",
176-
domain: nextAuthUrl.host,
176+
// domain: nextAuthUrl.host,
177177
nonce,
178178
});
179179
console.log({ verified });

0 commit comments

Comments
 (0)