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="/(profile|delegate|project)/:id" component={Project} />
<Route path="/(fund-project)/:id" component={FundProject} />
<Route path="/create-project/" render={(props) => <CreateProject {...props} />} />
<Route path="/create-delegate/" render={(props) => <CreateDelegate {...props} />} />
<Route path="/create-project/" component={CreateProject} />
<Route path="/create-delegate/" component={CreateDelegate} />
<Route path="/(back-delegate|back-project)/:id" component={BackProject} />
<Route path="/project-pledges/:id" component={ProjectPledges} />
<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 InputAdornment from '@material-ui/core/InputAdornment'
import { withStyles } from '@material-ui/core/styles'
import { withRouter } from "react-router-dom"
import { uploadFilesToIpfs, pinToGateway, formatMedia, isWeb } from '../../utils/ipfs'
import { FundingContext } from '../../context'
import {ZERO_ADDRESS} from '../../utils/address'
@ -461,4 +462,4 @@ function CreateProject({ classes, history }) {
}
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) {
const { selectedAddress: account } = window.ethereum
if (account) this.setState({ account })
} else {
console.log('window.ethreum not found :', {window})
}
}
@ -67,11 +69,15 @@ class App extends React.Component {
}
enableEthereum = async () => {
await EmbarkJS.enableEthereum()
try {
await await window.ethereum.enable()
const account = await web3.eth.getCoinbase()
this.setState({ account })
this.web3Init()
return account
} catch (error) {
console.error('Enable Ethereum :', {error})
}
}
getAndSetPrices = async () => {