working client addGiver method
This commit is contained in:
parent
e507075ab4
commit
60624b1871
30
app/dapp.js
30
app/dapp.js
|
@ -1,5 +1,7 @@
|
|||
import React from 'react';
|
||||
import EmbarkJS from 'Embark/EmbarkJS';
|
||||
import LPVault from 'Embark/contracts/LPVault';
|
||||
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock';
|
||||
import web3 from "Embark/web3";
|
||||
|
||||
const { getNetworkType } = web3.eth.net;
|
||||
|
@ -11,14 +13,39 @@ class App extends React.Component {
|
|||
state = { admin: false };
|
||||
|
||||
componentDidMount(){
|
||||
EmbarkJS.onReady((err) => {
|
||||
EmbarkJS.onReady(async (err) => {
|
||||
getNetworkType().then(network => {
|
||||
const { environment } = EmbarkJS
|
||||
this.setState({ network, environment })
|
||||
console.log({LiquidPledgingMock, LPVault})
|
||||
this.addGiver();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
addGiver = async () => {
|
||||
const { addGiver, numberOfPledgeAdmins, getPledgeAdmin } = LiquidPledgingMock.methods;
|
||||
const account = await web3.eth.getCoinbase();
|
||||
const name = 'Giver1';
|
||||
const url = 'urlGiver';
|
||||
const commitTime = 86400;
|
||||
const plugin = 0;
|
||||
const params = { from: account, gas: 1000000 };
|
||||
const args = [name, url, commitTime, plugin];
|
||||
console.log({account})
|
||||
addGiver(...args)
|
||||
.estimateGas({from: account})
|
||||
.then(async gas => {
|
||||
console.log({gas})
|
||||
addGiver(...args).send({ from: account, gas: gas + 100 })
|
||||
const nAdmins = await numberOfPledgeAdmins().call();
|
||||
console.log({nAdmins});
|
||||
const res = await getPledgeAdmin(0).call();
|
||||
console.log({res})
|
||||
})
|
||||
.catch(e => console.log({e}));
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
@ -28,5 +55,4 @@ class App extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export default App;
|
||||
|
|
Loading…
Reference in New Issue