Skip to content

Commit 62acb27

Browse files
committed
feat: some changes taking code from siwe example branch
1 parent 1749581 commit 62acb27

File tree

4 files changed

+33
-38
lines changed

4 files changed

+33
-38
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@next-auth/prisma-adapter": "^1.0.7",
2020
"@prisma/client": "^4.16.1",
2121
"@rainbow-me/rainbowkit": "^1.0.4",
22+
"@rainbow-me/rainbowkit-siwe-next-auth": "^0.2.0",
2223
"@tanstack/react-query": "^4.29.19",
2324
"@trpc/client": "^10.33.0",
2425
"@trpc/next": "^10.33.0",

src/pages/_app.tsx

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ import Topbar from "@/components/Topbar";
1515
//Raimbow Kit
1616
import "@rainbow-me/rainbowkit/styles.css";
1717
import {
18-
getDefaultWallets,
1918
connectorsForWallets,
2019
RainbowKitProvider,
2120
} from "@rainbow-me/rainbowkit";
22-
import {
23-
braveWallet,
24-
injectedWallet,
25-
coinbaseWallet,
26-
safeWallet,
27-
} from "@rainbow-me/rainbowkit/wallets";
21+
import { injectedWallet, coinbaseWallet } from "@rainbow-me/rainbowkit/wallets";
2822
import { MDXProvider } from "@mdx-js/react";
2923
import Components from "@/components/mdx/Components";
24+
import { RainbowKitSiweNextAuthProvider } from "@rainbow-me/rainbowkit-siwe-next-auth";
3025

3126
// Config
3227
// ========================================================
@@ -38,21 +33,12 @@ const { chains, publicClient, webSocketPublicClient } = configureChains(
3833
[publicProvider()]
3934
);
4035

41-
const { wallets } = getDefaultWallets({
42-
appName: "Developer DAO Academy",
43-
projectId: "123456789",
44-
chains,
45-
});
46-
4736
const connectors = connectorsForWallets([
48-
...wallets,
4937
{
50-
groupName: "Other",
38+
groupName: "Recommended",
5139
wallets: [
52-
braveWallet({ chains }),
5340
injectedWallet({ chains }),
54-
coinbaseWallet({ chains, appName: "Developer DAO Academy" }), // "Next dApp" is the name of the app
55-
safeWallet({ chains }),
41+
coinbaseWallet({ chains, appName: "Developer DAO Academy" }),
5642
],
5743
},
5844
]);
@@ -67,6 +53,10 @@ const config = createConfig({
6753
webSocketPublicClient,
6854
});
6955

56+
const getSiweMessageOptions = () => ({
57+
statement: "Sign in to Developer DAO Academy",
58+
});
59+
7060
// App Wrapper Component
7161
// ========================================================
7262
const MyApp: AppType<{ session: Session | null }> = ({
@@ -76,25 +66,24 @@ const MyApp: AppType<{ session: Session | null }> = ({
7666
return (
7767
<ChakraProvider theme={theme}>
7868
<WagmiConfig config={config}>
79-
<RainbowKitProvider
80-
//modalSize="compact"
81-
coolMode={true}
82-
chains={chains}
83-
// theme={theme}
84-
>
85-
<SessionProvider session={session}>
86-
<Box
87-
p="1.25em"
88-
px="5%"
89-
mx={{ base: "2rem", md: "6rem", lg: "10rem" }}
90-
>
91-
<Topbar />
92-
<MDXProvider components={Components}>
93-
<Component {...pageProps} />{" "}
94-
</MDXProvider>
95-
</Box>
96-
</SessionProvider>
97-
</RainbowKitProvider>
69+
<SessionProvider session={session} refetchInterval={0}>
70+
<RainbowKitSiweNextAuthProvider
71+
getSiweMessageOptions={getSiweMessageOptions}
72+
>
73+
<RainbowKitProvider chains={chains}>
74+
<Box
75+
p="1.25em"
76+
px="5%"
77+
mx={{ base: "2rem", md: "6rem", lg: "10rem" }}
78+
>
79+
<Topbar />
80+
<MDXProvider components={Components}>
81+
<Component {...pageProps} />{" "}
82+
</MDXProvider>
83+
</Box>
84+
</RainbowKitProvider>
85+
</RainbowKitSiweNextAuthProvider>
86+
</SessionProvider>
9887
</WagmiConfig>
9988
</ChakraProvider>
10089
);

src/server/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import CredentialsProvider from "next-auth/providers/credentials";
1313
import { SiweMessage } from "siwe";
1414
import { getCsrfToken } from "next-auth/react";
1515
import type { Session } from "next-auth";
16-
import { PrismaAdapter } from "@next-auth/prisma-adapter";
1716

1817
// Types
1918
// ========================================================
@@ -56,6 +55,7 @@ export const authOptions: (ctxReq: CtxOrReq) => NextAuthOptions = ({
5655
user: {
5756
...session.user,
5857
id: token.sub,
58+
image: "https://www.fillmurray.com/128/128",
5959
},
6060
} as Session & { user: { id: string } }),
6161
// OTHER CALLBACKS to take advantage of but not needed

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,11 @@
14361436
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.16.1.tgz#ee487620dc5135fd175ac7494b1c60c9f12c1e4b"
14371437
integrity sha512-gpZG0kGGxfemgvK/LghHdBIz+crHkZjzszja94xp4oytpsXrgt/Ice82MvPsWMleVIniKuARrowtsIsim0PFJQ==
14381438

1439+
"@rainbow-me/rainbowkit-siwe-next-auth@^0.2.0":
1440+
version "0.2.0"
1441+
resolved "https://registry.yarnpkg.com/@rainbow-me/rainbowkit-siwe-next-auth/-/rainbowkit-siwe-next-auth-0.2.0.tgz#ea1004c38990b6a14abec61f2f6286d7bdc16e4a"
1442+
integrity sha512-U0GPPc5tRhNSLgdLb4sU6eha7qxIJmfNbUmcGeQGh7IR/jw3xFdYYKYaHcEG8rB09/yfEMQodwJiV+vrjta6zQ==
1443+
14391444
"@rainbow-me/rainbowkit@^1.0.4":
14401445
version "1.0.4"
14411446
resolved "https://registry.yarnpkg.com/@rainbow-me/rainbowkit/-/rainbowkit-1.0.4.tgz#22f74c35ba036f7d1deb02528b162691ac5a32af"

0 commit comments

Comments
 (0)