Skip to content
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

Account improvements #302

Merged
merged 33 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
889a89b
begin account migration
NoahZinsmeister May 20, 2019
309ece4
Merge remote-tracking branch 'upstream/beta' into account-improvements
NoahZinsmeister May 20, 2019
804b11c
prep for styling
NoahZinsmeister May 20, 2019
d0e1ef8
improve multi-network support
NoahZinsmeister May 20, 2019
fd8040d
kill old modal
NoahZinsmeister May 21, 2019
73bc4fe
remove tests
NoahZinsmeister May 21, 2019
4c6a94f
clean up css
NoahZinsmeister May 21, 2019
aa7bea5
Style account modal
callil May 21, 2019
367ec5b
kill scss
NoahZinsmeister May 21, 2019
cd54cf7
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
NoahZinsmeister May 21, 2019
d6ca265
bug fixes
NoahZinsmeister May 21, 2019
5189273
use suspense for code-splitting and i18n
NoahZinsmeister May 22, 2019
11f958a
Account modal mobile styles
callil May 22, 2019
08416d5
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
callil May 22, 2019
dc49515
style tweaks
callil May 22, 2019
75dcb6c
finalize migration
NoahZinsmeister May 22, 2019
9648409
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
NoahZinsmeister May 22, 2019
b1dd204
fix account styling
callil May 23, 2019
4ecbfc1
fix ethereum svg
NoahZinsmeister May 23, 2019
eaa13e0
fixes
NoahZinsmeister May 23, 2019
68317a7
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
NoahZinsmeister May 23, 2019
e30e54d
Split wallet modal into components
callil May 23, 2019
3124a4c
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
callil May 23, 2019
c6480bf
refactor wallet modal and add connect button styles
callil May 23, 2019
ed1d7c9
removing tap highlights
NoahZinsmeister May 23, 2019
172213b
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
NoahZinsmeister May 23, 2019
9e4f433
Styling fixes for account and warning
callil May 23, 2019
d24d499
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
callil May 23, 2019
55d2015
clean up injected connector logic
NoahZinsmeister May 24, 2019
9a094cf
Merge branch 'account-improvements' of https://github.com/NoahZinsmei…
NoahZinsmeister May 24, 2019
f026fb6
remove console
NoahZinsmeister May 24, 2019
9600966
add wrong network copy
NoahZinsmeister May 24, 2019
2ff36ce
restore border radius
NoahZinsmeister May 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example → .env.local.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
REACT_APP_NETWORK_ID="1"
REACT_APP_NETWORK_URL=""
REACT_APP_NETWORK_NAME="Main Ethereum Network"
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ install: yarn
script:
- yarn check:all
- yarn build
- yarn test
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ yarn

### Configure Environment

Rename `.env.example` to `.env` and fill in the appropriate variables.
Rename `.env.local.example` to `.env.local` and fill in the appropriate variables.

### Run

```bash
yarn start
# or
yarn start:rinkeby
```

More robust support for other testnets is in the works!
To run on a testnet, simply update the `.env.local` file appropriately.

## Contributions

Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@
"homepage": ".",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.18",
"@fortawesome/free-brands-svg-icons": "^5.8.2",
"@fortawesome/free-regular-svg-icons": "^5.8.2",
"@fortawesome/free-solid-svg-icons": "^5.8.2",
"@fortawesome/react-fontawesome": "^0.1.4",
"@reach/dialog": "^0.2.8",
"@reach/tooltip": "^0.2.0",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.2.0",
"escape-string-regexp": "^2.0.0",
"ethers": "^4.0.27",
"i18next": "^15.0.9",
"i18next-browser-languagedetector": "^3.0.1",
"i18next-xhr-backend": "^2.0.1",
"jazzicon": "^1.5.0",
"node-sass": "^4.11.0",
"polished": "^3.3.2",
"react": "^16.8.6",
"react-aria-modal": "^4.0.0",
"react-device-detect": "^1.6.2",
"react-dom": "^16.8.6",
"react-ga": "^2.5.7",
"react-i18next": "^10.7.0",
"react-router-dom": "^5.0.0",
"react-scripts": "^3.0.1",
"react-transition-group": "1.x",
"react-spring": "^8.0.20",
"styled-components": "^4.2.0",
"ua-parser-js": "^0.7.18",
"web3-react": "^5.0.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"start:rinkeby": "REACT_APP_NETWORK_ID=4 REACT_APP_NETWORK_NAME='Rinkeby Test Network' yarn start",
"build:rinkeby": "REACT_APP_NETWORK_ID=4 REACT_APP_NETWORK_NAME='Rinkeby Test Network' yarn build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint:base": "yarn eslint './src/**/*.{js,jsx}'",
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
7 changes: 3 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<!DOCTYPE html />
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -23,8 +23,7 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div id="modal-root"></div>
<div id="root" />
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
67 changes: 0 additions & 67 deletions public/libraries/qr-scanner/qr-scanner-worker.min.js

This file was deleted.

1 change: 1 addition & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"searchOrPaste": "Search Token or Paste Address",
"noExchange": "No Exchange Found",
"exchangeRate": "Exchange Rate",
"unknownError": "Oops! An unknown error occurred. Please refresh the page, or visit from another browser or device.",
"enterValueCont": "Enter a {{ missingCurrencyValue }} value to continue.",
"selectTokenCont": "Select a token to continue.",
"noLiquidity": "No liquidity.",
Expand Down
100 changes: 100 additions & 0 deletions src/InjectedConnector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { Connectors } from 'web3-react'
const { Connector, ErrorCodeMixin } = Connectors

const InjectedConnectorErrorCodes = ['ETHEREUM_ACCESS_DENIED', 'NO_WEB3', 'UNLOCK_REQUIRED']
export default class InjectedConnector extends ErrorCodeMixin(Connector, InjectedConnectorErrorCodes) {
constructor(args = {}) {
super(args)
this.runOnDeactivation = []

this.networkChangedHandler = this.networkChangedHandler.bind(this)
this.accountsChangedHandler = this.accountsChangedHandler.bind(this)

const { ethereum } = window
if (ethereum && ethereum.isMetaMask) {
ethereum.autoRefreshOnNetworkChange = false
}
}

async onActivation() {
const { ethereum, web3 } = window

if (ethereum) {
await ethereum.enable().catch(error => {
const deniedAccessError = Error(error)
deniedAccessError.code = InjectedConnector.errorCodes.ETHEREUM_ACCESS_DENIED
throw deniedAccessError
})

// initialize event listeners
if (ethereum.on) {
ethereum.on('networkChanged', this.networkChangedHandler)
ethereum.on('accountsChanged', this.accountsChangedHandler)

this.runOnDeactivation.push(() => {
if (ethereum.removeListener) {
ethereum.removeListener('networkChanged', this.networkChangedHandler)
ethereum.removeListener('accountsChanged', this.accountsChangedHandler)
}
})
}
} else if (web3) {
console.warn('Your web3 provider is outdated, please upgrade to a modern provider.')
} else {
const noWeb3Error = Error('Your browser is not equipped with web3 capabilities.')
noWeb3Error.code = InjectedConnector.errorCodes.NO_WEB3
throw noWeb3Error
}
}

async getProvider() {
const { ethereum, web3 } = window
return ethereum || web3.currentProvider
}

async getAccount(provider) {
const account = await super.getAccount(provider)

if (account === null) {
const unlockRequiredError = Error('Ethereum account locked.')
unlockRequiredError.code = InjectedConnector.errorCodes.UNLOCK_REQUIRED
throw unlockRequiredError
}

return account
}

onDeactivation() {
this.runOnDeactivation.forEach(runner => runner())
this.runOnDeactivation = []
}

// event handlers
networkChangedHandler(networkId) {
const networkIdNumber = Number(networkId)

try {
super._validateNetworkId(networkIdNumber)

super._web3ReactUpdateHandler({
updateNetworkId: true,
networkId: networkIdNumber
})
} catch (error) {
super._web3ReactErrorHandler(error)
}
}

accountsChangedHandler(accounts) {
if (!accounts[0]) {
const unlockRequiredError = Error('Ethereum account locked.')
unlockRequiredError.code = InjectedConnector.errorCodes.UNLOCK_REQUIRED
super._web3ReactErrorHandler(unlockRequiredError)
} else {
super._web3ReactUpdateHandler({
updateAccount: true,
account: accounts[0]
})
}
}
}
24 changes: 0 additions & 24 deletions src/assets/images/brave-logo.svg

This file was deleted.

Binary file removed src/assets/images/coinbase-wallet-logo.png
Binary file not shown.
19 changes: 11 additions & 8 deletions src/assets/images/ethereum-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/generic-token-logo.png
Binary file not shown.
Binary file removed src/assets/images/logo.png
Binary file not shown.
60 changes: 0 additions & 60 deletions src/assets/images/metamask-logo.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/images/pending.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/images/qr-code.svg

This file was deleted.

17 changes: 17 additions & 0 deletions src/assets/images/spinner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading