web3-eth 0.2.13 → 0.2.14

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: c1a1dffc7e7cb171bcd55633ad913b208abfa4c9
4
- data.tar.gz: d80a5fd8df22cf65211d827a5b125e841274d9f4
3
+ metadata.gz: ef7c29f56dd299e95ab99030916ab74f49c8ab64
4
+ data.tar.gz: 37e532f820f44111b24985cb98821fb7e5773cfb
5
5
  SHA512:
6
- metadata.gz: 26e26cca29110c636b17a05924fdacd9ff6a96950ca8c42da6d0128fc2d77d1a94de8b11519bf9abda66f4a7f0dd74850b4161298be6e508ba4388a275f2c13d
7
- data.tar.gz: a6af3fd9cd9d3d33ffbf5504b73da451bf736be6784a19ccc155beb5f6b0fb1b568e276d3a9c7fba3698dcdd1063c7ec89f9f5d5df1b5dac7a37fe3ccff481c1
6
+ metadata.gz: 73178ab1c8530fbdbce1ad4fa8c489316e37e614b27f989c224d9a05e35ebf642340ea6d529532b025ee6ae43d1c802315cd0352f55c8a8faeb19da860e127e3
7
+ data.tar.gz: 3ab2344cff8b9b00cf7e06be974f5f89682bbbbfa5f126c2a5a1b7b913c3e6ce9d03d7b06bc8cd14d1188f2593b4a2ab9acf30095e0e3345018accf6b42c730f
@@ -95,7 +95,7 @@ module Web3
95
95
 
96
96
  end
97
97
 
98
- attr_reader :web3_rpc, :abi, :functions, :events, :constructor
98
+ attr_reader :web3_rpc, :abi, :functions, :events, :constructor, :functions_by_hash, :events_by_hash
99
99
 
100
100
  def initialize abi, web_rpc = nil
101
101
  @web3_rpc = web_rpc
@@ -115,11 +115,11 @@ module Web3
115
115
  end
116
116
 
117
117
  def find_event_by_hash method_hash
118
- events.values.detect{|e| e.signature_hash==method_hash}
118
+ @events_by_hash[method_hash]
119
119
  end
120
120
 
121
121
  def find_function_by_hash method_hash
122
- functions.values.detect{|e| e.signature_hash==method_hash}
122
+ @functions_by_hash[method_hash]
123
123
  end
124
124
 
125
125
  def parse_log_args log
@@ -142,9 +142,25 @@ module Web3
142
142
  private
143
143
 
144
144
  def parse_abi abi
145
- @functions = Hash[abi.select{|a| a['type']=='function'}.map{|a| [a['name'], ContractMethod.new(a)]}]
146
- @events = Hash[abi.select{|a| a['type']=='event'}.map{|a| [a['name'], ContractMethod.new(a)]}]
147
- @constructor = (constructor = abi.detect{|a| a['type']=='constructor'}) && ContractMethod.new(constructor)
145
+ @functions = {}
146
+ @events = {}
147
+
148
+ @functions_by_hash = {}
149
+ @events_by_hash = {}
150
+
151
+ abi.each{|a|
152
+ method = ContractMethod.new(a)
153
+ case a['type']
154
+ when 'function'
155
+ @functions[method.name] = method
156
+ @functions_by_hash[method.signature_hash] = method
157
+ when 'event'
158
+ @events[method.name] = method
159
+ @events_by_hash[method.signature_hash] = method
160
+ when 'constructor'
161
+ @constructor = method
162
+ end
163
+ }
148
164
  end
149
165
 
150
166
  end
@@ -36,7 +36,9 @@ module Web3
36
36
  end
37
37
 
38
38
  def block_number
39
- from_hex blockNumber
39
+ # if transaction is less than 12 seconds old, blockNumber will be nil
40
+ # :. nil check before calling `to_hex` to avoid argument error
41
+ blockNumber && from_hex(blockNumber)
40
42
  end
41
43
 
42
44
  def value_wei
@@ -68,4 +70,4 @@ module Web3
68
70
 
69
71
  end
70
72
  end
71
- end
73
+ end
@@ -1,5 +1,5 @@
1
1
  module Web3
2
2
  module Eth
3
- VERSION = "0.2.13"
3
+ VERSION = "0.2.14"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web3-eth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - studnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-05 00:00:00.000000000 Z
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rlp