web3 0.4.0 → 0.4.1
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/lib/eth_calls.rb +293 -0
- data/lib/miner_calls.rb +44 -0
- data/lib/net_calls.rb +20 -0
- data/lib/personal_calls.rb +55 -0
- data/lib/shh_calls.rb +62 -0
- data/lib/txpool_calls.rb +9 -0
- data/lib/web3.rb +21 -1
- data/lib/web3_calls.rb +14 -0
- metadata +9 -3
- data/lib/generated_web3_methods.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07897280ec48cfea7231b466820e0de75e88fcf5
|
4
|
+
data.tar.gz: 81556f6019057cf0ade38a71c68d91c9a50affe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f09337aefb4bfccf382e1a2e301054f67372e1482ec47f455d151ce77395883da3729be87d078d49bd2137dd33e270dee5284f1e75634c27fe8a70888d26cba0
|
7
|
+
data.tar.gz: 935c9a64d79070e5e65dc64b08f8a6794a3bc30bbc69f7e1189f0780f807a9e584de2e780514e94d42d067bb50ed46c4a209038e07605abe0084a0eeb22118bc
|
data/lib/eth_calls.rb
ADDED
@@ -0,0 +1,293 @@
|
|
1
|
+
module Web3::EthCalls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_protocolversion
|
4
|
+
def eth_protocolVersion()
|
5
|
+
raise NotImplementedError.new "JSON-RPC call to eth_protocolVersion is not currently supported"
|
6
|
+
end
|
7
|
+
|
8
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_syncing
|
9
|
+
def eth_syncing()
|
10
|
+
response = do_request("eth_syncing")
|
11
|
+
response["result"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_coinbase
|
15
|
+
def eth_coinbase()
|
16
|
+
response = do_request("eth_coinbase")
|
17
|
+
response["result"]
|
18
|
+
end
|
19
|
+
|
20
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_mining
|
21
|
+
def eth_mining()
|
22
|
+
response = do_request("eth_mining")
|
23
|
+
response["result"]
|
24
|
+
end
|
25
|
+
|
26
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_hashrate
|
27
|
+
def eth_hashrate()
|
28
|
+
response = do_request("eth_hashrate")
|
29
|
+
to_decimal response["result"]
|
30
|
+
end
|
31
|
+
|
32
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gasprice
|
33
|
+
def eth_gasPrice()
|
34
|
+
response = do_request("eth_gasPrice")
|
35
|
+
to_decimal response["result"]
|
36
|
+
end
|
37
|
+
|
38
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts
|
39
|
+
def eth_accounts()
|
40
|
+
response = do_request("eth_accounts")
|
41
|
+
response["result"]
|
42
|
+
end
|
43
|
+
|
44
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber
|
45
|
+
def eth_blockNumber()
|
46
|
+
response = do_request("eth_blockNumber")
|
47
|
+
to_decimal response["result"]
|
48
|
+
end
|
49
|
+
|
50
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance
|
51
|
+
def eth_getBalance(address, block = "latest")
|
52
|
+
response = do_request("eth_getBalance",[address, block])
|
53
|
+
to_decimal response["result"]
|
54
|
+
end
|
55
|
+
|
56
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getstorageat
|
57
|
+
def eth_getStorageAt(storage_address, position, block = "latest")
|
58
|
+
response = do_request("eth_getStorageAt",[storage_address, to_hex(position), block])
|
59
|
+
response["result"]
|
60
|
+
end
|
61
|
+
|
62
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactioncount
|
63
|
+
def eth_getTransactionCount(address, block = "latest")
|
64
|
+
response = do_request("eth_getTransactionCount",[address, block])
|
65
|
+
to_decimal response["result"]
|
66
|
+
end
|
67
|
+
|
68
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbyhash
|
69
|
+
def eth_getBlockTransactionCountByHash(data)
|
70
|
+
response = do_request("eth_getBlockTransactionCountByHash",[data])
|
71
|
+
to_decimal response["result"]
|
72
|
+
end
|
73
|
+
|
74
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblocktransactioncountbynumber
|
75
|
+
def eth_getBlockTransactionCountByNumber(block = "latest")
|
76
|
+
response = do_request("eth_getBlockTransactionCountByNumber",[block])
|
77
|
+
to_decimal response["result"]
|
78
|
+
end
|
79
|
+
|
80
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblockhash
|
81
|
+
def eth_getUncleCountByBlockHash(data)
|
82
|
+
response = do_request("eth_getUncleCountByBlockHash",[data])
|
83
|
+
to_decimal response["result"]
|
84
|
+
end
|
85
|
+
|
86
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclecountbyblocknumber
|
87
|
+
def eth_getUncleCountByBlockNumber(data)
|
88
|
+
response = do_request("eth_getUncleCountByBlockNumber",[data])
|
89
|
+
to_decimal response["result"]
|
90
|
+
end
|
91
|
+
|
92
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
|
93
|
+
def eth_getCode(address, block = "latest")
|
94
|
+
response = do_request("eth_getCode",[address, block])
|
95
|
+
response["result"]
|
96
|
+
end
|
97
|
+
|
98
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
99
|
+
def eth_sign(address, data)
|
100
|
+
response = do_request("eth_sign",[address, data])
|
101
|
+
response["result"]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Sends a transaction for posting to the ethereum network. The transaction_object
|
105
|
+
# that is sent should look something like this:
|
106
|
+
#
|
107
|
+
# {"from"=> accounts[0], "to" => accounts[1], "value" => w3.ether_to_0xwei(0.001)}
|
108
|
+
#
|
109
|
+
# Other 0x-fomatted attributes that can be included in the transaction_object are:
|
110
|
+
# "data" : formatted as hex
|
111
|
+
# "gas", "gasPrice", "value", and "nonce" : formatted as "0x" + hex
|
112
|
+
#
|
113
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction
|
114
|
+
def eth_sendTransaction(transaction_object)
|
115
|
+
response = do_request("eth_sendTransaction",[transaction_object])
|
116
|
+
response["result"]
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns pending transactions that belong to any of the users accounts
|
120
|
+
# See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#ethpendingtransactions
|
121
|
+
def eth_pendingTransactions()
|
122
|
+
response = do_request("eth_pendingTransactions")
|
123
|
+
response["result"]
|
124
|
+
end
|
125
|
+
|
126
|
+
# Resends a transaction. These can ge retrieved from eth_pendingTransactions().
|
127
|
+
# gasPrice and gasLimit can be included together if the gas settings are being changed from
|
128
|
+
# their original settings in the pending_transaction object
|
129
|
+
# See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#ethresend
|
130
|
+
def eth_resend(pending_transaction, gasPrice=nil, gasLimit=nil)
|
131
|
+
package = [pending_transaction]
|
132
|
+
if gasPrice != nil
|
133
|
+
package += [gasPrice, gasLimit]
|
134
|
+
end
|
135
|
+
response = do_request("eth_resend", package)
|
136
|
+
response["result"]
|
137
|
+
end
|
138
|
+
|
139
|
+
# This sends a transaction that looks something like this:
|
140
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction
|
141
|
+
def eth_sendRawTransaction(data)
|
142
|
+
response = do_request("eth_sendRawTransaction",[data])
|
143
|
+
response["result"]
|
144
|
+
end
|
145
|
+
|
146
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
|
147
|
+
def eth_call(trans_object,block="latest")
|
148
|
+
response = do_request("eth_call",[trans_object, block])
|
149
|
+
response["result"]
|
150
|
+
end
|
151
|
+
|
152
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_estimategas
|
153
|
+
def eth_estimateGas(trans_object)
|
154
|
+
response = do_request("eth_estimateGas",[trans_object])
|
155
|
+
response["result"]
|
156
|
+
end
|
157
|
+
|
158
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash
|
159
|
+
def eth_getBlockByHash(hash, full_transactions = true)
|
160
|
+
response = do_request("eth_getBlockByHash",[hash, full_transactions])
|
161
|
+
response["result"]
|
162
|
+
end
|
163
|
+
|
164
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber
|
165
|
+
def eth_getBlockByNumber(number, full_transactions = true)
|
166
|
+
response = do_request("eth_getBlockByNumber",[number, full_transactions])
|
167
|
+
response["result"]
|
168
|
+
end
|
169
|
+
|
170
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash
|
171
|
+
def eth_getTransactionByHash(hash)
|
172
|
+
response = do_request("eth_getTransactionByHash",[hash])
|
173
|
+
response["result"]
|
174
|
+
end
|
175
|
+
|
176
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblockhashandindex
|
177
|
+
def eth_getTransactionByBlockHashAndIndex(hash, index)
|
178
|
+
response = do_request("eth_getTransactionByBlockHashAndIndex",[hash, index])
|
179
|
+
response["result"]
|
180
|
+
end
|
181
|
+
|
182
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblocknumberandindex
|
183
|
+
def eth_getTransactionByBlockNumberAndIndex(number, index)
|
184
|
+
response = do_request("eth_getTransactionByBlockNumberAndIndex",[number, index])
|
185
|
+
response["result"]
|
186
|
+
end
|
187
|
+
|
188
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt
|
189
|
+
def eth_getTransactionReceipt(hash)
|
190
|
+
response = do_request("eth_getTransactionReceipt",[hash])
|
191
|
+
response["result"]
|
192
|
+
end
|
193
|
+
|
194
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblockhashandindex
|
195
|
+
def eth_getUncleByBlockHashAndIndex(hash, index)
|
196
|
+
response = do_request("eth_getUncleByBlockHashAndIndex",[hash, index])
|
197
|
+
response["result"]
|
198
|
+
end
|
199
|
+
|
200
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getunclebyblocknumberandindex
|
201
|
+
def eth_getUncleByBlockNumberAndIndex(number, index)
|
202
|
+
response = do_request("eth_getUncleByBlockNumberAndIndex",[number, index])
|
203
|
+
response["result"]
|
204
|
+
end
|
205
|
+
|
206
|
+
# deprecated
|
207
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcompilers
|
208
|
+
def eth_getCompilers()
|
209
|
+
response = do_request("eth_getCompilers")
|
210
|
+
response["result"]
|
211
|
+
end
|
212
|
+
|
213
|
+
#deprecated
|
214
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilelll
|
215
|
+
def eth_compileLLL(code)
|
216
|
+
response = do_request("eth_compileLLL",[code])
|
217
|
+
response["result"]
|
218
|
+
end
|
219
|
+
|
220
|
+
# deprecated
|
221
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compilesolidity
|
222
|
+
def eth_compileSolidity(code)
|
223
|
+
response = do_request("eth_compileSolidity",[code])
|
224
|
+
response["result"]
|
225
|
+
end
|
226
|
+
|
227
|
+
# deprecated
|
228
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_compileserpent
|
229
|
+
def eth_compileSerpent(code)
|
230
|
+
response = do_request("eth_compileSerpent",[code])
|
231
|
+
response["result"]
|
232
|
+
end
|
233
|
+
|
234
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
|
235
|
+
def eth_newFilter(fromBlock, toBlock, address, topics)
|
236
|
+
response = do_request("$CODE",[fromBlock, toBlock, address, topics])
|
237
|
+
to_decimal response["result"]
|
238
|
+
end
|
239
|
+
|
240
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
|
241
|
+
def eth_newBlockFilter()
|
242
|
+
response = do_request("eth_newBlockFilter")
|
243
|
+
to_decimal response["result"]
|
244
|
+
end
|
245
|
+
|
246
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter
|
247
|
+
def eth_newPendingTransactionFilter()
|
248
|
+
response = do_request("eth_newPendingTransactionFilter")
|
249
|
+
to_decimal response["result"]
|
250
|
+
end
|
251
|
+
|
252
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
|
253
|
+
def eth_uninstallFilter(id)
|
254
|
+
response = do_request("eth_uninstallFilter",[id])
|
255
|
+
response["result"]
|
256
|
+
end
|
257
|
+
|
258
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
|
259
|
+
def eth_getFilterChanges(id)
|
260
|
+
response = do_request("eth_getFilterChanges",[id])
|
261
|
+
response["result"]
|
262
|
+
end
|
263
|
+
|
264
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
|
265
|
+
def eth_getFilterLogs(id)
|
266
|
+
response = do_request("eth_getFilterLogs",[id])
|
267
|
+
response["result"]
|
268
|
+
end
|
269
|
+
|
270
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
|
271
|
+
def eth_getLogs(filter_obj)
|
272
|
+
response = do_request("eth_getLogs",[filter_obj])
|
273
|
+
response["result"]
|
274
|
+
end
|
275
|
+
|
276
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getwork
|
277
|
+
def eth_getWork()
|
278
|
+
response = do_request("eth_getWork")
|
279
|
+
response["result"]
|
280
|
+
end
|
281
|
+
|
282
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submitwork
|
283
|
+
def eth_submitWork(nonce, powHash, mixDigest)
|
284
|
+
response = do_request("eth_submitWork",[nonce, powHash, mixDigest])
|
285
|
+
response["result"]
|
286
|
+
end
|
287
|
+
|
288
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_submithashrate
|
289
|
+
def eth_submitHashrate(hashrate, id)
|
290
|
+
response = do_request("eth_submitHashrate",[hashrate, id])
|
291
|
+
response["result"]
|
292
|
+
end
|
293
|
+
end
|
data/lib/miner_calls.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Web3::MinerCalls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_makedag
|
4
|
+
def miner_makeDAG(number)
|
5
|
+
response = do_request("miner_makeDAG",[number])
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_setextra
|
10
|
+
def miner_setExtra(extra)
|
11
|
+
response = do_request("miner_setExtra",[extra])
|
12
|
+
response["result"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_setgasprice
|
16
|
+
def miner_setGasPrice(gasPrice)
|
17
|
+
response = do_request("miner_setGasPrice",[gasPrice])
|
18
|
+
response["result"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_start
|
22
|
+
def miner_start(threads)
|
23
|
+
response = do_request("miner_start",[threads])
|
24
|
+
response["result"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_startautodag
|
28
|
+
def miner_startAutoDAG(number)
|
29
|
+
response = do_request("miner_startAutoDAG",[number])
|
30
|
+
response["result"]
|
31
|
+
end
|
32
|
+
|
33
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_stop
|
34
|
+
def miner_stop()
|
35
|
+
response = do_request("miner_stop")
|
36
|
+
response["result"]
|
37
|
+
end
|
38
|
+
|
39
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#miner_stopautodag
|
40
|
+
def miner_stopAutoDAG()
|
41
|
+
response = do_request("miner_stopAutoDAG")
|
42
|
+
response["result"]
|
43
|
+
end
|
44
|
+
end
|
data/lib/net_calls.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Web3::NetCalls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_version
|
4
|
+
def net_version()
|
5
|
+
response = do_request("net_version")
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_peercount
|
10
|
+
def net_peerCount()
|
11
|
+
response = do_request("net_peerCount")
|
12
|
+
to_decimal response["result"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#net_listening
|
16
|
+
def net_listening()
|
17
|
+
response = do_request("net_listening")
|
18
|
+
response["result"]
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Web3::PersonalCalls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_listaccounts
|
4
|
+
def personal_listAccounts()
|
5
|
+
response = do_request("personal_listAccounts")
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_importrawkey
|
10
|
+
def personal_importRawKey(key, passphrase)
|
11
|
+
response = do_request("personal_importRawKey",[key, passphrase])
|
12
|
+
response["result"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_newaccount
|
16
|
+
def personal_newAccount(password)
|
17
|
+
response = do_request("personal_newAccount",[password])
|
18
|
+
response["result"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_signandsendtransaction
|
22
|
+
def personal_signAndSendTransaction(transaction, passphrase)
|
23
|
+
response = do_request("personal_signAndSendTransaction",[transaction, passphrase])
|
24
|
+
response["result"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_lockaccount
|
28
|
+
def personal_lockAccount(account)
|
29
|
+
response = do_request("personal_lockAccount",[account])
|
30
|
+
response["result"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# Be careful with this method. Do not leave an account unlocked, as that creates
|
35
|
+
# an opportunity for an attacker to make transactions from that account. In general
|
36
|
+
# personal_signAndSendTransaction is a better option than unlock -> send -> lock
|
37
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_unlockaccount
|
38
|
+
def personal_unlockAccount(account, passphrase, duration)
|
39
|
+
response = do_request("personal_unlockAccount",[account, passphrase, duration])
|
40
|
+
response["result"]
|
41
|
+
end
|
42
|
+
|
43
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
44
|
+
def personal_sign(message, account, password)
|
45
|
+
response = do_request("personal_sign",[message, account, password])
|
46
|
+
response["result"]
|
47
|
+
end
|
48
|
+
|
49
|
+
# See https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecrecover
|
50
|
+
def personal_ecRecover(message, signature)
|
51
|
+
response = do_request("personal_ecRecover",[message, signature])
|
52
|
+
response["result"]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/lib/shh_calls.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Web3::ShhCalls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_version
|
4
|
+
def shh_version()
|
5
|
+
response = do_request("shh_version")
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_post
|
10
|
+
def shh_post(post_object)
|
11
|
+
response = do_request("shh_post",[post_object])
|
12
|
+
response["result"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newidentity
|
16
|
+
def shh_newIdentity()
|
17
|
+
response = do_request("shh_newIdentity")
|
18
|
+
response["result"]
|
19
|
+
end
|
20
|
+
|
21
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_hasidentity
|
22
|
+
def shh_hasIdentity(address)
|
23
|
+
response = do_request("shh_hasIdentity",[address])
|
24
|
+
response["result"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newgroup
|
28
|
+
def shh_newGroup()
|
29
|
+
response = do_request("shh_newGroup")
|
30
|
+
response["result"]
|
31
|
+
end
|
32
|
+
|
33
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_addtogroup
|
34
|
+
def shh_addToGroup(address)
|
35
|
+
response = do_request("shh_addToGroup",[address])
|
36
|
+
response["result"]
|
37
|
+
end
|
38
|
+
|
39
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_newfilter
|
40
|
+
def shh_newFilter(filter_object)
|
41
|
+
response = do_request("shh_newFilter",[filter_object])
|
42
|
+
to_decimal response["result"]
|
43
|
+
end
|
44
|
+
|
45
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_uninstallfilter
|
46
|
+
def shh_uninstallFilter(id)
|
47
|
+
response = do_request("shh_uninstallFilter",[id])
|
48
|
+
response["result"]
|
49
|
+
end
|
50
|
+
|
51
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getfilterchanges
|
52
|
+
def shh_getFilterChanges(id)
|
53
|
+
response = do_request("shh_getFilterChanges",[id])
|
54
|
+
response["result"]
|
55
|
+
end
|
56
|
+
|
57
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#shh_getmessages
|
58
|
+
def shh_getMessages(id)
|
59
|
+
response = do_request("shh_getMessages",[id])
|
60
|
+
response["result"]
|
61
|
+
end
|
62
|
+
end
|
data/lib/txpool_calls.rb
ADDED
data/lib/web3.rb
CHANGED
@@ -76,9 +76,10 @@ include Web3::PersonalCalls
|
|
76
76
|
require_relative "txpool_calls.rb"
|
77
77
|
include Web3::TxpoolCalls
|
78
78
|
|
79
|
+
require_relative "miner_calls.rb"
|
80
|
+
include Web3::MinerCalls
|
79
81
|
|
80
82
|
#Utility methods
|
81
|
-
|
82
83
|
# Converts a hex string or int to a decimal integer
|
83
84
|
def to_decimal(hex)
|
84
85
|
if hex == nil
|
@@ -101,7 +102,10 @@ include Web3::TxpoolCalls
|
|
101
102
|
decimal.to_s(16) #this will throw an error if a non-integer is used
|
102
103
|
end
|
103
104
|
|
105
|
+
<<<<<<< HEAD
|
106
|
+
=======
|
104
107
|
|
108
|
+
>>>>>>> 765c1d4443a3e6c619b75f300db3722f9591db65
|
105
109
|
# Converts a decimal integer to a hex string that starts with a 0x marker
|
106
110
|
def to_0x(decimal)
|
107
111
|
"0x" + to_hex(decimal)
|
@@ -139,6 +143,21 @@ include Web3::TxpoolCalls
|
|
139
143
|
personal_signAndSendTransaction(trans, password)
|
140
144
|
end
|
141
145
|
|
146
|
+
<<<<<<< HEAD
|
147
|
+
def createContract(from_address, bin_file, password)
|
148
|
+
trans = {}
|
149
|
+
trans["from"] = from_address
|
150
|
+
trans["data"] = File.read(bin_file)
|
151
|
+
gas = eth_estimateGas[trans]
|
152
|
+
trans["gas"] = ether_to_0xwei(ether)
|
153
|
+
personal_signAndSendTransaction(trans, password)
|
154
|
+
end
|
155
|
+
|
156
|
+
def getContractAddress(tx_number)
|
157
|
+
receipt = eth_getTransactionReceipt tx_number
|
158
|
+
receipt["contract"]
|
159
|
+
end
|
160
|
+
=======
|
142
161
|
|
143
162
|
|
144
163
|
|
@@ -147,6 +166,7 @@ include Web3::TxpoolCalls
|
|
147
166
|
|
148
167
|
|
149
168
|
|
169
|
+
>>>>>>> 765c1d4443a3e6c619b75f300db3722f9591db65
|
150
170
|
end
|
151
171
|
|
152
172
|
w3 = Web3. new
|
data/lib/web3_calls.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Web3::Web3Calls
|
2
|
+
|
3
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_clientversion
|
4
|
+
def web3_clientVersion()
|
5
|
+
response = do_request("web3_clientVersion")
|
6
|
+
response["result"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# See https://github.com/ethereum/wiki/wiki/JSON-RPC#web3_sha3
|
10
|
+
def web3_sha3(data)
|
11
|
+
response = do_request("web3_sha3",[data])
|
12
|
+
response["result"]
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanna-nouveau
|
@@ -58,8 +58,14 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
-
- lib/
|
61
|
+
- lib/eth_calls.rb
|
62
|
+
- lib/miner_calls.rb
|
63
|
+
- lib/net_calls.rb
|
64
|
+
- lib/personal_calls.rb
|
65
|
+
- lib/shh_calls.rb
|
66
|
+
- lib/txpool_calls.rb
|
62
67
|
- lib/web3.rb
|
68
|
+
- lib/web3_calls.rb
|
63
69
|
homepage: https://github.com/spikewilliams/vtada-ethereum
|
64
70
|
licenses:
|
65
71
|
- MIT
|