cns 0.1.4 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +74 -0
- data/.rubocop.yml +4 -3
- data/Gemfile.lock +76 -10
- data/cns.gemspec +9 -6
- data/lib/cns.rb +2 -0
- data/lib/cns/apibc.rb +55 -48
- data/lib/cns/apice1.rb +22 -72
- data/lib/cns/apice2.rb +82 -39
- data/lib/cns/beaconchain1.rb +102 -0
- data/lib/cns/beaconchain2.rb +90 -0
- data/lib/cns/bigquery1.rb +28 -23
- data/lib/cns/bigquery2.rb +23 -0
- data/lib/cns/bigquery3.rb +109 -47
- data/lib/cns/bigquery4.rb +53 -52
- data/lib/cns/bitcoinde.rb +21 -20
- data/lib/cns/etherscan1.rb +21 -19
- data/lib/cns/etherscan2.rb +7 -7
- data/lib/cns/greymass1.rb +23 -18
- data/lib/cns/greymass2.rb +8 -26
- data/lib/cns/kraken.rb +21 -20
- data/lib/cns/paymium.rb +15 -15
- data/lib/cns/therock.rb +16 -15
- data/lib/cns/version.rb +1 -1
- metadata +69 -10
data/lib/cns/bigquery4.rb
CHANGED
@@ -8,23 +8,45 @@ module Cns
|
|
8
8
|
|
9
9
|
# @return [String] comando insert SQL formatado det (trades)
|
10
10
|
def det_ins
|
11
|
-
"insert #{BD}.det(txid,time,tp,user,btc,eur,dtc,dias) VALUES#{apide.trades.map { |
|
11
|
+
"insert #{BD}.det(txid,time,tp,user,btc,eur,dtc,dias) VALUES#{apide.trades.map { |obj| det_1val(obj) }.join(',')}"
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String] comando insert SQL formatado del (ledger)
|
15
|
+
def del_ins
|
16
|
+
"insert #{BD}.del(txid,time,tp,add,moe,qt,fee) VALUES#{apide.ledger.map { |obj| del_val(obj) }.join(',')}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String] comando insert SQL formatado ust (trades)
|
20
|
+
def ust_ins
|
21
|
+
"insert #{BD}.ust(txid,ordertxid,pair,time,type,ordertype,price,cost,fee,vol,margin,misc,ledgers,dias) " \
|
22
|
+
"VALUES#{apius.trades.map { |key, val| ust_1val(key, val) }.join(',')}"
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] comando insert SQL formatado usl (ledger)
|
26
|
+
def usl_ins
|
27
|
+
"insert #{BD}.usl(txid,refid,time,type,aclass,asset,amount,fee) " \
|
28
|
+
"VALUES#{apius.ledger.map { |key, val| usl_val(key, val) }.join(',')}"
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String] comando insert SQL formatado fr (ledger)
|
32
|
+
def frl_ins
|
33
|
+
"insert #{BD}.fr(uuid,tipo,valor,moe,time,dias) VALUES#{apifr.ledger.map { |obj| frl_val(obj) }.join(',')}"
|
12
34
|
end
|
13
35
|
|
14
36
|
# @example (see Apice#trades_de)
|
15
37
|
# @param [Hash] htx trade bitcoinde
|
16
38
|
# @return [String] valores formatados det (trades parte1)
|
17
|
-
def
|
39
|
+
def det_1val(htx)
|
18
40
|
"('#{htx[:trade_id]}'," \
|
19
41
|
"DATETIME(TIMESTAMP('#{htx[:successfully_finished_at]}'))," \
|
20
42
|
"'#{htx[:type]}'," \
|
21
43
|
"'#{htx[:trading_partner_information][:username]}'," \
|
22
|
-
"#{
|
44
|
+
"#{det_2val(htx)}"
|
23
45
|
end
|
24
46
|
|
25
|
-
# @param (see
|
47
|
+
# @param (see det_1val)
|
26
48
|
# @return [String] valores formatados det (trades parte2)
|
27
|
-
def
|
49
|
+
def det_2val(htx)
|
28
50
|
'cast(' \
|
29
51
|
"#{htx[:type] == 'buy' ? htx[:amount_currency_to_trade_after_fee] : "-#{htx[:amount_currency_to_trade]}"}" \
|
30
52
|
' as numeric),' \
|
@@ -33,36 +55,26 @@ module Cns
|
|
33
55
|
"#{Integer(ops[:h][htx[:trade_id]] || 0)})"
|
34
56
|
end
|
35
57
|
|
36
|
-
# @return [String] comando insert SQL formatado del (ledger)
|
37
|
-
def del_ins
|
38
|
-
"insert #{BD}.del(txid,time,tp,add,moe,qt,fee) VALUES#{apide.ledger.map { |h| del_val(h) }.join(',')}"
|
39
|
-
end
|
40
|
-
|
41
58
|
# @example (see Apice#deposits_de)
|
42
59
|
# @example (see Apice#withdrawals_de)
|
43
60
|
# @param [Hash] hlx ledger (deposits + withdrawals) bitcoinde
|
44
61
|
# @return [String] valores formatados del (ledger)
|
45
62
|
def del_val(hlx)
|
63
|
+
tip = hlx[:tp]
|
46
64
|
"(#{hlx[:txid]}," \
|
47
65
|
"DATETIME(TIMESTAMP('#{hlx[:time].iso8601}'))," \
|
48
|
-
"'#{
|
66
|
+
"'#{tip}'," \
|
49
67
|
"'#{hlx[:add]}'," \
|
50
68
|
"'#{hlx[:moe]}'," \
|
51
|
-
"cast(#{
|
69
|
+
"cast(#{tip == 'withdrawal' ? '-' : ''}#{hlx[:qt]} as numeric)," \
|
52
70
|
"cast(#{hlx[:fee]} as numeric))"
|
53
71
|
end
|
54
72
|
|
55
|
-
# @return [String] comando insert SQL formatado ust (trades)
|
56
|
-
def ust_ins
|
57
|
-
"insert #{BD}.ust(txid,ordertxid,pair,time,type,ordertype,price,cost,fee,vol,margin,misc,ledgers,dias) " \
|
58
|
-
"VALUES#{apius.trades.map { |k, v| ust_val1(k, v) }.join(',')}"
|
59
|
-
end
|
60
|
-
|
61
73
|
# @example (see Apice#trades_us)
|
62
74
|
# @param [String] idx identificador transacao
|
63
75
|
# @param [Hash] htx trade kraken
|
64
76
|
# @return [String] valores formatados ust (trades parte1)
|
65
|
-
def
|
77
|
+
def ust_1val(idx, htx)
|
66
78
|
"('#{idx}'," \
|
67
79
|
"'#{htx[:ordertxid]}'," \
|
68
80
|
"'#{htx[:pair]}'," \
|
@@ -72,81 +84,70 @@ module Cns
|
|
72
84
|
"cast(#{htx[:price]} as numeric)," \
|
73
85
|
"cast(#{htx[:cost]} as numeric)," \
|
74
86
|
"cast(#{htx[:fee]} as numeric)," \
|
75
|
-
"#{
|
87
|
+
"#{ust_2val(idx, htx)}"
|
76
88
|
end
|
77
89
|
|
78
|
-
# @param (see
|
90
|
+
# @param (see ust_1val)
|
79
91
|
# @return [String] valores formatados ust (trades parte2)
|
80
|
-
def
|
92
|
+
def ust_2val(idx, htx)
|
93
|
+
msc = htx[:misc].to_s
|
81
94
|
"cast(#{htx[:vol]} as numeric)," \
|
82
95
|
"cast(#{htx[:margin]} as numeric)," \
|
83
|
-
"#{
|
84
|
-
"'#{apius.ledger.select { |_,
|
96
|
+
"#{msc.empty? ? 'null' : "'#{msc}'"}," \
|
97
|
+
"'#{apius.ledger.select { |_, val| val[:refid] == idx }.keys.join(',') || ''}'," \
|
85
98
|
"#{Integer(ops[:h][idx] || 0)})"
|
86
99
|
end
|
87
100
|
|
88
|
-
# @return [String] comando insert SQL formatado usl (ledger)
|
89
|
-
def usl_ins
|
90
|
-
"insert #{BD}.usl(txid,refid,time,type,aclass,asset,amount,fee) " \
|
91
|
-
"VALUES#{apius.ledger.map { |k, v| usl_val(k, v) }.join(',')}"
|
92
|
-
end
|
93
|
-
|
94
101
|
# @example (see Apice#ledger_us)
|
95
|
-
# @param idx (see
|
102
|
+
# @param idx (see ust_1val)
|
96
103
|
# @param [Hash] hlx ledger kraken
|
97
104
|
# @return [String] valores formatados usl (ledger)
|
98
105
|
def usl_val(idx, hlx)
|
106
|
+
acl = hlx[:aclass].to_s
|
99
107
|
"('#{idx}'," \
|
100
108
|
"'#{hlx[:refid]}'," \
|
101
109
|
"PARSE_DATETIME('%s', '#{String(hlx[:time].round)}')," \
|
102
110
|
"'#{hlx[:type]}'," \
|
103
|
-
"#{
|
111
|
+
"#{acl.empty? ? 'null' : "'#{acl}'"}," \
|
104
112
|
"'#{hlx[:asset]}'," \
|
105
113
|
"cast(#{hlx[:amount]} as numeric)," \
|
106
114
|
"cast(#{hlx[:fee]} as numeric))"
|
107
115
|
end
|
108
116
|
|
109
|
-
# @return [String] comando insert SQL formatado fr (ledger)
|
110
|
-
def frl_ins
|
111
|
-
"insert #{BD}.fr(uuid,tipo,valor,moe,time,dias) VALUES#{apifr.ledger.map { |h| frl_val(h) }.join(',')}"
|
112
|
-
end
|
113
|
-
|
114
117
|
# @example (see Apice#ledger_fr)
|
115
118
|
# @param [Hash] hlx ledger paymium
|
116
119
|
# @return [String] valores formatados frl (ledger)
|
117
120
|
def frl_val(hlx)
|
118
|
-
|
121
|
+
uid = hlx[:uuid]
|
122
|
+
"('#{uid}'," \
|
119
123
|
"'#{hlx[:name]}'," \
|
120
124
|
"cast(#{hlx[:amount]} as numeric)," \
|
121
125
|
"'#{hlx[:currency]}'," \
|
122
126
|
"PARSE_DATETIME('%s', '#{hlx[:created_at_int]}')," \
|
123
|
-
"#{Integer(ops[:h][
|
124
|
-
end
|
125
|
-
|
126
|
-
# @return [String] comando insert SQL formatado fr (ledger)
|
127
|
-
def mtl_ins
|
128
|
-
"insert #{BD}.mt(id,time,type,valor,moe,pair,note,trade_id,dias) " \
|
129
|
-
"VALUES#{apimt.ledger.map { |h| mtl_val1(h) }.join(',')}"
|
127
|
+
"#{Integer(ops[:h][uid] || 0)})"
|
130
128
|
end
|
131
129
|
|
132
130
|
# @example (see Apice#ledger_mt)
|
133
131
|
# @param [Hash] hlx ledger therock
|
134
132
|
# @return [String] valores formatados mtl (ledger parte1)
|
135
|
-
def
|
133
|
+
def mtl_1val(hlx)
|
134
|
+
fid = hlx[:fund_id].to_s
|
136
135
|
"(#{hlx[:id]}," \
|
137
136
|
"DATETIME(TIMESTAMP('#{hlx[:date]}'))," \
|
138
137
|
"'#{hlx[:type]}'," \
|
139
138
|
"cast(#{hlx[:price]} as numeric)," \
|
140
139
|
"'#{hlx[:currency]}'," \
|
141
|
-
"#{
|
142
|
-
"#{
|
140
|
+
"#{fid.empty? ? 'null' : "'#{fid}'"}," \
|
141
|
+
"#{mtl_2val(hlx)}"
|
143
142
|
end
|
144
143
|
|
145
|
-
# @param (see
|
144
|
+
# @param (see mtl_1val)
|
146
145
|
# @return [String] valores formatados mtl (ledger parte2)
|
147
|
-
def
|
148
|
-
|
149
|
-
|
146
|
+
def mtl_2val(hlx)
|
147
|
+
nte = hlx[:note].to_s
|
148
|
+
tid = hlx[:trade_id].to_s
|
149
|
+
"#{nte.empty? ? 'null' : "'#{nte}'"}," \
|
150
|
+
"#{tid.empty? ? 'null' : tid.to_s}," \
|
150
151
|
"#{Integer(ops[:h][String(hlx[:id])] || 0)})"
|
151
152
|
end
|
152
153
|
end
|
data/lib/cns/bitcoinde.rb
CHANGED
@@ -27,25 +27,25 @@ module Cns
|
|
27
27
|
|
28
28
|
# @return [Array<Hash>] lista trades bitcoinde novos
|
29
29
|
def trades
|
30
|
-
@trades ||= exd[:tt].select { |
|
30
|
+
@trades ||= exd[:tt].select { |obj| kyt.include?(obj[:trade_id]) }
|
31
31
|
end
|
32
32
|
|
33
33
|
# @return [Array<Hash>] lista ledger (deposits + withdrawals) bitcoinde novos
|
34
34
|
def ledger
|
35
|
-
@ledger ||= exd[:tl].select { |
|
35
|
+
@ledger ||= exd[:tl].select { |obj| kyl.include?(obj[:txid]) }
|
36
36
|
end
|
37
37
|
|
38
38
|
# @return [String] texto saldos & transacoes & ajuste dias
|
39
39
|
def mostra_resumo
|
40
40
|
puts("\nBITCOINDE\ntipo bitcoinde bigquery")
|
41
|
-
exd[:sl].each { |
|
41
|
+
exd[:sl].each { |key, val| puts(formata_saldos(key, val)) }
|
42
42
|
mostra_totais
|
43
43
|
|
44
44
|
mostra_trades
|
45
45
|
mostra_ledger
|
46
46
|
return if trades.empty?
|
47
47
|
|
48
|
-
puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |
|
48
|
+
puts("\nstring ajuste dias dos trades\n-h=#{kyt.map { |obj| "#{obj}:0" }.join(' ')}")
|
49
49
|
end
|
50
50
|
|
51
51
|
# @return [Hash] dados exchange bitcoinde - saldos & trades & deposits & withdrawals
|
@@ -59,12 +59,12 @@ module Cns
|
|
59
59
|
|
60
60
|
# @return [Array<String>] lista txid dos trades novos
|
61
61
|
def kyt
|
62
|
-
@kyt ||= exd[:tt].map { |
|
62
|
+
@kyt ||= exd[:tt].map { |oex| oex[:trade_id] }.flatten - (ops[:t] ? [] : bqd[:nt].map { |obq| obq[:txid] })
|
63
63
|
end
|
64
64
|
|
65
65
|
# @return [Array<Integer>] lista txid dos ledger novos
|
66
66
|
def kyl
|
67
|
-
@kyl ||= exd[:tl].map { |
|
67
|
+
@kyl ||= exd[:tl].map { |oex| oex[:txid] }.flatten - (ops[:t] ? [] : bqd[:nl].map { |obq| obq[:txid] })
|
68
68
|
end
|
69
69
|
|
70
70
|
# @example (see Apice#account_de)
|
@@ -72,14 +72,14 @@ module Cns
|
|
72
72
|
# @param [Hash] hsx saldo bitcoinde da moeda
|
73
73
|
# @return [String] texto formatado saldos
|
74
74
|
def formata_saldos(moe, hsx)
|
75
|
-
|
76
|
-
|
75
|
+
vbq = bqd[:sl][moe.downcase.to_sym].to_d
|
76
|
+
vex = hsx[:total_amount].to_d
|
77
77
|
format(
|
78
78
|
'%<mo>-5.5s %<ex>21.9f %<bq>21.9f %<ok>3.3s',
|
79
79
|
mo: moe.upcase,
|
80
|
-
ex:
|
81
|
-
bq:
|
82
|
-
ok:
|
80
|
+
ex: vex,
|
81
|
+
bq: vbq,
|
82
|
+
ok: vex == vbq ? 'OK' : 'NOK'
|
83
83
|
)
|
84
84
|
end
|
85
85
|
|
@@ -117,13 +117,13 @@ module Cns
|
|
117
117
|
|
118
118
|
# @return [String] texto numero de transacoes
|
119
119
|
def mostra_totais
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
vtt = exd[:tt].count
|
121
|
+
vnt = bqd[:nt].count
|
122
|
+
vtl = exd[:tl].count
|
123
|
+
vnl = bqd[:nl].count
|
124
124
|
|
125
|
-
puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a:
|
126
|
-
puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c:
|
125
|
+
puts("TRADES #{format('%<a>20i %<b>21i %<o>3.3s', a: vtt, b: vnt, o: vtt == vnt ? 'OK' : 'NOK')}")
|
126
|
+
puts("LEDGER #{format('%<c>20i %<d>21i %<o>3.3s', c: vtl, d: vnl, o: vtl == vnl ? 'OK' : 'NOK')}")
|
127
127
|
end
|
128
128
|
|
129
129
|
# @return [String] texto transacoes trades
|
@@ -131,8 +131,9 @@ module Cns
|
|
131
131
|
return unless ops[:v] && !trades.empty?
|
132
132
|
|
133
133
|
puts("\ntrades data hora dt criacao tipo par qtd eur")
|
134
|
-
trades
|
135
|
-
|
134
|
+
trades
|
135
|
+
.sort { |ant, prx| Time.parse(prx[:successfully_finished_at]) <=> Time.parse(ant[:successfully_finished_at]) }
|
136
|
+
.each { |obj| puts(formata_trades(obj)) }
|
136
137
|
end
|
137
138
|
|
138
139
|
# @return [String] texto transacoes ledger
|
@@ -140,7 +141,7 @@ module Cns
|
|
140
141
|
return unless ops[:v] && !ledger.empty?
|
141
142
|
|
142
143
|
puts("\nledger data hora tipo moe quantidade custo")
|
143
|
-
ledger.sort { |
|
144
|
+
ledger.sort { |ant, prx| prx[:time] <=> ant[:time] }.each { |obj| puts(formata_ledger(obj)) }
|
144
145
|
end
|
145
146
|
end
|
146
147
|
end
|
data/lib/cns/etherscan1.rb
CHANGED
@@ -29,49 +29,51 @@ module Cns
|
|
29
29
|
|
30
30
|
# @return [Array<Hash>] lista transacoes normais novas
|
31
31
|
def novtx
|
32
|
-
@novtx ||= bcd.map { |
|
32
|
+
@novtx ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
|
33
33
|
end
|
34
34
|
|
35
35
|
# @return [Array<Hash>] lista transacoes token novas
|
36
36
|
def novkx
|
37
|
-
@novkx ||= bcd.map { |
|
37
|
+
@novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten
|
38
38
|
end
|
39
39
|
|
40
40
|
# @return [Array<String>] lista dos meus enderecos
|
41
41
|
def lax
|
42
|
-
@lax ||= bqd[:wb].map { |
|
42
|
+
@lax ||= bqd[:wb].map { |obj| obj[:ax] }
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [Array<Hash>] todos os dados etherscan - saldos & transacoes
|
46
46
|
def bcd
|
47
|
-
@bcd ||= api.account_es(lax).map { |
|
47
|
+
@bcd ||= api.account_es(lax).map { |obj| base_bc(obj) }
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Array<Hash>] todos os dados juntos bigquery & etherscan
|
51
51
|
def dados
|
52
|
-
@dados ||= bqd[:wb].map { |
|
52
|
+
@dados ||= bqd[:wb].map { |obq| bq_bc(obq, bcd.select { |obc| obq[:ax] == obc[:ax] }.first) }
|
53
53
|
end
|
54
54
|
|
55
55
|
# @return [Array<Integer>] lista indices transacoes normais novas
|
56
56
|
def idt
|
57
|
-
@idt ||=
|
57
|
+
@idt ||= bcd.map { |obc| obc[:tx].map { |obj| obj[:itx] } }.flatten -
|
58
|
+
(ops[:t] ? [] : bqd[:nt].map { |obq| obq[:itx] })
|
58
59
|
end
|
59
60
|
|
60
61
|
# @return [Array<Integer>] lista indices transacoes token novas
|
61
62
|
def idk
|
62
|
-
@idk ||=
|
63
|
+
@idk ||= bcd.map { |obc| obc[:kx].map { |obj| obj[:itx] } }.flatten -
|
64
|
+
(ops[:t] ? [] : bqd[:nk].map { |obq| obq[:itx] })
|
63
65
|
end
|
64
66
|
|
65
67
|
# @example (see Apibc#account_es)
|
66
68
|
# @param [Hash] abc account etherscan
|
67
69
|
# @return [Hash] dados etherscan - address, saldo & transacoes
|
68
70
|
def base_bc(abc)
|
69
|
-
|
71
|
+
acc = abc[:account]
|
70
72
|
{
|
71
|
-
ax:
|
73
|
+
ax: acc,
|
72
74
|
sl: (abc[:balance].to_d / 10**18).round(10),
|
73
|
-
tx: filtrar_tx(
|
74
|
-
kx: filtrar_tx(
|
75
|
+
tx: filtrar_tx(acc, api.norml_es(acc)),
|
76
|
+
kx: filtrar_tx(acc, api.token_es(acc))
|
75
77
|
}
|
76
78
|
end
|
77
79
|
|
@@ -81,10 +83,10 @@ module Cns
|
|
81
83
|
def bq_bc(wbq, hbc)
|
82
84
|
{
|
83
85
|
id: wbq[:id],
|
84
|
-
ax: wbq[:ax],
|
86
|
+
ax: xbq = wbq[:ax],
|
85
87
|
bs: wbq[:sl],
|
86
|
-
bt: bqd[:nt].select { |
|
87
|
-
bk: bqd[:nk].select { |
|
88
|
+
bt: bqd[:nt].select { |ont| ont[:iax] == xbq },
|
89
|
+
bk: bqd[:nk].select { |onk| onk[:iax] == xbq },
|
88
90
|
es: hbc[:sl],
|
89
91
|
et: hbc[:tx],
|
90
92
|
ek: hbc[:kx]
|
@@ -97,23 +99,23 @@ module Cns
|
|
97
99
|
def filtrar_tx(add, ary)
|
98
100
|
# elimina transferencia from: (lax) to: (add) - esta transferencia aparece em from: (add) to: (lax)
|
99
101
|
# elimina chaves irrelevantes (DL) & adiciona chave indice itx & adiciona identificador da carteira iax
|
100
|
-
ary.delete_if { |
|
101
|
-
.map { |
|
102
|
+
ary.delete_if { |odl| odl[:to] == add && lax.include?(odl[:from]) }
|
103
|
+
.map { |omp| omp.delete_if { |key, _| DL.include?(key) }.merge(itx: Integer(omp[:blockNumber]), iax: add) }
|
102
104
|
end
|
103
105
|
|
104
106
|
# @return [Array<Hash>] lista ordenada transacoes normais novas
|
105
107
|
def sortx
|
106
|
-
novtx.sort { |
|
108
|
+
novtx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
107
109
|
end
|
108
110
|
|
109
111
|
# @return [Array<Hash>] lista ordenada transacoes token novas
|
110
112
|
def sorkx
|
111
|
-
novkx.sort { |
|
113
|
+
novkx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
112
114
|
end
|
113
115
|
|
114
116
|
# @return [Array<Hash>] lista ordenada transacoes (normais & token) novas
|
115
117
|
def sorax
|
116
|
-
(novtx + novkx).sort { |
|
118
|
+
(novtx + novkx).sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
117
119
|
end
|
118
120
|
end
|
119
121
|
end
|
data/lib/cns/etherscan2.rb
CHANGED
@@ -9,7 +9,7 @@ module Cns
|
|
9
9
|
return unless dados.count.positive?
|
10
10
|
|
11
11
|
puts("\nid address etherscan nm tk bigquery nm tk")
|
12
|
-
dados.each { |
|
12
|
+
dados.each { |obj| puts(formata_carteira(obj)) }
|
13
13
|
mostra_transacao_norml
|
14
14
|
mostra_transacao_token
|
15
15
|
mostra_configuracao_ajuste_dias
|
@@ -52,9 +52,9 @@ module Cns
|
|
52
52
|
# @param [Integer] max chars a mostrar
|
53
53
|
# @return [String] endereco formatado
|
54
54
|
def formata_endereco(add, max)
|
55
|
-
|
56
|
-
|
57
|
-
max < 7 ? 'erro' : "#{
|
55
|
+
int = Integer((max - 2) / 2)
|
56
|
+
hid = (max <= 20 ? bqd[:wb].select { |obj| obj[:ax] == add }.first : nil) || { id: add }
|
57
|
+
max < 7 ? 'erro' : "#{hid[:id][0, int - 3]}..#{add[-int - 3..]}"
|
58
58
|
end
|
59
59
|
|
60
60
|
# @example (see Apibc#norml_es)
|
@@ -91,7 +91,7 @@ module Cns
|
|
91
91
|
return unless ops[:v] && novtx.count.positive?
|
92
92
|
|
93
93
|
puts("\ntx normal from to data valor")
|
94
|
-
sortx.each { |
|
94
|
+
sortx.each { |obj| puts(formata_transacao_norml(obj)) }
|
95
95
|
end
|
96
96
|
|
97
97
|
# @return [String] texto transacoes token
|
@@ -99,14 +99,14 @@ module Cns
|
|
99
99
|
return unless ops[:v] && novkx.count.positive?
|
100
100
|
|
101
101
|
puts("\ntx token from to data valor")
|
102
|
-
sorkx.each { |
|
102
|
+
sorkx.each { |obj| puts(formata_transacao_token(obj)) }
|
103
103
|
end
|
104
104
|
|
105
105
|
# @return [String] texto configuracao ajuste dias das transacoes (normais & token)
|
106
106
|
def mostra_configuracao_ajuste_dias
|
107
107
|
return unless (novtx.count + novkx.count).positive?
|
108
108
|
|
109
|
-
puts("\nstring ajuste dias\n-h=#{sorax.map { |
|
109
|
+
puts("\nstring ajuste dias\n-h=#{sorax.map { |obj| "#{obj[:blockNumber]}:0" }.join(' ')}")
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|