mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-01-28 20:25:19 +00:00
add ApolloProvider
This commit is contained in:
parent
5dfb17cb03
commit
cc2c2a073a
16
src/dapp.js
16
src/dapp.js
@ -4,6 +4,8 @@ import { HashRouter as Router } from 'react-router-dom'
|
|||||||
import EmbarkJS from './embarkArtifacts/embarkjs'
|
import EmbarkJS from './embarkArtifacts/embarkjs'
|
||||||
import LiquidPledging from './embarkArtifacts/contracts/LiquidPledging'
|
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 ApolloClient, { gql } from 'apollo-boost'
|
||||||
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
|
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
|
||||||
import { getAuthorizedPayments } from './utils/events'
|
import { getAuthorizedPayments } from './utils/events'
|
||||||
import { FundingContext } from './context'
|
import { FundingContext } from './context'
|
||||||
@ -39,6 +41,9 @@ class App extends React.Component {
|
|||||||
if (environment === 'development') console.log('mock_time:', await LiquidPledging.mock_time.call())
|
if (environment === 'development') console.log('mock_time:', await LiquidPledging.mock_time.call())
|
||||||
|
|
||||||
const graphUri = uris[network]
|
const graphUri = uris[network]
|
||||||
|
this.client = new ApolloClient({
|
||||||
|
uri: graphUri,
|
||||||
|
})
|
||||||
const account = await web3.eth.getCoinbase()
|
const account = await web3.eth.getCoinbase()
|
||||||
this.getAndSetPrices()
|
this.getAndSetPrices()
|
||||||
this.setState({ account })
|
this.setState({ account })
|
||||||
@ -98,14 +103,13 @@ class App extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar, prices, graphUri } = this.state
|
const { account, needsInit, lpAllowance: _lpAllowance, loading, authorizedPayments, snackbar, prices } = this.state
|
||||||
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, syncWithRemote, updateUsdPrice } = this
|
const { appendFundProfile, appendPledges, transferPledgeAmounts, openSnackBar, closeSnackBar, syncWithRemote, updateUsdPrice, client } = this
|
||||||
const fundingContext = {
|
const fundingContext = {
|
||||||
appendPledges,
|
appendPledges,
|
||||||
appendFundProfile,
|
appendFundProfile,
|
||||||
account,
|
account,
|
||||||
transferPledgeAmounts,
|
transferPledgeAmounts,
|
||||||
graphUri,
|
|
||||||
authorizedPayments,
|
authorizedPayments,
|
||||||
needsInit,
|
needsInit,
|
||||||
initVaultAndLP,
|
initVaultAndLP,
|
||||||
@ -116,7 +120,9 @@ class App extends React.Component {
|
|||||||
prices,
|
prices,
|
||||||
updateUsdPrice
|
updateUsdPrice
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
|
if (client) return (
|
||||||
|
<ApolloProvider client={client}>
|
||||||
<FundingContext.Provider value={fundingContext}>
|
<FundingContext.Provider value={fundingContext}>
|
||||||
<Router>
|
<Router>
|
||||||
<MainCointainer loading={loading} />
|
<MainCointainer loading={loading} />
|
||||||
@ -136,7 +142,9 @@ class App extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</Snackbar>}
|
</Snackbar>}
|
||||||
</FundingContext.Provider>
|
</FundingContext.Provider>
|
||||||
|
</ApolloProvider>
|
||||||
)
|
)
|
||||||
|
return <div>Loading</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export const uris = {
|
export const uris = {
|
||||||
ropsten: 'wss://api.thegraph.com/subgraphs/name/bgits/liquid-funding-rinkeby'
|
ropsten: 'https://api.thegraph.com/subgraphs/name/bgits/liquid-funding-rinkeby'
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user