remove unneeded web3Init method
This is no longer needed and is fairly resource intensive to invoke
This commit is contained in:
parent
a7e0cfcbbb
commit
c78e23826b
32
src/dapp.js
32
src/dapp.js
|
@ -1,15 +1,12 @@
|
||||||
/*global web3*/
|
|
||||||
/*global process*/
|
/*global process*/
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { HashRouter as Router } from 'react-router-dom'
|
import { HashRouter as Router } from 'react-router-dom'
|
||||||
import EmbarkJS from './embarkArtifacts/embarkjs'
|
import EmbarkJS from './embarkArtifacts/embarkjs'
|
||||||
import EthScan, { HttpProvider } from '@mycrypto/eth-scan'
|
import EthScan, { HttpProvider } from '@mycrypto/eth-scan'
|
||||||
import LiquidPledging from './embarkArtifacts/contracts/LiquidPledging'
|
|
||||||
import Snackbar from '@material-ui/core/Snackbar'
|
import Snackbar from '@material-ui/core/Snackbar'
|
||||||
import { ApolloProvider } from '@apollo/react-hooks'
|
import { ApolloProvider } from '@apollo/react-hooks'
|
||||||
import ApolloClient from 'apollo-boost'
|
import ApolloClient from 'apollo-boost'
|
||||||
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
|
import { initVaultAndLP, standardTokenApproval } from './utils/initialize'
|
||||||
import { getAuthorizedPayments } from './utils/events'
|
|
||||||
import { FundingContext } from './context'
|
import { FundingContext } from './context'
|
||||||
import MainCointainer from './components/MainCointainer'
|
import MainCointainer from './components/MainCointainer'
|
||||||
import Footer from './components/Footer'
|
import Footer from './components/Footer'
|
||||||
|
@ -24,8 +21,6 @@ import { currencies, currencyOrder } from './utils/currencies'
|
||||||
import { uris } from './remote/graph'
|
import { uris } from './remote/graph'
|
||||||
import { getKyberCurrencies } from './remote/kyber'
|
import { getKyberCurrencies } from './remote/kyber'
|
||||||
|
|
||||||
const { getNetworkType } = web3.eth.net
|
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
@ -100,7 +95,6 @@ class App extends React.Component {
|
||||||
const account = accounts[0]
|
const account = accounts[0]
|
||||||
this.setState({ account })
|
this.setState({ account })
|
||||||
this.getAndSetBalances(account)
|
this.getAndSetBalances(account)
|
||||||
this.web3Init()
|
|
||||||
return account
|
return account
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Enable Ethereum :', {error})
|
console.error('Enable Ethereum :', {error})
|
||||||
|
@ -146,30 +140,6 @@ class App extends React.Component {
|
||||||
this.setState({ prices: { ...prices, [key]: price }})
|
this.setState({ prices: { ...prices, [key]: price }})
|
||||||
}
|
}
|
||||||
|
|
||||||
web3Init = () => {
|
|
||||||
EmbarkJS.onReady(async (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(err);
|
|
||||||
} else {
|
|
||||||
getNetworkType().then(async network => {
|
|
||||||
const { environment } = EmbarkJS
|
|
||||||
const isInitialized = await vaultPledgingNeedsInit()
|
|
||||||
if (isInitialized) {
|
|
||||||
if (environment === 'development') console.log('mock_time:', await LiquidPledging.mock_time.call())
|
|
||||||
const authorizedPayments = await getAuthorizedPayments()
|
|
||||||
this.syncWithRemote()
|
|
||||||
this.setState({
|
|
||||||
network,
|
|
||||||
environment,
|
|
||||||
authorizedPayments,
|
|
||||||
needsInit: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, balances, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar, prices } = this.state
|
const { account, balances, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar, prices } = this.state
|
||||||
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, currencies, syncWithRemote, updateUsdPrice, client, enableEthereum } = this
|
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, currencies, syncWithRemote, updateUsdPrice, client, enableEthereum } = this
|
||||||
|
|
Loading…
Reference in New Issue