eth 0.5.7 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +1 -1
- data/.github/workflows/docs.yml +2 -2
- data/.github/workflows/spec.yml +3 -3
- data/CHANGELOG.md +33 -0
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/abis/ens.json +422 -0
- data/eth.gemspec +2 -2
- data/lib/eth/abi/event.rb +1 -1
- data/lib/eth/abi/type.rb +46 -12
- data/lib/eth/abi.rb +72 -14
- data/lib/eth/address.rb +2 -2
- data/lib/eth/api.rb +1 -1
- data/lib/eth/chain.rb +19 -7
- data/lib/eth/client/http.rb +1 -1
- data/lib/eth/client/http_auth.rb +1 -1
- data/lib/eth/client/ipc.rb +1 -1
- data/lib/eth/client.rb +70 -58
- data/lib/eth/constant.rb +1 -1
- data/lib/eth/contract/event.rb +1 -1
- data/lib/eth/contract/function.rb +2 -2
- data/lib/eth/contract/function_input.rb +7 -2
- data/lib/eth/contract/function_output.rb +1 -1
- data/lib/eth/contract/initializer.rb +1 -1
- data/lib/eth/contract.rb +1 -1
- data/lib/eth/eip712.rb +2 -2
- data/lib/eth/ens/resolver.rb +77 -0
- data/lib/eth/key/decrypter.rb +1 -1
- data/lib/eth/key/encrypter.rb +1 -1
- data/lib/eth/key.rb +5 -5
- data/lib/eth/rlp/decoder.rb +2 -2
- data/lib/eth/rlp/encoder.rb +3 -3
- data/lib/eth/rlp/sedes/big_endian_int.rb +1 -1
- data/lib/eth/rlp/sedes/binary.rb +2 -2
- data/lib/eth/rlp/sedes/list.rb +5 -5
- data/lib/eth/rlp/sedes.rb +4 -4
- data/lib/eth/rlp.rb +1 -1
- data/lib/eth/signature.rb +4 -4
- data/lib/eth/solidity.rb +5 -3
- data/lib/eth/tx/eip1559.rb +3 -3
- data/lib/eth/tx/eip2930.rb +3 -3
- data/lib/eth/tx/legacy.rb +3 -3
- data/lib/eth/tx.rb +5 -5
- data/lib/eth/unit.rb +1 -1
- data/lib/eth/util.rb +14 -14
- data/lib/eth/version.rb +2 -2
- data/lib/eth.rb +2 -1
- metadata +7 -4
data/lib/eth/solidity.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -42,8 +42,10 @@ module Eth
|
|
42
42
|
# @return [Array] JSON containing the compiled contract and ABI for all contracts.
|
43
43
|
def compile(contract)
|
44
44
|
raise Errno::ENOENT, "Contract file not found: #{contract}" unless File.exist? contract
|
45
|
-
|
46
|
-
|
45
|
+
flag_opt = "--optimize"
|
46
|
+
flag_json = "--combined-json=bin,abi"
|
47
|
+
path = File.realpath contract
|
48
|
+
output, error, status = Open3.capture3 @compiler, flag_opt, flag_json, path
|
47
49
|
raise SystemCallError, "Unable to run solc compiler!" if status.exitstatus === 127
|
48
50
|
raise CompilerError, error unless status.success?
|
49
51
|
json = JSON.parse output
|
data/lib/eth/tx/eip1559.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -231,7 +231,7 @@ module Eth
|
|
231
231
|
# @raise [Signature::SignatureError] if transaction is already signed.
|
232
232
|
# @raise [Signature::SignatureError] if sender address does not match signing key.
|
233
233
|
def sign(key)
|
234
|
-
if Tx.
|
234
|
+
if Tx.signed? self
|
235
235
|
raise Signature::SignatureError, "Transaction is already signed!"
|
236
236
|
end
|
237
237
|
|
@@ -258,7 +258,7 @@ module Eth
|
|
258
258
|
# @return [String] a raw, RLP-encoded EIP-1559 type transaction object.
|
259
259
|
# @raise [Signature::SignatureError] if the transaction is not yet signed.
|
260
260
|
def encoded
|
261
|
-
unless Tx.
|
261
|
+
unless Tx.signed? self
|
262
262
|
raise Signature::SignatureError, "Transaction is not signed!"
|
263
263
|
end
|
264
264
|
tx_data = []
|
data/lib/eth/tx/eip2930.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -225,7 +225,7 @@ module Eth
|
|
225
225
|
# @raise [Signature::SignatureError] if transaction is already signed.
|
226
226
|
# @raise [Signature::SignatureError] if sender address does not match signing key.
|
227
227
|
def sign(key)
|
228
|
-
if Tx.
|
228
|
+
if Tx.signed? self
|
229
229
|
raise Signature::SignatureError, "Transaction is already signed!"
|
230
230
|
end
|
231
231
|
|
@@ -252,7 +252,7 @@ module Eth
|
|
252
252
|
# @return [String] a raw, RLP-encoded EIP-2930 type transaction object.
|
253
253
|
# @raise [Signature::SignatureError] if the transaction is not yet signed.
|
254
254
|
def encoded
|
255
|
-
unless Tx.
|
255
|
+
unless Tx.signed? self
|
256
256
|
raise Signature::SignatureError, "Transaction is not signed!"
|
257
257
|
end
|
258
258
|
tx_data = []
|
data/lib/eth/tx/legacy.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -205,7 +205,7 @@ module Eth
|
|
205
205
|
# @raise [Signature::SignatureError] if transaction is already signed.
|
206
206
|
# @raise [Signature::SignatureError] if sender address does not match signing key.
|
207
207
|
def sign(key)
|
208
|
-
if Tx.
|
208
|
+
if Tx.signed? self
|
209
209
|
raise Signature::SignatureError, "Transaction is already signed!"
|
210
210
|
end
|
211
211
|
|
@@ -230,7 +230,7 @@ module Eth
|
|
230
230
|
# @return [String] a raw, RLP-encoded legacy transaction.
|
231
231
|
# @raise [Signature::SignatureError] if the transaction is not yet signed.
|
232
232
|
def encoded
|
233
|
-
unless Tx.
|
233
|
+
unless Tx.signed? self
|
234
234
|
raise Signature::SignatureError, "Transaction is not signed!"
|
235
235
|
end
|
236
236
|
tx_data = []
|
data/lib/eth/tx.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -164,7 +164,7 @@ module Eth
|
|
164
164
|
def estimate_intrinsic_gas(data = "", list = [])
|
165
165
|
gas = DEFAULT_GAS_LIMIT
|
166
166
|
unless data.nil? or data.empty?
|
167
|
-
data = Util.hex_to_bin data if Util.
|
167
|
+
data = Util.hex_to_bin data if Util.hex? data
|
168
168
|
|
169
169
|
# count zero bytes
|
170
170
|
zero = data.count ZERO_BYTE
|
@@ -288,7 +288,7 @@ module Eth
|
|
288
288
|
data = "" if data.nil?
|
289
289
|
|
290
290
|
# ensure payload to be binary if it's hex, otherwise we'll treat it raw
|
291
|
-
data = Util.hex_to_bin data if Util.
|
291
|
+
data = Util.hex_to_bin data if Util.hex? data
|
292
292
|
return data
|
293
293
|
end
|
294
294
|
|
@@ -305,7 +305,7 @@ module Eth
|
|
305
305
|
|
306
306
|
# recursively check the entire array
|
307
307
|
list[index] = sanitize_list value
|
308
|
-
elsif Util.
|
308
|
+
elsif Util.hex? value
|
309
309
|
|
310
310
|
# only modify if we find a hex value
|
311
311
|
list[index] = Util.hex_to_bin value
|
@@ -317,7 +317,7 @@ module Eth
|
|
317
317
|
# Allows to check wether a transaction is signed already.
|
318
318
|
#
|
319
319
|
# @return [Bool] true if transaction is already signed.
|
320
|
-
def
|
320
|
+
def signed?(tx)
|
321
321
|
!tx.signature_r.nil? and tx.signature_r != 0 and
|
322
322
|
!tx.signature_s.nil? and tx.signature_s != 0
|
323
323
|
end
|
data/lib/eth/unit.rb
CHANGED
data/lib/eth/util.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -27,7 +27,7 @@ module Eth
|
|
27
27
|
# @param str [String] the public key to be converted.
|
28
28
|
# @return [Eth::Address] an Ethereum address.
|
29
29
|
def public_key_to_address(str)
|
30
|
-
str = hex_to_bin str if
|
30
|
+
str = hex_to_bin str if hex? str
|
31
31
|
bytes = keccak256(str[1..-1])[-20..-1]
|
32
32
|
Address.new bin_to_prefixed_hex bytes
|
33
33
|
end
|
@@ -59,7 +59,7 @@ module Eth
|
|
59
59
|
def hex_to_bin(hex)
|
60
60
|
raise TypeError, "Value must be an instance of String" unless hex.instance_of? String
|
61
61
|
hex = remove_hex_prefix hex
|
62
|
-
raise TypeError, "Non-hexadecimal digit found" unless
|
62
|
+
raise TypeError, "Non-hexadecimal digit found" unless hex? hex
|
63
63
|
[hex].pack("H*")
|
64
64
|
end
|
65
65
|
|
@@ -68,7 +68,7 @@ module Eth
|
|
68
68
|
# @param hex [String] a hex-string to be prefixed.
|
69
69
|
# @return [String] a prefixed hex-string.
|
70
70
|
def prefix_hex(hex)
|
71
|
-
return hex if
|
71
|
+
return hex if prefixed? hex
|
72
72
|
return "0x#{hex}"
|
73
73
|
end
|
74
74
|
|
@@ -77,7 +77,7 @@ module Eth
|
|
77
77
|
# @param hex [String] a prefixed hex-string.
|
78
78
|
# @return [String] an unprefixed hex-string.
|
79
79
|
def remove_hex_prefix(hex)
|
80
|
-
return hex[2..-1] if
|
80
|
+
return hex[2..-1] if prefixed? hex
|
81
81
|
return hex
|
82
82
|
end
|
83
83
|
|
@@ -93,7 +93,7 @@ module Eth
|
|
93
93
|
#
|
94
94
|
# @param str [String] a string to be checked.
|
95
95
|
# @return [String] a match if true; `nil` if not.
|
96
|
-
def
|
96
|
+
def hex?(str)
|
97
97
|
return false unless str.is_a? String
|
98
98
|
str = remove_hex_prefix str
|
99
99
|
str.match /\A[0-9a-fA-F]*\z/
|
@@ -103,7 +103,7 @@ module Eth
|
|
103
103
|
#
|
104
104
|
# @param hex [String] a string to be checked.
|
105
105
|
# @return [String] a match if true; `nil` if not.
|
106
|
-
def
|
106
|
+
def prefixed?(hex)
|
107
107
|
hex.match /\A0x/
|
108
108
|
end
|
109
109
|
|
@@ -113,7 +113,7 @@ module Eth
|
|
113
113
|
# @return [String] serialized big endian integer string.
|
114
114
|
# @raise [ArgumentError] if unsigned integer is out of bounds.
|
115
115
|
def serialize_int_to_big_endian(num)
|
116
|
-
num = num.to_i(16) if
|
116
|
+
num = num.to_i(16) if hex? num
|
117
117
|
unless num.is_a? Integer and num >= 0 and num <= Constant::UINT_MAX
|
118
118
|
raise ArgumentError, "Integer invalid or out of range: #{num}"
|
119
119
|
end
|
@@ -125,7 +125,7 @@ module Eth
|
|
125
125
|
# @param num [Integer] integer to be converted.
|
126
126
|
# @return [String] packed, big-endian integer string.
|
127
127
|
def int_to_big_endian(num)
|
128
|
-
hex = num.to_s(16) unless
|
128
|
+
hex = num.to_s(16) unless hex? num
|
129
129
|
hex = "0#{hex}" if hex.size.odd?
|
130
130
|
hex_to_bin hex
|
131
131
|
end
|
@@ -151,7 +151,7 @@ module Eth
|
|
151
151
|
# @param str [String] binary string to be converted.
|
152
152
|
# @return [Object] the string bytes.
|
153
153
|
def str_to_bytes(str)
|
154
|
-
|
154
|
+
bytes?(str) ? str : str.b
|
155
155
|
end
|
156
156
|
|
157
157
|
# Converts bytes to a binary string.
|
@@ -166,7 +166,7 @@ module Eth
|
|
166
166
|
#
|
167
167
|
# @param str [String] a string to check.
|
168
168
|
# @return [Boolean] true if it's an ASCII-8bit encoded byte-string.
|
169
|
-
def
|
169
|
+
def bytes?(str)
|
170
170
|
str && str.instance_of?(String) && str.encoding.name == Constant::BINARY_ENCODING
|
171
171
|
end
|
172
172
|
|
@@ -174,7 +174,7 @@ module Eth
|
|
174
174
|
#
|
175
175
|
# @param item [Object] the item to check.
|
176
176
|
# @return [Boolean] true if it's a string primitive.
|
177
|
-
def
|
177
|
+
def primitive?(item)
|
178
178
|
item.instance_of?(String)
|
179
179
|
end
|
180
180
|
|
@@ -182,8 +182,8 @@ module Eth
|
|
182
182
|
#
|
183
183
|
# @param item [Object] the item to check.
|
184
184
|
# @return [Boolean] true if it's a list.
|
185
|
-
def
|
186
|
-
!
|
185
|
+
def list?(item)
|
186
|
+
!primitive?(item) && item.respond_to?(:each)
|
187
187
|
end
|
188
188
|
|
189
189
|
# Ceil and integer to the next multiple of 32 bytes.
|
data/lib/eth/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -16,5 +16,5 @@
|
|
16
16
|
module Eth
|
17
17
|
|
18
18
|
# Defines the version of the {Eth} module.
|
19
|
-
VERSION = "0.5.
|
19
|
+
VERSION = "0.5.9".freeze
|
20
20
|
end
|
data/lib/eth.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2023 The Ruby-Eth Contributors
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -32,4 +32,5 @@ require "eth/solidity"
|
|
32
32
|
require "eth/tx"
|
33
33
|
require "eth/unit"
|
34
34
|
require "eth/util"
|
35
|
+
require "eth/ens/resolver"
|
35
36
|
require "eth/version"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Ellis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: keccak
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- LICENSE.txt
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
|
+
- abis/ens.json
|
112
113
|
- bin/console
|
113
114
|
- bin/setup
|
114
115
|
- codecov.yml
|
@@ -132,6 +133,7 @@ files:
|
|
132
133
|
- lib/eth/contract/function_output.rb
|
133
134
|
- lib/eth/contract/initializer.rb
|
134
135
|
- lib/eth/eip712.rb
|
136
|
+
- lib/eth/ens/resolver.rb
|
135
137
|
- lib/eth/key.rb
|
136
138
|
- lib/eth/key/decrypter.rb
|
137
139
|
- lib/eth/key/encrypter.rb
|
@@ -164,11 +166,12 @@ post_install_message:
|
|
164
166
|
rdoc_options: []
|
165
167
|
require_paths:
|
166
168
|
- lib
|
169
|
+
- abis
|
167
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
168
171
|
requirements:
|
169
172
|
- - ">="
|
170
173
|
- !ruby/object:Gem::Version
|
171
|
-
version: '2.
|
174
|
+
version: '2.7'
|
172
175
|
- - "<"
|
173
176
|
- !ruby/object:Gem::Version
|
174
177
|
version: '4.0'
|
@@ -178,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
181
|
- !ruby/object:Gem::Version
|
179
182
|
version: '0'
|
180
183
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
184
|
+
rubygems_version: 3.2.32
|
182
185
|
signing_key:
|
183
186
|
specification_version: 4
|
184
187
|
summary: Ruby Ethereum library.
|