check if contracts config is defined and if not use defaults

This commit is contained in:
Iuri Matias 2015-06-20 08:09:34 -04:00
parent 7bb67dacc8
commit 972bb3a254
1 changed files with 4 additions and 4 deletions

View File

@ -31,14 +31,14 @@ module.exports = (grunt) ->
compiled_contracts = web3.eth.compile.solidity(source) compiled_contracts = web3.eth.compile.solidity(source)
for className, contract of compiled_contracts for className, contract of compiled_contracts
contractGasLimit = contractsConfig[className].gasLimit || gasLimit contractGasLimit = contractsConfig?[className]?.gasLimit || gasLimit
contractGasPrice = contractsConfig[className].gasPrice || gasPrice contractGasPrice = contractsConfig?[className]?.gasPrice || gasPrice
args = contractsConfig[className].args args = contractsConfig?[className]?.args
contractObject = web3.eth.contract(contract.info.abiDefinition) contractObject = web3.eth.contract(contract.info.abiDefinition)
contractParams = args contractParams = args || []
contractParams.push({from: primaryAddress, data: contract.code, gas: contractGasLimit, gasPrice: contractGasPrice}) contractParams.push({from: primaryAddress, data: contract.code, gas: contractGasLimit, gasPrice: contractGasPrice})
contractAddress = contractObject.new.apply(contractObject, contractParams).address contractAddress = contractObject.new.apply(contractObject, contractParams).address