Skip to content

Commit

Permalink
WIP for Next project
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 24, 2024
1 parent 9f4e813 commit 3693921
Show file tree
Hide file tree
Showing 36 changed files with 1,628 additions and 96 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { off } = require("process")

module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down Expand Up @@ -32,7 +30,6 @@ module.exports = {
'import/no-named-as-default-member': 'off',
'import/export': 'off'


// 'import/order': [
// 'warn',
// {
Expand All @@ -43,6 +40,5 @@ module.exports = {
// }
// },
// ]

}
}
3 changes: 3 additions & 0 deletions examples/next/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/next/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/next/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
10 changes: 10 additions & 0 deletions examples/next/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin'

const withVanillaExtract = createVanillaExtractPlugin()

/** @type {import('next').NextConfig} */
const nextConfig = {
// transpilePackages: ['@0xsequence/kit', '@0xsequence/kit-wallet', '@0xsequence/kit-connectors', '@0xsequence/checkout']
}

export default withVanillaExtract(nextConfig)
36 changes: 36 additions & 0 deletions examples/next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@0xsequence/kit-example-next",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@0xsequence/design-system": "^1.4.7",
"@0xsequence/kit": "workspace:*",
"@0xsequence/kit-checkout": "workspace:*",
"@0xsequence/kit-connectors": "workspace:*",
"@0xsequence/kit-wallet": "workspace:*",
"@0xsequence/network": "^1.9.19",
"@tanstack/react-query": "^5.29.2",
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"viem": "^2.5.7",
"wagmi": "^2.5.7"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@vanilla-extract/next-plugin": "^2.4.0",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
"tailwindcss": "^3.4.3",
"typescript": "^5"
}
}
8 changes: 8 additions & 0 deletions examples/next/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};

export default config;
1 change: 1 addition & 0 deletions examples/next/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/next/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions examples/next/src/app/WalletOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client'

import { Connector, useConnect } from 'wagmi'

export const WalletOptions = () => {
const { connectors, connect } = useConnect()

return (
<div className="flex flex-col gap-1">
{connectors.map(connector => (
<button key={connector.uid} onClick={() => connect({ connector })} className="border-2 border-slate-700 px-2 py-1">
{(connector as any)._wallet?.name || connector.name} <span className="text-sm text-slate-600">({connector.type})</span>
</button>
))}
</div>
)
}
62 changes: 62 additions & 0 deletions examples/next/src/app/Web3Provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use client'

import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { WagmiProvider } from 'wagmi'
// import { KitProvider } from '@0xsequence/kit'

import { config } from './config'

const queryClient = new QueryClient()

// const kitConfig: KitConfig = {
// defaultTheme: 'dark',
// signIn: {
// projectName: 'Kit Demo'
// // logoUrl: 'sw-logo-white.svg',
// // useMock: isDebugMode
// },
// displayedAssets: [
// // Native token
// {
// contractAddress: '0x0000000000000000000000000000000000000000',
// chainId: 42170
// },
// // Native token
// {
// contractAddress: '0x0000000000000000000000000000000000000000',
// chainId: 421614
// },
// // Waas demo NFT
// {
// contractAddress: '0x0d402c63cae0200f0723b3e6fa0914627a48462e',
// chainId: 42170
// },
// // Waas demo NFT
// {
// contractAddress: '0x0d402c63cae0200f0723b3e6fa0914627a48462e',
// chainId: 421614
// },
// // Skyweaver assets
// {
// contractAddress: '0x631998e91476da5b870d741192fc5cbc55f5a52e',
// chainId: 137
// }
// ]
// }

export interface Web3ProviderProps {
children: React.ReactNode
}

export const Web3Provider = (props: Web3ProviderProps) => {
const { children } = props

return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
{/* <KitProvider config={kitConfig}>{children}</KitProvider> */}
{children}
</QueryClientProvider>
</WagmiProvider>
)
}
44 changes: 44 additions & 0 deletions examples/next/src/app/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use client'

import { findNetworkConfig, allNetworks } from '@0xsequence/network'
import { CreateConnectorFn, createConfig, http } from 'wagmi'
import { Transport } from 'viem'
import { arbitrumNova, arbitrumSepolia, mainnet, polygon } from 'viem/chains'
import { getDefaultConnectors } from '@0xsequence/kit-connectors'

const walletConnectProjectId = 'c65a6cb1aa83c4e24500130f23a437d8'
const projectAccessKey = 'AQAAAAAAAEGvyZiWA9FMslYeG_yayXaHnSI'

const chains = [arbitrumNova, arbitrumSepolia, mainnet, polygon] as const
const transports = chains.reduce<Record<number, Transport>>((acc, chain) => {
const network = findNetworkConfig(allNetworks, chain.id)

if (network) {
acc[chain.id] = http(network.rpcUrl)
}

return acc
}, {})

const connectors: CreateConnectorFn[] = [
...getDefaultConnectors({
walletConnectProjectId,
defaultChainId: arbitrumNova.id,
appName: 'demo app',
projectAccessKey
})
// ...(isDebugMode
// ? getKitConnectWallets(projectAccessKey, [
// mock({
// accounts: ['0xCb88b6315507e9d8c35D81AFB7F190aB6c3227C9']
// })
// ])
// : [])
]

export const config = createConfig({
chains,
transports,
connectors,
ssr: true // For Next.js SSR support
})
Binary file added examples/next/src/app/favicon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions examples/next/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
27 changes: 27 additions & 0 deletions examples/next/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import '@0xsequence/design-system/styles.css'

import { Web3Provider } from './Web3Provider'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app'
}

export default function RootLayout({
children
}: Readonly<{
children: React.ReactNode
}>) {
return (
<html lang="en">
<body className={inter.className}>
<Web3Provider>{children}</Web3Provider>
</body>
</html>
)
}
Loading

0 comments on commit 3693921

Please sign in to comment.