mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-01-12 12:34:39 +00:00
move Embark onReady from didMount to its own init
This commit is contained in:
parent
8984a9b2b1
commit
0aeaae5935
50
src/dapp.js
50
src/dapp.js
@ -36,32 +36,7 @@ class App extends React.Component {
|
||||
this.setGraphClient(network)
|
||||
this.getAndSetPrices()
|
||||
|
||||
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 account = await web3.eth.getCoinbase()
|
||||
this.setState({ account })
|
||||
//TODO add block based sync
|
||||
const authorizedPayments = await getAuthorizedPayments()
|
||||
this.syncWithRemote()
|
||||
this.setState({
|
||||
account,
|
||||
network,
|
||||
environment,
|
||||
authorizedPayments,
|
||||
needsInit: false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setGraphClient = network => {
|
||||
@ -91,6 +66,7 @@ class App extends React.Component {
|
||||
await EmbarkJS.enableEthereum()
|
||||
const account = await web3.eth.getCoinbase()
|
||||
this.setState({ account })
|
||||
this.web3Init()
|
||||
}
|
||||
|
||||
getAndSetPrices = async () => {
|
||||
@ -118,6 +94,30 @@ class App extends React.Component {
|
||||
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() {
|
||||
const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar, prices } = this.state
|
||||
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, syncWithRemote, updateUsdPrice, client, enableEthereum } = this
|
||||
|
Loading…
x
Reference in New Issue
Block a user