Merge pull request #14 from status-im/etherscan_url

display etherscan url
This commit is contained in:
Iuri Matias 2019-05-24 17:30:17 -04:00 committed by GitHub
commit d1fedb5ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View File

@ -82,7 +82,7 @@ class Actions {
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({gas: 2000000})`
return doAction(text, async () => {
const toSend = this.contracts.LiquidPledging.methods.addProject(params.name, params.url, params.account, params.parentProject, params.commitTime, params.plugin);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
const projectId = receipt.events.ProjectAdded.returnValues.idProject;
console.log("Project ID: " , projectId);
@ -122,14 +122,14 @@ class Actions {
let toSend, receipt;
toSend = this.contracts.LiquidPledging.methods.withdraw(params.id.toString(), this.web3.utils.toWei(params.amount.toString(), "ether"));
receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
const paymentId = receipt.events.AuthorizePayment.returnValues.idPayment;
console.log("Payment ID: " , paymentId);
toSend = this.contracts.LPVault.methods.confirmPayment(paymentId);
receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
});
}
@ -164,7 +164,7 @@ class Actions {
let text = `await LiquidPledging.methods.addGiver(\"${params.name}\", \"${params.url}\", ${params.commitTime}, \"${params.plugin}\").send({gas: 2000000})`
return doAction(text, async () => {
const toSend = this.contracts.LiquidPledging.methods.addGiver(params.name, params.url, params.commitTime, params.plugin);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
const funderId = receipt.events.GiverAdded.returnValues.idGiver;
console.log("Funder ID: " , funderId);
@ -175,7 +175,7 @@ class Actions {
let text = `await StandardToken.methods.mint(\"${params.account}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
return doAction(text, async () => {
const toSend = this.contracts.StandardToken.methods.mint(params.account, this.web3.utils.toWei(params.amount.toString(), "ether"));
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
});
}
@ -184,7 +184,7 @@ class Actions {
let text = `await StandardToken.methods.approve(\"${this.contracts.LiquidPledging.options.address}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
return doAction(text, async () => {
const toSend = this.contracts.StandardToken.methods.approve(this.contracts.LiquidPledging.options.address, this.web3.utils.toWei(params.amount.toString(), "ether"));
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
});
}
@ -193,7 +193,7 @@ class Actions {
let text = `await LiquidPledging.methods.donate(${params.funderId}, ${params.projectId}, \"${params.tokenAddress}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000});`
return doAction(text, async () => {
const toSend = this.contracts.LiquidPledging.methods.donate(params.funderId, params.projectId, params.tokenAddress, this.web3.utils.toWei(params.amount.toString(), "ether"));
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount);
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount, this.chain);
console.dir("txHash: " + receipt.transactionHash);
});
}

View File

@ -241,6 +241,7 @@ const menus = {
},
mintToken: async function() {
console.dir("note: If the transaction fails it likely means this account cannot mint the token (e.g not the owner)");
return inquirer.prompt([
{
type: 'input',

View File

@ -1,6 +1,6 @@
const Spinner = require('cli-spinner').Spinner;
const executeAndWait = async (toSend, account) => {
const executeAndWait = async (toSend, account, chain) => {
return new Promise(async (resolve, reject) => {
const spinner = new Spinner('%s');
spinner.setSpinnerString(18);
@ -8,7 +8,19 @@ const executeAndWait = async (toSend, account) => {
try {
const estimatedGas = await toSend.estimateGas({from: account});
const receipt = await toSend.send({from: account, gas: estimatedGas + 10000});
const tx = toSend.send({from: account, gas: estimatedGas + 10000});
if (chain && chain !== "development") {
tx.on('transactionHash', (transactionHash) => {
let network = "";
if (chain !== "mainnet") {
network = chain + "."
}
console.dir("https://" + network + "etherscan.io/tx/" + transactionHash);
})
}
const receipt = await tx;
spinner.stop(true);
return resolve(receipt);