fix displaying menu when tx is still ongoing

This commit is contained in:
Iuri Matias 2019-05-23 14:42:40 -04:00
parent af8ca0894d
commit daf41954da
3 changed files with 19 additions and 17 deletions

View File

@ -39,15 +39,15 @@ class Actions {
connect(url, cb) { connect(url, cb) {
console.dir("connecting to: " + url); console.dir("connecting to: " + url);
this.provider = new Provider(); this.provider = new Provider();
const accounts = [{mnemonic: ""}] const accounts = [{mnemonic: ""}]
this.provider.initAccounts(accounts); this.provider.initAccounts(accounts);
this.provider.startWeb3Provider("ws", url) this.provider.startWeb3Provider("ws", url)
//web3.setProvider(url); //web3.setProvider(url);
setTimeout(async () => { setTimeout(async () => {
this.web3 = this.provider.web3; this.web3 = this.provider.web3;
let accounts = await this.web3.eth.getAccounts(); let accounts = await this.web3.eth.getAccounts();
console.dir("== accounts"); console.dir("== accounts");

View File

@ -30,7 +30,6 @@ class Provider {
//} else { //} else {
this.accounts.push(this.web3.eth.accounts.privateKeyToAccount('0x' + wallet.getPrivateKey().toString('hex'))); this.accounts.push(this.web3.eth.accounts.privateKeyToAccount('0x' + wallet.getPrivateKey().toString('hex')));
//} //}
} }
} }
} }

View File

@ -1,20 +1,23 @@
const Spinner = require('cli-spinner').Spinner; const Spinner = require('cli-spinner').Spinner;
const executeAndWait = async (toSend, account) => { const executeAndWait = async (toSend, account) => {
const spinner = new Spinner('%s'); return new Promise(async (resolve, reject) => {
spinner.setSpinnerString(18); const spinner = new Spinner('%s');
spinner.start(); spinner.setSpinnerString(18);
spinner.start();
try { try {
const estimatedGas = await toSend.estimateGas({from: account}); const estimatedGas = await toSend.estimateGas({from: account});
const receipt = await toSend.send({from: account, gas: estimatedGas + 10000}); const receipt = await toSend.send({from: account, gas: estimatedGas + 10000});
spinner.stop(true); spinner.stop(true);
return receipt; return resolve(receipt);
} catch(error) { } catch(error) {
console.log("Error: ", error.message); console.log("Error: ", error.message);
spinner.stop(true); spinner.stop(true);
} }
resolve();
});
} }
module.exports = { module.exports = {