first deployment
This commit is contained in:
parent
87eaf79afc
commit
68371c7c57
2825
package-lock.json
generated
2825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -14,12 +14,17 @@
|
|||
"dependencies": {
|
||||
"@headlessui/react": "^1.7.3",
|
||||
"@heroicons/react": "^2.0.12",
|
||||
"@privy-io/react-auth": "1.76.4",
|
||||
"@privy-io/react-auth": "^1.76.4",
|
||||
"@privy-io/server-auth": "1.9.5",
|
||||
"@privy-io/wagmi": "^0.2.12",
|
||||
"@privy-io/wagmi-connector": "^0.1.13",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@tanstack/react-query": "^5.51.15",
|
||||
"axios": "^1.7.2",
|
||||
"next": "latest",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
"react-dom": "18.2.0",
|
||||
"wagmi": "^1.4.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/next": "^2.0.0",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,29 @@ import "../styles/globals.css";
|
|||
import type { AppProps } from "next/app";
|
||||
import Head from "next/head";
|
||||
import { PrivyProvider } from "@privy-io/react-auth";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { PrivyWagmiConnector } from '@privy-io/wagmi-connector';
|
||||
|
||||
import { mainnet, sepolia, configureChains } from 'wagmi';
|
||||
import { alchemyProvider } from 'wagmi/providers/alchemy';
|
||||
import { infuraProvider } from 'wagmi/providers/infura';
|
||||
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
|
||||
|
||||
// Configure chains and providers
|
||||
const configureChainsConfig = configureChains(
|
||||
[mainnet, sepolia],
|
||||
[
|
||||
alchemyProvider({ apiKey: 'XrSV5mVhj-BIUnneNRm66ReQeuO19jJ-' }),
|
||||
infuraProvider({ apiKey: '25c9f1810f234c278a4f13736a897836' }),
|
||||
jsonRpcProvider({
|
||||
rpc: (chain) => {
|
||||
if (chain.id === mainnet.id) return { http: `https://mainnet.infura.io/v3/25c9f1810f234c278a4f13736a897836` };
|
||||
if (chain.id === sepolia.id) return { http: `https://sepolia.infura.io/v3/25c9f1810f234c278a4f13736a897836` };
|
||||
return null; // Replace with your fallback RPC if needed
|
||||
}
|
||||
})
|
||||
]
|
||||
);
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
|
|
@ -48,7 +71,9 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|||
},
|
||||
}}
|
||||
>
|
||||
<Component {...pageProps} />
|
||||
<PrivyWagmiConnector wagmiChainsConfig={configureChainsConfig}>
|
||||
<Component {...pageProps} />
|
||||
</PrivyWagmiConnector>
|
||||
</PrivyProvider>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
75
pages/auth.tsx
Normal file
75
pages/auth.tsx
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import axios from 'axios';
|
||||
import { PrivyProvider, usePrivy } from '@privy-io/react-auth';
|
||||
import Link from 'next/link';
|
||||
|
||||
const Home: React.FC = () => {
|
||||
const { login, ready, user } = usePrivy();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const setResult = async (result: string, wallet: string) => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const requestIdFromUrl = params.get('request_id');
|
||||
|
||||
if(!result.includes('privy')){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await axios({
|
||||
method: 'get',
|
||||
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php`,
|
||||
withCredentials: false,
|
||||
params: {
|
||||
id: requestIdFromUrl,
|
||||
result: result
|
||||
},
|
||||
});
|
||||
console.log(`https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php?id=${requestIdFromUrl}&result=${result}`);
|
||||
await axios({
|
||||
method: 'get',
|
||||
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_wallet.php`,
|
||||
withCredentials: false,
|
||||
params: {
|
||||
id: result,
|
||||
wallet: wallet
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error making GET request:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const requestIdFromUrl = new URLSearchParams(window.location.search).get('request_id');
|
||||
|
||||
if (!ready) {
|
||||
console.log("not ready yet");
|
||||
}
|
||||
else if (requestIdFromUrl) {
|
||||
setResult(user?.id ?? "", user?.wallet?.address ?? "no wallet"); // Replace 'some_result' with the actual result you want to send
|
||||
}
|
||||
}, [ready, user]);
|
||||
|
||||
return (
|
||||
<div className='flex items-center justify-center bg-black h-screen text-white'>
|
||||
{user && ready ? (
|
||||
<div className='justify-center grid-flow-row grid items-center flex-col '>
|
||||
<h1 className='neon-text mb-4 text-3xl'>Login Success. You may close this now.</h1>
|
||||
<Link href="/dashboard">
|
||||
<div className='bg-purple-700 w-36 items-center justify-center flex rounded-xl h-10'>Dashboard</div>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
) : (
|
||||
<>
|
||||
<h1 className='neon-text mb-4 text-3xl'>Complete W3B Wallet Login</h1>
|
||||
<button className='bg-green-700 rounded-full p-1 px-4 text-lg m-5' onClick={login}>Login</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getAccessToken, usePrivy } from "@privy-io/react-auth";
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import Head from "next/head";
|
||||
import { useBalance } from 'wagmi';
|
||||
|
||||
async function verifyToken() {
|
||||
const url = "/api/verify";
|
||||
|
|
@ -16,26 +18,16 @@ async function verifyToken() {
|
|||
}
|
||||
|
||||
export default function DashboardPage() {
|
||||
const [verifyResult, setVerifyResult] = useState();
|
||||
const [verifyResult, setVerifyResult] = useState(0);
|
||||
const router = useRouter();
|
||||
const {
|
||||
ready,
|
||||
authenticated,
|
||||
user,
|
||||
logout,
|
||||
linkEmail,
|
||||
linkWallet,
|
||||
unlinkEmail,
|
||||
linkPhone,
|
||||
unlinkPhone,
|
||||
unlinkWallet,
|
||||
linkGoogle,
|
||||
unlinkGoogle,
|
||||
linkTwitter,
|
||||
unlinkTwitter,
|
||||
linkDiscord,
|
||||
unlinkDiscord,
|
||||
} = usePrivy();
|
||||
|
||||
const { ready, authenticated, user, logout, linkTwitter, unlinkTwitter, unlinkDiscord, linkDiscord, unlinkWallet, linkWallet } = usePrivy();
|
||||
const { data: balanceData } = useBalance({
|
||||
// address: '0x4557B18E779944BFE9d78A672452331C186a9f48'
|
||||
address: user?.wallet?.address,
|
||||
});
|
||||
const balance = balanceData?.formatted;
|
||||
const token = balanceData?.symbol;
|
||||
|
||||
useEffect(() => {
|
||||
if (ready && !authenticated) {
|
||||
|
|
@ -72,11 +64,22 @@ export default function DashboardPage() {
|
|||
Logout
|
||||
</button>
|
||||
</div>
|
||||
<div className="items-center flex flex-wrap justify-center p-20">
|
||||
<h1 className="text-4xl">$0.1</h1>
|
||||
<div className="flex flex-wrap items-center justify-center">
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Vault Credits</h1>
|
||||
<h1 className="text-4xl flex justify-center">1 VC</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-xs">{user?.wallet?.address}</h1>
|
||||
<h1 className="text-4xl flex justify-center">{balance || 0} {token}</h1>
|
||||
</div>
|
||||
<div className="items-center justify-center p-20">
|
||||
<h1 className="text-s">Pre-hunt Points</h1>
|
||||
<h1 className="text-4xl flex justify-center">1 PHP</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-12 flex gap-4 flex-wrap">
|
||||
|
||||
{twitterSubject ? (
|
||||
<button
|
||||
onClick={() => {
|
||||
|
|
@ -136,8 +139,10 @@ export default function DashboardPage() {
|
|||
Connect wallet
|
||||
</button>
|
||||
)}
|
||||
<button onClick={linkWallet}>
|
||||
Wallet
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</>
|
||||
) : null}
|
||||
</main>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import { useRouter } from "next/router";
|
|||
|
||||
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
||||
const cookieAuthToken = req.cookies["privy-token"];
|
||||
|
||||
// If no cookie is found, skip any further checks
|
||||
if (!cookieAuthToken) return { props: {} };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user