Skip to content

Commit 97f25e8

Browse files
committed
fixed bugs in helper
1 parent 2599ae9 commit 97f25e8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

solc_helper

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

55
def library_code
6-
'function create(abiDefinition) { return web3.eth.contract(abiDefinition);}function deploy(account, value, gas, contract, code, input) { if (typeof(input)===\'undefined\') input = null; var instance = contract.new(input,{from:account, value: value, 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);}'
6+
'function create(abiDefinition) { return web3.eth.contract(abiDefinition);}/*function deploy(account, value, gas, contract, code, input) */function deploy() { var account = arguments[0]; var value = arguments[1]; var gas = arguments[2]; var contract = arguments[3]; var code = arguments[4]; var codeString = "contract.new(inputMarker,{from:\'accountMarker\', value: valueMarker, data: \'codeMarker\', gas: gasMarker}, 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) } })"; codeString = codeString.replace("accountMarker", account); codeString = codeString.replace("valueMarker", value); codeString = codeString.replace("codeMarker", code); codeString = codeString.replace("gasMarker", gas); console.log(codeString); input = "null"; if (arguments.length > 5) { if (arguments[5] != null) { var args = Array.prototype.slice.call(arguments, 5); console.log(args); input = args.join(","); console.log(input); } } codeString = codeString.replace("inputMarker", input); var instance = eval(codeString); 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);}function send(from_index, to, value, gas){ return eth.sendTransaction({from:eth.accounts[from_index], to:to, value:web3.toWei(value,\'ether\'), gas:gas});}'
77
end
88

99

1010
def compile_solidity(file)
11-
puts `solc --optimize --gas #{file}`
12-
puts "\n\n"
1311
json_string = `solc --add-std --optimize --combined-json abi,bin,userdoc,devdoc #{file}`
1412
json_string = json_string.gsub("\\n","")
1513
begin
1614
json_object = JSON.parse(json_string)
1715
throw if json_object.nil?
16+
puts `solc --optimize --gas #{file}`
17+
puts "\n\n"
18+
puts "-------------------------------------"
1819
json_object["contracts"]
1920
rescue
20-
puts json_string
21-
puts "Failed to Compile"
21+
puts "Failed to Compile."
2222
abort
2323
end
2424
end
@@ -104,5 +104,3 @@ File.open(javascript_file_name, 'w') do |f|
104104
end
105105

106106
puts "loadScript('#{`pwd`}/#{javascript_file_name}')".gsub("\n",'')
107-
# ~> -:64:in `read': no implicit conversion of nil into String (TypeError)
108-
# ~> from -:64:in `<main>'

test_compiled.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)