Merge pull request #13 from status-im/feat/confirm

feat: confirm payment
This commit is contained in:
Iuri Matias 2019-05-23 15:19:40 -04:00 committed by GitHub
commit 485cf48dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -7,7 +7,7 @@ const Provider = require("./provider.js");
const Web3 = require('web3'); const Web3 = require('web3');
function doAction(actionText, action) { function doAction(actionText, action) {
console.dir(actionText) console.log(actionText)
return new Promise(async(resolve, reject) => { return new Promise(async(resolve, reject) => {
inquirer inquirer
.prompt([ .prompt([
@ -112,13 +112,21 @@ class Actions {
} }
async withdraw(params) { async withdraw(params) {
let text = `await LiquidPledging.methods.withdraw(\"${params.id}\", web3.utils.toWei(\"${params.amount}\", "ether")).send({gas: 2000000})`; let text = `await LiquidPledging.methods.withdraw(\"${params.id}\", web3.utils.toWei(\"${params.amount}\", "ether")).send({gas: 2000000});\nawait LPVault.methods.confirmPayment(paymentId).send({gas: 2000000})`;
return doAction(text, async () => { return doAction(text, async () => {
const toSend = this.contracts.LiquidPledging.methods.withdraw(params.id.toString(), this.web3.utils.toWei(params.amount.toString(), "ether"));
const receipt = await TrxUtils.executeAndWait(toSend, this.web3.eth.defaultAccount); 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);
console.dir("txHash: " + receipt.transactionHash); console.dir("txHash: " + receipt.transactionHash);
const paymentId = receipt.events.AuthorizePayment.returnValues.idPayment; const paymentId = receipt.events.AuthorizePayment.returnValues.idPayment;
console.log("Payment ID: " , paymentId); console.log("Payment ID: " , paymentId);
toSend = this.contracts.LPVault.methods.confirmPayment(paymentId);
receipt = await TrxUtils.executeAndWait(toSend, web3.eth.defaultAccount);
console.dir("txHash: " + receipt.transactionHash);
}); });
} }