etherlite 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/etherlite/account/base.rb +9 -0
- data/lib/etherlite/account/private_key.rb +2 -4
- data/lib/etherlite/nonce_manager.rb +3 -1
- data/lib/etherlite/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd613d95d4aaec97652278de22e3599754a18979185f8a0eeaea0ef6db3e3c4
|
4
|
+
data.tar.gz: c21fe17680a4b4cc82eceedbd413df822da0c9475b9ee4c58f9ba124a481d82e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202253e8cea38ae5b51977e130e442cdcc5fb4563f93dd5da802e6dbc8e86e154e08a4b13fc50f05b17c17ba4541d8a9adb6406aee7fb05f79e90fde8e8da594
|
7
|
+
data.tar.gz: 1cbca94d66686e94db2ff819f4d21f6c64035a6004ab56d9d641ab02895ea8dbdb00495a120f4813c75cf00a9d1e0d4efe8e1655f2d23cb907615c0cf60102f6
|
@@ -9,6 +9,15 @@ module Etherlite::Account
|
|
9
9
|
@normalized_address = _normalized_address
|
10
10
|
end
|
11
11
|
|
12
|
+
def next_nonce
|
13
|
+
if @connection.use_parity
|
14
|
+
@connection.parity_next_nonce(address)
|
15
|
+
else
|
16
|
+
# https://github.com/ethereum/go-ethereum/issues/2736
|
17
|
+
@connection.eth_get_transaction_count(address, 'pending')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
12
21
|
def transfer_to(_target, _options = {})
|
13
22
|
send_transaction _options.merge(to: _target, value: _options.fetch(:amount, 0))
|
14
23
|
end
|
@@ -9,10 +9,8 @@ module Etherlite
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def send_transaction(_options = {})
|
12
|
-
nonce_options =
|
13
|
-
|
14
|
-
}
|
15
|
-
|
12
|
+
nonce_options = _options.slice(:replace, :nonce)
|
13
|
+
|
16
14
|
nonce_manager.with_next_nonce_for(normalized_address, nonce_options) do |nonce|
|
17
15
|
tx = Eth::Tx.new(
|
18
16
|
value: _options.fetch(:value, 0),
|
@@ -17,8 +17,10 @@ module Etherlite
|
|
17
17
|
last_nonce
|
18
18
|
end
|
19
19
|
|
20
|
-
def with_next_nonce_for(_normalized_address, replace: false)
|
20
|
+
def with_next_nonce_for(_normalized_address, replace: false, nonce: nil)
|
21
21
|
@@nonce_mutex.synchronize do
|
22
|
+
return yield nonce if nonce.present?
|
23
|
+
|
22
24
|
next_nonce = last_nonce_for(_normalized_address)
|
23
25
|
next_nonce += 1 if next_nonce.negative? || !replace # if first tx, don't replace
|
24
26
|
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: digest-sha3
|