cns 0.9.2 → 0.9.4

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/lib/cns/etherscan.rb CHANGED
@@ -4,50 +4,45 @@ require('bigdecimal/util')
4
4
 
5
5
  # @author Hernani Rodrigues Vaz
6
6
  module Cns
7
- # chaves a eliminar da API - resultado deve ser ignirado pois muda a cada pedido API feito
8
- DL = %i[cumulativeGasUsed confirmations].freeze
9
-
10
7
  # classe para processar transacoes do etherscan
11
8
  class Etherscan
12
9
  # @return [Apibc] API blockchains
13
- attr_reader :api
14
10
  # @return [Array<Hash>] todos os dados bigquery
15
- attr_reader :bqd
16
11
  # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
17
- attr_reader :ops
12
+ attr_reader :api, :bqd, :ops
18
13
 
19
14
  TT = {
20
15
  normal: {
21
16
  new: :novnetht,
22
- format: :formata_tx_ti,
17
+ format: :foti,
23
18
  header: "\ntx normal from to data valor",
24
19
  sork: :srx,
25
20
  adjk: :hash
26
21
  },
27
22
  internal: {
28
23
  new: :novnethi,
29
- format: :formata_tx_ti,
24
+ format: :foti,
30
25
  header: "\ntx intern from to data valor",
31
26
  sork: :srx,
32
27
  adjk: :hash
33
28
  },
34
29
  block: {
35
30
  new: :novnethp,
36
- format: :formata_tx_block,
31
+ format: :fop,
37
32
  header: "\ntx block address data valor",
38
33
  sork: :itx,
39
34
  adjk: :blockNumber
40
35
  },
41
36
  token: {
42
37
  new: :novnethk,
43
- format: :formata_tx_token,
38
+ format: :fok,
44
39
  header: "\ntx token from to data valor moeda",
45
40
  sork: :srx,
46
41
  adjk: :hash
47
42
  },
48
43
  withdrawal: {
49
44
  new: :novnethw,
50
- format: :formata_tx_withw,
45
+ format: :fow,
51
46
  header: "\nwithdrawal validator data valor",
52
47
  sork: :itx,
53
48
  adjk: :withdrawalIndex
@@ -57,59 +52,77 @@ module Cns
57
52
  # @param [Hash] dad todos os dados bigquery
58
53
  # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
59
54
  # @option pop [Hash] :h ({}) configuracao dias ajuste reposicionamento temporal
60
- # @option pop [Boolean] :v (false) mostra dados transacoes normais & tokens?
61
- # @return [Etherscan] API etherscan - processar transacoes normais e tokens
55
+ # @option pop [Boolean] :v (false) mostra dados transacoes
56
+ # @return [Etherscan] API etherscan - processar transacoes
62
57
  def initialize(dad, pop)
63
58
  @api = Apibc.new
64
59
  @bqd = dad
65
60
  @ops = pop.transform_keys(&:to_sym)
66
61
  end
67
62
 
68
- # @return [String] texto carteiras & transacoes & ajuste dias
63
+ # mostra resumo carteiras & transacoes & ajuste dias
69
64
  def mresumo_simples
70
65
  return unless dados.any?
71
66
 
72
67
  puts("\nid address etherscan bigquery")
73
- dados.each { |obj| puts(formata_carteira_simples(obj)) }
68
+ dados.each { |o| puts(focs(o)) }
74
69
  mtransacoes_novas
75
70
  mconfiguracao_ajuste_dias
76
71
  end
77
72
 
78
- # @return [String] texto carteiras & transacoes & ajuste dias
73
+ # mostra resumo carteiras & transacoes & ajuste dias (com contadores)
79
74
  def mresumo
80
75
  return unless dados.any?
81
76
 
82
77
  puts("\nid address etherscan tn ti tb tk tw bigquery tn ti tb tk tw")
83
- dados.each { |obj| puts(formata_carteira(obj)) }
78
+ dados.each { |o| puts(foct(o)) }
84
79
  mtransacoes_novas
85
80
  mconfiguracao_ajuste_dias
86
81
  end
87
82
 
88
83
  private
89
84
 
90
- # @param [Hash] hjn dados juntos bigquery & etherscan
91
- # @return [String] texto formatado duma carteira
92
- def formata_carteira_simples(hjn)
93
- format('%<s1>-6.6s %<s2>-42.42s ', s1: hjn[:id], s2: hjn[:ax]) + formata_valores_simples(hjn)
85
+ # mosta transacoes novas
86
+ def mtransacoes_novas
87
+ TT.each do |_, c|
88
+ ntx = send(c[:new])
89
+ next unless ops[:v] && ntx.any?
90
+
91
+ puts(c[:header])
92
+ ntx.sort_by { |s| -s[c[:sork]] }.each { |t| puts(send(c[:format], t)) }
93
+ end
94
94
  end
95
95
 
96
- # @param [Hash] hjn dados juntos bigquery & etherscan
97
- # @return [String] texto formatado duma carteira
98
- def formata_carteira(hjn)
99
- format('%<s1>-6.6s %<s2>-10.10s ', s1: hjn[:id], s2: formata_enderec1(hjn[:ax], 10)) + formata_valores(hjn)
96
+ # mostra configuration text for adjusting days
97
+ def mconfiguracao_ajuste_dias
98
+ TT.each do |p, c|
99
+ ntx = send(c[:new])
100
+ next unless ntx.any?
101
+
102
+ puts("\najuste dias transacoes #{p}\n-h=#{ntx.sort_by { |s| -s[c[:sork]] }.map { |t| "#{t[c[:adjk]]}:0" }.join(' ')}")
103
+ end
100
104
  end
101
105
 
102
- # @param (see formata_carteira)
103
- # @return [String] texto formatado valores duma carteira
104
- def formata_valores_simples(hjn)
105
- format('%<v1>13.6f %<v2>13.6f %<ok>-3s', v1: hjn[:es], v2: hjn[:bs], ok: ok?(hjn) ? 'OK' : 'NOK')
106
+ # @param [Hash] hjn dados juntos bigquery & etherscan
107
+ # @return [String] texto formatado duma carteira
108
+ def focs(hjn)
109
+ format(
110
+ '%<s1>-6.6s %<s2>-42.42s %<v1>13.6f %<v2>13.6f %<ok>-3s',
111
+ s1: hjn[:id],
112
+ s2: hjn[:ax],
113
+ v1: hjn[:es],
114
+ v2: hjn[:bs],
115
+ ok: ok?(hjn) ? 'OK' : 'NOK'
116
+ )
106
117
  end
107
118
 
108
- # @param (see formata_carteira)
109
- # @return [String] texto formatado valores duma carteira
110
- def formata_valores(hjn)
119
+ # @param (see focs)
120
+ # @return [String] texto formatado duma carteira (com contadores)
121
+ def foct(hjn)
111
122
  format(
112
- '%<v1>11.4f %<n1>3i %<n2>2i %<n3>2i %<n4>2i %<w1>4i %<v2>11.4f %<n5>3i %<n6>2i %<n7>2i %<n8>2i %<w2>4i %<ok>-3s',
123
+ '%<s1>-6.6s %<s2>-10.10s %<v1>11.4f %<n1>3i %<n2>2i %<n3>2i %<n4>2i %<w1>4i %<v2>11.4f %<n5>3i %<n6>2i %<n7>2i %<n8>2i %<w2>4i %<ok>-3s',
124
+ s1: hjn[:id],
125
+ s2: foe1(hjn[:ax], 10),
113
126
  v1: hjn[:es],
114
127
  n1: hjn[:et].count,
115
128
  n2: hjn[:ei].count,
@@ -126,25 +139,30 @@ module Cns
126
139
  )
127
140
  end
128
141
 
129
- # @return [Boolean] carteira tem transacoes novas(sim=NOK, nao=OK)?
142
+ # @param (see focs)
143
+ # @return [Boolean] check saldo & contadores ipwtk
130
144
  def ok?(hjn)
131
145
  oks?(hjn) && okipw?(hjn) && hjn[:bt].count == hjn[:et].count && hjn[:bk].count == hjn[:ek].count
132
146
  end
133
147
 
148
+ # @param (see focs)
149
+ # @return [Boolean] check contadores ipw
134
150
  def okipw?(hjn)
135
151
  oks?(hjn) && hjn[:bi].count == hjn[:ei].count && hjn[:bp].count == hjn[:ep].count && hjn[:bw].count == hjn[:ew].count
136
152
  end
137
153
 
138
- # @return [Boolean] carteira tem transacoes novas(sim=NOK, nao=OK)?
154
+ # @param (see focs)
155
+ # @return [Boolean] carteira tem transacoes novas (sim=NOK, nao=OK)?
139
156
  def oks?(hjn)
140
157
  hjn[:es].round(6) == hjn[:bs].round(6)
141
158
  end
142
159
 
143
160
  # @example ether address inicio..fim
144
161
  # 0x10f3a0cf0b534c..c033cf32e8a03586
162
+ # @param [String] add endereco ETH
145
163
  # @param [Integer] max chars a mostrar
146
164
  # @return [String] endereco formatado
147
- def formata_enderec1(add, max)
165
+ def foe1(add, max)
148
166
  return 'erro' if max < 7
149
167
 
150
168
  max -= 2
@@ -155,241 +173,218 @@ module Cns
155
173
 
156
174
  # @example ether address inicio..fim
157
175
  # me-app..4b437776403d
176
+ # @param add (see foe1)
158
177
  # @param [Integer] max chars a mostrar
159
178
  # @return [String] endereco formatado
160
- def formata_enderec2(add, max)
179
+ def foe2(add, max)
161
180
  return 'erro' if max < 7
162
181
 
163
182
  max -= 2
164
183
  ini = Integer(max / 2)
165
184
  inf = max % 2
166
- hid = bqd[:wb].find { |obj| obj[:ax] == add }
185
+ hid = bqd[:wb].find { |o| o[:ax] == add }
167
186
  ndd = hid ? "#{hid[:id]}-#{add}" : add
168
187
  "#{ndd[0, ini]}..#{ndd[-inf - ini..]}"
169
188
  end
170
189
 
171
- # @example (see Apibc#norml_es)
172
- # @param [Hash] htx transacao normal etherscan
173
- # @return [String] texto formatado transacao normal etherscan
174
- def formata_tx_ti(htx)
190
+ # @param [Hash] htx transacao etherscan normal(t)/(i)nternal
191
+ # @return [String] texto formatado
192
+ def foti(htx)
175
193
  format(
176
194
  '%<hx>-29.29s %<fr>-15.15s %<to>-15.15s %<dt>10.10s %<vl>7.3f',
177
- hx: formata_enderec1(htx[:hash], 29),
178
- fr: formata_enderec2(htx[:from], 15),
179
- to: formata_enderec2(htx[:to], 15),
195
+ hx: foe1(htx[:hash], 29),
196
+ fr: foe2(htx[:from], 15),
197
+ to: foe2(htx[:to], 15),
180
198
  dt: htx[:timeStamp].strftime('%F'),
181
199
  vl: htx[:value] / (10**18)
182
200
  )
183
201
  end
184
202
 
185
- # @example (see Apibc#token_es)
186
- # @param [Hash] hkx transacao token etherscan
187
- # @return [String] texto formatado transacao token etherscan
188
- def formata_tx_token(hkx)
203
+ # @param [Hash] hkx transacao etherscan to(k)en
204
+ # @return [String] texto formatado
205
+ def fok(hkx)
189
206
  format(
190
207
  '%<hx>-20.20s %<fr>-15.15s %<to>-15.15s %<dt>10.10s %<vl>10.3f %<sy>-5.5s',
191
- hx: formata_enderec1(hkx[:hash], 20),
192
- fr: formata_enderec2(hkx[:from], 15),
193
- to: formata_enderec2(hkx[:to], 15),
208
+ hx: foe1(hkx[:hash], 20),
209
+ fr: foe2(hkx[:from], 15),
210
+ to: foe2(hkx[:to], 15),
194
211
  dt: hkx[:timeStamp].strftime('%F'),
195
212
  vl: hkx[:value] / (10**18),
196
213
  sy: hkx[:tokenSymbol]
197
214
  )
198
215
  end
199
216
 
200
- # @example (see Apibc#block_es)
201
- # @param [Hash] htx transacao block etherscan
202
- # @return [String] texto formatado transacao block etherscan
203
- def formata_tx_block(htx)
204
- format(
205
- '%<bn>9i %<fr>-41.41s %<dt>10.10s %<vl>17.6f',
206
- bn: htx[:blockNumber],
207
- fr: formata_enderec2(htx[:iax], 41),
208
- dt: htx[:timeStamp].strftime('%F'),
209
- vl: htx[:blockReward] / (10**18)
210
- )
217
+ # @param [Hash] hpx transacao etherscan (p)roduced blocks
218
+ # @return [String] texto formatado
219
+ def fop(hpx)
220
+ format('%<bn>9i %<fr>-41.41s %<dt>10.10s %<vl>17.6f', bn: hpx[:blockNumber], fr: foe2(hpx[:iax], 41), dt: hpx[:timeStamp].strftime('%F'), vl: hpx[:blockReward] / (10**18))
211
221
  end
212
222
 
213
- # @example (see Apibc#block_es)
214
- # @param [Hash] htx transacao withdrawals etherscan
223
+ # @param [Hash] hwx transacao etherscan (w)ithdrawals
215
224
  # @return [String] texto formatado transacao withdrawals etherscan
216
- def formata_tx_withw(htx)
217
- format('%<bn>10i %<vi>9i %<dt>10.10s %<vl>10.6f', bn: htx[:withdrawalIndex], vi: htx[:validatorIndex], dt: htx[:timeStamp].strftime('%F'), vl: htx[:amount] / (10**9))
225
+ def fow(hwx)
226
+ format('%<bn>10i %<vi>9i %<dt>10.10s %<vl>10.6f', bn: hwx[:withdrawalIndex], vi: hwx[:validatorIndex], dt: hwx[:timeStamp].strftime('%F'), vl: hwx[:amount] / (10**9))
218
227
  end
219
228
 
220
- # @return [String] Display all new transactions based on verbose option
221
- def mtransacoes_novas
222
- TT.each do |_, cfg|
223
- ntx = send(cfg[:new])
224
- next unless ops[:v] && ntx.any?
229
+ # @return [Boolean] mostra todas/novas transacoes
230
+ def show_all?
231
+ ops[:t] || false
232
+ end
225
233
 
226
- puts(cfg[:header])
227
- ntx.sort_by { |s| -s[cfg[:sork]] }.each { |t| puts(send(cfg[:format], t)) }
228
- end
234
+ # @param [Hash] htx transacao
235
+ # @return [Hash] transaccao filtrada
236
+ def pess(htx)
237
+ tym = Integer(htx[:timeStamp])
238
+ htx.merge(srx: tym, timeStamp: Time.at(tym))
229
239
  end
230
240
 
231
- # @return [String] Configuration text for adjusting transaction days
232
- def mconfiguracao_ajuste_dias
233
- TT.each do |typ, cfg|
234
- ntx = send(cfg[:new])
235
- next unless ntx.any?
241
+ # @param add (see foe1)
242
+ # @param [Array<Hash>] ary lista transacoes normal(t)/(i)nternal/to(k)en
243
+ # @return [Array<Hash>] lista transacoes filtrada
244
+ def ftik(add, ary)
245
+ ary.map { |o| pess(o).merge(itx: String(o[:hash]), iax: add, value: o[:value].to_d) }
246
+ end
236
247
 
237
- puts("\najuste dias transacoes #{typ}\n-h=#{ntx.sort_by { |s| -s[cfg[:sork]] }.map { |t| "#{t[cfg[:adjk]]}:0" }.join(' ')}")
238
- end
248
+ # @param add (see foe1)
249
+ # @param [Array<Hash>] ary lista transacoes (p)roduced blocks
250
+ # @return [Array<Hash>] lista transacoes filtrada
251
+ def fppp(add, ary)
252
+ ary.map { |o| o.merge(itx: Integer(o[:blockNumber]), iax: add, blockReward: o[:blockReward].to_d, timeStamp: Time.at(Integer(o[:timeStamp]))) }
239
253
  end
240
254
 
241
- # @return [Array<String>] lista dos meus enderecos
242
- def lax
243
- @lax ||= bqd[:wb].map { |obj| obj[:ax] }
255
+ # @param add (see foe1)
256
+ # @param [Array<Hash>] ary lista transacoes (w)ithdrawals
257
+ # @return [Array<Hash>] lista transacoes filtrada
258
+ def fwww(add, ary)
259
+ ary.map { |o| o.merge(itx: Integer(o[:withdrawalIndex]), iax: add, amount: o[:amount].to_d, timeStamp: Time.at(Integer(o[:timestamp]))) }
244
260
  end
245
261
 
246
- # @return [Array<Hash>] todos os dados etherscan - saldos & transacoes
247
- def bcd
248
- @bcd ||= api.account_es(lax).map { |obj| base_bc(obj) }
262
+ # @param [Hash] aes account etherscan
263
+ # @return [Hash] dados etherscan - address, saldo & transacoes
264
+ def bses(aes)
265
+ acc = aes[:account].downcase
266
+ {
267
+ ax: acc,
268
+ sl: aes[:balance].to_d / (10**18),
269
+ tx: ftik(acc, api.norml_es(acc)),
270
+ ix: ftik(acc, api.inter_es(acc)),
271
+ px: fppp(acc, api.block_es(acc)),
272
+ wx: fwww(acc, api.withw_es(acc)),
273
+ kx: ftik(acc, api.token_es(acc))
274
+ }
249
275
  end
250
276
 
251
- # @return [Array<Hash>] todos os dados juntos bigquery & etherscan
252
- def dados
253
- @dados ||= bqd[:wb].map { |b| bq_bc(b, bcd.find { |e| b[:ax] == e[:ax] }) }
277
+ # @param [Hash] wbq wallet bigquery
278
+ # @param [Hash] hes dados etherscan - address, saldo & transacoes
279
+ # @return [Hash] dados juntos bigquery & etherscan
280
+ def bqes(wbq, hes)
281
+ xbq = wbq[:ax]
282
+ {
283
+ id: wbq[:id],
284
+ ax: xbq,
285
+ bs: wbq[:sl],
286
+ bt: bqd[:nt].select { |t| t[:iax].casecmp?(xbq) },
287
+ bi: bqd[:ni].select { |i| i[:iax].casecmp?(xbq) },
288
+ bp: bqd[:np].select { |p| p[:iax].casecmp?(xbq) },
289
+ bw: bqd[:nw].select { |w| w[:iax].casecmp?(xbq) },
290
+ bk: bqd[:nk].select { |k| k[:iax].casecmp?(xbq) },
291
+ es: hes[:sl],
292
+ et: hes[:tx],
293
+ ei: hes[:ix],
294
+ ep: hes[:px],
295
+ ew: hes[:wx],
296
+ ek: hes[:kx]
297
+ }
254
298
  end
255
299
 
256
- def show_all?
257
- ops[:t] || false
300
+ # @return [Array<String>] lista enderecos
301
+ def lax
302
+ @lax ||= bqd[:wb].map { |o| o[:ax] }
258
303
  end
259
304
 
260
- def bqidt
261
- @bqidt ||= show_all? ? [] : (bqd[:nt]&.map { |i| i[:itx] } || [])
305
+ # @return [Array<Hash>] todos os dados etherscan - saldos & transacoes
306
+ def esd
307
+ @esd ||= api.account_es(lax).map { |o| bses(o) }
262
308
  end
263
309
 
264
- # @return [Array<Integer>] lista indices transacoes novas
265
- def idt
266
- @idt ||= bcd.map { |o| o[:tx].map { |i| i[:itx] } }.flatten - bqidt
310
+ # @return [Array<Hash>] todos os dados juntos bigquery & etherscan
311
+ def dados
312
+ @dados ||= bqd[:wb].map { |b| bqes(b, esd.find { |e| b[:ax] == e[:ax] }) }
267
313
  end
268
314
 
269
- def bqidi
270
- @bqidi ||= show_all? ? [] : (bqd[:ni]&.map { |i| i[:itx] } || [])
315
+ # @return [Array<Integer>] indices transacoes bigquery
316
+ def bqidt
317
+ @bqidt ||= show_all? ? [] : bqd[:nt].map { |i| i[:itx] }
271
318
  end
272
319
 
273
- # @return [Array<Integer>] lista indices transacoes novas
274
- def idi
275
- @idi ||= bcd.map { |o| o[:ix].map { |i| i[:itx] } }.flatten - bqidi
320
+ # @return [Array<Integer>] indices transacoes bigquery
321
+ def bqidi
322
+ @bqidi ||= show_all? ? [] : bqd[:ni].map { |i| i[:itx] }
276
323
  end
277
324
 
325
+ # @return [Array<Integer>] indices transacoes bigquery
278
326
  def bqidp
279
- @bqidp ||= show_all? ? [] : (bqd[:np]&.map { |i| i[:itx] } || [])
327
+ @bqidp ||= show_all? ? [] : bqd[:np].map { |i| i[:itx] }
280
328
  end
281
329
 
282
- # @return [Array<Integer>] lista indices transacoes novas
283
- def idp
284
- @idp ||= bcd.map { |o| o[:px].map { |i| i[:itx] } }.flatten - bqidp
330
+ # @return [Array<Integer>] indices transacoes bigquery
331
+ def bqidw
332
+ @bqidw ||= show_all? ? [] : bqd[:nw].map { |i| i[:itx] }
285
333
  end
286
334
 
287
- def bqidw
288
- @bqidw ||= show_all? ? [] : (bqd[:nw]&.map { |i| i[:itx] } || [])
335
+ # @return [Array<Integer>] indices transacoes bigquery
336
+ def bqidk
337
+ @bqidk ||= show_all? ? [] : bqd[:nk].map { |i| i[:itx] }
289
338
  end
290
339
 
291
- # @return [Array<Integer>] lista indices transacoes novas
292
- def idw
293
- @idw ||= bcd.map { |o| o[:wx].map { |i| i[:itx] } }.flatten - bqidw
340
+ # @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
341
+ def idt
342
+ @idt ||= esd.map { |o| o[:tx].map { |i| i[:itx] } }.flatten - bqidt
294
343
  end
295
344
 
296
- def bqidk
297
- @bqidk ||= show_all? ? [] : (bqd[:nk]&.map { |i| i[:itx] } || [])
345
+ # @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
346
+ def idi
347
+ @idi ||= esd.map { |o| o[:ix].map { |i| i[:itx] } }.flatten - bqidi
298
348
  end
299
349
 
300
- # @return [Array<Integer>] lista indices transacoes novas
301
- def idk
302
- @idk ||= bcd.map { |o| o[:kx].map { |i| i[:itx] } }.flatten - bqidk
350
+ # @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
351
+ def idp
352
+ @idp ||= esd.map { |o| o[:px].map { |i| i[:itx] } }.flatten - bqidp
303
353
  end
304
354
 
305
- # @example (see Apibc#account_es)
306
- # @param [Hash] abc account etherscan
307
- # @return [Hash] dados etherscan - address, saldo & transacoes
308
- def base_bc(abc)
309
- acc = abc[:account].downcase
310
- {
311
- ax: acc,
312
- sl: abc[:balance].to_d / (10**18),
313
- tx: ftik(acc, api.norml_es(acc)),
314
- ix: ftik(acc, api.inter_es(acc)),
315
- px: fppp(acc, api.block_es(acc)),
316
- wx: fwww(acc, api.withw_es(acc)),
317
- kx: ftik(acc, api.token_es(acc))
318
- }
355
+ # @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
356
+ def idw
357
+ @idw ||= esd.map { |o| o[:wx].map { |i| i[:itx] } }.flatten - bqidw
319
358
  end
320
359
 
321
- # @param [Hash] wbq wallet bigquery
322
- # @param [Hash] hbc dados etherscan - address, saldo & transacoes
323
- # @return [Hash] dados juntos bigquery & etherscan
324
- def bq_bc(wbq, hbc)
325
- xbq = wbq[:ax]
326
- {
327
- id: wbq[:id],
328
- ax: xbq,
329
- bs: wbq[:sl],
330
- bt: bqd[:nt].select { |ont| ont[:iax].casecmp?(xbq) },
331
- bi: bqd[:ni].select { |oni| oni[:iax].casecmp?(xbq) },
332
- bp: bqd[:np].select { |onp| onp[:iax].casecmp?(xbq) },
333
- bw: bqd[:nw].select { |onw| onw[:iax].casecmp?(xbq) },
334
- bk: bqd[:nk].select { |onk| onk[:iax].casecmp?(xbq) },
335
- es: hbc[:sl],
336
- et: hbc[:tx],
337
- ei: hbc[:ix],
338
- ep: hbc[:px],
339
- ew: hbc[:wx],
340
- ek: hbc[:kx]
341
- }
360
+ # @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
361
+ def idk
362
+ @idk ||= esd.map { |o| o[:kx].map { |i| i[:itx] } }.flatten - bqidk
342
363
  end
343
364
 
344
365
  # @return [Array<Hash>] lista transacoes normais novas
345
366
  def novnetht
346
- @novnetht ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
367
+ @novnetht ||= esd.map { |o| o[:tx].select { |t| idt.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
347
368
  end
348
369
 
349
370
  # @return [Array<Hash>] lista transacoes internas novas
350
371
  def novnethi
351
- @novnethi ||= bcd.map { |obc| obc[:ix].select { |obj| idi.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
372
+ @novnethi ||= esd.map { |o| o[:ix].select { |t| idi.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
352
373
  end
353
374
 
354
375
  # @return [Array<Hash>] lista transacoes block novas
355
376
  def novnethp
356
- @novnethp ||= bcd.map { |obc| obc[:px].select { |obj| idp.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
377
+ @novnethp ||= esd.map { |o| o[:px].select { |t| idp.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
357
378
  end
358
379
 
359
380
  # @return [Array<Hash>] lista transacoes withdrawals novas
360
381
  def novnethw
361
- @novnethw ||= bcd.map { |obc| obc[:wx].select { |obj| idw.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
382
+ @novnethw ||= esd.map { |o| o[:wx].select { |t| idw.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
362
383
  end
363
384
 
364
385
  # @return [Array<Hash>] lista transacoes token novas
365
386
  def novnethk
366
- @novnethk ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten.uniq { |itm| itm[:itx] }
367
- end
368
-
369
- def pess(itm)
370
- tym = Integer(itm[:timeStamp])
371
- itm.merge(srx: tym, timeStamp: Time.at(tym))
372
- end
373
-
374
- # @param add (see Apibc#norml_es)
375
- # @param [Array<Hash>] ary lista transacoes/token events
376
- # @return [Array<Hash>] lista transacoes/token events filtrada
377
- def ftik(add, ary)
378
- ary.map { |o| pess(o).merge(itx: String(o[:hash]), iax: add, value: o[:value].to_d) }
379
- end
380
-
381
- # @param add (see Apibc#norml_es)
382
- # @param [Array<Hash>] ary lista blocks events
383
- # @return [Array<Hash>] lista blocks events filtrada
384
- def fppp(add, ary)
385
- ary.map { |o| o.merge(itx: Integer(o[:blockNumber]), iax: add, blockReward: o[:blockReward].to_d, timeStamp: Time.at(Integer(o[:timeStamp]))) }
386
- end
387
-
388
- # @param add (see Apibc#norml_es)
389
- # @param [Array<Hash>] ary lista blocks events
390
- # @return [Array<Hash>] lista blocks events filtrada
391
- def fwww(add, ary)
392
- ary.map { |o| o.merge(itx: Integer(o[:withdrawalIndex]), iax: add, amount: o[:amount].to_d, timeStamp: Time.at(Integer(o[:timestamp]))) }
387
+ @novnethk ||= esd.map { |o| o[:kx].select { |t| idk.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
393
388
  end
394
389
  end
395
390
  end