From c6b3c226c469da9498f2898f46e653d3b1132104 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 23 Aug 2018 15:58:09 -0400 Subject: [PATCH] Simplifying code --- gas-relayer/src/contract-settings.js | 12 ++++++------ gas-relayer/src/strategy/BaseStrategy.js | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gas-relayer/src/contract-settings.js b/gas-relayer/src/contract-settings.js index 22d3e50..09bcad1 100644 --- a/gas-relayer/src/contract-settings.js +++ b/gas-relayer/src/contract-settings.js @@ -54,21 +54,21 @@ class ContractSettings { return this.web3.utils.toHex(contractName).slice(0, 10); } - _obtainContractBytecode(topicName){ + async _obtainContractBytecode(topicName){ if(this.contracts[topicName].isIdentity) return; this.pendingToLoad++; - this.web3.eth.getCode(this.contracts[topicName].address) - .then(code => { + + try { + const code = await this.web3.eth.getCode(this.contracts[topicName].address) this.contracts[topicName].code = this.web3.utils.soliditySha3(code); this.pendingToLoad--; if(this.pendingToLoad == 0) this.events.emit("setup:complete", this); - }) - .catch((err) => { + } catch(err) { console.error("Invalid contract for " + topicName); console.error(err); process.exit(); - }); + } } _extractFunctions(topicName){ diff --git a/gas-relayer/src/strategy/BaseStrategy.js b/gas-relayer/src/strategy/BaseStrategy.js index bd0b45e..bdd0ec7 100644 --- a/gas-relayer/src/strategy/BaseStrategy.js +++ b/gas-relayer/src/strategy/BaseStrategy.js @@ -29,8 +29,6 @@ class BaseStrategy { } async _estimateGas(input){ -console.dir(input); - let p = { from: this.config.node.blockchain.account, to: input.contract,