eth 0.5.6 → 0.5.8

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.
data/abis/ens.json ADDED
@@ -0,0 +1,422 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "contract ENS",
6
+ "name": "_old",
7
+ "type": "address"
8
+ }
9
+ ],
10
+ "payable": false,
11
+ "stateMutability": "nonpayable",
12
+ "type": "constructor"
13
+ },
14
+ {
15
+ "anonymous": false,
16
+ "inputs": [
17
+ {
18
+ "indexed": true,
19
+ "internalType": "address",
20
+ "name": "owner",
21
+ "type": "address"
22
+ },
23
+ {
24
+ "indexed": true,
25
+ "internalType": "address",
26
+ "name": "operator",
27
+ "type": "address"
28
+ },
29
+ {
30
+ "indexed": false,
31
+ "internalType": "bool",
32
+ "name": "approved",
33
+ "type": "bool"
34
+ }
35
+ ],
36
+ "name": "ApprovalForAll",
37
+ "type": "event"
38
+ },
39
+ {
40
+ "anonymous": false,
41
+ "inputs": [
42
+ {
43
+ "indexed": true,
44
+ "internalType": "bytes32",
45
+ "name": "node",
46
+ "type": "bytes32"
47
+ },
48
+ {
49
+ "indexed": true,
50
+ "internalType": "bytes32",
51
+ "name": "label",
52
+ "type": "bytes32"
53
+ },
54
+ {
55
+ "indexed": false,
56
+ "internalType": "address",
57
+ "name": "owner",
58
+ "type": "address"
59
+ }
60
+ ],
61
+ "name": "NewOwner",
62
+ "type": "event"
63
+ },
64
+ {
65
+ "anonymous": false,
66
+ "inputs": [
67
+ {
68
+ "indexed": true,
69
+ "internalType": "bytes32",
70
+ "name": "node",
71
+ "type": "bytes32"
72
+ },
73
+ {
74
+ "indexed": false,
75
+ "internalType": "address",
76
+ "name": "resolver",
77
+ "type": "address"
78
+ }
79
+ ],
80
+ "name": "NewResolver",
81
+ "type": "event"
82
+ },
83
+ {
84
+ "anonymous": false,
85
+ "inputs": [
86
+ {
87
+ "indexed": true,
88
+ "internalType": "bytes32",
89
+ "name": "node",
90
+ "type": "bytes32"
91
+ },
92
+ {
93
+ "indexed": false,
94
+ "internalType": "uint64",
95
+ "name": "ttl",
96
+ "type": "uint64"
97
+ }
98
+ ],
99
+ "name": "NewTTL",
100
+ "type": "event"
101
+ },
102
+ {
103
+ "anonymous": false,
104
+ "inputs": [
105
+ {
106
+ "indexed": true,
107
+ "internalType": "bytes32",
108
+ "name": "node",
109
+ "type": "bytes32"
110
+ },
111
+ {
112
+ "indexed": false,
113
+ "internalType": "address",
114
+ "name": "owner",
115
+ "type": "address"
116
+ }
117
+ ],
118
+ "name": "Transfer",
119
+ "type": "event"
120
+ },
121
+ {
122
+ "constant": true,
123
+ "inputs": [
124
+ {
125
+ "internalType": "address",
126
+ "name": "owner",
127
+ "type": "address"
128
+ },
129
+ {
130
+ "internalType": "address",
131
+ "name": "operator",
132
+ "type": "address"
133
+ }
134
+ ],
135
+ "name": "isApprovedForAll",
136
+ "outputs": [
137
+ {
138
+ "internalType": "bool",
139
+ "name": "",
140
+ "type": "bool"
141
+ }
142
+ ],
143
+ "payable": false,
144
+ "stateMutability": "view",
145
+ "type": "function"
146
+ },
147
+ {
148
+ "constant": true,
149
+ "inputs": [],
150
+ "name": "old",
151
+ "outputs": [
152
+ {
153
+ "internalType": "contract ENS",
154
+ "name": "",
155
+ "type": "address"
156
+ }
157
+ ],
158
+ "payable": false,
159
+ "stateMutability": "view",
160
+ "type": "function"
161
+ },
162
+ {
163
+ "constant": true,
164
+ "inputs": [
165
+ {
166
+ "internalType": "bytes32",
167
+ "name": "node",
168
+ "type": "bytes32"
169
+ }
170
+ ],
171
+ "name": "owner",
172
+ "outputs": [
173
+ {
174
+ "internalType": "address",
175
+ "name": "",
176
+ "type": "address"
177
+ }
178
+ ],
179
+ "payable": false,
180
+ "stateMutability": "view",
181
+ "type": "function"
182
+ },
183
+ {
184
+ "constant": true,
185
+ "inputs": [
186
+ {
187
+ "internalType": "bytes32",
188
+ "name": "node",
189
+ "type": "bytes32"
190
+ }
191
+ ],
192
+ "name": "recordExists",
193
+ "outputs": [
194
+ {
195
+ "internalType": "bool",
196
+ "name": "",
197
+ "type": "bool"
198
+ }
199
+ ],
200
+ "payable": false,
201
+ "stateMutability": "view",
202
+ "type": "function"
203
+ },
204
+ {
205
+ "constant": true,
206
+ "inputs": [
207
+ {
208
+ "internalType": "bytes32",
209
+ "name": "node",
210
+ "type": "bytes32"
211
+ }
212
+ ],
213
+ "name": "resolver",
214
+ "outputs": [
215
+ {
216
+ "internalType": "address",
217
+ "name": "",
218
+ "type": "address"
219
+ }
220
+ ],
221
+ "payable": false,
222
+ "stateMutability": "view",
223
+ "type": "function"
224
+ },
225
+ {
226
+ "constant": false,
227
+ "inputs": [
228
+ {
229
+ "internalType": "address",
230
+ "name": "operator",
231
+ "type": "address"
232
+ },
233
+ {
234
+ "internalType": "bool",
235
+ "name": "approved",
236
+ "type": "bool"
237
+ }
238
+ ],
239
+ "name": "setApprovalForAll",
240
+ "outputs": [],
241
+ "payable": false,
242
+ "stateMutability": "nonpayable",
243
+ "type": "function"
244
+ },
245
+ {
246
+ "constant": false,
247
+ "inputs": [
248
+ {
249
+ "internalType": "bytes32",
250
+ "name": "node",
251
+ "type": "bytes32"
252
+ },
253
+ {
254
+ "internalType": "address",
255
+ "name": "owner",
256
+ "type": "address"
257
+ }
258
+ ],
259
+ "name": "setOwner",
260
+ "outputs": [],
261
+ "payable": false,
262
+ "stateMutability": "nonpayable",
263
+ "type": "function"
264
+ },
265
+ {
266
+ "constant": false,
267
+ "inputs": [
268
+ {
269
+ "internalType": "bytes32",
270
+ "name": "node",
271
+ "type": "bytes32"
272
+ },
273
+ {
274
+ "internalType": "address",
275
+ "name": "owner",
276
+ "type": "address"
277
+ },
278
+ {
279
+ "internalType": "address",
280
+ "name": "resolver",
281
+ "type": "address"
282
+ },
283
+ {
284
+ "internalType": "uint64",
285
+ "name": "ttl",
286
+ "type": "uint64"
287
+ }
288
+ ],
289
+ "name": "setRecord",
290
+ "outputs": [],
291
+ "payable": false,
292
+ "stateMutability": "nonpayable",
293
+ "type": "function"
294
+ },
295
+ {
296
+ "constant": false,
297
+ "inputs": [
298
+ {
299
+ "internalType": "bytes32",
300
+ "name": "node",
301
+ "type": "bytes32"
302
+ },
303
+ {
304
+ "internalType": "address",
305
+ "name": "resolver",
306
+ "type": "address"
307
+ }
308
+ ],
309
+ "name": "setResolver",
310
+ "outputs": [],
311
+ "payable": false,
312
+ "stateMutability": "nonpayable",
313
+ "type": "function"
314
+ },
315
+ {
316
+ "constant": false,
317
+ "inputs": [
318
+ {
319
+ "internalType": "bytes32",
320
+ "name": "node",
321
+ "type": "bytes32"
322
+ },
323
+ {
324
+ "internalType": "bytes32",
325
+ "name": "label",
326
+ "type": "bytes32"
327
+ },
328
+ {
329
+ "internalType": "address",
330
+ "name": "owner",
331
+ "type": "address"
332
+ }
333
+ ],
334
+ "name": "setSubnodeOwner",
335
+ "outputs": [
336
+ {
337
+ "internalType": "bytes32",
338
+ "name": "",
339
+ "type": "bytes32"
340
+ }
341
+ ],
342
+ "payable": false,
343
+ "stateMutability": "nonpayable",
344
+ "type": "function"
345
+ },
346
+ {
347
+ "constant": false,
348
+ "inputs": [
349
+ {
350
+ "internalType": "bytes32",
351
+ "name": "node",
352
+ "type": "bytes32"
353
+ },
354
+ {
355
+ "internalType": "bytes32",
356
+ "name": "label",
357
+ "type": "bytes32"
358
+ },
359
+ {
360
+ "internalType": "address",
361
+ "name": "owner",
362
+ "type": "address"
363
+ },
364
+ {
365
+ "internalType": "address",
366
+ "name": "resolver",
367
+ "type": "address"
368
+ },
369
+ {
370
+ "internalType": "uint64",
371
+ "name": "ttl",
372
+ "type": "uint64"
373
+ }
374
+ ],
375
+ "name": "setSubnodeRecord",
376
+ "outputs": [],
377
+ "payable": false,
378
+ "stateMutability": "nonpayable",
379
+ "type": "function"
380
+ },
381
+ {
382
+ "constant": false,
383
+ "inputs": [
384
+ {
385
+ "internalType": "bytes32",
386
+ "name": "node",
387
+ "type": "bytes32"
388
+ },
389
+ {
390
+ "internalType": "uint64",
391
+ "name": "ttl",
392
+ "type": "uint64"
393
+ }
394
+ ],
395
+ "name": "setTTL",
396
+ "outputs": [],
397
+ "payable": false,
398
+ "stateMutability": "nonpayable",
399
+ "type": "function"
400
+ },
401
+ {
402
+ "constant": true,
403
+ "inputs": [
404
+ {
405
+ "internalType": "bytes32",
406
+ "name": "node",
407
+ "type": "bytes32"
408
+ }
409
+ ],
410
+ "name": "ttl",
411
+ "outputs": [
412
+ {
413
+ "internalType": "uint64",
414
+ "name": "",
415
+ "type": "uint64"
416
+ }
417
+ ],
418
+ "payable": false,
419
+ "stateMutability": "view",
420
+ "type": "function"
421
+ }
422
+ ]
data/eth.gemspec CHANGED
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
28
28
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
29
  spec.bindir = "exe"
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
31
+ spec.require_paths = ["lib", "abis"]
32
32
  spec.test_files = spec.files.grep %r{^(test|spec|features)/}
