Skip to content

Commit 25fcf3e

Browse files
committed
added watcher function
1 parent 8009d93 commit 25fcf3e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

solc_helper

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
require 'json'
44

55
def library_code
6-
'function createContract(abiDefinition) { return web3.eth.contract(abiDefinition);}function deployContract(account, gas, contract, code, input) { if (typeof(input)===\'undefined\') input = null; var instance = contract.new(input,{from:account, data: code, gas: gas}, function (e, contract) { if(!e) { if(!contract.address) { console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } else { console.log("Contract mined! Address: " + contract.address); console.log(contract); } } else { console.log(e) } }); return instance;}
7-
'
6+
'function create(abiDefinition) { return web3.eth.contract(abiDefinition);}function deploy(account, gas, contract, code, input) { if (typeof(input)===\'undefined\') input = null; var instance = contract.new(input,{from:account, data: code, gas: gas}, function (e, contract) { if(!e) { if(!contract.address) { console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } else { console.log("Contract mined! Address: " + contract.address); } } else { console.log(e) } }); return instance;}function watcher(error, result) { if (!error) { console.log("Result"); console.log(JSON.stringify(result)); return; } console.log("Error" + error);}function call(account, gas, func, input) { if (typeof(input)===\'undefined\') input = null; func.sendTransaction(input, gas, {from:account}, watcher);}'
87
end
98

109

@@ -65,13 +64,11 @@ contract_instance_variable_name = "#{current_contract}"
6564

6665
gas = get_gas
6766
input = get_input
68-
puts input
69-
7067

7168
File.open(javascript_file_name, 'w') do |f|
7269
f.write("#{library_code};\nvar #{compiled_variable_name} = #{compiled_object.to_json};")
73-
f.write("#{contract_variable_name} = createContract(#{compiled_variable_name}.#{current_contract}.info.abiDefinition);")
74-
f.write("#{contract_instance_variable_name} = deployContract(eth.coinbase,#{gas},#{contract_variable_name},#{compiled_variable_name}.#{current_contract}.code,#{input});")
70+
f.write("#{contract_variable_name} = create(#{compiled_variable_name}.#{current_contract}.info.abiDefinition);")
71+
f.write("#{contract_instance_variable_name} = deploy(eth.coinbase,#{gas},#{contract_variable_name},#{compiled_variable_name}.#{current_contract}.code,#{input});")
7572
f.write("console.log('Compiled Object : #{compiled_variable_name}');")
7673
f.write("console.log('Contract : #{contract_variable_name}');")
7774
f.write("console.log('Contract Instance : #{contract_instance_variable_name}');")

0 commit comments

Comments
 (0)