-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.rb
32 lines (27 loc) · 804 Bytes
/
build.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Author: Xiao Liang
require 'tempfile'
require 'shellwords'
f = Tempfile.new('err')
IN="{
\"language\": \"Solidity\",
\"sources\": {
\"main\": {
\"content\": $RC
}
},
\"settings\": {
\"optimizer\": {
\"enabled\": true,
},
\"outputSelection\": {
\"*\": {
'*': [\"evm.deployedBytecode.object\"]
}
}
}
}"
f.close
out = `echo "(jq -n --arg RC #{Shellwords.escape(ENV['R'])} '#{Shellwords.escape(IN)}')" | /bin/solc --standard-json | tee #{Shellwords.escape(f.path)}`
bytecode = `jq -r ".['contracts']['main'][
#{Shellwords.escape(ENV['C'])}]['evm']['deployedBytecode']['object']" < "#{Shellwords.escape(f.path)}"`
exec("echo #{Shellwords.escape(bytecode)}")