33
33
 
34
34
  spec.platform = Gem::Platform::RUBY
35
- spec.required_ruby_version = ">= 2.6", "< 4.0"
35
+ spec.required_ruby_version = ">= 2.7", "< 4.0"
36
36
 
37
37
  # keccak for hashing everything in ethereum
38
38
  spec.add_dependency "keccak", "~> 1.3"
data/lib/eth/chain.rb CHANGED
@@ -92,6 +92,15 @@ module Eth
92
92
  # Chain ID for the geth private network preset.
93
93
  PRIVATE_GETH = 1337.freeze
94
94
 
95
+ # Indicates wether the given `v` indicates a legacy chain value
96
+ # used by ledger wallets without EIP-155 replay protection.
97
+ #
98
+ # @param v [Integer] the signature's `v` value.
99
+ # @return [Boolean] true if ledger's legacy value.
100
+ def is_ledger?(v)
101
+ [0, 1].include? v
102
+ end
103
+
95
104
  # Indicates wether the given `v` indicates a legacy chain value
96
105
  # without EIP-155 replay protection.
97
106
  #
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2016-2022 The Ruby-Eth Contributors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "net/http"
16
+
17
+ # Provides the {Eth} module.
18
+ module Eth
19
+
20
+ # Provides an HTTP/S-RPC client with basic authentication.
21
+ class Client::HttpAuth < Client
22
+
23
+ # The host of the HTTP endpoint.
24
+ attr_reader :host
25
+
26
+ # The port of the HTTP endpoint.
27
+ attr_reader :port
28
+
29
+ # The full URI of the HTTP endpoint, including path.
30
+ attr_reader :uri
31
+
32
+ # Attribute indicator for SSL.
33
+ attr_reader :ssl
34
+
35
+ # Attribute for user.
36
+ attr_reader :user
37
+
38
+ # Constructor for the HTTP Client. Should not be used; use
39
+ # {Client.create} intead.
40
+ #
41
+ # @param host [String] an URI pointing to an HTTP RPC-API.
42
+ def initialize(host)
43
+ super
44
+ uri = URI.parse(host)
45
+ raise ArgumentError, "Unable to parse the HTTP-URI!" unless ["http", "https"].include? uri.scheme
46
+ @host = uri.host
47
+ @port = uri.port
48
+ @ssl = uri.scheme == "https"
49
+ @user = uri.user
50
+ @password = uri.password
51
+ @uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}")
52
+ end
53
+
54
+ # Sends an RPC request to the connected HTTP client.
55
+ #
56
+ # @param payload [Hash] the RPC request parameters.
57
+ # @return [String] a JSON-encoded response.
58
+ def send(payload)
59
+ http = Net::HTTP.new(@host, @port)
60
+ http.use_ssl = @ssl
61
+ header = { "Content-Type" => "application/json" }
62
+ request = Net::HTTP::Post.new(@uri, header)
63
+ request.body = payload
64
+ response = http.request(request)
65
+ response.body
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ # Attribute for password.
72
+ attr_reader :password
73
+ end