web3-eth 0.2.16 → 0.2.17
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 +4 -4
- data/lib/web3/eth/abi/abi_coder.rb +3 -1
- data/lib/web3/eth/abi/type.rb +27 -0
- data/lib/web3/eth/contract.rb +10 -2
- data/lib/web3/eth/version.rb +1 -1
- data/web3-eth.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4758d5a4540a14b447eb213e16092e860146af3f
|
4
|
+
data.tar.gz: 3a1ac8621164a3c9b89e87c70453bb2025d20222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae81f830cab286398b126134345614421417b3ac279fed512403344f431192251faaacef0a85fc0bd3a89f4f5c2b48deb8ed095a9febef2744bca7ec9c79bb1f
|
7
|
+
data.tar.gz: 1102a1c92255349f489f4568b609df283e6e77ed97a866f23524cd6fd76ad3bed641304219a732f0634ec2d9472880bb28609fb8b49005bfeda59814fb69f8c3
|
@@ -248,7 +248,9 @@ module Web3::Eth::Abi
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def decode_type(type, arg)
|
251
|
-
if
|
251
|
+
if type.kind_of?(Tuple)
|
252
|
+
decode_abi(type.types, arg)
|
253
|
+
elsif %w(string bytes).include?(type.base) && type.sub.empty?
|
252
254
|
l = Utils.big_endian_to_int arg[0,32]
|
253
255
|
data = arg[32..-1]
|
254
256
|
data[0, l]
|
data/lib/web3/eth/abi/type.rb
CHANGED
@@ -12,6 +12,11 @@ module Web3::Eth::Abi
|
|
12
12
|
# 256, 128x128, nil), array component (eg. [], [45], nil)
|
13
13
|
#
|
14
14
|
def parse(type)
|
15
|
+
|
16
|
+
if type =~ /^\((.*)\)((\[[0-9]*\])*)/
|
17
|
+
return Tuple.new $1.split(','), $2.scan(/\[[0-9]*\]/)
|
18
|
+
end
|
19
|
+
|
15
20
|
_, base, sub, dimension = /([a-z]*)([0-9]*x?[0-9]*)((\[[0-9]*\])*)/.match(type).to_a
|
16
21
|
|
17
22
|
dims = dimension.scan(/\[[0-9]*\]/)
|
@@ -115,4 +120,26 @@ module Web3::Eth::Abi
|
|
115
120
|
end
|
116
121
|
|
117
122
|
end
|
123
|
+
|
124
|
+
class Tuple < Type
|
125
|
+
|
126
|
+
attr_reader :types
|
127
|
+
def initialize types, dims
|
128
|
+
super('tuple', '', dims)
|
129
|
+
@types = types
|
130
|
+
end
|
131
|
+
|
132
|
+
def ==(another_type)
|
133
|
+
another_type.kind_of?(Tuple) &&
|
134
|
+
another_type.types == types &&
|
135
|
+
another_type.dims == dims
|
136
|
+
end
|
137
|
+
|
138
|
+
def size
|
139
|
+
nil
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
end
|
144
|
+
|
118
145
|
end
|
data/lib/web3/eth/contract.rb
CHANGED
@@ -35,12 +35,20 @@ module Web3
|
|
35
35
|
@abi = abi
|
36
36
|
@name = abi['name']
|
37
37
|
@constant = !!abi['constant']
|
38
|
-
@input_types = abi['inputs'].map{|a| a
|
39
|
-
@output_types = abi['outputs'].map{|a| a
|
38
|
+
@input_types = abi['inputs'].map{|a| parse_component_type a }
|
39
|
+
@output_types = abi['outputs'].map{|a| parse_component_type a } if abi['outputs']
|
40
40
|
@signature = Abi::Utils.function_signature @name, @input_types
|
41
41
|
@signature_hash = Abi::Utils.signature_hash @signature, (abi['type']=='event' ? 64 : 8)
|
42
42
|
end
|
43
43
|
|
44
|
+
def parse_component_type argument
|
45
|
+
if argument['type']=='tuple'
|
46
|
+
argument['components'] ? "(#{argument['components'].collect{|c| c['type'] }.join(',')})" : '()'
|
47
|
+
else
|
48
|
+
argument['type']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
44
52
|
def parse_event_args log
|
45
53
|
|
46
54
|
log_data = remove_0x_head log.raw_data['data']
|
data/lib/web3/eth/version.rb
CHANGED
data/web3-eth.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "web3-eth"
|
8
8
|
spec.version = Web3::Eth::VERSION
|
9
9
|
spec.authors = ["studnev"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["aleksey@bloxy.info"]
|
11
11
|
|
12
12
|
spec.summary = %q{Web3 client to connect to Ethereum node by RPC.}
|
13
13
|
spec.description = %q{Calling RPC methods of Ethereum node with Ruby.}
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- studnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rlp
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
version: '5.0'
|
83
83
|
description: Calling RPC methods of Ethereum node with Ruby.
|
84
84
|
email:
|
85
|
-
-
|
85
|
+
- aleksey@bloxy.info
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.2.3
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Web3 client to connect to Ethereum node by RPC.
|