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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab1aee5c95b0e162120826ec4d182dad03a7e771
4
- data.tar.gz: 71652479b2bb2a4f81a5d8b417a8703dff1492c6
3
+ metadata.gz: fed925e12c750f5d20aacd3ac6629f53a9b5f2bd
4
+ data.tar.gz: 0bfd128f76455bea9937f82d4d338923d7c6108f
5
5
  SHA512:
6
- metadata.gz: 66065eda0356fa17adf2e017e202c90f8f7e237b0652257816bee3e3cd73d16c435e4bfc1b27d9c69446f5a5d1b53e4b11515e13a56ce48b08f162cc99db90ae
7
- data.tar.gz: 7a34dd68afe840e9f1c37edc64df9176aa7224f38f10fe3c954f3038de7099a76d62dd0fcddd3ae1680285b1ea33f3d9c94a01cc09c8aaf60cdd1571366c69c8
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
- * Pure Ruby implementation
10
- * IPC & HTTP Client with batch calls support
11
- * Compile Solidity contracts with solc compiler
12
- * Deploy and interact with contracts
13
- * Support for contract events
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 to go through [prerequisites](https://github.com/marekkirejczyk/ethereum.rb/blob/master/PREREQUISITES.md) section.
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
 
@@ -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 do |e, i|
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
- raise NotImplementedError
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)
@@ -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
- raise NotImplementedError
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
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Ethereum
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -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 -d ~/.parity"
8
+ args = "--chain testnet"
9
9
  out, _, _ = Open3.capture3("parity #{args} account list")
10
10
  account = out.split(/[\[,\]]/)[1]
11
- cmd = "parity #{args} --password ~/.parity/pass --unlock #{account} --author #{account}"
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.3
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-03 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler