File tree 4 files changed +45
-7
lines changed
4 files changed +45
-7
lines changed Original file line number Diff line number Diff line change
1
+ import { PrivyClient } from "@privy-io/server-auth" ;
2
+ import { type NextRequest , NextResponse } from "next/server" ;
3
+
4
+ export async function POST ( req : NextRequest ) {
5
+ const privy = new PrivyClient (
6
+ process . env . PRIVY_APP_ID ?? "" ,
7
+ process . env . PRIVY_APP_SECRET ?? "" ,
8
+ ) ;
9
+ console . log ( process . env . PRIVY_APP_ID , process . env . PRIVY_APP_SECRET ) ;
10
+ console . log ( { privy } ) ;
11
+ const { address } = await req . json ( ) ;
12
+ console . log ( "address" , address ) ;
13
+
14
+ if ( ! address ) {
15
+ console . log ( "Missing required fields" ) ;
16
+ return NextResponse . json (
17
+ { error : "Missing required fields" } ,
18
+ { status : 400 } ,
19
+ ) ;
20
+ }
21
+
22
+ console . log ( "Creating wallet for user with email: " , address ) ;
23
+
24
+ const wallet = await privy . importUser ( {
25
+ linkedAccounts : [
26
+ {
27
+ type : "email" ,
28
+ address : address ,
29
+ } ,
30
+ ] ,
31
+ createEthereumWallet : true ,
32
+ } ) ;
33
+ console . log ( wallet ) ;
34
+ return NextResponse . json ( { wallet } , { status : 200 } ) ;
35
+ }
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ import { Footer } from "@/components/global/footer";
9
9
import { NavMenu } from "@/components/global/nav-menu" ;
10
10
import { siteConfig } from "@/config/site" ;
11
11
import { config } from "@/config/wagmi" ;
12
+ import { PrivyContextProvider } from "@/contexts/privy" ;
12
13
import { WagmiContextProvider } from "@/contexts/wagmi" ;
14
+ import { PrivyProvider } from "@privy-io/react-auth" ;
13
15
import { headers } from "next/headers" ;
14
16
15
17
export const metadata : Metadata = {
@@ -51,11 +53,13 @@ export default function RootLayout({
51
53
"min-h-screen bg-background font-sans antialiased flex flex-col" ,
52
54
) }
53
55
>
54
- < WagmiContextProvider initialState = { initialState } >
55
- < NavMenu />
56
- < div className = "flex-1" > { children } </ div >
57
- < Footer />
58
- </ WagmiContextProvider >
56
+ < PrivyContextProvider >
57
+ < WagmiContextProvider initialState = { initialState } >
58
+ < NavMenu />
59
+ < div className = "flex-1" > { children } </ div >
60
+ < Footer />
61
+ </ WagmiContextProvider >
62
+ </ PrivyContextProvider >
59
63
</ body >
60
64
</ html >
61
65
) ;
Original file line number Diff line number Diff line change 3
3
4
4
import { ReactNode } from "react" ;
5
5
import { PrivyProvider } from "@privy-io/react-auth" ;
6
- import { optimism } from "viem /chains" ;
6
+ import { optimism } from "wagmi /chains" ;
7
7
8
8
const appId = process . env . NEXT_PUBLIC_PRIVY_APP_ID ?? '' ;
9
9
Original file line number Diff line number Diff line change 22
22
"@hypercerts-org/sdk" : " 2.2.0-beta.2" ,
23
23
"@privy-io/react-auth" : " ^1.92.5" ,
24
24
"@privy-io/server-auth" : " 1.15.0" ,
25
- "@privy-io/wagmi" : " ^0.2.12" ,
26
25
"@radix-ui/react-aspect-ratio" : " ^1.0.3" ,
27
26
"@radix-ui/react-avatar" : " ^1.0.4" ,
28
27
"@radix-ui/react-checkbox" : " ^1.0.4" ,
You can’t perform that action at this time.
0 commit comments