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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b9832436b967b5fcc29897d0acd81d13ef096c2
4
- data.tar.gz: e94b5686cf626963bb25826ccb86af4242567045
3
+ metadata.gz: 9457f0f37c7e766684fddc7e812780c18a50bfb0
4
+ data.tar.gz: 540378a3280a8ab186f3edf15836d0f2557f667d
5
5
  SHA512:
6
- metadata.gz: 5e34fd5d57be1f53bcb6721ae4c373594e4f6ea510678b77a64e70ff6d9fcf6f24351550507b8ee9304cc6b1449ba741bd5541534879d6cd6e9a2c208c1606b1
7
- data.tar.gz: 49a78adeb862ee7c2075cee1074d0759e228a6b64484618172fc97c3cf5185e2edcb61a7995aa9a7fc174381ba04122c199c65e5b5ff1236528e70572fbe9607
6
+ metadata.gz: 767efe7b83351d8d4151a2bb704c088f979ff4fbd54bbab549bd64c50bc82d26fe3ffae170a2e2e09cc0d86b79b8e3a8d1a088c74b22574175f5c5ba4d2d3bb7
7
+ data.tar.gz: cdd047324382f45b15b61376083cd1e1798721df3147f18b3a5c43dec934be2d3a8a6434e9c9edcb9ddd8dc46abcc12bf4b220d6dfcee6df4e8b31387826c0e7
@@ -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 = ContractMethod.new abi.detect{|a| a['type']=='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
- json = JSON.parse(response.body)['result']
47
- raise "No response on request #{@uri.to_s} #{request.body}" unless json
46
+ body = JSON.parse(response.body)
48
47
 
49
- json
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
@@ -1,5 +1,5 @@
1
1
  module Web3
2
2
  module Eth
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
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.0
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: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2018-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rlp