cns 2.0.3 → 2.0.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cns/bitcoinde.rb +10 -10
- data/lib/cns/etherscan.rb +34 -34
- data/lib/cns/greymass.rb +13 -13
- data/lib/cns/kraken.rb +11 -11
- 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: d694cb783e1251f3f407be238aab038991afc5fb59ff3aedd47c9e7b916b5c82
|
4
|
+
data.tar.gz: 5fcc7fd02541ab31d788d04a83cac269bddc05bdd18c63308159c88062434e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a7d81e1fa81a8b843a17473644f0762b0d144cf97f267ffdb63bf160a5c84fac4eb105e05d11516aaf7f5985a6b075280aa8115bfb40f0535f6fa8d619d1ae
|
7
|
+
data.tar.gz: d02c614fdcc3610173506b2646223e10bc3b1f74a86e0e08fc8a46f0f9befeed11dedb2b606f58b8b667398319e55f821d2d0f125ea2ebad687fa8c31422567c
|
data/Gemfile.lock
CHANGED
data/lib/cns/bitcoinde.rb
CHANGED
@@ -25,7 +25,7 @@ module Cns
|
|
25
25
|
# @return [String] texto saldos & transacoes & ajuste dias
|
26
26
|
def mresumo
|
27
27
|
puts("\nBITCOINDE\ntipo bitcoinde bigquery")
|
28
|
-
|
28
|
+
exd[:sl].sort.each { |k, v| puts(fos(k, v)) }
|
29
29
|
mtotais
|
30
30
|
|
31
31
|
mtrades
|
@@ -39,8 +39,8 @@ module Cns
|
|
39
39
|
|
40
40
|
# mosta contadores transacoes
|
41
41
|
def mtotais
|
42
|
-
vtt, vnt =
|
43
|
-
vtl, vnl =
|
42
|
+
vtt, vnt = exd[:tt].count, bqd[:nt].count
|
43
|
+
vtl, vnl = exd[:tl].count, bqd[:nl].count
|
44
44
|
|
45
45
|
puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: vtt, b: vnt, o: vtt == vnt ? 'OK' : 'NOK')}")
|
46
46
|
puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: vtl, d: vnl, o: vtl == vnl ? 'OK' : 'NOK')}")
|
@@ -157,7 +157,7 @@ module Cns
|
|
157
157
|
end
|
158
158
|
|
159
159
|
# @return [Hash] dados exchange bitcoinde - saldos & trades & deposits & withdrawals
|
160
|
-
memoize def
|
160
|
+
memoize def exd
|
161
161
|
{sl: pdea(api.account_de), tt: pdet(api.trades_de), tl: pdel(api.deposits_de + api.withdrawals_de)}
|
162
162
|
end
|
163
163
|
|
@@ -172,23 +172,23 @@ module Cns
|
|
172
172
|
end
|
173
173
|
|
174
174
|
# @return [Array<String>] lista txid trades novos
|
175
|
-
memoize def
|
176
|
-
|
175
|
+
memoize def exkyt
|
176
|
+
exd[:tt].map { |t| t[:trade_id] } - bqkyt
|
177
177
|
end
|
178
178
|
|
179
179
|
# @return [Array<Integer>] lista nxid ledger novos
|
180
|
-
memoize def
|
181
|
-
|
180
|
+
memoize def exkyl
|
181
|
+
exd[:tl].map { |t| t[:nxid] } - bqkyl
|
182
182
|
end
|
183
183
|
|
184
184
|
# @return [Array<Hash>] lista trades novos bitcoinde
|
185
185
|
memoize def novxt
|
186
|
-
|
186
|
+
exd[:tt].select { |o| exkyt.include?(o[:trade_id]) }
|
187
187
|
end
|
188
188
|
|
189
189
|
# @return [Array<Hash>] lista ledgers (deposits + withdrawals) novos bitcoinde
|
190
190
|
memoize def novxl
|
191
|
-
|
191
|
+
exd[:tl].select { |o| exkyl.include?(o[:nxid]) }
|
192
192
|
end
|
193
193
|
end
|
194
194
|
end
|
data/lib/cns/etherscan.rb
CHANGED
@@ -61,20 +61,20 @@ module Cns
|
|
61
61
|
|
62
62
|
# mostra resumo carteiras & transacoes & ajuste dias
|
63
63
|
def mresumo_simples
|
64
|
-
return unless
|
64
|
+
return unless bqexd.any?
|
65
65
|
|
66
66
|
puts("\nid address etherscan bigquery")
|
67
|
-
|
67
|
+
bqexd.each { |o| puts(focs(o)) }
|
68
68
|
mtransacoes_novas
|
69
69
|
mconfiguracao_ajuste_dias
|
70
70
|
end
|
71
71
|
|
72
72
|
# mostra resumo carteiras & transacoes & ajuste dias (com contadores)
|
73
73
|
def mresumo
|
74
|
-
return unless
|
74
|
+
return unless bqexd.any?
|
75
75
|
|
76
76
|
puts("\nid address etherscan tn ti tb tk tw bigquery tn ti tb tk tw")
|
77
|
-
|
77
|
+
bqexd.each { |o| puts(foct(o)) }
|
78
78
|
mtransacoes_novas
|
79
79
|
mconfiguracao_ajuste_dias
|
80
80
|
end
|
@@ -286,7 +286,7 @@ module Cns
|
|
286
286
|
# Fetch Etherscan data for an account
|
287
287
|
# @param [Hash] aes account etherscan
|
288
288
|
# @return [Hash] dados etherscan - address, saldo & transacoes
|
289
|
-
def
|
289
|
+
def esd(aes)
|
290
290
|
acc = aes[:account].downcase
|
291
291
|
{
|
292
292
|
ax: acc,
|
@@ -303,7 +303,7 @@ module Cns
|
|
303
303
|
# @param [Hash] wbq wallet bigquery
|
304
304
|
# @param [Hash] hes dados etherscan - address, saldo & transacoes
|
305
305
|
# @return [Hash] dados juntos bigquery & etherscan
|
306
|
-
def
|
306
|
+
def bqesd(wbq, hes)
|
307
307
|
xbq = wbq[:ax]
|
308
308
|
{
|
309
309
|
id: wbq[:id],
|
@@ -323,12 +323,6 @@ module Cns
|
|
323
323
|
}
|
324
324
|
end
|
325
325
|
|
326
|
-
# Fetch all Etherscan data
|
327
|
-
# @return [Hash] saldos & transacoes, indexed by address
|
328
|
-
memoize def bcd
|
329
|
-
api.account_es(lax).map { |o| bses(o) }.to_h { |h| [h[:ax], h] }
|
330
|
-
end
|
331
|
-
|
332
326
|
# Lazy Etherscan API Initialization
|
333
327
|
# @return [Apibc] API instance
|
334
328
|
memoize def api
|
@@ -340,90 +334,96 @@ module Cns
|
|
340
334
|
bqd[:wb].map { |o| o[:ax] }
|
341
335
|
end
|
342
336
|
|
337
|
+
# Fetch all Etherscan data
|
338
|
+
# @return [Hash] saldos & transacoes, indexed by address
|
339
|
+
memoize def exd
|
340
|
+
api.account_es(lax).map { |o| esd(o) }.to_h { |h| [h[:ax], h] }
|
341
|
+
end
|
342
|
+
|
343
343
|
# Fetch combined data
|
344
344
|
# @return [Array<Hash>] todos os dados juntos bigquery & etherscan
|
345
|
-
memoize def
|
346
|
-
bqd[:wb].map { |b|
|
345
|
+
memoize def bqexd
|
346
|
+
bqd[:wb].map { |b| bqesd(b, exd[b[:ax]]) }
|
347
347
|
end
|
348
348
|
|
349
349
|
# @return [Array<Integer>] indices transacoes bigquery
|
350
|
-
memoize def
|
350
|
+
memoize def bqkyt
|
351
351
|
show_all? ? [] : bqd[:nt].map { |i| i[:itx] }
|
352
352
|
end
|
353
353
|
|
354
354
|
# @return [Array<Integer>] indices transacoes bigquery
|
355
|
-
memoize def
|
355
|
+
memoize def bqkyi
|
356
356
|
show_all? ? [] : bqd[:ni].map { |i| i[:itx] }
|
357
357
|
end
|
358
358
|
|
359
359
|
# @return [Array<Integer>] indices transacoes bigquery
|
360
|
-
memoize def
|
360
|
+
memoize def bqkyp
|
361
361
|
show_all? ? [] : bqd[:np].map { |i| i[:itx] }
|
362
362
|
end
|
363
363
|
|
364
364
|
# @return [Array<Integer>] indices transacoes bigquery
|
365
|
-
memoize def
|
365
|
+
memoize def bqkyw
|
366
366
|
show_all? ? [] : bqd[:nw].map { |i| i[:itx] }
|
367
367
|
end
|
368
368
|
|
369
369
|
# @return [Array<Integer>] indices transacoes bigquery
|
370
|
-
memoize def
|
370
|
+
memoize def bqkyk
|
371
371
|
show_all? ? [] : bqd[:nk].map { |i| i[:itx] }
|
372
372
|
end
|
373
373
|
|
374
374
|
# @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
|
375
|
-
memoize def
|
376
|
-
|
375
|
+
memoize def exkyt
|
376
|
+
exd.values.map { |o| o[:tx].map { |i| i[:itx] } }.flatten - bqkyt
|
377
377
|
end
|
378
378
|
|
379
379
|
# @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
|
380
|
-
memoize def
|
381
|
-
|
380
|
+
memoize def exkyi
|
381
|
+
exd.values.map { |o| o[:ix].map { |i| i[:itx] } }.flatten - bqkyi
|
382
382
|
end
|
383
383
|
|
384
384
|
# @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
|
385
|
-
memoize def
|
386
|
-
|
385
|
+
memoize def exkyp
|
386
|
+
exd.values.map { |o| o[:px].map { |i| i[:itx] } }.flatten - bqkyp
|
387
387
|
end
|
388
388
|
|
389
389
|
# @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
|
390
|
-
memoize def
|
391
|
-
|
390
|
+
memoize def exkyw
|
391
|
+
exd.values.map { |o| o[:wx].map { |i| i[:itx] } }.flatten - bqkyw
|
392
392
|
end
|
393
393
|
|
394
394
|
# @return [Array<Integer>] indices transacoes novas (etherscan - bigquery)
|
395
|
-
memoize def
|
396
|
-
|
395
|
+
memoize def exkyk
|
396
|
+
exd.values.map { |o| o[:kx].map { |i| i[:itx] } }.flatten - bqkyk
|
397
397
|
end
|
398
398
|
|
399
399
|
# Get new normal transactions
|
400
400
|
# @return [Array<Hash>] List of new transactions
|
401
401
|
memoize def novxt
|
402
|
-
|
402
|
+
exd.values.map { |o| o[:tx].select { |t| exkyt.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
403
403
|
end
|
404
404
|
|
405
405
|
# Get new internal transactions
|
406
406
|
# @return [Array<Hash>] List of new transactions
|
407
407
|
memoize def novxi
|
408
|
-
|
408
|
+
exd.values.map { |o| o[:ix].select { |t| exkyi.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
409
409
|
end
|
410
410
|
|
411
411
|
# Get new produced block transactions
|
412
412
|
# @return [Array<Hash>] List of new transactions
|
413
413
|
memoize def novxp
|
414
|
-
|
414
|
+
exd.values.map { |o| o[:px].select { |t| exkyp.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
415
415
|
end
|
416
416
|
|
417
417
|
# Get new withdrawal transactions
|
418
418
|
# @return [Array<Hash>] List of new transactions
|
419
419
|
memoize def novxw
|
420
|
-
|
420
|
+
exd.values.map { |o| o[:wx].select { |t| exkyw.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
421
421
|
end
|
422
422
|
|
423
423
|
# Get new token transactions
|
424
424
|
# @return [Array<Hash>] List of new transactions
|
425
425
|
memoize def novxk
|
426
|
-
|
426
|
+
exd.values.map { |o| o[:kx].select { |t| exkyk.include?(t[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
427
427
|
end
|
428
428
|
end
|
429
429
|
end
|
data/lib/cns/greymass.rb
CHANGED
@@ -26,10 +26,10 @@ module Cns
|
|
26
26
|
|
27
27
|
# Display summary of wallets, transactions, and adjustment days configuration
|
28
28
|
def mresumo
|
29
|
-
return unless
|
29
|
+
return unless bqexd.any?
|
30
30
|
|
31
31
|
puts("\naddress greymass ntx bigquery ntx")
|
32
|
-
|
32
|
+
bqexd.each { |e| puts(foct(e)) }
|
33
33
|
mtransacoes_novas
|
34
34
|
mconfiguracao_ajuste_dias
|
35
35
|
end
|
@@ -131,16 +131,16 @@ module Cns
|
|
131
131
|
# Fetch Greymass data for a wallet
|
132
132
|
# @param [Hash] wbq wallet bigquery
|
133
133
|
# @return [Hash] dados greymass - address, saldo & transacoes
|
134
|
-
def
|
134
|
+
def gmd(wbq)
|
135
135
|
xbq = wbq[:ax]
|
136
136
|
{ax: xbq, sl: peosa(xbq).reduce(:+), tx: peost(xbq, api.ledger_gm(xbq))}
|
137
137
|
end
|
138
138
|
|
139
139
|
# Combine BigQuery and Greymass data
|
140
|
-
# @param wbq (see
|
140
|
+
# @param wbq (see gmd)
|
141
141
|
# @param [Hash] hgm dados greymass - address, saldo & transacoes
|
142
142
|
# @return [Hash] dados juntos bigquery & greymass
|
143
|
-
def
|
143
|
+
def bqgmd(wbq, hgm)
|
144
144
|
xbq = wbq[:ax]
|
145
145
|
{
|
146
146
|
id: wbq[:id],
|
@@ -160,30 +160,30 @@ module Cns
|
|
160
160
|
|
161
161
|
# Fetch all Greymass data
|
162
162
|
# @return [Hash] Hash of Greymass data indexed by address
|
163
|
-
memoize def
|
164
|
-
bqd[:wb].map { |o|
|
163
|
+
memoize def exd
|
164
|
+
bqd[:wb].map { |o| gmd(o) }.to_h { |h| [h[:ax], h] }
|
165
165
|
end
|
166
166
|
|
167
167
|
# Fetch combined BigQuery and Greymass data
|
168
168
|
# @return [Array<Hash>] Combined data list
|
169
|
-
memoize def
|
170
|
-
bqd[:wb].map { |b|
|
169
|
+
memoize def bqexd
|
170
|
+
bqd[:wb].map { |b| bqgmd(b, exd[b[:ax]]) }
|
171
171
|
end
|
172
172
|
|
173
173
|
# @return [Array<Integer>] indices transacoes bigquery
|
174
|
-
memoize def
|
174
|
+
memoize def bqkyt
|
175
175
|
show_all? ? [] : bqd[:nt].map { |i| i[:itx] }
|
176
176
|
end
|
177
177
|
|
178
178
|
# @return [Array<Integer>] indices transacoes novas (greymass - bigquery)
|
179
|
-
memoize def
|
180
|
-
|
179
|
+
memoize def exkyt
|
180
|
+
exd.values.map { |o| o[:tx].map { |i| i[:itx] } }.flatten - bqkyt
|
181
181
|
end
|
182
182
|
|
183
183
|
# Get new transactions
|
184
184
|
# @return [Array<Hash>] List of new transactions
|
185
185
|
memoize def novxt
|
186
|
-
|
186
|
+
exd.values.map { |t| t[:tx].select { |o| exkyt.include?(o[:itx]) } }.flatten.uniq { |i| i[:itx] }
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
data/lib/cns/kraken.rb
CHANGED
@@ -25,7 +25,7 @@ module Cns
|
|
25
25
|
# mosta resumo saldos & transacoes & ajuste dias
|
26
26
|
def mresumo
|
27
27
|
puts("\nKRAKEN\ntipo kraken bigquery")
|
28
|
-
|
28
|
+
exd[:sl].sort.each { |key, val| puts(fos(key, val)) }
|
29
29
|
mtotais
|
30
30
|
|
31
31
|
mtrades
|
@@ -37,15 +37,15 @@ module Cns
|
|
37
37
|
|
38
38
|
# @return [Hash] ledgers exchange kraken
|
39
39
|
def uskl
|
40
|
-
|
40
|
+
exd[:kl]
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
45
|
# mosta contadores transacoes
|
46
46
|
def mtotais
|
47
|
-
vkt, vnt =
|
48
|
-
vkl, vnl =
|
47
|
+
vkt, vnt = exd[:kt].count, bqd[:nt].count
|
48
|
+
vkl, vnl = exd[:kl].count, bqd[:nl].count
|
49
49
|
|
50
50
|
puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: vkt, b: vnt, o: vkt == vnt ? 'OK' : 'NOK')}")
|
51
51
|
puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: vkl, d: vnl, o: vkl == vnl ? 'OK' : 'NOK')}")
|
@@ -147,7 +147,7 @@ module Cns
|
|
147
147
|
end
|
148
148
|
|
149
149
|
# @return [Hash] dados exchange kraken - saldos & transacoes trades e ledger
|
150
|
-
memoize def
|
150
|
+
memoize def exd
|
151
151
|
{sl: pusa(api.account_us), kt: pust(api.trades_us), kl: pusl(api.ledger_us)}
|
152
152
|
end
|
153
153
|
|
@@ -162,23 +162,23 @@ module Cns
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# @return [Array<String>] lista txid trades novos
|
165
|
-
memoize def
|
166
|
-
|
165
|
+
memoize def exkyt
|
166
|
+
exd[:kt].map { |t| t[:txid] } - bqkyt
|
167
167
|
end
|
168
168
|
|
169
169
|
# @return [Array<String>] lista txid ledger novos
|
170
|
-
memoize def
|
171
|
-
|
170
|
+
memoize def exkyl
|
171
|
+
exd[:kl].map { |t| t[:txid] } - bqkyl
|
172
172
|
end
|
173
173
|
|
174
174
|
# @return [Array<Hash>] trades novos kraken
|
175
175
|
memoize def novxt
|
176
|
-
|
176
|
+
exd[:kt].select { |o| exkyt.include?(o[:txid]) }
|
177
177
|
end
|
178
178
|
|
179
179
|
# @return [Array<Hash>] ledgers novos kraken
|
180
180
|
memoize def novxl
|
181
|
-
|
181
|
+
exd[:kl].select { |o| exkyl.include?(o[:txid]) }
|
182
182
|
end
|
183
183
|
end
|
184
184
|
end
|
data/lib/cns/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hernâni Rodrigues Vaz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|