eth 0.5.12 → 0.5.14
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.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +1 -1
- data/.github/workflows/docs.yml +2 -2
- data/.github/workflows/spec.yml +5 -7
- data/CHANGELOG.md +39 -1
- data/Gemfile +8 -8
- data/LICENSE.txt +1 -1
- data/README.md +1 -3
- data/SECURITY.md +1 -1
- data/eth.gemspec +4 -1
- data/lib/eth/abi/decoder.rb +3 -4
- data/lib/eth/abi/encoder.rb +4 -5
- data/lib/eth/abi/event.rb +5 -1
- data/lib/eth/abi/packed/encoder.rb +196 -0
- data/lib/eth/abi/type.rb +12 -12
- data/lib/eth/abi.rb +27 -2
- data/lib/eth/address.rb +11 -1
- data/lib/eth/api.rb +96 -1
- data/lib/eth/chain.rb +63 -12
- data/lib/eth/client/http.rb +7 -3
- data/lib/eth/client/ipc.rb +1 -1
- data/lib/eth/client.rb +3 -3
- data/lib/eth/constant.rb +1 -1
- data/lib/eth/contract/event.rb +69 -16
- data/lib/eth/contract/function.rb +1 -1
- data/lib/eth/contract/function_input.rb +1 -1
- 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 +3 -2
- data/lib/eth/ens/coin_type.rb +1 -1
- data/lib/eth/ens/resolver.rb +1 -1
- data/lib/eth/ens.rb +1 -1
- data/lib/eth/key/decrypter.rb +1 -1
- data/lib/eth/key/encrypter.rb +1 -1
- data/lib/eth/key.rb +1 -1
- data/lib/eth/rlp/decoder.rb +1 -1
- data/lib/eth/rlp/encoder.rb +1 -1
- data/lib/eth/rlp/sedes/big_endian_int.rb +1 -1
- data/lib/eth/rlp/sedes/binary.rb +1 -1
- data/lib/eth/rlp/sedes/list.rb +1 -1
- data/lib/eth/rlp/sedes.rb +1 -1
- data/lib/eth/rlp.rb +1 -1
- data/lib/eth/signature.rb +1 -1
- data/lib/eth/solidity.rb +1 -1
- data/lib/eth/tx/eip1559.rb +2 -2
- data/lib/eth/tx/eip2930.rb +2 -2
- data/lib/eth/tx/eip7702.rb +495 -0
- data/lib/eth/tx/legacy.rb +1 -1
- data/lib/eth/tx.rb +53 -2
- data/lib/eth/unit.rb +1 -1
- data/lib/eth/util.rb +6 -3
- data/lib/eth/version.rb +2 -2
- data/lib/eth.rb +1 -1
- metadata +20 -4
data/lib/eth/api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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,17 +27,25 @@ module Eth
|
|
27
27
|
"account_signTypedData",
|
28
28
|
"admin_addPeer",
|
29
29
|
"admin_addTrustedPeer",
|
30
|
+
"admin_clearHistory",
|
30
31
|
"admin_datadir",
|
31
32
|
"admin_exportChain",
|
33
|
+
"admin_getDatadir",
|
34
|
+
"admin_getNodeInfo",
|
35
|
+
"admin_getPeers",
|
32
36
|
"admin_importChain",
|
33
37
|
"admin_nodeInfo",
|
34
38
|
"admin_peerEvents",
|
35
39
|
"admin_peers",
|
36
40
|
"admin_removePeer",
|
37
41
|
"admin_removeTrustedPeer",
|
42
|
+
"admin_sleep",
|
43
|
+
"admin_sleepBlocks",
|
38
44
|
"admin_startHTTP",
|
45
|
+
"admin_startRPC",
|
39
46
|
"admin_startWS",
|
40
47
|
"admin_stopHTTP",
|
48
|
+
"admin_stopRPC",
|
41
49
|
"admin_stopWS",
|
42
50
|
"clef_deriveAccount",
|
43
51
|
"clef_listWallets",
|
@@ -78,6 +86,7 @@ module Eth
|
|
78
86
|
"debug_getRawHeader",
|
79
87
|
"debug_getRawReceipts",
|
80
88
|
"debug_getRawTransaction",
|
89
|
+
"debug_getTrieFlushInterval",
|
81
90
|
"debug_goTrace",
|
82
91
|
"debug_intermediateRoots",
|
83
92
|
"debug_memStats",
|
@@ -89,6 +98,7 @@ module Eth
|
|
89
98
|
"debug_setGCPercent",
|
90
99
|
"debug_setHead",
|
91
100
|
"debug_setMutexProfileFraction",
|
101
|
+
"debug_setTrieFlushInterval",
|
92
102
|
"debug_stacks",
|
93
103
|
"debug_standardTraceBadBlockToFile",
|
94
104
|
"debug_standardTraceBlockToFile",
|
@@ -111,51 +121,92 @@ module Eth
|
|
111
121
|
"debug_writeBlockProfile",
|
112
122
|
"debug_writeMemProfile",
|
113
123
|
"debug_writeMutexProfile",
|
124
|
+
"dev_addWithdrawal",
|
125
|
+
"dev_setFeeRecipient",
|
114
126
|
"eth_accounts",
|
127
|
+
"eth_blobBaseFee",
|
115
128
|
"eth_blockNumber",
|
116
129
|
"eth_call",
|
117
130
|
"eth_chainId",
|
131
|
+
"eth_coinbase",
|
132
|
+
"eth_compile",
|
118
133
|
"eth_compileLLL",
|
119
134
|
"eth_compileSerpent",
|
120
135
|
"eth_compileSolidity",
|
136
|
+
"eth_contract",
|
121
137
|
"eth_createAccessList",
|
138
|
+
"eth_defaultAccount",
|
139
|
+
"eth_defaultBlock",
|
122
140
|
"eth_estimateGas",
|
123
141
|
"eth_feeHistory",
|
142
|
+
"eth_fillTransaction",
|
143
|
+
"eth_filter",
|
124
144
|
"eth_gasPrice",
|
145
|
+
"eth_getAccounts",
|
125
146
|
"eth_getBalance",
|
147
|
+
"eth_getBlobBaseFee",
|
148
|
+
"eth_getBlock",
|
126
149
|
"eth_getBlockByHash",
|
127
150
|
"eth_getBlockByNumber",
|
151
|
+
"eth_getBlockNumber",
|
152
|
+
"eth_getBlockReceipts",
|
153
|
+
"eth_getBlockTransactionCount",
|
128
154
|
"eth_getBlockTransactionCountByHash",
|
129
155
|
"eth_getBlockTransactionCountByNumber",
|
156
|
+
"eth_getBlockUncleCount",
|
130
157
|
"eth_getCode",
|
158
|
+
"eth_getCoinbase",
|
131
159
|
"eth_getCompilers",
|
132
160
|
"eth_getFilterChanges",
|
133
161
|
"eth_getFilterLogs",
|
162
|
+
"eth_getGasPrice",
|
163
|
+
"eth_getHashrate",
|
164
|
+
"eth_getHeaderByHash",
|
165
|
+
"eth_getHeaderByNumber",
|
134
166
|
"eth_getLogs",
|
167
|
+
"eth_getMaxPriorityFeePerGas",
|
168
|
+
"eth_getMining",
|
169
|
+
"eth_getPendingTransactions",
|
135
170
|
"eth_getProof",
|
171
|
+
"eth_getProtocolVersion",
|
172
|
+
"eth_getRawTransaction",
|
173
|
+
"eth_getRawTransactionFromBlock",
|
136
174
|
"eth_getStorageAt",
|
175
|
+
"eth_getSyncing",
|
176
|
+
"eth_getTransaction",
|
137
177
|
"eth_getTransactionByBlockHashAndIndex",
|
138
178
|
"eth_getTransactionByBlockNumberAndIndex",
|
139
179
|
"eth_getTransactionByHash",
|
140
180
|
"eth_getTransactionCount",
|
181
|
+
"eth_getTransactionFromBlock",
|
141
182
|
"eth_getTransactionReceipt",
|
183
|
+
"eth_getUncle",
|
142
184
|
"eth_getUncleByBlockHashAndIndex",
|
143
185
|
"eth_getUncleByBlockNumberAndIndex",
|
144
186
|
"eth_getUncleCountByBlockHash",
|
145
187
|
"eth_getUncleCountByBlockNumber",
|
146
188
|
"eth_getWork",
|
147
189
|
"eth_hashrate",
|
190
|
+
"eth_iban",
|
191
|
+
"eth_icapNamereg",
|
192
|
+
"eth_isSyncing",
|
148
193
|
"eth_maxPriorityFeePerGas",
|
149
194
|
"eth_mining",
|
195
|
+
"eth_namereg",
|
150
196
|
"eth_newBlockFilter",
|
151
197
|
"eth_newFilter",
|
152
198
|
"eth_newPendingTransactionFilter",
|
199
|
+
"eth_pendingTransactions",
|
153
200
|
"eth_protocolVersion",
|
201
|
+
"eth_resend",
|
202
|
+
"eth_sendIBANTransaction",
|
154
203
|
"eth_sendRawTransaction",
|
155
204
|
"eth_sendTransaction",
|
156
205
|
"eth_sign",
|
157
206
|
"eth_signTransaction",
|
207
|
+
"eth_simulateV1",
|
158
208
|
"eth_submitHashrate",
|
209
|
+
"eth_submitTransaction",
|
159
210
|
"eth_submitWork",
|
160
211
|
"eth_syncing",
|
161
212
|
"eth_uninstallFilter",
|
@@ -177,6 +228,9 @@ module Eth
|
|
177
228
|
"miner_setRecommitInterval",
|
178
229
|
"miner_start",
|
179
230
|
"miner_stop",
|
231
|
+
"net_getListening",
|
232
|
+
"net_getPeerCount",
|
233
|
+
"net_getVersion",
|
180
234
|
"net_listening",
|
181
235
|
"net_peerCount",
|
182
236
|
"net_version",
|
@@ -195,6 +249,8 @@ module Eth
|
|
195
249
|
"personal_signTransaction",
|
196
250
|
"personal_unlockAccount",
|
197
251
|
"personal_unpair",
|
252
|
+
"rpc_getModules",
|
253
|
+
"rpc_modules",
|
198
254
|
"shh_addToGroup",
|
199
255
|
"shh_getFilterChanges",
|
200
256
|
"shh_getMessages",
|
@@ -207,10 +263,49 @@ module Eth
|
|
207
263
|
"shh_version",
|
208
264
|
"txpool_content",
|
209
265
|
"txpool_contentFrom",
|
266
|
+
"txpool_getContent",
|
267
|
+
"txpool_getInspect",
|
268
|
+
"txpool_getStatus",
|
210
269
|
"txpool_inspect",
|
211
270
|
"txpool_status",
|
271
|
+
"web3_admin",
|
272
|
+
"web3_bzz",
|
212
273
|
"web3_clientVersion",
|
274
|
+
"web3_createBatch",
|
275
|
+
"web3_currentProvider",
|
276
|
+
"web3_db",
|
277
|
+
"web3_debug",
|
278
|
+
"web3_dev",
|
279
|
+
"web3_eth",
|
280
|
+
"web3_fromAscii",
|
281
|
+
"web3_fromDecimal",
|
282
|
+
"web3_fromICAP",
|
283
|
+
"web3_fromUtf8",
|
284
|
+
"web3_fromWei",
|
285
|
+
"web3_isAddress",
|
286
|
+
"web3_isChecksumAddress",
|
287
|
+
"web3_isConnected",
|
288
|
+
"web3_isIBAN",
|
289
|
+
"web3_miner",
|
290
|
+
"web3_net",
|
291
|
+
"web3_padLeft",
|
292
|
+
"web3_padRight",
|
293
|
+
"web3_personal",
|
294
|
+
"web3_providers",
|
295
|
+
"web3_reset",
|
296
|
+
"web3_rpc",
|
297
|
+
"web3_setProvider",
|
298
|
+
"web3_settings",
|
213
299
|
"web3_sha3",
|
300
|
+
"web3_shh",
|
301
|
+
"web3_toAscii",
|
302
|
+
"web3_toChecksumAddress",
|
303
|
+
"web3_toDecimal",
|
304
|
+
"web3_toHex",
|
305
|
+
"web3_toUtf8",
|
306
|
+
"web3_toWei",
|
307
|
+
"web3_txpool",
|
308
|
+
"web3_version",
|
214
309
|
]
|
215
310
|
end
|
216
311
|
end
|
data/lib/eth/chain.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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,6 +32,15 @@ module Eth
|
|
32
32
|
# Chain ID for Optimistic Ethereum mainnet.
|
33
33
|
OPTIMISM = 10.freeze
|
34
34
|
|
35
|
+
# Chain ID for Cronos mainnet.
|
36
|
+
CRONOS = 25.freeze
|
37
|
+
|
38
|
+
# Chain ID for Rootstock mainnet.
|
39
|
+
RSK = 30.freeze
|
40
|
+
|
41
|
+
# Chain ID for BNB Smart Chain mainnet.
|
42
|
+
BNB = 56.freeze
|
43
|
+
|
35
44
|
# Chain ID for Ethereum Classic mainnet.
|
36
45
|
CLASSIC = 61.freeze
|
37
46
|
|
@@ -50,9 +59,45 @@ module Eth
|
|
50
59
|
# Chain ID for the Polygon mainnet (formerly Matic).
|
51
60
|
POLYGON = MATIC.freeze
|
52
61
|
|
53
|
-
# Chain ID for
|
62
|
+
# Chain ID for Filecoin mainnet.
|
63
|
+
FILECOIN = 314.freeze
|
64
|
+
|
65
|
+
# Chain ID for the Cronos zkEVM chain.
|
66
|
+
CRONOS_ZK = 388.freeze
|
67
|
+
|
68
|
+
# Chain ID for Redstone Optimistic Rollup.
|
69
|
+
REDSTONE = 690.freeze
|
70
|
+
|
71
|
+
# Chain ID for the Polygon zkEVM.
|
72
|
+
POLYGON_ZK = 1101.freeze
|
73
|
+
|
74
|
+
# Chain ID for the Lisk layer 2.
|
75
|
+
LISK = 1135.freeze
|
76
|
+
|
77
|
+
# Chain ID for Moonbeam
|
78
|
+
MOONBEAM = 1284.freeze
|
79
|
+
|
80
|
+
# Chain ID for Base mainnet.
|
81
|
+
BASE = 8453.freeze
|
82
|
+
|
83
|
+
# Chain ID for the EVMOS mainnet.
|
84
|
+
EVMOS = 9001.freeze
|
85
|
+
|
86
|
+
# Chain ID for the Celo layer 2.
|
87
|
+
CELO = 42220.freeze
|
88
|
+
|
89
|
+
# Chain ID for Arbitrum One mainnet.
|
54
90
|
ARBITRUM = 42161.freeze
|
55
91
|
|
92
|
+
# Chain ID for Avalance C-Chain mainnet.
|
93
|
+
AVALANCHE = 43114.freeze
|
94
|
+
|
95
|
+
# Chain ID for Linea mainnet.
|
96
|
+
LINEA = 59144.freeze
|
97
|
+
|
98
|
+
# Chain ID for the Scroll layer 2.
|
99
|
+
SCROLL = 534352.freeze
|
100
|
+
|
56
101
|
# Chain ID for Morden (Ethereum) testnet.
|
57
102
|
MORDEN = 2.freeze
|
58
103
|
|
@@ -77,7 +122,7 @@ module Eth
|
|
77
122
|
# Chain ID for Mordor testnet.
|
78
123
|
MORDOR = 63.freeze
|
79
124
|
|
80
|
-
# Chain ID for
|
125
|
+
# Chain ID for Optimistm Kovan testnet.
|
81
126
|
KOVAN_OPTIMISM = 69.freeze
|
82
127
|
|
83
128
|
# Chain ID for Arbitrum xDAI testnet.
|
@@ -86,6 +131,15 @@ module Eth
|
|
86
131
|
# Chain ID for Optimistic Goerli testnet.
|
87
132
|
GOERLI_OPTIMISM = 420.freeze
|
88
133
|
|
134
|
+
# Chain ID for Moonriver testnet
|
135
|
+
MOONRIVER = 1285.freeze
|
136
|
+
|
137
|
+
# Chain ID for Moonbase alpha
|
138
|
+
MOONBASE = 1287.freeze
|
139
|
+
|
140
|
+
# Chain ID for the Garnet Holesky testnet
|
141
|
+
GARNET = 17069.freeze
|
142
|
+
|
89
143
|
# Chain ID for the Polygon Mumbai testnet.
|
90
144
|
MUMBAI = 80001.freeze
|
91
145
|
|
@@ -95,24 +149,21 @@ module Eth
|
|
95
149
|
# Chain ID for Arbitrum Goerli testnet.
|
96
150
|
GOERLI_ARBITRUM = 421613.freeze
|
97
151
|
|
152
|
+
# Chain ID for Hoodi testnet.
|
153
|
+
HOODI = 560048.freeze
|
154
|
+
|
98
155
|
# Chain ID for Sepolia testnet.
|
99
156
|
SEPOLIA = 11155111.freeze
|
100
157
|
|
101
158
|
# Chain ID for Holesovice testnet.
|
102
159
|
HOLESOVICE = 11166111.freeze
|
103
160
|
|
161
|
+
# Chain ID for Holesovice testnet.
|
162
|
+
HOLESKY = HOLESOVICE
|
163
|
+
|
104
164
|
# Chain ID for the geth private network preset.
|
105
165
|
PRIVATE_GETH = 1337.freeze
|
106
166
|
|
107
|
-
# Chain ID for Moonbase
|
108
|
-
MOONBASE = 1287.freeze
|
109
|
-
|
110
|
-
# Chain ID for Moonriver
|
111
|
-
MOONRIVER = 1285.freeze
|
112
|
-
|
113
|
-
# Chain ID for Moonbeam
|
114
|
-
MOONBEAM = 1284.freeze
|
115
|
-
|
116
167
|
# Indicates wether the given `v` indicates a legacy chain value
|
117
168
|
# used by ledger wallets without EIP-155 replay protection.
|
118
169
|
#
|
data/lib/eth/client/http.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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.
|
@@ -49,9 +49,13 @@ module Eth
|
|
49
49
|
if !(uri.user.nil? && uri.password.nil?)
|
50
50
|
@user = uri.user
|
51
51
|
@password = uri.password
|
52
|
-
|
52
|
+
if uri.query
|
53
|
+
@uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}?#{uri.query}")
|
54
|
+
else
|
55
|
+
@uri = URI("#{uri.scheme}://#{uri.user}:#{uri.password}@#{@host}:#{@port}#{uri.path}")
|
56
|
+
end
|
53
57
|
else
|
54
|
-
@uri =
|
58
|
+
@uri = uri
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
data/lib/eth/client/ipc.rb
CHANGED
data/lib/eth/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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.
|
@@ -315,11 +315,11 @@ module Eth
|
|
315
315
|
# See {#transact} for params and overloads.
|
316
316
|
#
|
317
317
|
# @raise [Client::ContractExecutionError] if the execution fails.
|
318
|
-
# @return [Object] returns the result of the transaction.
|
318
|
+
# @return [Object, Boolean] returns the result of the transaction (hash and execution status).
|
319
319
|
def transact_and_wait(contract, function, *args, **kwargs)
|
320
320
|
begin
|
321
321
|
hash = wait_for_tx(transact(contract, function, *args, **kwargs))
|
322
|
-
return hash
|
322
|
+
return hash, tx_succeeded?(hash)
|
323
323
|
rescue IOError => e
|
324
324
|
raise ContractExecutionError, e
|
325
325
|
end
|
data/lib/eth/constant.rb
CHANGED
data/lib/eth/contract/event.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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,40 +16,93 @@
|
|
16
16
|
|
17
17
|
# Provides the {Eth} module.
|
18
18
|
module Eth
|
19
|
-
|
20
19
|
# Provide classes for contract event.
|
21
20
|
class Contract::Event
|
22
|
-
attr_accessor :name, :signature, :input_types, :inputs, :event_string, :address
|
23
|
-
|
24
21
|
# Constructor of the {Eth::Contract::Event} class.
|
25
22
|
#
|
26
23
|
# @param data [Hash] contract event data.
|
27
24
|
def initialize(data)
|
28
|
-
@
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
@data = data
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the name of the event.
|
29
|
+
#
|
30
|
+
# @return [String] The event name.
|
31
|
+
def name
|
32
|
+
@data["name"]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns the input types for the event.
|
36
|
+
#
|
37
|
+
# @return [Array<String>] An array of input type names.
|
38
|
+
def input_types
|
39
|
+
@input_types ||= @data["inputs"].map { |x| type_name(x) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the names of input parameters.
|
43
|
+
#
|
44
|
+
# @return [Array<String>] An array of input parameter names.
|
45
|
+
def inputs
|
46
|
+
@inputs ||= @data["inputs"].map { |x| x["name"] }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the event signature string.
|
50
|
+
#
|
51
|
+
# @return [String] The event signature string, generated from ABI.
|
52
|
+
def event_string
|
53
|
+
@event_string ||= Abi::Event.signature(@data)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the Keccak-256 event signature hash.
|
57
|
+
#
|
58
|
+
# @return [String] The event signature hash in hexadecimal format.
|
59
|
+
def signature
|
60
|
+
@signature ||= Digest::Keccak.hexdigest(event_string, 256)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the Ethereum address associated with the event.
|
64
|
+
#
|
65
|
+
# @return [String, nil] The Ethereum address, or `nil` if not set.
|
66
|
+
def address
|
67
|
+
@address ||= nil
|
35
68
|
end
|
36
69
|
|
37
70
|
# Set the address of the smart contract
|
38
71
|
#
|
39
72
|
# @param address [String] contract address.
|
40
73
|
def set_address(address)
|
41
|
-
@address = address
|
74
|
+
@address = address ? Eth::Address.new(address).address : nil
|
75
|
+
end
|
76
|
+
|
77
|
+
# Decodes event parameters from logs.
|
78
|
+
#
|
79
|
+
# @param topics [Array<String>] The list of log topics, including the event selector.
|
80
|
+
# @param data [String] The log data containing non-indexed parameters.
|
81
|
+
# @return [ActiveSupport::HashWithIndifferentAccess] A hash of decoded event parameters.
|
82
|
+
def decode_params(topics, data = "0x")
|
83
|
+
inputs = @data["inputs"]
|
84
|
+
|
85
|
+
indexed_inputs, non_indexed_inputs = inputs.partition { _1["indexed"] }
|
86
|
+
|
87
|
+
{
|
88
|
+
**indexed_inputs.each_with_index.inject({}) do |result, (input, index)|
|
89
|
+
result[input["name"]] = Eth::Abi.decode([input["type"]], topics[index + 1])[0]
|
90
|
+
result
|
91
|
+
end,
|
92
|
+
**Hash[non_indexed_inputs.map { _1["name"] }.zip(
|
93
|
+
Eth::Abi.decode(non_indexed_inputs.map { |i| i["type"] }, data)
|
94
|
+
)],
|
95
|
+
}
|
42
96
|
end
|
43
97
|
|
44
98
|
private
|
45
99
|
|
46
100
|
def type_name(x)
|
47
|
-
|
48
|
-
case type
|
101
|
+
case x["type"]
|
49
102
|
when "tuple"
|
50
|
-
"(#{x["components"].
|
103
|
+
"(#{x["components"].map { |c| type_name(c) }.join(",")})"
|
51
104
|
else
|
52
|
-
type
|
105
|
+
x["type"]
|
53
106
|
end
|
54
107
|
end
|
55
108
|
end
|
data/lib/eth/contract.rb
CHANGED
data/lib/eth/eip712.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2016-
|
1
|
+
# Copyright (c) 2016-2025 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.
|
@@ -113,7 +113,6 @@ module Eth
|
|
113
113
|
types[primary_type.to_sym].each do |field|
|
114
114
|
value = data[field[:name].to_sym]
|
115
115
|
type = field[:type]
|
116
|
-
raise NotImplementedError, "Arrays currently unimplemented for EIP-712." if type.end_with? "]"
|
117
116
|
if type == "string"
|
118
117
|
encoded_types.push "bytes32"
|
119
118
|
encoded_values.push Util.keccak256 value
|
@@ -125,6 +124,8 @@ module Eth
|
|
125
124
|
encoded_types.push "bytes32"
|
126
125
|
value = encode_data type, value, types
|
127
126
|
encoded_values.push Util.keccak256 value
|
127
|
+
elsif type.end_with? "]"
|
128
|
+
raise NotImplementedError, "Arrays currently unimplemented for EIP-712."
|
128
129
|
else
|
129
130
|
encoded_types.push type
|
130
131
|
encoded_values.push value
|
data/lib/eth/ens/coin_type.rb
CHANGED
data/lib/eth/ens/resolver.rb
CHANGED
data/lib/eth/ens.rb
CHANGED
data/lib/eth/key/decrypter.rb
CHANGED
data/lib/eth/key/encrypter.rb
CHANGED
data/lib/eth/key.rb
CHANGED
data/lib/eth/rlp/decoder.rb
CHANGED
data/lib/eth/rlp/encoder.rb
CHANGED
data/lib/eth/rlp/sedes/binary.rb
CHANGED
data/lib/eth/rlp/sedes/list.rb
CHANGED
data/lib/eth/rlp/sedes.rb
CHANGED
data/lib/eth/rlp.rb
CHANGED
data/lib/eth/signature.rb
CHANGED
data/lib/eth/solidity.rb
CHANGED