add vault and LP initialization
This commit is contained in:
parent
f3499e69be
commit
e6c74f731a
|
@ -25,24 +25,19 @@ const CreateFunding = () => (
|
|||
const { funderId, receiverId, tokenAddress, amount } = values
|
||||
const account = await web3.eth.getCoinbase()
|
||||
const args = [funderId, receiverId, tokenAddress, web3.utils.toWei(amount, 'ether')]
|
||||
console.log({args, donate, LiquidPledgingMock})
|
||||
donate(...args)
|
||||
.estimateGas({ from: account })
|
||||
.then(async gas => {
|
||||
donate(...args)
|
||||
.send({ from: account, gas: gas + 100 })
|
||||
.then(res => {
|
||||
console.log({res})
|
||||
setStatus({
|
||||
snackbar: { variant: 'success', message: 'funding provided!' }
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
console.log({e})
|
||||
setStatus({
|
||||
snackbar: { variant: 'error', message: 'There was an error' }
|
||||
})
|
||||
})
|
||||
.send({ from: account })
|
||||
.then(res => {
|
||||
console.log({res})
|
||||
setStatus({
|
||||
snackbar: { variant: 'success', message: 'funding provided!' }
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
console.log({e})
|
||||
setStatus({
|
||||
snackbar: { variant: 'error', message: 'There was an error' }
|
||||
})
|
||||
})
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -3,8 +3,10 @@ import EmbarkJS from 'Embark/EmbarkJS';
|
|||
import LPVault from 'Embark/contracts/LPVault';
|
||||
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock';
|
||||
import web3 from "Embark/web3";
|
||||
import Divider from '@material-ui/core/Divider';
|
||||
import AddFunder from './components/AddFunder';
|
||||
import CreateFunding from './components/CreateFunding';
|
||||
import { initVaultAndLP } from './utils/initialize';
|
||||
|
||||
const { getNetworkType } = web3.eth.net;
|
||||
|
||||
|
@ -16,9 +18,12 @@ class App extends React.Component {
|
|||
|
||||
componentDidMount(){
|
||||
EmbarkJS.onReady(async (err) => {
|
||||
getNetworkType().then(network => {
|
||||
getNetworkType().then(async network => {
|
||||
const { environment } = EmbarkJS
|
||||
const needsInit = Number(await LiquidPledgingMock.methods.getInitializationBlock().call())
|
||||
+ Number(await LPVault.methods.getInitializationBlock().call())
|
||||
this.setState({ network, environment })
|
||||
if (!needsInit) initVaultAndLP(LiquidPledgingMock, LPVault)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -27,6 +32,7 @@ class App extends React.Component {
|
|||
return (
|
||||
<div>
|
||||
<AddFunder />
|
||||
<Divider variant="middle" />
|
||||
<CreateFunding />
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
export const initVaultAndLP = async (lp, vault) => {
|
||||
const vaultInit = await vault.methods.initialize(lp._address).send()
|
||||
console.log(vaultInit)
|
||||
const lpInit = await lp.methods.initialize(vault._address).send()
|
||||
console.log(lpInit)
|
||||
}
|
Loading…
Reference in New Issue