etherlite 0.5.3 → 0.6.0

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
  SHA256:
3
- metadata.gz: 3e0dfced593354434b36a9de586f7b19828b9f5e7eb30764efd9623b91a3496e
4
- data.tar.gz: 68fbf0acbe771dc1c86d94a969f8222b05697c0b954c41ffb78e4017ffa22180
3
+ metadata.gz: 98f9a12feec6ffb0a40a90f914810d9960f526920cc86bbbfe1c323ea83cc2ea
4
+ data.tar.gz: ea64f460710a7f52bcc3b1ea1a0ec1f7dbc2c3d06eba96f5a07df491efd07bb7
5
5
  SHA512:
6
- metadata.gz: 69bdfe008c0d08c9cabcda8f651401715441eba7b97de61fc55e9b99459ac428b17b465eacdfd96698ca5cd361d7133a0c17b70e964684ae9d0cb279d5ccc861
7
- data.tar.gz: dc82638a7c9a62c28bb507e0e213fe3afcf5836f2a11b8b717b6caac1b06c87bc9073373fbb0e88d0fab43557de4bf8d4be9be1ea04c9a2c0ecbc62cb4d00c3f
6
+ metadata.gz: 8af135b1ea2716ee896df900dcc425fd47d0384990d89964fd06b43dae03ad7c0e3bf1937937b0119ebed6171e416548d4744b258b0607ddf6a6dae9bcd45f2d
7
+ data.tar.gz: 6e0f1ec2f8db9860147e475b0ec7e283902ce70a580a6633d5eff126d18b3dcbd6c039f72ddeed4b1a47e0b30edd7cb7c2caa1b22fe83548add6591e2f19f7dd
data/etherlite.gemspec CHANGED
@@ -3,33 +3,33 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'etherlite/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "etherlite"
6
+ spec.name = 'etherlite'
7
7
  spec.version = Etherlite::VERSION
8
- spec.authors = ["Ignacio Baixas"]
9
- spec.email = ["ignacio@budacom.com"]
8
+ spec.authors = ['Ignacio Baixas']
9
+ spec.email = ['ignacio@budacom.com']
10
10
 
11
11
  spec.summary = 'Ethereum integration for ruby on rails'
12
12
  spec.description = ''
13
- spec.homepage = "https://github.com/budacom/etherlite"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/budacom/etherlite'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency "activesupport"
24
- spec.add_dependency "eth", "~> 0.4.4"
23
+ spec.add_dependency 'activesupport'
24
+ spec.add_dependency 'eth', '~> 0.5.10'
25
25
  spec.add_dependency 'keccak', '~> 1.3', '>= 1.3.1'
26
- spec.add_dependency "power-types", "~> 0.1"
26
+ spec.add_dependency 'power-types', '~> 0.1'
27
27
 
28
- spec.add_development_dependency "bundler", "~> 2.1"
29
- spec.add_development_dependency "guard", "~> 2.14"
30
- spec.add_development_dependency "guard-rspec", "~> 4.7"
31
- spec.add_development_dependency "pry"
32
- spec.add_development_dependency "rake", "~> 10.0"
33
- spec.add_development_dependency "rspec", "~> 3.0"
34
- spec.add_development_dependency "webmock", "~> 3.7.5"
28
+ spec.add_development_dependency 'bundler', '~> 2.1'
29
+ spec.add_development_dependency 'guard', '~> 2.14'
30
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
31
+ spec.add_development_dependency 'pry'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'webmock', '~> 3.7.5'
35
35
  end
@@ -5,13 +5,14 @@ module Etherlite
5
5
  class PrivateKey < Base
6
6
  def initialize(_connection, _pk)
7
7
  @key = Eth::Key.new priv: _pk
8
- super _connection, Etherlite::Utils.normalize_address(@key.address)
8
+ super _connection, Etherlite::Utils.normalize_address(@key.address.to_s)
9
9
  end
10
10
 
11
11
  def build_raw_transaction(_options = {})
12
12
  nonce = nonce_manager.next_nonce_for(normalized_address, _options.slice(:replace, :nonce))
13
13
 
14
14
  tx = Eth::Tx.new(
15
+ chain_id: @connection.chain_id,
15
16
  value: _options.fetch(:value, 0),
16
17
  data: _options.fetch(:data, ''),
17
18
  gas_limit: _options.fetch(:gas, 90_000),
@@ -20,23 +21,20 @@ module Etherlite
20
21
  nonce: nonce
21
22
  )
22
23
 
23
- sign_with_connection_chain tx
24
-
24
+ tx.sign @key
25
25
  tx
26
26
  end
27
27
 
28
28
  def send_transaction(_options = {})
29
29
  tx = build_raw_transaction(_options)
30
30
 
31
- nonce_manager.with_next_nonce_for(normalized_address, nonce: tx.nonce) do |nonce|
32
- Etherlite::Transaction.new @connection, @connection.eth_send_raw_transaction(tx.hex)
31
+ nonce_manager.with_next_nonce_for(normalized_address, nonce: tx.signer_nonce) do |_|
32
+ Etherlite::Transaction.new @connection, @connection.eth_send_raw_transaction("0x#{tx.hex}")
33
33
  end
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- @@eth_mutex = Mutex.new
39
-
40
38
  def gas_price
41
39
  # TODO: improve on this
42
40
  @gas_price ||= connection.eth_gas_price
@@ -45,13 +43,6 @@ module Etherlite
45
43
  def nonce_manager
46
44
  Etherlite::NonceManager.new @connection
47
45
  end
48
-
49
- def sign_with_connection_chain(_tx)
50
- @@eth_mutex.synchronize do
51
- Eth.configure { |c| c.chain_id = @connection.chain_id }
52
- _tx.sign @key
53
- end
54
- end
55
46
  end
56
47
  end
57
48
  end
@@ -60,15 +60,6 @@ module Etherlite
60
60
  @anonymous_account ||= Etherlite::Account::Anonymous.new(connection)
61
61
  end
62
62
 
63
- def account_from_pk(_pk)
64
- Etherlite.logger.warn(
65
- "use of 'account_from_pk' is deprecated and will be removed in next version, \
66
- use 'load_account' instead"
67
- )
68
-
69
- load_account(from_pk: _pk)
70
- end
71
-
72
63
  def_delegators :default_account, :unlock, :lock, :normalized_address, :transfer_to, :call
73
64
  end
74
65
  end
@@ -3,7 +3,7 @@ module Etherlite
3
3
  include Api::Rpc
4
4
  include Api::ParityRpc
5
5
 
6
- attr_reader :chain_id, :use_parity
6
+ attr_reader :uri, :chain_id, :use_parity
7
7
 
8
8
  def initialize(_uri, _options = {})
9
9
  @uri = _uri
@@ -1,3 +1,3 @@
1
1
  module Etherlite
2
- VERSION = "0.5.3"
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/lib/etherlite.rb CHANGED
@@ -56,7 +56,7 @@ module Etherlite
56
56
  _url = URI(_url) unless _url.is_a? URI
57
57
 
58
58
  options = config.default_connection_options
59
- options = options.merge _options.slice options.keys
59
+ options = options.merge _options.slice(*options.keys)
60
60
 
61
61
  Client.new Connection.new(_url, options)
62
62
  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.5.3
4
+ version: 0.6.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: 2023-04-11 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.4
33
+ version: 0.5.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.4
40
+ version: 0.5.10
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: keccak
43
43
  requirement: !ruby/object:Gem::Requirement