-
Notifications
You must be signed in to change notification settings - Fork 541
Enhancement: Examples/with-ledger #1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ab64753
weifix
mahmud-bn f16dcc0
weifix
mahmud-bn 2a2940a
weifix
mahmud-bn 29a7502
with-ledger
mahmud-bn a11c4c8
with-ledger
mahmud-bn 8025687
readme
mahmud-bn 43f63c7
Merge branch 'v2-web3-onboard-develop' into examples/with-ledger
mahmud-bn 155a5c2
merge develop
mahmud-bn 8afb02b
delete unwanted
mahmud-bn 30269d2
delete unwanted
mahmud-bn a9aa410
delete unwanted
mahmud-bn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "next/core-web-vitals" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # dependencies | ||
| /node_modules | ||
| /.pnp | ||
| .pnp.js | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
| # next.js | ||
| /.next/ | ||
| /out/ | ||
|
|
||
| # production | ||
| /build | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # local env files | ||
| .env*.local | ||
|
|
||
| # vercel | ||
| .vercel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| This is a sample [Web3Onboard](https://github.com/blocknative/web3-onboard) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) showing how to integrate the Ledger wallet into your web3 dApp. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| Clone this repo | ||
|
|
||
| ``` | ||
| https://github.com/blocknative/web3-onboard.git | ||
| ``` | ||
|
|
||
| Navigate to the project directory: | ||
|
|
||
| ``` | ||
| cd examples | ||
| ``` | ||
|
|
||
| Install the dependencies: | ||
|
|
||
| ``` | ||
| yarn | ||
| ``` | ||
|
|
||
| Run the development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| ``` | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
|
||
| ## Learn More | ||
|
|
||
| To learn more about how you can use web3Onboard to integrate Ledger and other popular web3 wallets into your dApps, take a look at our documentation: [Web3Onboard Documentation](https://docs.blocknative.com/onboard) for more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| swcMinify: true, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "name": "with-ledger", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "next dev", | ||
| "build": "next build", | ||
| "start": "next start", | ||
| "lint": "next lint" | ||
| }, | ||
| "dependencies": { | ||
| "@web3-onboard/ledger": "^2.1.6", | ||
| "@web3-onboard/react": "^2.2.4", | ||
| "next": "12.2.3", | ||
| "react": "18.2.0", | ||
| "react-dom": "18.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "eslint": "8.20.0", | ||
| "eslint-config-next": "12.2.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import '../styles/globals.css' | ||
|
|
||
| function MyApp({ Component, pageProps }) { | ||
| return <Component {...pageProps} /> | ||
| } | ||
|
|
||
| export default MyApp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
|
|
||
| export default function handler(req, res) { | ||
| res.status(200).json({ name: 'John Doe' }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import Head from 'next/head' | ||
| import { init, useConnectWallet } from '@web3-onboard/react' | ||
| import ledgerModule from '@web3-onboard/ledger' | ||
| import styles from '../styles/Home.module.css' | ||
|
|
||
| const buttonStyles = { | ||
| borderRadius: '6px', | ||
| background: '#111827', | ||
| border: 'none', | ||
| fontSize: '18px', | ||
| fontWeight: '600', | ||
| cursor: 'pointer', | ||
| color: 'white', | ||
| padding: '14px 12px', | ||
| marginTop: '40px', | ||
| fontFamily: 'inherit' | ||
| } | ||
|
|
||
|
|
||
| const INFURA__KEY = 'cf540cb0b3b643d399e59aef4f5ac179' | ||
| const ledger = ledgerModule() | ||
|
|
||
| // initialize Onboard | ||
| init({ | ||
| wallets: [ledger], | ||
| chains: [ | ||
| { | ||
| id: '0x1', | ||
| token: 'ETH', | ||
| label: 'Ethereum', | ||
| rpcUrl: `https://mainnet.infura.io/v3/${INFURA__KEY}` | ||
| }, | ||
| { | ||
| id: '0x3', | ||
| token: 'tROP', | ||
| label: 'Ropsten', | ||
| rpcUrl: `https://ropsten.infura.io/v3/${INFURA__KEY}` | ||
| }, | ||
| { | ||
| id: '0x4', | ||
| token: 'rETH', | ||
| label: 'Rinkeby', | ||
| rpcUrl: `https://rinkeby.infura.io/v3/${INFURA__KEY}` | ||
| }, | ||
| { | ||
| id: '0x38', | ||
| token: 'BNB', | ||
| label: 'Binance', | ||
| rpcUrl: 'https://bsc-dataseed.binance.org/' | ||
| }, | ||
| { | ||
| id: '0x89', | ||
| token: 'MATIC', | ||
| label: 'Polygon', | ||
| rpcUrl: 'https://matic-mainnet.chainstacklabs.com' | ||
| }, | ||
| { | ||
| id: '0xfa', | ||
| token: 'FTM', | ||
| label: 'Fantom', | ||
| rpcUrl: 'https://rpc.ftm.tools/' | ||
| } | ||
| ], | ||
| appMetadata: { | ||
| name: "Web3-Onboard Demo", | ||
| icon: '<svg>My App Icon</svg>', | ||
| description: "A demo of Web3-Onboard with Ledger." | ||
| }, | ||
| accountCenter: { | ||
| desktop: { | ||
| position: 'topRight', | ||
| enabled: true, | ||
| minimal: false | ||
| } | ||
| } | ||
| }) | ||
|
|
||
|
|
||
|
|
||
| export default function Home() { | ||
| const [{ wallet, connecting }, connect, disconnect] = useConnectWallet() | ||
|
|
||
| return ( | ||
| <div className={styles.container}> | ||
| <Head> | ||
| <title>Web3-Onboard + Ledger Demo</title> | ||
| <meta | ||
| name="description" | ||
| content="Web3-Onboard Example with Ledger Hardware Wallet" | ||
| /> | ||
| <link rel="icon" href="/favicon.ico" /> | ||
| </Head> | ||
|
|
||
| <main className={styles.main}> | ||
| <h1 className={styles.title}> | ||
| Welcome to a demo of | ||
| <a href="https://github.com/blocknative/web3-onboard"> | ||
| {' '} | ||
| Web3-Onboard + Ledger | ||
| </a> | ||
| ! | ||
| </h1> | ||
| <button | ||
| style={buttonStyles} | ||
| disabled={connecting} | ||
| onClick={() => (wallet ? disconnect(wallet) : connect())} | ||
| > | ||
| {connecting ? 'connecting' : wallet ? 'disconnect' : 'connect'} | ||
| </button> | ||
| </main> | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| .container { | ||
| padding: 0 2rem; | ||
| } | ||
|
|
||
| .main { | ||
| min-height: 100vh; | ||
| padding: 4rem 0; | ||
| flex: 1; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .footer { | ||
| display: flex; | ||
| flex: 1; | ||
| padding: 2rem 0; | ||
| border-top: 1px solid #eaeaea; | ||
| justify-content: center; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .footer a { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| flex-grow: 1; | ||
| } | ||
|
|
||
| .title a { | ||
| color: #0070f3; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| .title a:hover, | ||
| .title a:focus, | ||
| .title a:active { | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| .title { | ||
| margin: 0; | ||
| line-height: 1.15; | ||
| font-size: 4rem; | ||
| } | ||
|
|
||
| .title, | ||
| .description { | ||
| text-align: center; | ||
| } | ||
|
|
||
| .description { | ||
| margin: 4rem 0; | ||
| line-height: 1.5; | ||
| font-size: 1.5rem; | ||
| } | ||
|
|
||
| .code { | ||
| background: #fafafa; | ||
| border-radius: 5px; | ||
| padding: 0.75rem; | ||
| font-size: 1.1rem; | ||
| font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, | ||
| Bitstream Vera Sans Mono, Courier New, monospace; | ||
| } | ||
|
|
||
| .grid { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| flex-wrap: wrap; | ||
| max-width: 800px; | ||
| } | ||
|
|
||
| .card { | ||
| margin: 1rem; | ||
| padding: 1.5rem; | ||
| text-align: left; | ||
| color: inherit; | ||
| text-decoration: none; | ||
| border: 1px solid #eaeaea; | ||
| border-radius: 10px; | ||
| transition: color 0.15s ease, border-color 0.15s ease; | ||
| max-width: 300px; | ||
| } | ||
|
|
||
| .card:hover, | ||
| .card:focus, | ||
| .card:active { | ||
| color: #0070f3; | ||
| border-color: #0070f3; | ||
| } | ||
|
|
||
| .card h2 { | ||
| margin: 0 0 1rem 0; | ||
| font-size: 1.5rem; | ||
| } | ||
|
|
||
| .card p { | ||
| margin: 0; | ||
| font-size: 1.25rem; | ||
| line-height: 1.5; | ||
| } | ||
|
|
||
| .logo { | ||
| height: 1em; | ||
| margin-left: 0.5rem; | ||
| } | ||
|
|
||
| @media (max-width: 600px) { | ||
| .grid { | ||
| width: 100%; | ||
| flex-direction: column; | ||
| } | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| .card, | ||
| .footer { | ||
| border-color: #222; | ||
| } | ||
| .code { | ||
| background: #111; | ||
| } | ||
| .logo img { | ||
| filter: invert(1); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| html, | ||
| body { | ||
| padding: 0; | ||
| margin: 0; | ||
| font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
| Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
| } | ||
|
|
||
| a { | ||
| color: inherit; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| * { | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| html { | ||
| color-scheme: dark; | ||
| } | ||
| body { | ||
| color: white; | ||
| background: black; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.