cns 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +4 -3
- data/lib/cns/bigquery.rb +141 -195
- data/lib/cns/etherscan.rb +17 -9
- data/lib/cns/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1bca1a698024e59b3f4e8d69775a26223730139af0e7b5a717c26512046ec06
|
4
|
+
data.tar.gz: a3d3734c9322ae42283f1871314c28864c536a24a23219474f3eab5ec97a90da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0047d7643b0e402d6d059bf1f0e7b4fdc024ec8439929e5dc53fac26a5c617df4d0923fb3dca0e1188887006aaf89f78ee3770c402335ca39845fc8a098de250
|
7
|
+
data.tar.gz: 9bb7c6ad69b0635f9bc09304918dba12f5d7f0a97a4b1413a020ac5b704b1694ef3b3a854260bd7706f544233c2753fa3a3d26b950fe1b0b5f0da27f3585db6f
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cns (0.8.
|
4
|
+
cns (0.8.4)
|
5
5
|
curb
|
6
6
|
faraday
|
7
7
|
google-cloud-bigquery
|
@@ -89,7 +89,8 @@ GEM
|
|
89
89
|
multi_json (~> 1.11)
|
90
90
|
os (>= 0.9, < 2.0)
|
91
91
|
signet (>= 0.16, < 2.a)
|
92
|
-
httpclient (2.
|
92
|
+
httpclient (2.9.0)
|
93
|
+
mutex_m
|
93
94
|
jaro_winkler (1.6.0)
|
94
95
|
json (2.10.1)
|
95
96
|
jwt (2.10.1)
|
@@ -106,7 +107,7 @@ GEM
|
|
106
107
|
mutex_m (0.3.0)
|
107
108
|
net-http (0.6.0)
|
108
109
|
uri
|
109
|
-
nokogiri (1.18.
|
110
|
+
nokogiri (1.18.3-x86_64-linux-gnu)
|
110
111
|
racc (~> 1.4)
|
111
112
|
observer (0.1.2)
|
112
113
|
os (1.1.4)
|
data/lib/cns/bigquery.rb
CHANGED
@@ -7,17 +7,27 @@ require('bigdecimal/util')
|
|
7
7
|
module Cns
|
8
8
|
BD = 'hernanirvaz.coins'
|
9
9
|
FO = File.expand_path("~/#{File.basename($PROGRAM_NAME)}.log")
|
10
|
+
# Define table configurations at the class level
|
11
|
+
TC = {
|
12
|
+
i: %w[blocknumber timestamp txhash axfrom axto iax value contractaddress input type gas gasused traceid iserror errcode],
|
13
|
+
p: %w[blocknumber timestamp blockreward iax],
|
14
|
+
w: %w[withdrawalindex validatorindex address amount blocknumber timestamp],
|
15
|
+
t: %w[blocknumber timestamp txhash nonce blockhash transactionindex axfrom axto iax value gas gasprice gasused iserror txreceipt_status input contractaddress dias],
|
16
|
+
k: %w[blocknumber timestamp txhash nonce blockhash transactionindex axfrom axto iax value tokenname tokensymbol tokendecimal gas gasprice gasused input contractaddress dias],
|
17
|
+
neost: %w[gseq aseq bnum time contract action acfrom acto iax amount moeda memo dias],
|
18
|
+
cdet: %w[txid time tp user btc eur dtc dias],
|
19
|
+
cdel: %w[txid time tp add moe qt fee],
|
20
|
+
cust: %w[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers dias],
|
21
|
+
cusl: %w[txid refid time type aclass asset amount fee]
|
22
|
+
}
|
10
23
|
|
11
24
|
# classe para processar bigquery
|
12
25
|
class Bigquery
|
13
26
|
# @return [Google::Cloud::Bigquery] API bigquery
|
14
|
-
attr_reader :api
|
15
27
|
# @return [Google::Cloud::Bigquery::QueryJob] job bigquery
|
16
|
-
attr_reader :job
|
17
28
|
# @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
|
18
|
-
attr_reader :ops
|
19
29
|
# @return (see sql)
|
20
|
-
attr_reader :sqr
|
30
|
+
attr_reader :api, :job, :ops, :sqr
|
21
31
|
|
22
32
|
# @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
|
23
33
|
# @option pop [Hash] :h ({}) configuracao ajuste reposicionamento temporal
|
@@ -85,26 +95,14 @@ module Cns
|
|
85
95
|
#
|
86
96
|
# @return [String] linhas & tabelas afetadas
|
87
97
|
def processa_eth
|
88
|
-
|
89
|
-
str += format(' %<n>i netht', n: dml(netht_ins)) if apies.novtx.count.positive?
|
90
|
-
str += format(' %<n>i nethi', n: dml(nethi_ins)) if apies.novix.count.positive?
|
91
|
-
str += format(' %<n>i nethp', n: dml(nethp_ins)) if apies.novpx.count.positive?
|
92
|
-
str += format(' %<n>i nethw', n: dml(nethw_ins)) if apies.novwx.count.positive?
|
93
|
-
str += format(' %<n>i nethk', n: dml(nethk_ins)) if apies.novkx.count.positive?
|
94
|
-
str
|
98
|
+
tabelas_eth(apies, 'netb')
|
95
99
|
end
|
96
100
|
|
97
101
|
# insere transacoes blockchain novas nas tabelas netht (norml), nethi (internas), nethp (block), nethw (withdrawals), nethk (token)
|
98
102
|
#
|
99
103
|
# @return [String] linhas & tabelas afetadas
|
100
104
|
def processa_ethc
|
101
|
-
|
102
|
-
str += format(' %<n>i netht', n: dml(netbt_ins)) if apiesc.novtx.count.positive?
|
103
|
-
str += format(' %<n>i nethi', n: dml(netbi_ins)) if apiesc.novix.count.positive?
|
104
|
-
str += format(' %<n>i nethp', n: dml(netbp_ins)) if apiesc.novpx.count.positive?
|
105
|
-
str += format(' %<n>i nethw', n: dml(netbw_ins)) if apiesc.novwx.count.positive?
|
106
|
-
str += format(' %<n>i nethk', n: dml(netbk_ins)) if apiesc.novkx.count.positive?
|
107
|
-
str
|
105
|
+
tabelas_eth(apiesc, 'netc')
|
108
106
|
end
|
109
107
|
|
110
108
|
# insere transacoes exchange kraken novas nas tabelas ust (trades), usl (ledger)
|
@@ -143,9 +141,11 @@ module Cns
|
|
143
141
|
def job?(cmd)
|
144
142
|
@job = api.query_job(cmd)
|
145
143
|
job.wait_until_done!
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
|
145
|
+
return false unless job.failed?
|
146
|
+
|
147
|
+
puts("BigQuery Error: #{job.error['message']}")
|
148
|
+
true
|
149
149
|
end
|
150
150
|
|
151
151
|
# cria Structured Query Language (SQL) job bigquery
|
@@ -165,34 +165,28 @@ module Cns
|
|
165
165
|
job?(cmd) ? 0 : job.num_dml_affected_rows
|
166
166
|
end
|
167
167
|
|
168
|
-
|
169
|
-
|
170
|
-
@apies ||= Etherscan.new(
|
168
|
+
def initialize_etherscan_client(prx)
|
169
|
+
Etherscan.new(
|
171
170
|
{
|
172
|
-
wb: sql("
|
173
|
-
ni: sql("
|
174
|
-
nk: sql("
|
175
|
-
np: sql("
|
176
|
-
nt: sql("
|
177
|
-
nw: sql("
|
171
|
+
wb: sql("SELECT * FROM #{BD}.wet#{prx[-1]} ORDER BY ax"),
|
172
|
+
ni: sql("SELECT * FROM #{BD}.#{prx}i"),
|
173
|
+
nk: sql("SELECT * FROM #{BD}.#{prx}k"),
|
174
|
+
np: sql("SELECT * FROM #{BD}.#{prx}p"),
|
175
|
+
nt: sql("SELECT * FROM #{BD}.#{prx}t"),
|
176
|
+
nw: sql("SELECT * FROM #{BD}.#{prx}w")
|
178
177
|
},
|
179
178
|
ops
|
180
179
|
)
|
181
180
|
end
|
182
181
|
|
182
|
+
# @return [Etherscan] API blockchain ETH
|
183
|
+
def apies
|
184
|
+
@apies ||= initialize_etherscan_client('netb')
|
185
|
+
end
|
186
|
+
|
183
187
|
# @return [Etherscan] API blockchain ETH
|
184
188
|
def apiesc
|
185
|
-
@apiesc ||=
|
186
|
-
{
|
187
|
-
wb: sql("select * from #{BD}.wetc order by ax"),
|
188
|
-
ni: sql("select * from #{BD}.netci"),
|
189
|
-
nk: sql("select * from #{BD}.netck"),
|
190
|
-
np: sql("select * from #{BD}.netcp"),
|
191
|
-
nt: sql("select * from #{BD}.netct"),
|
192
|
-
nw: sql("select * from #{BD}.netcw")
|
193
|
-
},
|
194
|
-
ops
|
195
|
-
)
|
189
|
+
@apiesc ||= initialize_etherscan_client('netc')
|
196
190
|
end
|
197
191
|
|
198
192
|
# @return [Greymass] API blockchain EOS
|
@@ -224,140 +218,92 @@ module Cns
|
|
224
218
|
)
|
225
219
|
end
|
226
220
|
|
227
|
-
#
|
228
|
-
def
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
# @return [String] comando insert SQL formatado nethi (internas)
|
234
|
-
def bnethi_ins
|
235
|
-
"insert #{BD}.nethi(blocknumber,timestamp,txhash,axfrom,axto,iax," \
|
236
|
-
'value,contractaddress,input,type,gas,gasused,traceid,iserror,errcode) VALUES'
|
237
|
-
end
|
238
|
-
|
239
|
-
# @return [String] comando insert SQL formatado nethp (block)
|
240
|
-
def bnethp_ins
|
241
|
-
"insert #{BD}.nethp(blocknumber,timestamp,blockreward,iax) VALUES"
|
242
|
-
end
|
243
|
-
|
244
|
-
# @return [String] comando insert SQL formatado nethw (withdrawals)
|
245
|
-
def bnethw_ins
|
246
|
-
"insert #{BD}.nethw(withdrawalindex,validatorindex,address,amount,blocknumber,timestamp) VALUES"
|
247
|
-
end
|
248
|
-
|
249
|
-
# @return [String] comando insert SQL formatado nethk (token)
|
250
|
-
def bnethk_ins
|
251
|
-
"insert #{BD}.nethk(blocknumber,timestamp,txhash,nonce,blockhash,transactionindex,axfrom,axto,iax," \
|
252
|
-
'value,tokenname,tokensymbol,tokendecimal,gas,gasprice,gasused,input,contractaddress,dias) VALUES'
|
253
|
-
end
|
254
|
-
|
255
|
-
# @return [String] comando insert SQL formatado netht (norml)
|
256
|
-
def netht_ins
|
257
|
-
"#{bnetht_ins}#{apies.novtx.map { |obj| netht_val(obj) }.join(',')}"
|
258
|
-
end
|
259
|
-
|
260
|
-
# @return [String] comando insert SQL formatado nethi (internas)
|
261
|
-
def nethi_ins
|
262
|
-
"#{bnethi_ins}#{apies.novix.map { |obj| nethi_val(obj) }.join(',')}"
|
263
|
-
end
|
221
|
+
# Generic ETH data processor
|
222
|
+
def tabelas_eth(src, prx)
|
223
|
+
str = ['ETH']
|
224
|
+
%i[t i p w k].each do |typ|
|
225
|
+
novx = src.send("nov#{typ}x")
|
226
|
+
next if novx.empty?
|
264
227
|
|
265
|
-
|
266
|
-
|
267
|
-
|
228
|
+
str << format(' %<n>i %<t>s', n: dml(insert_eht(typ, novx)), t: "#{prx.chop}h#{typ}")
|
229
|
+
end
|
230
|
+
str.join
|
268
231
|
end
|
269
232
|
|
270
|
-
|
271
|
-
|
272
|
-
"#{bnethw_ins}#{apies.novwx.map { |obj| nethw_val(obj) }.join(',')}"
|
273
|
-
end
|
274
|
-
|
275
|
-
# @return [String] comando insert SQL formatado nethk (token)
|
276
|
-
def nethk_ins
|
277
|
-
"#{bnethk_ins}#{apies.novkx.map { |obj| nethk_val(obj) }.join(',')}"
|
278
|
-
end
|
279
|
-
|
280
|
-
# @return [String] comando insert SQL formatado netht (norml)
|
281
|
-
def netbt_ins
|
282
|
-
"#{bnetht_ins}#{apiesc.novtx.map { |obj| netht_val(obj) }.join(',')}"
|
283
|
-
end
|
284
|
-
|
285
|
-
# @return [String] comando insert SQL formatado nethi (internas)
|
286
|
-
def netbi_ins
|
287
|
-
"#{bnethi_ins}#{apiesc.novix.map { |obj| nethi_val(obj) }.join(',')}"
|
288
|
-
end
|
289
|
-
|
290
|
-
# @return [String] comando insert SQL formatado nethp (block)
|
291
|
-
def netbp_ins
|
292
|
-
"#{bnethp_ins}#{apiesc.novpx.map { |obj| nethp_val(obj) }.join(',')}"
|
293
|
-
end
|
294
|
-
|
295
|
-
# @return [String] comando insert SQL formatado nethw (withdrawals)
|
296
|
-
def netbw_ins
|
297
|
-
"#{bnethw_ins}#{apiesc.novwx.map { |obj| nethw_val(obj) }.join(',')}"
|
298
|
-
end
|
299
|
-
|
300
|
-
# @return [String] comando insert SQL formatado nethk (token)
|
301
|
-
def netbk_ins
|
302
|
-
"#{bnethk_ins}#{apiesc.novkx.map { |obj| nethk_val(obj) }.join(',')}"
|
233
|
+
def insert_eht(typ, lin)
|
234
|
+
"INSERT #{BD}.neth#{typ} (#{TC[typ].join(',')}) VALUES #{lin.map { |itm| send("neth#{typ}_val", itm) }.join(',')}"
|
303
235
|
end
|
304
236
|
|
305
237
|
# @return [String] comando insert SQL formatado eos
|
306
238
|
def eost_ins
|
307
|
-
"insert #{BD}.neost(
|
308
|
-
") VALUES#{apigm.novax.map { |obj| eost_val(obj) }.join(',')}"
|
239
|
+
"insert #{BD}.neost(#{TC[:neost].join(',')}) VALUES#{apigm.novax.map { |obj| eost_val(obj) }.join(',')}"
|
309
240
|
end
|
310
241
|
|
311
242
|
# @return [String] comando insert SQL formatado det (trades)
|
312
243
|
def det_ins
|
313
|
-
"insert #{BD}.cdet(
|
244
|
+
"insert #{BD}.cdet(#{TC[:cdet].join(',')}) VALUES#{apide.trades.map { |obj| det_val(obj) }.join(',')}"
|
314
245
|
end
|
315
246
|
|
316
247
|
# @return [String] comando insert SQL formatado del (ledger)
|
317
248
|
def del_ins
|
318
|
-
"insert #{BD}.cdel(
|
249
|
+
"insert #{BD}.cdel(#{TC[:cdel].join(',')}) VALUES#{apide.ledger.map { |obj| del_val(obj) }.join(',')}"
|
319
250
|
end
|
320
251
|
|
321
252
|
# @return [String] comando insert SQL formatado ust (trades)
|
322
253
|
def ust_ins
|
323
|
-
"insert #{BD}.cust(
|
324
|
-
"VALUES#{apius.trades.map { |key, val| ust_val(key, val) }.join(',')}"
|
254
|
+
"insert #{BD}.cust(#{TC[:cust].join(',')}) VALUES#{apius.trades.map { |key, val| ust_val(key, val) }.join(',')}"
|
325
255
|
end
|
326
256
|
|
327
257
|
# @return [String] comando insert SQL formatado usl (ledger)
|
328
258
|
def usl_ins
|
329
|
-
"insert #{BD}.cusl(
|
330
|
-
|
259
|
+
"insert #{BD}.cusl(#{TC[:cusl].join(',')}) VALUES#{apius.ledger.map { |key, val| usl_val(key, val) }.join(',')}"
|
260
|
+
end
|
261
|
+
|
262
|
+
# SQL value formatting methods with improved safety
|
263
|
+
def quote(value)
|
264
|
+
return 'null' if value.nil? || value.empty?
|
265
|
+
|
266
|
+
"'#{value.gsub('\'', "''")}'" # Escape single quotes
|
267
|
+
end
|
268
|
+
|
269
|
+
def numeric(value)
|
270
|
+
"CAST('#{value}' AS NUMERIC)"
|
271
|
+
end
|
272
|
+
|
273
|
+
def integer(value)
|
274
|
+
Integer(value).to_s
|
275
|
+
rescue StandardError
|
276
|
+
'null'
|
331
277
|
end
|
332
278
|
|
333
|
-
# @example (see Apibc#norml_es)
|
334
279
|
# @param [Hash] htx transacao norml etherscan
|
335
280
|
# @return [String] valores formatados netht (norml parte1)
|
336
281
|
def netht_val(htx)
|
337
282
|
txr = htx[:txreceipt_status]
|
338
|
-
cta = htx[:contractAddress]
|
339
283
|
inp = htx[:input]
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
284
|
+
cta = htx[:contractAddress]
|
285
|
+
"(#{[
|
286
|
+
integer(htx[:blockNumber]),
|
287
|
+
integer(htx[:timeStamp]),
|
288
|
+
quote(htx[:hash]),
|
289
|
+
integer(htx[:nonce]),
|
290
|
+
quote(htx[:blockHash]),
|
291
|
+
integer(htx[:transactionIndex]),
|
292
|
+
quote(htx[:from]),
|
293
|
+
quote(htx[:to]),
|
294
|
+
quote(htx[:iax]),
|
295
|
+
numeric(htx[:value]),
|
296
|
+
numeric(htx[:gas]),
|
297
|
+
numeric(htx[:gasPrice]),
|
298
|
+
numeric(htx[:gasUsed]),
|
299
|
+
integer(htx[:isError]),
|
300
|
+
txr.empty? ? 'null' : integer(txr),
|
301
|
+
inp.empty? ? 'null' : quote(inp),
|
302
|
+
cta.empty? ? 'null' : quote(cta),
|
303
|
+
integer(ops.dig(:h, htx[:blockNumber]) || 0)
|
304
|
+
].join(',')})"
|
305
|
+
end
|
306
|
+
|
361
307
|
# @param [Hash] htx transacao internas etherscan
|
362
308
|
# @return [String] valores formatados nethi (internas parte1)
|
363
309
|
def nethi_val(htx)
|
@@ -365,70 +311,70 @@ module Cns
|
|
365
311
|
inp = htx[:input]
|
366
312
|
tid = htx[:traceId]
|
367
313
|
txr = htx[:errCode]
|
368
|
-
"(#{
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
314
|
+
"(#{[
|
315
|
+
integer(htx[:blockNumber]),
|
316
|
+
integer(htx[:timeStamp]),
|
317
|
+
quote(htx[:hash]),
|
318
|
+
quote(htx[:from]),
|
319
|
+
quote(htx[:to]),
|
320
|
+
quote(htx[:iax]),
|
321
|
+
numeric(htx[:value]),
|
322
|
+
cta.empty? ? 'null' : quote(cta),
|
323
|
+
inp.empty? ? 'null' : quote(inp),
|
324
|
+
quote(htx[:type]),
|
325
|
+
numeric(htx[:gas]),
|
326
|
+
numeric(htx[:gasUsed]),
|
327
|
+
tid.empty? ? 'null' : quote(tid),
|
328
|
+
integer(htx[:isError]),
|
329
|
+
txr.empty? ? 'null' : integer(txr)
|
330
|
+
].join(',')})"
|
383
331
|
end
|
384
332
|
|
385
|
-
# @example (see Apibc#block_es)
|
386
333
|
# @param [Hash] htx transacao block etherscan
|
387
334
|
# @return [String] valores formatados nethi (block parte1)
|
388
335
|
def nethp_val(htx)
|
389
|
-
"(#{
|
390
|
-
"#{Integer(htx[:timeStamp])}," \
|
391
|
-
"cast('#{htx[:blockReward]}' as numeric)," \
|
392
|
-
"'#{htx[:iax]}')"
|
336
|
+
"(#{[integer(htx[:blockNumber]), integer(htx[:timeStamp]), numeric(htx[:blockReward]), quote(htx[:iax])].join(',')})"
|
393
337
|
end
|
394
338
|
|
395
|
-
# @example (see Apibc#block_es)
|
396
339
|
# @param [Hash] htx transacao withdrawals etherscan
|
397
340
|
# @return [String] valores formatados nethi (withdrawals parte1)
|
398
341
|
def nethw_val(htx)
|
399
|
-
"(#{
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
342
|
+
"(#{[
|
343
|
+
integer(htx[:withdrawalIndex]),
|
344
|
+
integer(htx[:validatorIndex]),
|
345
|
+
quote(htx[:address]),
|
346
|
+
numeric(htx[:amount]),
|
347
|
+
integer(htx[:blockNumber]),
|
348
|
+
integer(htx[:timestamp])
|
349
|
+
].join(',')})"
|
405
350
|
end
|
406
351
|
|
407
|
-
# @example (see Apibc#token_es)
|
408
352
|
# @param [Hash] hkx token event etherscan
|
409
353
|
# @return [String] valores formatados nethk (token parte1)
|
410
|
-
def nethk_val(
|
411
|
-
|
412
|
-
|
413
|
-
"(#{
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
354
|
+
def nethk_val(htx)
|
355
|
+
inp = htx[:input]
|
356
|
+
cta = htx[:contractAddress]
|
357
|
+
"(#{[
|
358
|
+
integer(htx[:blockNumber]),
|
359
|
+
integer(htx[:timeStamp]),
|
360
|
+
quote(htx[:hash]),
|
361
|
+
integer(htx[:nonce]),
|
362
|
+
quote(htx[:blockHash]),
|
363
|
+
integer(htx[:transactionIndex]),
|
364
|
+
quote(htx[:from]),
|
365
|
+
quote(htx[:to]),
|
366
|
+
quote(htx[:iax]),
|
367
|
+
numeric(htx[:value]),
|
368
|
+
quote(htx[:tokenName]),
|
369
|
+
quote(htx[:tokenSymbol]),
|
370
|
+
integer(htx[:tokenDecimal]),
|
371
|
+
numeric(htx[:gas]),
|
372
|
+
numeric(htx[:gasPrice]),
|
373
|
+
numeric(htx[:gasUsed]),
|
374
|
+
inp.empty? ? 'null' : quote(inp),
|
375
|
+
cta.empty? ? 'null' : quote(cta),
|
376
|
+
integer(ops.dig(:h, htx[:blockNumber]) || 0)
|
377
|
+
].join(',')})"
|
432
378
|
end
|
433
379
|
|
434
380
|
# @example (see Apibc#ledger_gm)
|
data/lib/cns/etherscan.rb
CHANGED
@@ -29,27 +29,27 @@ module Cns
|
|
29
29
|
|
30
30
|
# @return [Array<Hash>] lista transacoes normais novas
|
31
31
|
def novtx
|
32
|
-
@novtx ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
|
32
|
+
@novtx ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
33
33
|
end
|
34
34
|
|
35
35
|
# @return [Array<Hash>] lista transacoes internas novas
|
36
36
|
def novix
|
37
|
-
@novix ||= bcd.map { |obc| obc[:ix].select { |obj| idi.include?(obj[:itx]) } }.flatten
|
37
|
+
@novix ||= bcd.map { |obc| obc[:ix].select { |obj| idi.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
38
38
|
end
|
39
39
|
|
40
40
|
# @return [Array<Hash>] lista transacoes block novas
|
41
41
|
def novpx
|
42
|
-
@novpx ||= bcd.map { |obc| obc[:px].select { |obj| idp.include?(obj[:itx]) } }.flatten
|
42
|
+
@novpx ||= bcd.map { |obc| obc[:px].select { |obj| idp.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [Array<Hash>] lista transacoes withdrawals novas
|
46
46
|
def novwx
|
47
|
-
@novwx ||= bcd.map { |obc| obc[:wx].select { |obj| idw.include?(obj[:itx]) } }.flatten
|
47
|
+
@novwx ||= bcd.map { |obc| obc[:wx].select { |obj| idw.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Array<Hash>] lista transacoes token novas
|
51
51
|
def novkx
|
52
|
-
@novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten
|
52
|
+
@novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
|
53
53
|
end
|
54
54
|
|
55
55
|
# @return [Array<String>] lista dos meus enderecos
|
@@ -108,7 +108,7 @@ module Cns
|
|
108
108
|
tx: filtrar_tx(acc, api.norml_es(acc)),
|
109
109
|
ix: filtrar_tx(acc, api.inter_es(acc)),
|
110
110
|
px: filtrar_px(acc, api.block_es(acc)),
|
111
|
-
wx:
|
111
|
+
wx: filtrar_wx(acc, api.withw_es(acc)),
|
112
112
|
kx: filtrar_tx(acc, api.token_es(acc))
|
113
113
|
}
|
114
114
|
end
|
@@ -153,6 +153,14 @@ module Cns
|
|
153
153
|
ary.map { |omp| omp.merge(itx: Integer(omp[:blockNumber]), iax: add) }
|
154
154
|
end
|
155
155
|
|
156
|
+
# @param add (see Apibc#norml_es)
|
157
|
+
# @param [Array<Hash>] ary lista blocks events
|
158
|
+
# @return [Array<Hash>] lista blocks events filtrada
|
159
|
+
def filtrar_wx(add, ary)
|
160
|
+
# adiciona chave indice itx & adiciona identificador da carteira iax
|
161
|
+
ary.map { |omp| omp.merge(itx: Integer(omp[:withdrawalIndex]), iax: add) }
|
162
|
+
end
|
163
|
+
|
156
164
|
# dt: Time.at(Integer(htx[:timeStamp])),
|
157
165
|
# @return [Array<Hash>] lista ordenada transacoes normais novas
|
158
166
|
def sortx
|
@@ -339,9 +347,9 @@ module Cns
|
|
339
347
|
# @return [String] texto formatado transacao withdrawals etherscan
|
340
348
|
def formata_transacao_withw(htx)
|
341
349
|
format(
|
342
|
-
'%<vi>9i %<bn>
|
350
|
+
'%<vi>9i %<bn>10i %<dt>10.10s %<vl>10.6f',
|
343
351
|
vi: htx[:validatorIndex],
|
344
|
-
bn: htx[:
|
352
|
+
bn: htx[:withdrawalIndex],
|
345
353
|
dt: Time.at(Integer(htx[:timestamp])),
|
346
354
|
vl: (htx[:amount].to_d / (10**9)).round(10)
|
347
355
|
)
|
@@ -383,7 +391,7 @@ module Cns
|
|
383
391
|
def mostra_transacao_withw
|
384
392
|
return unless ops[:v] && novwx.count.positive?
|
385
393
|
|
386
|
-
puts("\nvalidator
|
394
|
+
puts("\nvalidator withdrawal data valor")
|
387
395
|
sorwx.each { |obj| puts(formata_transacao_withw(obj)) }
|
388
396
|
end
|
389
397
|
|
data/lib/cns/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hernâni Rodrigues Vaz
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|