-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added metamask & localstorage saving
- Loading branch information
Showing
8 changed files
with
2,317 additions
and
185 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,4 @@ | ||
import { createMetaMaskContext } from "@tokenfoundry/react-metamask"; | ||
|
||
const MetaMaskContext = createMetaMaskContext(); | ||
export default MetaMaskContext; |
This file contains 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,61 @@ | ||
// MetaMaskButton.js | ||
import React, { useContext } from "react"; | ||
|
||
import MetaMaskContext from "./MetaMask"; | ||
|
||
export default function MetaMaskButton() { | ||
const { web3, accounts, error, awaiting, openMetaMask } = useContext( | ||
MetaMaskContext, | ||
); | ||
|
||
function handleButtonClick() { | ||
alert(`Web3 (${web3.version}) is enabled`); | ||
} | ||
|
||
if (error && error.message === "MetaMask not installed") { | ||
return ( | ||
<a href="https://metamask.io/" target="_blank" rel="noopener noreferrer"> | ||
Install MetaMask | ||
</a> | ||
); | ||
} else if (error && error.message === "User denied account authorization") { | ||
return ( | ||
<button type="button" onClick={openMetaMask}> | ||
Please allow MetaMask to connect. | ||
</button> | ||
); | ||
} else if (error && error.message === "MetaMask is locked") { | ||
return ( | ||
<button type="button" onClick={openMetaMask}> | ||
Please allow MetaMask to connect. | ||
</button> | ||
); | ||
} else if (error) { | ||
return ( | ||
<button type="button" onClick={openMetaMask}> | ||
UNHANDLED ERROR: {error.message} | ||
</button> | ||
); | ||
} else if (!web3 && awaiting) { | ||
return ( | ||
<button type="button" onClick={openMetaMask}> | ||
MetaMask is loading... | ||
</button> | ||
); | ||
} else if (!web3) { | ||
return ( | ||
<button type="button" onClick={openMetaMask}> | ||
Please open and allow MetaMask | ||
</button> | ||
); | ||
} else if (accounts.length === 0) { | ||
return <button type="button">No Wallet 🦊</button>; | ||
} else { | ||
// `web3` and `account` loaded 🎉 | ||
return ( | ||
<button type="button" onClick={handleButtonClick}> | ||
<code>{accounts[0]}</code> 🦊 (v: {web3.version.api}) | ||
</button> | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,99 +1,5 @@ | ||
@charset "utf-8"; | ||
@import url('https://fonts.googleapis.com/css?family=Baloo+Bhaijaan:400,700|Exo+2:400,700'); | ||
|
||
|
||
// ********************************** | ||
// overwrites | ||
// ********************************** | ||
// Core Variables | ||
$info: #413594 | ||
$success: #20BC44 | ||
$family-sans-serif: 'Exo 2', sans-serif | ||
|
||
$base-col: #2e4e72 | ||
$accent-col-1: #c6dc94 | ||
$accent-col-2: #54b276 | ||
|
||
$input-background-color: transparent | ||
$input-color: white | ||
$input-focus-border-color: white | ||
$input-border-color: rgba(255,255,255,0.5) | ||
|
||
$footer-background-color: #253548 | ||
|
||
$switch-background: rgba(255,255,255,0.1) | ||
|
||
$link-col: #aaaaaa | ||
$link-col-hover: #eeeeee | ||
|
||
|
||
@import '~bulma/bulma.sass' | ||
@import '~bulma-switch/src/sass/index.sass' | ||
|
||
|
||
$dottedlinecolor: rgba(0,0,0,0.3) | ||
|
||
.switch[type="checkbox"].is-rounded + label::after | ||
outline: 0 | ||
|
||
.switch[type="checkbox"].is-link:checked + label::before | ||
outline: 0 | ||
|
||
.switch[type="checkbox"]:focus + label::before | ||
outline: 0 | ||
|
||
|
||
a | ||
color: $link-col | ||
|
||
html | ||
background-color: $base-col | ||
font-family: 'Baloo Bhaijaan', cursive | ||
|
||
a:hover | ||
color: $link-col-hover | ||
|
||
.subtitle | ||
opacity: .7 | ||
|
||
.setting | ||
border-top: 1px dashed $dottedlinecolor | ||
box-sizing:border-box | ||
padding-top: 40px | ||
margin: 50px 0 | ||
|
||
.setting input | ||
margin-top: 15px | ||
outline:none | ||
|
||
.help | ||
margin-top: 10px | ||
font-weight: bold | ||
|
||
|
||
.footer .content p | ||
opacity: .25 | ||
|
||
|
||
.buttons | ||
margin-top: 10vh | ||
|
||
|
||
.set_setting | ||
border-top: 1px dashed $dottedlinecolor | ||
box-sizing:border-box | ||
padding-top: 2vh | ||
margin: 3vh 0 | ||
|
||
.changebtn | ||
margin-top: 4vh | ||
|
||
.switch_w_options | ||
margin-top: 10px | ||
|
||
|
||
.spacer | ||
height: 15px | ||
width: 100% |
Oops, something went wrong.