web3-eth 0.2.0 → 0.2.1
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/contract.rb +4 -4
- data/lib/web3/eth/rpc.rb +9 -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: 9457f0f37c7e766684fddc7e812780c18a50bfb0
|
4
|
+
data.tar.gz: 540378a3280a8ab186f3edf15836d0f2557f667d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 767efe7b83351d8d4151a2bb704c088f979ff4fbd54bbab549bd64c50bc82d26fe3ffae170a2e2e09cc0d86b79b8e3a8d1a088c74b22574175f5c5ba4d2d3bb7
|
7
|
+
data.tar.gz: cdd047324382f45b15b61376083cd1e1798721df3147f18b3a5c43dec934be2d3a8a6434e9c9edcb9ddd8dc46abcc12bf4b220d6dfcee6df4e8b31387826c0e7
|
data/lib/web3/eth/contract.rb
CHANGED
@@ -6,7 +6,7 @@ module Web3
|
|
6
6
|
include Abi::Utils
|
7
7
|
include Utility
|
8
8
|
|
9
|
-
|
9
|
+
|
10
10
|
class ContractInstance
|
11
11
|
|
12
12
|
def initialize contract, address
|
@@ -63,7 +63,7 @@ module Web3
|
|
63
63
|
|
64
64
|
data = '0x' + function.signature_hash + encode_hex(encode_abi(function.input_types, args) )
|
65
65
|
|
66
|
-
response = web3_rpc.request "eth_call", [{ to: contract_address, data: data}]
|
66
|
+
response = web3_rpc.request "eth_call", [{ to: contract_address, data: data}, 'latest']
|
67
67
|
|
68
68
|
string_data = [remove_0x_head(response)].pack('H*')
|
69
69
|
return nil if string_data.empty?
|
@@ -126,9 +126,9 @@ module Web3
|
|
126
126
|
def parse_abi abi
|
127
127
|
@functions = Hash[abi.select{|a| a['type']=='function'}.map{|a| [a['name'], ContractMethod.new(a)]}]
|
128
128
|
@events = Hash[abi.select{|a| a['type']=='event'}.map{|a| [a['name'], ContractMethod.new(a)]}]
|
129
|
-
@constructor =
|
129
|
+
@constructor = (constructor = abi.detect{|a| a['type']=='constructor'}) && ContractMethod.new(constructor)
|
130
130
|
end
|
131
131
|
|
132
132
|
end
|
133
133
|
end
|
134
|
-
end
|
134
|
+
end
|
data/lib/web3/eth/rpc.rb
CHANGED
@@ -43,10 +43,15 @@ module Web3
|
|
43
43
|
|
44
44
|
raise "Error code #{response.code} on request #{@uri.to_s} #{request.body}" unless response.kind_of? Net::HTTPOK
|
45
45
|
|
46
|
-
|
47
|
-
raise "No response on request #{@uri.to_s} #{request.body}" unless json
|
46
|
+
body = JSON.parse(response.body)
|
48
47
|
|
49
|
-
|
48
|
+
if body['result']
|
49
|
+
body['result']
|
50
|
+
elsif body['error']
|
51
|
+
raise "Error #{@uri.to_s} #{body['error']} on request #{@uri.to_s} #{request.body}"
|
52
|
+
else
|
53
|
+
raise "No response on request #{@uri.to_s} #{request.body}"
|
54
|
+
end
|
50
55
|
|
51
56
|
end
|
52
57
|
|
@@ -55,4 +60,4 @@ module Web3
|
|
55
60
|
|
56
61
|
end
|
57
62
|
end
|
58
|
-
end
|
63
|
+
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- studnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rlp
|