web3-eth 0.2.40 → 0.2.45

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
  SHA256:
3
- metadata.gz: 5aacea6822d6743a8cecd1620d10c39fe1552cb3ec3f98891527c93bbf20c66e
4
- data.tar.gz: a70a11f63c761b1923dce7c4e9cf66ddd93c4e0914a03e539fd94d5f638b9c33
3
+ metadata.gz: ca610f7e51cabe8deea63017a90d5615e2bea31a798e06c6034a1f20f5c7c7f9
4
+ data.tar.gz: a783f5b5830db81f5ced929f078b82225565e28afb71d64fdec4d380a8fe0254
5
5
  SHA512:
6
- metadata.gz: 2f0d38f4875da54624615267a9502b022efd7f2e780c3e07a7fe9b66f0e5479a365b63afca17da62f76385fbf30fb9fc1100eb690a56a04340c842ab0110cd74
7
- data.tar.gz: 4cbf7ccd1ab947b86591343d5177ebc2f617388549a62fe0c916d8beee3b87910598c075b92c5e6977a566064a81b6a317a1c8e1c64e0c34846135890f7ae0a0
6
+ metadata.gz: 9026b970e0f81d6fb33b897077a8419be91f36875f482afb79531375cbd9db5822bd13de977383995273c439029a823d25162fe5842c97d7ee8844d7315c4973
7
+ data.tar.gz: b546093564ee5eb379ef8ddcb803bff39476b263ea8936eeb49a80af691eafc1685e809f80783a195d458bda62fde765d6e7340a18bd1683d92eb4b22775b96c
@@ -231,7 +231,7 @@ module Web3::Eth::Abi
231
231
 
232
232
  pos += 32
233
233
  else
234
- outputs[i] = data[pos, t.size]
234
+ outputs[i] = zero_padding data, pos, t.size, start_positions
235
235
  pos += t.size
236
236
  end
237
237
  end
@@ -266,6 +266,18 @@ module Web3::Eth::Abi
266
266
  end
267
267
  alias :decode :decode_abi
268
268
 
269
+ def zero_padding data, pos, count, start_positions
270
+ if pos >= data.size
271
+ start_positions[start_positions.size-1] += count
272
+ "\x00"*count
273
+ elsif pos + count > data.size
274
+ start_positions[start_positions.size-1] += ( count - (data.size-pos))
275
+ data[pos,data.size-pos] + "\x00"*( count - (data.size-pos))
276
+ else
277
+ data[pos, count]
278
+ end
279
+ end
280
+
269
281
  def decode_typed_data type_name, data
270
282
  decode_primitive_type Type.parse(type_name), data
271
283
  end
@@ -34,7 +34,7 @@ module Web3
34
34
  def initialize abi
35
35
  @abi = abi
36
36
  @name = abi['name']
37
- @constant = !!abi['constant']
37
+ @constant = !!abi['constant'] || abi['stateMutability']=='view'
38
38
  @input_types = abi['inputs'] ? abi['inputs'].map{|a| parse_component_type a } : []
39
39
  @output_types = abi['outputs'].map{|a| parse_component_type a } if abi['outputs']
40
40
  @signature = Abi::Utils.function_signature @name, @input_types
@@ -92,7 +92,7 @@ module Web3
92
92
  def do_call web3_rpc, contract_address, args
93
93
  data = '0x' + signature_hash + encode_hex(encode_abi(input_types, args) )
94
94
 
95
- response = web3_rpc.request "eth_call", [{ to: contract_address, data: data}, 'latest']
95
+ response = web3_rpc.eth.call [{ to: contract_address, data: data}, 'latest']
96
96
 
97
97
  string_data = [remove_0x_head(response)].pack('H*')
98
98
  return nil if string_data.empty?
@@ -53,7 +53,7 @@ module Web3
53
53
 
54
54
  raise "Error code #{response.code} on request #{@uri.to_s} #{request.body}" unless response.kind_of? Net::HTTPOK
55
55
 
56
- body = JSON.parse(response.body)
56
+ body = JSON.parse(response.body, max_nesting: 1500)
57
57
 
58
58
  if body['result']
59
59
  body['result']
@@ -12,7 +12,7 @@ module Web3
12
12
  end
13
13
 
14
14
  def from_hex h
15
- h.nil? ? 0 : h.to_i(16)
15
+ h.nil? ? 0 : (h.kind_of?(String) ? h.to_i(16) : h)
16
16
  end
17
17
 
18
18
  def remove_0x_head(s)
@@ -1,5 +1,5 @@
1
1
  module Web3
2
2
  module Eth
3
- VERSION = "0.2.40"
3
+ VERSION = "0.2.45"
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.40
4
+ version: 0.2.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - studnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-01 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rlp