etherlite 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe14df0fc898d4e298d57704e8a7f2acf0cb3dcace02b94903b8f295f94e971c
4
- data.tar.gz: 87c4bc2dca3fb92d8a1eca54080cbfa50107defe48d0007cc5e6c3910bdfaa4e
3
+ metadata.gz: bbd613d95d4aaec97652278de22e3599754a18979185f8a0eeaea0ef6db3e3c4
4
+ data.tar.gz: c21fe17680a4b4cc82eceedbd413df822da0c9475b9ee4c58f9ba124a481d82e
5
5
  SHA512:
6
- metadata.gz: c1e16e2460b1e67948efd91921b1e03e6805c114fdba9a375c4b83695baa6d01ca80b46fc3530be5ac923c641d47190cc7fc466cdf6daef793f55cb54993be0a
7
- data.tar.gz: 76cb54b21dd785777fcd474f0bbf85e374b9a6aad8bd64d1ddfed73f195c51a736b339045b09056be8da32c34e7d272abcf7393b4bc1bd187efe2fb2186adc57
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
- replace: _options.fetch(:replace, false)
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
 
@@ -1,3 +1,3 @@
1
1
  module Etherlite
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest-sha3