fix contract init; display txhash

This commit is contained in:
Iuri Matias 2019-05-22 13:56:41 -04:00
parent bac8b0f93c
commit a8fa5f2666
1 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,7 @@ const Web3 = require("web3");
const web3 = new Web3();
const LiquidPledgingJSONConfig = require("../dist/contracts/LiquidPledging.json");
const LiquidPledging = new web3.eth.Contract(LiquidPledgingJSONConfig.abiDefinition, LiquidPledgingJSONConfig.address);
let LiquidPledging;
function doAction(actionText, action) {
console.dir(actionText)
@ -36,17 +36,22 @@ class Actions {
setTimeout(async () => {
let accounts = await web3.eth.getAccounts();
console.dir("== accounts");
console.dir(accounts);
web3.eth.defaultAccount = accounts[0]
LiquidPledging = new web3.eth.Contract(LiquidPledgingJSONConfig.abiDefinition, LiquidPledgingJSONConfig.address);
cb();
}, 1000);
}
addProject(params) {
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({from: \"${web3.eth.defaultAccount}\", gas: 2000000})`
doAction(text, async () => {
let projectReceipt = await LiquidPledging.methods.addProject(params.name, params.url, params.account, params.parentProject, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000});
console.dir("receipt:")
console.dir(projectReceipt)
console.dir("txHash: " + projectReceipt.transactionHash)
var projectId = projectReceipt.events.ProjectAdded.returnValues.idProject;
console.log(projectId);
@ -57,6 +62,7 @@ class Actions {
let text = `await LiquidPledging.methods.addGiver(\"${params.name}\", \"${params.url}\", ${params.commitTime}, \"${params.plugin}\").send({from: \"${web3.eth.defaultAccount}\", gas: 2000000})`
doAction(text, async () => {
let funderReceipt = await LiquidPledging.methods.addGiver(params.name, params.url, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000})
console.dir("txHash: " + funderReceipt.transactionHash)
var funderId = funderReceipt.events.GiverAdded.returnValues.idGiver;
console.log(funderId);
});
@ -65,7 +71,8 @@ class Actions {
mintToken(params) {
let text = `await StandardToken.methods.mint(\"${params.account}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
doAction(text, async () => {
await StandardToken.methods.mint(params.account, web3.utils.toWei(params.amount, "ether")).send({gas: 2000000})
let mintReceipt = await StandardToken.methods.mint(params.account, web3.utils.toWei(params.amount, "ether")).send({gas: 2000000})
console.dir("txHash: " + mintReceipt.transactionHash)
});
}