ethereum.rb 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/lib/ethereum/decoder.rb +6 -6
- data/lib/ethereum/encoder.rb +6 -4
- data/lib/ethereum/ipc_client.rb +4 -1
- data/lib/ethereum/version.rb +1 -1
- data/lib/tasks/ethereum_node.rake +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fed925e12c750f5d20aacd3ac6629f53a9b5f2bd
|
4
|
+
data.tar.gz: 0bfd128f76455bea9937f82d4d338923d7c6108f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04f8f2bada3e7ad9862a36793954452ce4a6c7f0244953bac92a6321dd815422a717d67954b9e7b7d7e9a034e543401ad5cb3de430e6886558a10bbaaad267eb
|
7
|
+
data.tar.gz: 25db0535bd9f92c205e2cbb3b3eaad6da21994893b7431e7192d8ed5bd59698cdd7e0401b0b9d805a2f14a2abf88aea970b4f04dfdffc89be5a3223cb0ec1c50
|
data/README.md
CHANGED
@@ -6,15 +6,16 @@ The goal of ethereum.rb is to make interacting with ethereum blockchain from rub
|
|
6
6
|
|
7
7
|
## Highlights
|
8
8
|
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
9
|
+
* Deploy and interact with contracts on the blockchain
|
10
|
+
* Compile Solidity contracts with solc compiler from ruby
|
11
|
+
* Receive events from contract
|
12
|
+
* Run json rpc calls from ruby
|
13
|
+
* Connect to node via IPC or HTTP
|
14
|
+
* Helpful rake tasks for common actions
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
17
|
-
Before installing gem make sure
|
18
|
+
Before installing gem make sure you meet all [prerequisites](https://github.com/marekkirejczyk/ethereum.rb/blob/master/PREREQUISITES.md).
|
18
19
|
|
19
20
|
To install gem simply add this line to your application's Gemfile:
|
20
21
|
|
data/lib/ethereum/decoder.rb
CHANGED
@@ -6,7 +6,7 @@ module Ethereum
|
|
6
6
|
if is_array && arity
|
7
7
|
decode_static_array(arity, array_subtype, value, start)
|
8
8
|
elsif is_array
|
9
|
-
decode_dynamic_array()
|
9
|
+
decode_dynamic_array(array_subtype, value, start)
|
10
10
|
else
|
11
11
|
value = value.gsub(/^0x/,'')
|
12
12
|
core, subtype = Abi::parse_type(type)
|
@@ -16,13 +16,13 @@ module Ethereum
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def decode_static_array(arity, array_subtype, value, start)
|
19
|
-
(1..arity).map.with_index
|
20
|
-
decode(array_subtype, value, start + i * 64)
|
21
|
-
end
|
19
|
+
(1..arity).map.with_index { |e, i| decode(array_subtype, value, start + i * 64) }
|
22
20
|
end
|
23
21
|
|
24
|
-
def decode_dynamic_array()
|
25
|
-
|
22
|
+
def decode_dynamic_array(array_subtype, value, start)
|
23
|
+
location = decode_uint(value[start..(start+63)]) * 2
|
24
|
+
size = decode_uint(value[location..location+63])
|
25
|
+
(1..size).map.with_index { |e, i| decode(array_subtype, value, location + (i+1) * 64) }
|
26
26
|
end
|
27
27
|
|
28
28
|
def decode_fixed(value, subtype = "128x128", start = 0)
|
data/lib/ethereum/encoder.rb
CHANGED
@@ -7,7 +7,7 @@ module Ethereum
|
|
7
7
|
if is_array && arity
|
8
8
|
encode_static_array(arity, array_subtype, value)
|
9
9
|
elsif is_array
|
10
|
-
encode_dynamic_array()
|
10
|
+
encode_dynamic_array(array_subtype, value)
|
11
11
|
else
|
12
12
|
core, subtype = Abi::parse_type(type)
|
13
13
|
method_name = "encode_#{core}".to_sym
|
@@ -19,11 +19,13 @@ module Ethereum
|
|
19
19
|
(1..arity).map.with_index { |e, i| encode(array_subtype, array[i]) }.join
|
20
20
|
end
|
21
21
|
|
22
|
-
def encode_dynamic_array()
|
23
|
-
|
22
|
+
def encode_dynamic_array(array_subtype, array)
|
23
|
+
location = encode_uint(@inputs ? size_of_inputs(@inputs) + @tail.size/2 : 32)
|
24
|
+
size = encode_uint(array.size)
|
25
|
+
data = (1..array.size).map.with_index { |e, i| encode(array_subtype, array[i]) }.join
|
26
|
+
[location, size + data]
|
24
27
|
end
|
25
28
|
|
26
|
-
|
27
29
|
def encode_int(value, _ = nil)
|
28
30
|
to_twos_complement(value).to_s(16).rjust(64, '0')
|
29
31
|
end
|
data/lib/ethereum/ipc_client.rb
CHANGED
@@ -6,7 +6,10 @@ module Ethereum
|
|
6
6
|
IPC_PATHS = [
|
7
7
|
"#{ENV['HOME']}/.parity/jsonrpc.ipc",
|
8
8
|
"#{ENV['HOME']}/Library/Ethereum/geth.ipc",
|
9
|
-
"#{ENV['HOME']}/Library/Ethereum/testnet/geth.ipc"
|
9
|
+
"#{ENV['HOME']}/Library/Ethereum/testnet/geth.ipc",
|
10
|
+
"#{ENV['HOME']}/Library/Application\ Support/io.parity.ethereum/jsonrpc.ipc",
|
11
|
+
"#{ENV['HOME']}/.local/share/parity",
|
12
|
+
"#{ENV['HOME']}/AppData/Roaming/Parity/Ethereum"
|
10
13
|
]
|
11
14
|
|
12
15
|
def initialize(ipcpath = nil, log = true)
|
data/lib/ethereum/version.rb
CHANGED
@@ -5,10 +5,10 @@ namespace :ethereum do
|
|
5
5
|
|
6
6
|
desc "Run testnet (ropsten) node"
|
7
7
|
task :test do
|
8
|
-
args = "--chain testnet
|
8
|
+
args = "--chain testnet"
|
9
9
|
out, _, _ = Open3.capture3("parity #{args} account list")
|
10
10
|
account = out.split(/[\[,\]]/)[1]
|
11
|
-
cmd = "parity #{args} --password
|
11
|
+
cmd = "parity #{args} --password ~/Library/Application\\ Support/io.parity.ethereum/pass --unlock #{account} --author #{account}"
|
12
12
|
puts cmd
|
13
13
|
system cmd
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethereum.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Kirejczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|