From d0162a6c789032858601b83d0851f60026b770b9 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Jul 2018 15:10:22 +0300 Subject: [PATCH] move - for now - determining gas price to deployment to avoid race conditions --- lib/contracts/contract_deployer.js | 7 +++++++ lib/contracts/contracts.js | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/contracts/contract_deployer.js b/lib/contracts/contract_deployer.js index 3385d642a..589992b44 100644 --- a/lib/contracts/contract_deployer.js +++ b/lib/contracts/contract_deployer.js @@ -199,6 +199,13 @@ class ContractDeployer { function applyBeforeDeploy(next) { self.plugins.emitAndRunActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next); }, + function getGasPriceForNetwork(next) { + self.events.request("blockchain:gasPrice", (gasPrice) => { + console.dir('[contracts/contracts]: got gasPrice of ' + gasPrice); + contract.gasPrice = contract.gasPrice || gasPrice; + next(); + }); + }, function createDeployObject(next) { let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition}); diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 007dbbaaf..6e60a5eb6 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -95,13 +95,7 @@ class ContractsManager { }, function getGasPriceForNetwork(callback) { console.dir('[contracts/contracts]: gas price for network, passed in gasPrice from config: ' + self.contractsConfig.gasPrice); - if (self.contractsConfig.gasPrice) { - return callback(null, self.contractsConfig.gasPrice); - } - self.events.request("blockchain:gasPrice", (gasprice) => { - console.dir('[contracts/contracts]: got gasPrice of ' + gasprice); - callback(null, gasprice); - }); + return callback(null, self.contractsConfig.gasPrice); }, function prepareContractsFromCompilation(gasPrice, callback) { console.dir('[contracts/contracts]: using gasprice ' + gasPrice + ', prepare contracts from compilation');