cns 0.3.0 → 0.3.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/Gemfile.lock +7 -1
- data/cns.gemspec +1 -0
- data/lib/cns/apibc.rb +70 -4
- data/lib/cns/beaconchain2.rb +8 -8
- data/lib/cns/bigquery1.rb +6 -4
- data/lib/cns/bigquery2.rb +2 -0
- data/lib/cns/bigquery3.rb +54 -0
- data/lib/cns/etherscan1.rb +47 -1
- data/lib/cns/etherscan2.rb +70 -16
- data/lib/cns/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9763844e7eaa6b17c7efa7cbbd05d051ea0ef68146e88ad03cdac9a548047fa7
|
|
4
|
+
data.tar.gz: 726d97291f8a8ebe6ff03856bc1785f3256501e8b8e2aca983e1291ecf266169
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5988e292e7025ae6f4afe71f2ebc301b8ff55f6a468da12de5ff07eca9046b4e7028d351cd05ed40f4acef84c1c854759cc08f6d9b054af1c547e114ada79c47
|
|
7
|
+
data.tar.gz: 3fef70b5adc4287a1276fe50e5e2dea05bd0ba79983c9b03963cb100ca040c5c616c7912bc7b9241cf1a7dd729f88a5830f6b45ba6f7744ec56c0a6bcf58f436
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cns (0.3.
|
|
4
|
+
cns (0.3.1)
|
|
5
5
|
curb
|
|
6
6
|
faraday
|
|
7
7
|
google-cloud-bigquery
|
|
@@ -103,6 +103,10 @@ GEM
|
|
|
103
103
|
parser (>= 3.1.1.0)
|
|
104
104
|
rubocop-rake (0.6.0)
|
|
105
105
|
rubocop (~> 1.0)
|
|
106
|
+
ruby-lint (0.9.1)
|
|
107
|
+
parser (>= 2.0.0)
|
|
108
|
+
racc (>= 1.4.10)
|
|
109
|
+
slop
|
|
106
110
|
ruby-progressbar (1.11.0)
|
|
107
111
|
ruby2_keywords (0.0.5)
|
|
108
112
|
signet (0.17.0)
|
|
@@ -110,6 +114,7 @@ GEM
|
|
|
110
114
|
faraday (>= 0.17.5, < 3.a)
|
|
111
115
|
jwt (>= 1.5, < 3.0)
|
|
112
116
|
multi_json (~> 1.10)
|
|
117
|
+
slop (4.9.3)
|
|
113
118
|
solargraph (0.47.2)
|
|
114
119
|
backport (~> 1.2)
|
|
115
120
|
benchmark
|
|
@@ -144,6 +149,7 @@ DEPENDENCIES
|
|
|
144
149
|
reek
|
|
145
150
|
rubocop
|
|
146
151
|
rubocop-rake
|
|
152
|
+
ruby-lint
|
|
147
153
|
solargraph
|
|
148
154
|
yard
|
|
149
155
|
|
data/cns.gemspec
CHANGED
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_development_dependency('reek')
|
|
32
32
|
spec.add_development_dependency('rubocop')
|
|
33
33
|
spec.add_development_dependency('rubocop-rake')
|
|
34
|
+
spec.add_development_dependency('ruby-lint')
|
|
34
35
|
spec.add_development_dependency('solargraph')
|
|
35
36
|
spec.add_development_dependency('yard')
|
|
36
37
|
|
data/lib/cns/apibc.rb
CHANGED
|
@@ -38,7 +38,6 @@ module Cns
|
|
|
38
38
|
[]
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
# @example account_gm
|
|
42
41
|
# @example account_gm
|
|
43
42
|
# {
|
|
44
43
|
# account_name: '...',
|
|
@@ -128,7 +127,7 @@ module Cns
|
|
|
128
127
|
# @param [String] add endereco ETH
|
|
129
128
|
# @param [Integer] pag pagina transacoes
|
|
130
129
|
# @param [Array<Hash>] aes acumulador transacoes
|
|
131
|
-
# @return [Array<Hash>] lista
|
|
130
|
+
# @return [Array<Hash>] lista transacoes normais etherscan
|
|
132
131
|
def norml_es(add, pag = 0, aes = [])
|
|
133
132
|
res = JSON.parse(
|
|
134
133
|
conn_es.get('/api', action: 'txlist', offset: 10_000, address: add, page: pag += 1).body,
|
|
@@ -140,6 +139,73 @@ module Cns
|
|
|
140
139
|
aes
|
|
141
140
|
end
|
|
142
141
|
|
|
142
|
+
# @example inter_es
|
|
143
|
+
# {
|
|
144
|
+
# status: '1',
|
|
145
|
+
# message: 'OK',
|
|
146
|
+
# result: [
|
|
147
|
+
# {
|
|
148
|
+
# blockNumber: '15592786',
|
|
149
|
+
# timeStamp: '1663896779',
|
|
150
|
+
# hash: '0x...',
|
|
151
|
+
# from: '0x...',
|
|
152
|
+
# to: '0x...',
|
|
153
|
+
# value: '22000000000000000',
|
|
154
|
+
# contractAddress: '',
|
|
155
|
+
# input: '',
|
|
156
|
+
# type: 'call',
|
|
157
|
+
# gas: '2300',
|
|
158
|
+
# gasUsed: '0',
|
|
159
|
+
# traceId: '0_1_1',
|
|
160
|
+
# isError: '0',
|
|
161
|
+
# errCode: ''
|
|
162
|
+
# }
|
|
163
|
+
# ]
|
|
164
|
+
# }
|
|
165
|
+
# @param (see norml_es)
|
|
166
|
+
# @return [Array<Hash>] lista transacoes internas etherscan
|
|
167
|
+
def inter_es(add, pag = 0, aes = [])
|
|
168
|
+
res = JSON.parse(
|
|
169
|
+
conn_es.get('/api', action: 'txlistinternal', offset: 10_000, address: add, page: pag += 1).body,
|
|
170
|
+
symbolize_names: true
|
|
171
|
+
)[:result]
|
|
172
|
+
aes += res
|
|
173
|
+
res.count < 10_000 ? aes : inter_es(add, pag, aes)
|
|
174
|
+
rescue StandardError
|
|
175
|
+
aes
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# @example block_es
|
|
179
|
+
# {
|
|
180
|
+
# status: '1',
|
|
181
|
+
# message: 'OK',
|
|
182
|
+
# result: [
|
|
183
|
+
# { blockNumber: '15737070', timeStamp: '1665638459', blockReward: '8922867945448231' },
|
|
184
|
+
# { blockNumber: '15592786', timeStamp: '1663896779', blockReward: '44997990286623752' },
|
|
185
|
+
# { blockNumber: '15570222', timeStamp: '1663622819', blockReward: '261211525682683684' },
|
|
186
|
+
# { blockNumber: '15568554', timeStamp: '1663602539', blockReward: '41993833217879559' }
|
|
187
|
+
# ]
|
|
188
|
+
# }
|
|
189
|
+
# @param (see norml_es)
|
|
190
|
+
# @return [Array<Hash>] lista blocos etherscan
|
|
191
|
+
def block_es(add, pag = 0, aes = [])
|
|
192
|
+
res = JSON.parse(
|
|
193
|
+
conn_es.get(
|
|
194
|
+
'/api',
|
|
195
|
+
action: 'getminedblocks',
|
|
196
|
+
blocktype: 'blocks',
|
|
197
|
+
offset: 10_000,
|
|
198
|
+
address: add,
|
|
199
|
+
page: pag += 1
|
|
200
|
+
).body,
|
|
201
|
+
symbolize_names: true
|
|
202
|
+
)[:result]
|
|
203
|
+
aes += res
|
|
204
|
+
res.count < 10_000 ? aes : block_es(add, pag, aes)
|
|
205
|
+
rescue StandardError
|
|
206
|
+
aes
|
|
207
|
+
end
|
|
208
|
+
|
|
143
209
|
# @example token_es
|
|
144
210
|
# {
|
|
145
211
|
# status: '1',
|
|
@@ -170,7 +236,7 @@ module Cns
|
|
|
170
236
|
# ]
|
|
171
237
|
# }
|
|
172
238
|
# @param (see norml_es)
|
|
173
|
-
# @return [Array<Hash>] lista
|
|
239
|
+
# @return [Array<Hash>] lista token transfer events etherscan
|
|
174
240
|
def token_es(add, pag = 0, aes = [])
|
|
175
241
|
# registos duplicados aparecem em token events (ver exemplo acima)
|
|
176
242
|
# -quando ha erros na blockchain (acho)
|
|
@@ -258,7 +324,7 @@ module Cns
|
|
|
258
324
|
@conn_es ||=
|
|
259
325
|
Faraday.new(
|
|
260
326
|
url: 'https://api.etherscan.io',
|
|
261
|
-
params: { module: 'account', apikey: ENV
|
|
327
|
+
params: { module: 'account', apikey: ENV.fetch('ETHERSCAN_API_KEY', nil) },
|
|
262
328
|
headers: { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
|
263
329
|
) do |con|
|
|
264
330
|
con.request(:url_encoded)
|
data/lib/cns/beaconchain2.rb
CHANGED
|
@@ -16,11 +16,7 @@ module Cns
|
|
|
16
16
|
# @param [Hash] hjn dados juntos bigquery & beaconchain
|
|
17
17
|
# @return [String] texto formatado dum validador
|
|
18
18
|
def formata_validador(hjn)
|
|
19
|
-
format(
|
|
20
|
-
'%<s1>-5.5s %<s2>-34.34s ',
|
|
21
|
-
s1: hjn[:id],
|
|
22
|
-
s2: formata_endereco(hjn[:ax], 34)
|
|
23
|
-
) + formata_valores(hjn)
|
|
19
|
+
format('%<s1>-5.5s %<s2>-34.34s ', s1: hjn[:id], s2: formata_endereco(hjn[:ax], 34)) + formata_valores(hjn)
|
|
24
20
|
end
|
|
25
21
|
|
|
26
22
|
# @param (see formata_validador)
|
|
@@ -48,8 +44,12 @@ module Cns
|
|
|
48
44
|
# @param [Integer] max chars a mostrar
|
|
49
45
|
# @return [String] pubkey formatada
|
|
50
46
|
def formata_endereco(add, max)
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
return 'erro' if max < 7
|
|
48
|
+
|
|
49
|
+
max -= 2
|
|
50
|
+
ini = Integer(max / 2)
|
|
51
|
+
inf = max % 2
|
|
52
|
+
"#{add[0, ini - 3]}..#{add[-inf - ini - 3..]}"
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# @example
|
|
@@ -68,7 +68,7 @@ module Cns
|
|
|
68
68
|
format(
|
|
69
69
|
'%<vi>5i %<vl>17.6f %<ep>6i %<id>9i',
|
|
70
70
|
vi: idx,
|
|
71
|
-
vl: (hbh[:balance].to_d / 10**9).round(10),
|
|
71
|
+
vl: (hbh[:balance].to_d / (10**9)).round(10),
|
|
72
72
|
ep: epc,
|
|
73
73
|
id: itx(epc, idx)
|
|
74
74
|
)
|
data/lib/cns/bigquery1.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Cns
|
|
|
38
38
|
apimt.mostra_resumo
|
|
39
39
|
apies.mostra_resumo
|
|
40
40
|
apigm.mostra_resumo
|
|
41
|
-
apibc.mostra_resumo
|
|
41
|
+
# apibc.mostra_resumo
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# insere (caso existam) dados novos kraken/bitcoinde/paymium/therock/etherscan/greymass/beaconchain no bigquery
|
|
@@ -48,7 +48,7 @@ module Cns
|
|
|
48
48
|
processa_frmt
|
|
49
49
|
processa_eth
|
|
50
50
|
processa_eos
|
|
51
|
-
processa_bc
|
|
51
|
+
# processa_bc
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
private
|
|
@@ -71,9 +71,11 @@ module Cns
|
|
|
71
71
|
puts(format("%<n>4i LEDGER\tTHEROCK\t\tINSERIDAS mt", n: apimt.ledger.empty? ? 0 : dml(mtl_ins)))
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
# insere transacoes blockchain novas nas tabelas etht (norml), ethk (token)
|
|
74
|
+
# insere transacoes blockchain novas nas tabelas etht (norml), ethi (internas), ethp (block), ethk (token)
|
|
75
75
|
def processa_eth
|
|
76
|
-
puts(format("%<n>4i TRANSACOES\
|
|
76
|
+
puts(format("%<n>4i TRANSACOES ETH NORMAIS\tINSERIDAS etht", n: apies.novtx.empty? ? 0 : dml(etht_ins)))
|
|
77
|
+
puts(format("%<n>4i TRANSACOES ETH INTERNAS\tINSERIDAS ethi", n: apies.novix.empty? ? 0 : dml(ethi_ins)))
|
|
78
|
+
puts(format("%<n>4i TRANSACOES ETH BLOCK\tINSERIDAS ethp", n: apies.novpx.empty? ? 0 : dml(ethp_ins)))
|
|
77
79
|
puts(format("%<n>4i TOKENS\tETH\t\tINSERIDAS ethk", n: apies.novkx.empty? ? 0 : dml(ethk_ins)))
|
|
78
80
|
end
|
|
79
81
|
|
data/lib/cns/bigquery2.rb
CHANGED
|
@@ -24,6 +24,8 @@ module Cns
|
|
|
24
24
|
{
|
|
25
25
|
wb: sql("select * from #{BD}.walletEth order by 2"),
|
|
26
26
|
nt: sql("select itx,iax from #{BD}.ethtx"),
|
|
27
|
+
ni: sql("select itx,iax from #{BD}.ethix"),
|
|
28
|
+
np: sql("select itx,iax from #{BD}.ethpx"),
|
|
27
29
|
nk: sql("select itx,iax from #{BD}.ethkx")
|
|
28
30
|
},
|
|
29
31
|
ops
|
data/lib/cns/bigquery3.rb
CHANGED
|
@@ -16,6 +16,19 @@ module Cns
|
|
|
16
16
|
") VALUES#{apies.novtx.map { |obj| etht_1val(obj) }.join(',')}"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# @return [String] comando insert SQL formatado ethi (internas)
|
|
20
|
+
def ethi_ins
|
|
21
|
+
"insert #{BD}.ethi(blocknumber,timestamp,txhash,axfrom,axto,iax," \
|
|
22
|
+
'value,contractaddress,input,type,gas,gasused,traceid,iserror,errcode' \
|
|
23
|
+
") VALUES#{apies.novix.map { |obj| ethi_1val(obj) }.join(',')}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @return [String] comando insert SQL formatado ethp (block)
|
|
27
|
+
def ethp_ins
|
|
28
|
+
"insert #{BD}.ethp(blocknumber,timestamp,blockreward,iax" \
|
|
29
|
+
") VALUES#{apies.novpx.map { |obj| ethp_1val(obj) }.join(',')}"
|
|
30
|
+
end
|
|
31
|
+
|
|
19
32
|
# @return [String] comando insert SQL formatado ethk (token)
|
|
20
33
|
def ethk_ins
|
|
21
34
|
"insert #{BD}.ethk(blocknumber,timestamp,txhash,nonce,blockhash,transactionindex,axfrom,axto,iax," \
|
|
@@ -78,6 +91,47 @@ module Cns
|
|
|
78
91
|
"#{Integer(ops[:h][htx[:blockNumber]] || 0)})"
|
|
79
92
|
end
|
|
80
93
|
|
|
94
|
+
# @example (see Apibc#inter_es)
|
|
95
|
+
# @param [Hash] htx transacao internas etherscan
|
|
96
|
+
# @return [String] valores formatados ethi (internas parte1)
|
|
97
|
+
def ethi_1val(htx)
|
|
98
|
+
cta = htx[:contractAddress]
|
|
99
|
+
"(#{Integer(htx[:blockNumber])}," \
|
|
100
|
+
"#{Integer(htx[:timeStamp])}," \
|
|
101
|
+
"'#{htx[:hash]}'," \
|
|
102
|
+
"'#{htx[:from]}'," \
|
|
103
|
+
"'#{htx[:to]}'," \
|
|
104
|
+
"'#{htx[:iax]}'," \
|
|
105
|
+
"cast('#{htx[:value]}' as numeric)," \
|
|
106
|
+
"#{cta.length.zero? ? 'null' : "'#{cta}'"}," \
|
|
107
|
+
"#{ethi_2val(htx)}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# @param (see ethi_1val)
|
|
111
|
+
# @return [String] valores formatados ethi (internas parte2)
|
|
112
|
+
def ethi_2val(htx)
|
|
113
|
+
inp = htx[:input]
|
|
114
|
+
tid = htx[:traceId]
|
|
115
|
+
txr = htx[:errCode]
|
|
116
|
+
"#{inp.length.zero? ? 'null' : "'#{inp}'"}," \
|
|
117
|
+
"'#{htx[:type]}'," \
|
|
118
|
+
"cast('#{htx[:gas]}' as numeric)," \
|
|
119
|
+
"cast('#{htx[:gasUsed]}' as numeric)," \
|
|
120
|
+
"#{tid.length.zero? ? 'null' : "'#{tid}'"}," \
|
|
121
|
+
"#{Integer(htx[:isError])}," \
|
|
122
|
+
"#{txr.length.zero? ? 'null' : txr})"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @example (see Apibc#block_es)
|
|
126
|
+
# @param [Hash] htx transacao block etherscan
|
|
127
|
+
# @return [String] valores formatados ethi (block parte1)
|
|
128
|
+
def ethp_1val(htx)
|
|
129
|
+
"(#{Integer(htx[:blockNumber])}," \
|
|
130
|
+
"#{Integer(htx[:timeStamp])}," \
|
|
131
|
+
"cast('#{htx[:blockReward]}' as numeric)," \
|
|
132
|
+
"'#{htx[:iax]}')"
|
|
133
|
+
end
|
|
134
|
+
|
|
81
135
|
# @example (see Apibc#token_es)
|
|
82
136
|
# @param [Hash] hkx token event etherscan
|
|
83
137
|
# @return [String] valores formatados ethk (token parte1)
|
data/lib/cns/etherscan1.rb
CHANGED
|
@@ -32,6 +32,16 @@ module Cns
|
|
|
32
32
|
@novtx ||= bcd.map { |obc| obc[:tx].select { |obj| idt.include?(obj[:itx]) } }.flatten
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
# @return [Array<Hash>] lista transacoes internas novas
|
|
36
|
+
def novix
|
|
37
|
+
@novix ||= bcd.map { |obc| obc[:ix].select { |obj| idi.include?(obj[:itx]) } }.flatten
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [Array<Hash>] lista transacoes block novas
|
|
41
|
+
def novpx
|
|
42
|
+
@novpx ||= bcd.map { |obc| obc[:px].select { |obj| idp.include?(obj[:itx]) } }.flatten
|
|
43
|
+
end
|
|
44
|
+
|
|
35
45
|
# @return [Array<Hash>] lista transacoes token novas
|
|
36
46
|
def novkx
|
|
37
47
|
@novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten
|
|
@@ -58,6 +68,18 @@ module Cns
|
|
|
58
68
|
(ops[:t] ? [] : bqd[:nt].map { |obq| obq[:itx] })
|
|
59
69
|
end
|
|
60
70
|
|
|
71
|
+
# @return [Array<Integer>] lista indices transacoes internas novas
|
|
72
|
+
def idi
|
|
73
|
+
@idi ||= bcd.map { |obc| obc[:ix].map { |obj| obj[:itx] } }.flatten -
|
|
74
|
+
(ops[:t] ? [] : bqd[:ni].map { |obq| obq[:itx] })
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @return [Array<Integer>] lista indices transacoes block novas
|
|
78
|
+
def idp
|
|
79
|
+
@idp ||= bcd.map { |obc| obc[:px].map { |obj| obj[:itx] } }.flatten -
|
|
80
|
+
(ops[:t] ? [] : bqd[:np].map { |obq| obq[:itx] })
|
|
81
|
+
end
|
|
82
|
+
|
|
61
83
|
# @return [Array<Integer>] lista indices transacoes token novas
|
|
62
84
|
def idk
|
|
63
85
|
@idk ||= bcd.map { |obc| obc[:kx].map { |obj| obj[:itx] } }.flatten -
|
|
@@ -71,8 +93,10 @@ module Cns
|
|
|
71
93
|
acc = abc[:account].downcase
|
|
72
94
|
{
|
|
73
95
|
ax: acc,
|
|
74
|
-
sl: (abc[:balance].to_d / 10**18)
|
|
96
|
+
sl: (abc[:balance].to_d / 10**18),
|
|
75
97
|
tx: filtrar_tx(acc, api.norml_es(acc)),
|
|
98
|
+
ix: filtrar_tx(acc, api.inter_es(acc)),
|
|
99
|
+
px: filtrar_px(acc, api.block_es(acc)),
|
|
76
100
|
kx: filtrar_tx(acc, api.token_es(acc))
|
|
77
101
|
}
|
|
78
102
|
end
|
|
@@ -86,9 +110,13 @@ module Cns
|
|
|
86
110
|
ax: xbq = wbq[:ax],
|
|
87
111
|
bs: wbq[:sl],
|
|
88
112
|
bt: bqd[:nt].select { |ont| ont[:iax] == xbq },
|
|
113
|
+
bi: bqd[:ni].select { |oni| oni[:iax] == xbq },
|
|
114
|
+
bp: bqd[:np].select { |onp| onp[:iax] == xbq },
|
|
89
115
|
bk: bqd[:nk].select { |onk| onk[:iax] == xbq },
|
|
90
116
|
es: hbc[:sl],
|
|
91
117
|
et: hbc[:tx],
|
|
118
|
+
ei: hbc[:ix],
|
|
119
|
+
ep: hbc[:px],
|
|
92
120
|
ek: hbc[:kx]
|
|
93
121
|
}
|
|
94
122
|
end
|
|
@@ -103,11 +131,29 @@ module Cns
|
|
|
103
131
|
.map { |omp| omp.delete_if { |key, _| DL.include?(key) }.merge(itx: Integer(omp[:blockNumber]), iax: add) }
|
|
104
132
|
end
|
|
105
133
|
|
|
134
|
+
# @param add (see Apibc#norml_es)
|
|
135
|
+
# @param [Array<Hash>] ary lista blocks events
|
|
136
|
+
# @return [Array<Hash>] lista blocks events filtrada
|
|
137
|
+
def filtrar_px(add, ary)
|
|
138
|
+
# adiciona chave indice itx & adiciona identificador da carteira iax
|
|
139
|
+
ary.map { |omp| omp.merge(itx: Integer(omp[:blockNumber]), iax: add) }
|
|
140
|
+
end
|
|
141
|
+
|
|
106
142
|
# @return [Array<Hash>] lista ordenada transacoes normais novas
|
|
107
143
|
def sortx
|
|
108
144
|
novtx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
|
109
145
|
end
|
|
110
146
|
|
|
147
|
+
# @return [Array<Hash>] lista ordenada transacoes internas novas
|
|
148
|
+
def sorix
|
|
149
|
+
novix.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# @return [Array<Hash>] lista ordenada transacoes block novas
|
|
153
|
+
def sorpx
|
|
154
|
+
novpx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
|
155
|
+
end
|
|
156
|
+
|
|
111
157
|
# @return [Array<Hash>] lista ordenada transacoes token novas
|
|
112
158
|
def sorkx
|
|
113
159
|
novkx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
|
data/lib/cns/etherscan2.rb
CHANGED
|
@@ -8,9 +8,11 @@ module Cns
|
|
|
8
8
|
def mostra_resumo
|
|
9
9
|
return unless dados.count.positive?
|
|
10
10
|
|
|
11
|
-
puts("\nid address
|
|
11
|
+
puts("\nid address etherscan tn ti tb tk bigquery tn ti tb tk")
|
|
12
12
|
dados.each { |obj| puts(formata_carteira(obj)) }
|
|
13
13
|
mostra_transacao_norml
|
|
14
|
+
mostra_transacao_inter
|
|
15
|
+
mostra_transacao_block
|
|
14
16
|
mostra_transacao_token
|
|
15
17
|
mostra_configuracao_ajuste_dias
|
|
16
18
|
end
|
|
@@ -19,9 +21,9 @@ module Cns
|
|
|
19
21
|
# @return [String] texto formatado duma carteira
|
|
20
22
|
def formata_carteira(hjn)
|
|
21
23
|
format(
|
|
22
|
-
'%<s1>-6.6s %<s2>-
|
|
24
|
+
'%<s1>-6.6s %<s2>-20.20s ',
|
|
23
25
|
s1: hjn[:id],
|
|
24
|
-
s2:
|
|
26
|
+
s2: formata_enderec1(hjn[:ax], 20)
|
|
25
27
|
) + formata_valores(hjn)
|
|
26
28
|
end
|
|
27
29
|
|
|
@@ -29,13 +31,17 @@ module Cns
|
|
|
29
31
|
# @return [String] texto formatado valores duma carteira
|
|
30
32
|
def formata_valores(hjn)
|
|
31
33
|
format(
|
|
32
|
-
'%<v1>
|
|
34
|
+
'%<v1>12.6f %<n1>2i %<n2>2i %<n3>2i %<n4>2i %<v2>12.6f %<n5>2i %<n6>2i %<n7>2i %<n8>2i %<ok>-3s',
|
|
33
35
|
v1: hjn[:es],
|
|
34
36
|
n1: hjn[:et].count,
|
|
35
|
-
|
|
37
|
+
n2: hjn[:ei].count,
|
|
38
|
+
n3: hjn[:ep].count,
|
|
39
|
+
n4: hjn[:ek].count,
|
|
36
40
|
v2: hjn[:bs],
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
n5: hjn[:bt].count,
|
|
42
|
+
n6: hjn[:bi].count,
|
|
43
|
+
n7: hjn[:bp].count,
|
|
44
|
+
n8: hjn[:bk].count,
|
|
39
45
|
ok: ok?(hjn) ? 'OK' : 'NOK'
|
|
40
46
|
)
|
|
41
47
|
end
|
|
@@ -43,7 +49,7 @@ module Cns
|
|
|
43
49
|
# @param (see formata_carteira)
|
|
44
50
|
# @return [Boolean] carteira tem transacoes novas(sim=NOK, nao=OK)?
|
|
45
51
|
def ok?(hjn)
|
|
46
|
-
hjn[:bs] == hjn[:es] && hjn[:bt].count == hjn[:et].count && hjn[:bk].count == hjn[:ek].count
|
|
52
|
+
hjn[:bs].round(6) == hjn[:es].round(6) && hjn[:bt].count == hjn[:et].count && hjn[:bi].count == hjn[:ei].count && hjn[:bp].count == hjn[:ep].count && hjn[:bk].count == hjn[:ek].count
|
|
47
53
|
end
|
|
48
54
|
|
|
49
55
|
# @example ether address inicio..fim
|
|
@@ -51,10 +57,29 @@ module Cns
|
|
|
51
57
|
# @param add (see filtrar_tx)
|
|
52
58
|
# @param [Integer] max chars a mostrar
|
|
53
59
|
# @return [String] endereco formatado
|
|
54
|
-
def
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
max
|
|
60
|
+
def formata_enderec1(add, max)
|
|
61
|
+
return 'erro' if max < 7
|
|
62
|
+
|
|
63
|
+
max -= 2
|
|
64
|
+
ini = Integer(max / 2)
|
|
65
|
+
inf = max % 2
|
|
66
|
+
"#{add[0, ini - 3]}..#{add[-inf - ini - 3..]}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @example ether address inicio..fim
|
|
70
|
+
# me-app..4b437776403d
|
|
71
|
+
# @param add (see filtrar_tx)
|
|
72
|
+
# @param [Integer] max chars a mostrar
|
|
73
|
+
# @return [String] endereco formatado
|
|
74
|
+
def formata_enderec2(add, max)
|
|
75
|
+
return 'erro' if max < 7
|
|
76
|
+
|
|
77
|
+
max -= 2
|
|
78
|
+
ini = Integer(max / 2)
|
|
79
|
+
inf = max % 2
|
|
80
|
+
hid = bqd[:wb].select { |obj| obj[:ax] == add }.first
|
|
81
|
+
ndd = hid ? hid[:id] + '-' + add : add
|
|
82
|
+
"#{ndd[0, ini - 3]}..#{ndd[-inf - ini - 3..]}"
|
|
58
83
|
end
|
|
59
84
|
|
|
60
85
|
# @example (see Apibc#norml_es)
|
|
@@ -64,13 +89,26 @@ module Cns
|
|
|
64
89
|
format(
|
|
65
90
|
'%<bn>9i %<fr>-20.20s %<to>-20.20s %<dt>10.10s %<vl>17.6f',
|
|
66
91
|
bn: htx[:blockNumber],
|
|
67
|
-
fr:
|
|
68
|
-
to:
|
|
92
|
+
fr: formata_enderec2(htx[:from], 20),
|
|
93
|
+
to: formata_enderec2(htx[:to], 20),
|
|
69
94
|
dt: Time.at(Integer(htx[:timeStamp])),
|
|
70
95
|
vl: (htx[:value].to_d / 10**18).round(10)
|
|
71
96
|
)
|
|
72
97
|
end
|
|
73
98
|
|
|
99
|
+
# @example (see Apibc#block_es)
|
|
100
|
+
# @param [Hash] htx transacao block etherscan
|
|
101
|
+
# @return [String] texto formatado transacao block etherscan
|
|
102
|
+
def formata_transacao_block(htx)
|
|
103
|
+
format(
|
|
104
|
+
'%<bn>9i %<fr>-41.41s %<dt>10.10s %<vl>17.6f',
|
|
105
|
+
bn: htx[:blockNumber],
|
|
106
|
+
fr: formata_enderec2(htx[:iax], 41),
|
|
107
|
+
dt: Time.at(Integer(htx[:timeStamp])),
|
|
108
|
+
vl: (htx[:blockReward].to_d / 10**18).round(10)
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
|
|
74
112
|
# @example (see Apibc#token_es)
|
|
75
113
|
# @param [Hash] hkx transacao token etherscan
|
|
76
114
|
# @return [String] texto formatado transacao token etherscan
|
|
@@ -78,8 +116,8 @@ module Cns
|
|
|
78
116
|
format(
|
|
79
117
|
'%<bn>9i %<fr>-20.20s %<to>-20.20s %<dt>10.10s %<vl>11.3f %<sy>-5.5s',
|
|
80
118
|
bn: hkx[:blockNumber],
|
|
81
|
-
fr:
|
|
82
|
-
to:
|
|
119
|
+
fr: formata_enderec2(hkx[:from], 20),
|
|
120
|
+
to: formata_enderec2(hkx[:to], 20),
|
|
83
121
|
dt: Time.at(Integer(hkx[:timeStamp])),
|
|
84
122
|
vl: (hkx[:value].to_d / 10**18).round(10),
|
|
85
123
|
sy: hkx[:tokenSymbol]
|
|
@@ -94,6 +132,22 @@ module Cns
|
|
|
94
132
|
sortx.each { |obj| puts(formata_transacao_norml(obj)) }
|
|
95
133
|
end
|
|
96
134
|
|
|
135
|
+
# @return [String] texto transacoes internas
|
|
136
|
+
def mostra_transacao_inter
|
|
137
|
+
return unless ops[:v] && novix.count.positive?
|
|
138
|
+
|
|
139
|
+
puts("\ntx intern from to data valor")
|
|
140
|
+
sorix.each { |obj| puts(formata_transacao_norml(obj)) }
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @return [String] texto transacoes block
|
|
144
|
+
def mostra_transacao_block
|
|
145
|
+
return unless ops[:v] && novpx.count.positive?
|
|
146
|
+
|
|
147
|
+
puts("\ntx block address data valor")
|
|
148
|
+
sorpx.each { |obj| puts(formata_transacao_block(obj)) }
|
|
149
|
+
end
|
|
150
|
+
|
|
97
151
|
# @return [String] texto transacoes token
|
|
98
152
|
def mostra_transacao_token
|
|
99
153
|
return unless ops[:v] && novkx.count.positive?
|
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: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
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: 2022-10-
|
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: ruby-lint
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: solargraph
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|