etherlite 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/etherlite.rb +7 -2
- data/lib/etherlite/api/parity_rpc.rb +9 -0
- data/lib/etherlite/configuration.rb +9 -1
- data/lib/etherlite/connection.rb +5 -3
- data/lib/etherlite/nonce_manager.rb +6 -2
- data/lib/etherlite/version.rb +1 -1
- data/lib/generators/etherlite/templates/etherlite.yml +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69db28d5eaaf5cb965fedd9cbe71f1aec362d7b
|
4
|
+
data.tar.gz: 9cf45824a5b10fa8462ac11580111f69e7c9d18d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
77
|
+
@connection ||= Connection.new(URI(config.url), config.default_connection_options)
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
@@ -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
|
data/lib/etherlite/connection.rb
CHANGED
@@ -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,
|
8
|
+
def initialize(_uri, _options = {})
|
8
9
|
@uri = _uri
|
9
|
-
@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
|
-
|
40
|
-
|
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?
|
data/lib/etherlite/version.rb
CHANGED
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.
|
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-
|
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
|