clean up more lazy imports

try catch enable ethereum
This commit is contained in:
Barry Gitarts 2019-08-25 12:46:05 -04:00 committed by Barry G
parent 325a19b683
commit 8a189ba7fb
3 changed files with 15 additions and 8 deletions

View File

@ -256,8 +256,8 @@ class PersistentDrawerLeft extends React.Component {
<Route path="/projects" component={Projects} /> <Route path="/projects" component={Projects} />
<Route path="/(profile|delegate|project)/:id" component={Project} /> <Route path="/(profile|delegate|project)/:id" component={Project} />
<Route path="/(fund-project)/:id" component={FundProject} /> <Route path="/(fund-project)/:id" component={FundProject} />
<Route path="/create-project/" render={(props) => <CreateProject {...props} />} /> <Route path="/create-project/" component={CreateProject} />
<Route path="/create-delegate/" render={(props) => <CreateDelegate {...props} />} /> <Route path="/create-delegate/" component={CreateDelegate} />
<Route path="/(back-delegate|back-project)/:id" component={BackProject} /> <Route path="/(back-delegate|back-project)/:id" component={BackProject} />
<Route path="/project-pledges/:id" component={ProjectPledges} /> <Route path="/project-pledges/:id" component={ProjectPledges} />
<Route path="/console" render={() => <Console logs={logs} variant="dark" />} /> <Route path="/console" render={() => <Console logs={logs} variant="dark" />} />

View File

@ -6,6 +6,7 @@ import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
import Button from '@material-ui/core/Button' import Button from '@material-ui/core/Button'
import InputAdornment from '@material-ui/core/InputAdornment' import InputAdornment from '@material-ui/core/InputAdornment'
import { withStyles } from '@material-ui/core/styles' import { withStyles } from '@material-ui/core/styles'
import { withRouter } from "react-router-dom"
import { uploadFilesToIpfs, pinToGateway, formatMedia, isWeb } from '../../utils/ipfs' import { uploadFilesToIpfs, pinToGateway, formatMedia, isWeb } from '../../utils/ipfs'
import { FundingContext } from '../../context' import { FundingContext } from '../../context'
import {ZERO_ADDRESS} from '../../utils/address' import {ZERO_ADDRESS} from '../../utils/address'
@ -461,4 +462,4 @@ function CreateProject({ classes, history }) {
} }
const StyledProject = withStyles(styles)(CreateProject) const StyledProject = withStyles(styles)(CreateProject)
export default StyledProject export default withRouter(StyledProject)

View File

@ -39,6 +39,8 @@ class App extends React.Component {
if (window.ethereum) { if (window.ethereum) {
const { selectedAddress: account } = window.ethereum const { selectedAddress: account } = window.ethereum
if (account) this.setState({ account }) if (account) this.setState({ account })
} else {
console.log('window.ethreum not found :', {window})
} }
} }
@ -67,11 +69,15 @@ class App extends React.Component {
} }
enableEthereum = async () => { enableEthereum = async () => {
await EmbarkJS.enableEthereum() try {
const account = await web3.eth.getCoinbase() await await window.ethereum.enable()
this.setState({ account }) const account = await web3.eth.getCoinbase()
this.web3Init() this.setState({ account })
return account this.web3Init()
return account
} catch (error) {
console.error('Enable Ethereum :', {error})
}
} }
getAndSetPrices = async () => { getAndSetPrices = async () => {