Skip to content

Commit

Permalink
init project
Browse files Browse the repository at this point in the history
  • Loading branch information
nikos-koukis committed Oct 4, 2023
1 parent 4e99638 commit c2f8400
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 464 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
"lint": "next lint"
},
"dependencies": {
"@multiversx/sdk-dapp": "^2.22.1",
"@multiversx/sdk-wallet": "^4.2.0",
"next": "13.5.4",
"next-auth": "^4.23.2",
"react": "^18",
"react-dom": "^18",
"next": "13.5.4"
"react-dom": "^18"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "13.5.4"
"eslint-config-next": "13.5.4",
"typescript": "^5"
}
}
18 changes: 18 additions & 0 deletions src/api/net.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

const {
network,
contractAddress,
GAS_LIMIT,
ENVIROMENT,
TOKENS_ID,
ChainID,
QXTAGSLINK
} = require("config.devnet");

export const tokensID = TOKENS_ID;
export const environment = ENVIROMENT;
export const contractAddr = contractAddress;
export const gasLimit = GAS_LIMIT;
export const ChainId = ChainID;
export const QxTagsLink = QXTAGSLINK;
export { network };
36 changes: 36 additions & 0 deletions src/config.devnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const contractAddress = {
hoot: '',
qxtags: ""
}
export const ENVIROMENT = "devnet";

export const ChainID = "D";
export const network = {
id: "devnet",
name: "Devnet",
egldLabel: "xEGLD",
walletAddress: "https://devnet-wallet.multiversx.com",
apiAddress: "https://devnet-api.multiversx.com",
gatewayAddress: "https://devnet-api.multiversx.com",
explorerAddress: "http://devnet-explorer.multiversx.com",
graphQlAddress: "https://devnet-exchange-graph.multiversx.com/graphql",
apiTimeout: 10000,
};

export const GAS_LIMIT = 60000000;

//general configs
export const apiTimeout = 6000;
export const TOOLS_API_URL = "https://tools.multiversx.com";
export const sampleAuthenticatedDomains = [TOOLS_API_URL];

export const QXTAGSLINK = "https://quantum-original-dev.vercel.app/qtags"

export const walletConnectBridge = "https://bridge.walletconnect.org";

export const walletConnectDeepLink =
"https://maiar.page.link/?apn=com.multiversx.maiar.wallet&isi=1519405832&ibi=com.multiversx.maiar.wallet&link=https://maiar.com/";

export const TOKENS_ID = {
wegld: "WEGLD-d7c6bb"
};
36 changes: 36 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const contractAddress = {
hoot: '',
qxtags: ""
}
export const ENVIROMENT = "devnet";

export const ChainID = "D";
export const network = {
id: "devnet",
name: "Devnet",
egldLabel: "xEGLD",
walletAddress: "https://devnet-wallet.multiversx.com",
apiAddress: "https://devnet-api.multiversx.com",
gatewayAddress: "https://devnet-api.multiversx.com",
explorerAddress: "http://devnet-explorer.multiversx.com",
graphQlAddress: "https://devnet-exchange-graph.multiversx.com/graphql",
apiTimeout: 10000,
};

export const GAS_LIMIT = 60000000;

//general configs
export const apiTimeout = 6000;
export const TOOLS_API_URL = "https://tools.multiversx.com";
export const sampleAuthenticatedDomains = [TOOLS_API_URL];

export const QXTAGSLINK = "https://quantum-original-dev.vercel.app/qtags"

export const walletConnectBridge = "https://bridge.walletconnect.org";

export const walletConnectDeepLink =
"https://maiar.page.link/?apn=com.multiversx.maiar.wallet&isi=1519405832&ibi=com.multiversx.maiar.wallet&link=https://maiar.com/";

export const TOKENS_ID = {
wegld: "WEGLD-d7c6bb"
};
64 changes: 64 additions & 0 deletions src/hoc/withDappProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react';
import { DappProvider } from '@multiversx/sdk-dapp/wrappers/DappProvider';
import type { AppProps } from 'next/app';
import { network } from "../api/net.config";
import dynamic from "next/dynamic";
import { AxiosInterceptorContext } from "@multiversx/sdk-dapp/wrappers/AxiosInterceptorContext";
import { sampleAuthenticatedDomains } from "../config";

const SignTransactionsModals: any = dynamic(
async () => {
return (await import("@multiversx/sdk-dapp/UI/SignTransactionsModals"))
.SignTransactionsModals;
},
{ ssr: false }
);
const NotificationModal: any = dynamic(
async () => {
return (await import("@multiversx/sdk-dapp/UI/NotificationModal"))
.NotificationModal;
},
{ ssr: false }
);
const TransactionsToastList: any = dynamic(
async () => {
return (await import("@multiversx/sdk-dapp/UI/TransactionsToastList"))
.TransactionsToastList;
},
{ ssr: false }
);

const withDappProvider = (WrappedComponent: React.ComponentType<AppProps>) => {
const WithDappProvider: React.FC<AppProps> = (props) => {
return (
<AxiosInterceptorContext.Provider>
{/* @ts-ignore */}
<AxiosInterceptorContext.Interceptor
authenticatedDomanis={sampleAuthenticatedDomains}
>
<DappProvider
environment={network.id}
customNetworkConfig={{
name: "Hackathon Dapp",
walletConnectV2ProjectId: "b2d85a1d5f8e40aa6d2858b1e2ed83d8",
}}
dappConfig={{
shouldUseWebViewProvider: true,
}}
>
<>
<TransactionsToastList />
<NotificationModal />
<SignTransactionsModals className="custom-class-for-modals" />
</>
<AxiosInterceptorContext.Listener />
<WrappedComponent {...props} />
</DappProvider>
</AxiosInterceptorContext.Interceptor>
</AxiosInterceptorContext.Provider>
);
};

return WithDappProvider;
};
export default withDappProvider;
12 changes: 12 additions & 0 deletions src/lib/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NextAuthOptions, User } from "next-auth";
import GoogleProvider from "next-auth/providers/google";


export const authConfig: NextAuthOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
}),
],
};
15 changes: 11 additions & 4 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import '@/styles/globals.css'
import { SessionProvider } from "next-auth/react"
import type { AppProps } from 'next/app'

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default function App({
Component,
pageProps: { session, ...pageProps },
}: AppProps) {
return (
<SessionProvider session={session} refetchInterval={5 * 60}>
<Component {...pageProps} />
</SessionProvider>
)
}
14 changes: 14 additions & 0 deletions src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import NextAuth from "next-auth"
import GoogleProvider from "next-auth/providers/google"

export const authOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
}),
],
}

export default NextAuth(authOptions)

13 changes: 0 additions & 13 deletions src/pages/api/hello.ts

This file was deleted.

122 changes: 15 additions & 107 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,114 +1,22 @@
import Head from 'next/head'
import Image from 'next/image'
import { Inter } from 'next/font/google'
import styles from '@/styles/Home.module.css'

const inter = Inter({ subsets: ['latin'] })
import { useSession, signIn, signOut } from "next-auth/react"

export default function Home() {

const { data: session } = useSession()
console.log(session);

if (session) {
return (
<>
Signed in as {session?.user?.email} <br />
<button onClick={() => signOut()}>Sign out</button>
</>
)
}
return (
<>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={`${styles.main} ${inter.className}`}>
<div className={styles.description}>
<p>
Get started by editing&nbsp;
<code className={styles.code}>src/pages/index.tsx</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className={styles.vercelLogo}
width={100}
height={24}
priority
/>
</a>
</div>
</div>

<div className={styles.center}>
<Image
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>

<div className={styles.grid}>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>
Find in-depth information about Next.js features and&nbsp;API.
</p>
</a>

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>
Discover and deploy boilerplate example Next.js&nbsp;projects.
</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>
Instantly deploy your Next.js site to a shareable URL
with&nbsp;Vercel.
</p>
</a>
</div>
</main>
Not signed in <br />
<button onClick={() => signIn()}>Sign in</button>
</>
)
}
Loading

0 comments on commit c2f8400

Please sign in to comment.