mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 06:25:57 +00:00
support for geth versions that return multiple contracts in compiled object; maintain compatibility with older geth versions
This commit is contained in:
parent
bea68f8263
commit
1cffb46808
@ -25,7 +25,22 @@ module.exports = (grunt) ->
|
||||
source = grunt.file.read(contractFile)
|
||||
|
||||
grunt.log.writeln("deploying #{contractFile}")
|
||||
contract = web3.eth.compile.solidity(source)
|
||||
compiled_contracts = web3.eth.compile.solidity(source)
|
||||
|
||||
#TODO: refactor this into a common method
|
||||
if compiled_contracts.info is undefined
|
||||
for className, contract of compiled_contracts
|
||||
contractAddress = web3.eth.sendTransaction({from: primaryAddress, data: contract.code})
|
||||
grunt.log.writeln("deployed #{className} at #{contractAddress}")
|
||||
|
||||
abi = JSON.stringify(contract.info.abiDefinition)
|
||||
|
||||
result += "var #{className}Abi = #{abi};"
|
||||
result += "var #{className}Contract = web3.eth.contract(#{className}Abi);"
|
||||
result += "var #{className} = new #{className}Contract('#{contractAddress}');";
|
||||
else
|
||||
#for geth < 0.9.23
|
||||
contract = compiled_contracts
|
||||
contractAddress = web3.eth.sendTransaction({from: primaryAddress, data: contract.code})
|
||||
grunt.log.writeln("deployed at #{contractAddress}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user