web3-eth 0.2.21 → 0.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/web3/eth/abi/abi_coder.rb +1 -1
- data/lib/web3/eth/abi/type.rb +57 -4
- data/lib/web3/eth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367f280dbfd454078088f84b5285554facb4c0ef
|
4
|
+
data.tar.gz: 46b237bcdfa35281333e08a7e75b30b25a2f021b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fd72406fee7ec39e1e0301083c67cc43b2515f8946d00a4cc6143018a1119f9eed4e4248c3d9275a16da3796173cf628f93f7ee99ab0cbdbe3bf771da696273
|
7
|
+
data.tar.gz: fb1a3ddc4178a0e0163bebed295baca51bc350682ec4da3ba746bfca38d4482b95b876c8a6afa369a06dd81f9580a90d12ecc2787021b4f864a97333020b29b0
|
@@ -248,7 +248,7 @@ module Web3::Eth::Abi
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def decode_type(type, arg)
|
251
|
-
return nil if arg.nil?
|
251
|
+
return nil if arg.nil? || arg.empty?
|
252
252
|
if type.kind_of?(Tuple) && type.dims.empty?
|
253
253
|
arg ? decode_abi(type.types, arg) : []
|
254
254
|
elsif %w(string bytes).include?(type.base) && type.sub.empty?
|
data/lib/web3/eth/abi/type.rb
CHANGED
@@ -14,7 +14,7 @@ module Web3::Eth::Abi
|
|
14
14
|
def parse(type)
|
15
15
|
|
16
16
|
if type =~ /^\((.*)\)((\[[0-9]*\])*)/
|
17
|
-
return Tuple.
|
17
|
+
return Tuple.parse $1, $2.scan(/\[[0-9]*\]/)
|
18
18
|
end
|
19
19
|
|
20
20
|
_, base, sub, dimension = /([a-z]*)([0-9]*x?[0-9]*)((\[[0-9]*\])*)/.match(type).to_a
|
@@ -123,10 +123,43 @@ module Web3::Eth::Abi
|
|
123
123
|
|
124
124
|
class Tuple < Type
|
125
125
|
|
126
|
-
|
126
|
+
def self.parse types, dims
|
127
|
+
|
128
|
+
depth = 0
|
129
|
+
collected = []
|
130
|
+
current = ''
|
131
|
+
|
132
|
+
types.split('').each do |c|
|
133
|
+
case c
|
134
|
+
when ',' then
|
135
|
+
if depth==0
|
136
|
+
collected << current
|
137
|
+
current = ''
|
138
|
+
else
|
139
|
+
current += c
|
140
|
+
end
|
141
|
+
when '(' then
|
142
|
+
depth += 1
|
143
|
+
current += c
|
144
|
+
when ')' then
|
145
|
+
depth -= 1
|
146
|
+
current += c
|
147
|
+
else
|
148
|
+
current += c
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
collected << current unless current.empty?
|
153
|
+
|
154
|
+
Tuple.new collected, dims
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
attr_reader :types, :parsed_types
|
127
159
|
def initialize types, dims
|
128
|
-
super('tuple', '', dims)
|
160
|
+
super('tuple', '', dims.map {|x| x[1...-1].to_i})
|
129
161
|
@types = types
|
162
|
+
@parsed_types = types.map{|t| Type.parse t}
|
130
163
|
end
|
131
164
|
|
132
165
|
def ==(another_type)
|
@@ -136,7 +169,27 @@ module Web3::Eth::Abi
|
|
136
169
|
end
|
137
170
|
|
138
171
|
def size
|
139
|
-
|
172
|
+
@size ||= calculate_size
|
173
|
+
end
|
174
|
+
|
175
|
+
def calculate_size
|
176
|
+
if dims.empty?
|
177
|
+
s = 0
|
178
|
+
parsed_types.each do |type|
|
179
|
+
ts = type.size
|
180
|
+
return nil if ts.nil?
|
181
|
+
s += ts
|
182
|
+
end
|
183
|
+
s
|
184
|
+
else
|
185
|
+
if dims.last == 0 # 0 for dynamic array []
|
186
|
+
nil
|
187
|
+
else
|
188
|
+
subtype.dynamic? ? nil : dims.last * subtype.size
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
|
140
193
|
end
|
141
194
|
|
142
195
|
def subtype
|
data/lib/web3/eth/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- studnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rlp
|