etherlite 0.1.7 → 0.1.8

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: cb97370a946be81259847d2b1f3c7a6da33593e2
4
- data.tar.gz: 373696bf36bcf5b5b7889ffe7eadfd0bf3544881
3
+ metadata.gz: c69db28d5eaaf5cb965fedd9cbe71f1aec362d7b
4
+ data.tar.gz: 9cf45824a5b10fa8462ac11580111f69e7c9d18d
5
5
  SHA512:
6
- metadata.gz: f45918243e835c01d28c6beb7f3c42ffb77fa35047aab3051aba1f555eb4a65c6e6d7dc0b218a4efbdcb1efef3b3fd3b0b2a1e79f4bd22f202e43085169fc5f7
7
- data.tar.gz: 22a6b1e87b0b9778de84607fd2d7d6cc59e35b14c14928ef984d4bfa32901f82d549f7c90ee018071847c69c1ba887e6ec4216989456b5d98efd8c278679d362
6
+ metadata.gz: f53a236a303da24b8fa4871b375ad84f2f70f44ad9b0aa14a9cf893159a218ac75ab38ef5299a2a6affa85ac1ee1b02b1bc8f7d0dd89e2bdf1ffe6d9acd1c1f1
7
+ data.tar.gz: bc975a810c245c95f7eabbb9e671556d4ffd6a085b45afc48a2b7516f11b92a7bc8bff71e75b78079f7d99bc8840a1d1d5cf3db8a8d153cfa7dedc0c979fd511
data/lib/etherlite.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "digest/sha3"
2
2
  require "active_support/all"
3
3
  require "forwardable"
4
+ require "net/http"
4
5
  require "power-types"
5
6
 
6
7
  require "etherlite/version"
@@ -8,6 +9,7 @@ require "etherlite/version"
8
9
  require "etherlite/api/address"
9
10
  require "etherlite/api/node"
10
11
  require "etherlite/api/rpc"
12
+ require "etherlite/api/parity_rpc"
11
13
 
12
14
  require "etherlite/support/array"
13
15
 
@@ -52,7 +54,10 @@ module Etherlite
52
54
  def self.connect(_url, _options = {})
53
55
  _url = URI(_url) unless _url.is_a? URI
54
56
 
55
- Client.new Connection.new(_url, _options.fetch(:chain_id, config.chain_id))
57
+ options = config.default_connection_options
58
+ options = options.merge _options.slice options.keys
59
+
60
+ Client.new Connection.new(_url, options)
56
61
  end
57
62
 
58
63
  def self.config
@@ -69,7 +74,7 @@ module Etherlite
69
74
  end
70
75
 
71
76
  def self.connection
72
- @connection ||= Connection.new(URI(config.url), config.chain_id)
77
+ @connection ||= Connection.new(URI(config.url), config.default_connection_options)
73
78
  end
74
79
  end
75
80
 
@@ -0,0 +1,9 @@
1
+ module Etherlite
2
+ module Api
3
+ module ParityRpc
4
+ def parity_next_nonce(_address)
5
+ Etherlite::Utils.hex_to_uint ipc_call(:parity_nextNonce, _address)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -3,11 +3,19 @@ module Etherlite
3
3
  DEFAULTS = {
4
4
  url: 'http://127.0.0.1:8545',
5
5
  enable_nonce_cache: false,
6
+ use_parity: false,
6
7
  chain_id: nil, # any chain
7
8
  logger: nil # set by method
8
9
  }
9
10
 
10
- attr_accessor :url, :chain_id, :logger, :enable_nonce_cache
11
+ attr_accessor :url, :chain_id, :logger, :use_parity, :enable_nonce_cache
12
+
13
+ def default_connection_options
14
+ {
15
+ chain_id: chain_id,
16
+ use_parity: use_parity
17
+ }
18
+ end
11
19
 
12
20
  def initialize
13
21
  assign_attributes DEFAULTS
@@ -1,12 +1,14 @@
1
1
  module Etherlite
2
2
  class Connection
3
3
  include Api::Rpc
4
+ include Api::ParityRpc
4
5
 
5
- attr_reader :chain_id
6
+ attr_reader :chain_id, :use_parity
6
7
 
7
- def initialize(_uri, _chain_id = nil)
8
+ def initialize(_uri, _options = {})
8
9
  @uri = _uri
9
- @chain_id = _chain_id
10
+ @chain_id = _options[:chain_id]
11
+ @use_parity = _options[:use_parity]
10
12
  end
11
13
 
12
14
  def ipc_call(_method, *_params)
@@ -36,8 +36,12 @@ module Etherlite
36
36
  private
37
37
 
38
38
  def last_observed_nonce_for(_normalized_address)
39
- # https://github.com/ethereum/go-ethereum/issues/2736
40
- @connection.eth_get_transaction_count('0x' + _normalized_address, 'pending') - 1
39
+ if @connection.use_parity
40
+ @connection.parity_next_nonce('0x' + _normalized_address) - 1
41
+ else
42
+ # https://github.com/ethereum/go-ethereum/issues/2736
43
+ @connection.eth_get_transaction_count('0x' + _normalized_address, 'pending') - 1
44
+ end
41
45
  end
42
46
 
43
47
  def caching_enabled?
@@ -1,3 +1,3 @@
1
1
  module Etherlite
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  defaults:
2
+ use_parity: false
2
3
  contract_path: 'contracts'
3
4
 
4
5
  development: &defaults
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etherlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignacio Baixas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest-sha3
@@ -192,6 +192,7 @@ files:
192
192
  - lib/etherlite/address.rb
193
193
  - lib/etherlite/api/address.rb
194
194
  - lib/etherlite/api/node.rb
195
+ - lib/etherlite/api/parity_rpc.rb
195
196
  - lib/etherlite/api/rpc.rb
196
197
  - lib/etherlite/client.rb
197
198
  - lib/etherlite/commands/abi/load_contract.rb