cns 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba2ef03e5bc93d772b32c6bbf375ae4322778e4ff00ca43fddf5c041924f4597
4
- data.tar.gz: 63c40eebbcb8ca9425153db0a6113659b1ef7f3b16f00b3faa7153e1af04d79d
3
+ metadata.gz: 628583895b421b1b5d84af2753d24d28d4c0f2d1e4ed4f363160ef07b1d0e23d
4
+ data.tar.gz: 7e14420b81120d01f9abe1171fc248949ff8ffbeff2c698901dc0d60d7d68ad5
5
5
  SHA512:
6
- metadata.gz: c32420b68e4ab9e8b4015b2ad2bf55d6b668da22a7ef58e71b57deb6a908961f2050057c3d7bb80b189fc13b365d239282e9aefce7beca59a7534388431cd2dd
7
- data.tar.gz: bb370c40be2ed5ae0b3da752270ddbe44746e9f584c1a14715e23a76a5aa0b3c5431e9587504c64d074ad49c89c65b78bda6cad8580527842f1d1862e4940836
6
+ metadata.gz: 2d0f31b4f43dcef2abcfddce96174ee06de7650fa5413390e126bd532056df1349f3e438f13759651b35cf666e78e688a6378f92f3dff782a0a14f51ff1c575c
7
+ data.tar.gz: 89e7998c421ad34256815ca720f02814875a2d58958c97604c24b3313388e9d6c324ba67473784299a47c9fb90b76af8806bad80563bd985fd3d56a588110029
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cns (0.3.2)
4
+ cns (0.3.4)
5
5
  curb
6
6
  faraday
7
7
  google-cloud-bigquery
@@ -10,22 +10,22 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.8.1)
13
+ addressable (2.8.4)
14
14
  public_suffix (>= 2.0.2, < 6.0)
15
15
  ast (2.4.2)
16
16
  backport (1.2.0)
17
- benchmark (0.2.0)
18
- concurrent-ruby (1.1.10)
19
- curb (1.0.1)
17
+ benchmark (0.2.1)
18
+ concurrent-ruby (1.2.2)
19
+ curb (1.0.5)
20
20
  declarative (0.0.20)
21
21
  e2mmap (0.1.0)
22
- faraday (2.6.0)
22
+ faraday (2.7.10)
23
23
  faraday-net_http (>= 2.0, < 3.1)
24
24
  ruby2_keywords (>= 0.0.4)
25
25
  faraday-net_http (3.0.2)
26
- google-apis-bigquery_v2 (0.42.0)
27
- google-apis-core (>= 0.9.0, < 2.a)
28
- google-apis-core (0.9.1)
26
+ google-apis-bigquery_v2 (0.55.0)
27
+ google-apis-core (>= 0.11.0, < 2.a)
28
+ google-apis-core (0.11.0)
29
29
  addressable (~> 2.5, >= 2.5.1)
30
30
  googleauth (>= 0.16.2, < 2.a)
31
31
  httpclient (>= 2.8.1, < 3.a)
@@ -34,7 +34,7 @@ GEM
34
34
  retriable (>= 2.0, < 4.a)
35
35
  rexml
36
36
  webrick
37
- google-cloud-bigquery (1.39.0)
37
+ google-cloud-bigquery (1.43.1)
38
38
  concurrent-ruby (~> 1.0)
39
39
  google-apis-bigquery_v2 (~> 0.1)
40
40
  google-cloud-core (~> 1.6)
@@ -45,8 +45,8 @@ GEM
45
45
  google-cloud-errors (~> 1.0)
46
46
  google-cloud-env (1.6.0)
47
47
  faraday (>= 0.17.3, < 3.0)
48
- google-cloud-errors (1.3.0)
49
- googleauth (1.3.0)
48
+ google-cloud-errors (1.3.1)
49
+ googleauth (1.6.0)
50
50
  faraday (>= 0.17.3, < 3.a)
51
51
  jwt (>= 1.4, < 3.0)
52
52
  memoist (~> 0.16)
@@ -54,8 +54,8 @@ GEM
54
54
  os (>= 0.9, < 2.0)
55
55
  signet (>= 0.16, < 2.a)
56
56
  httpclient (2.8.3)
57
- jaro_winkler (1.5.4)
58
- jwt (2.5.0)
57
+ jaro_winkler (1.5.6)
58
+ jwt (2.7.1)
59
59
  kramdown (2.4.0)
60
60
  rexml
61
61
  kramdown-parser-gfm (1.1.0)
@@ -64,15 +64,15 @@ GEM
64
64
  memoist (0.16.2)
65
65
  mini_mime (1.1.2)
66
66
  multi_json (1.15.0)
67
- nokogiri (1.13.9-x86_64-linux)
67
+ nokogiri (1.15.3-x86_64-linux)
68
68
  racc (~> 1.4)
69
69
  os (1.1.4)
70
- parallel (1.22.1)
70
+ parallel (1.23.0)
71
71
  parser (2.7.2.0)
72
72
  ast (~> 2.4.1)
73
73
  psych (3.3.4)
74
- public_suffix (5.0.0)
75
- racc (1.6.0)
74
+ public_suffix (5.0.1)
75
+ racc (1.7.1)
76
76
  rainbow (3.1.1)
77
77
  rake (12.3.3)
78
78
  reek (6.0.2)
@@ -80,7 +80,7 @@ GEM
80
80
  parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
81
81
  psych (~> 3.1)
82
82
  rainbow (>= 2.0, < 4.0)
83
- regexp_parser (2.6.0)
83
+ regexp_parser (2.8.1)
84
84
  representable (3.2.0)
85
85
  declarative (< 0.1.0)
86
86
  trailblazer-option (>= 0.1.1, < 0.2.0)
@@ -105,7 +105,7 @@ GEM
105
105
  ruby-lint (2.3.1)
106
106
  parser (~> 2.2)
107
107
  slop (~> 3.4, >= 3.4.7)
108
- ruby-progressbar (1.11.0)
108
+ ruby-progressbar (1.13.0)
109
109
  ruby2_keywords (0.0.5)
110
110
  signet (0.17.0)
111
111
  addressable (~> 2.8)
@@ -127,14 +127,13 @@ GEM
127
127
  thor (~> 1.0)
128
128
  tilt (~> 2.0)
129
129
  yard (~> 0.9, >= 0.9.24)
130
- thor (1.2.1)
131
- tilt (2.0.11)
130
+ thor (1.2.2)
131
+ tilt (2.2.0)
132
132
  trailblazer-option (0.1.2)
133
133
  uber (0.1.0)
134
134
  unicode-display_width (1.8.0)
135
- webrick (1.7.0)
136
- yard (0.9.28)
137
- webrick (~> 1.7.0)
135
+ webrick (1.8.1)
136
+ yard (0.9.34)
138
137
 
139
138
  PLATFORMS
140
139
  x86_64-linux
data/lib/cns/apibc.rb CHANGED
@@ -206,6 +206,40 @@ module Cns
206
206
  aes
207
207
  end
208
208
 
209
+ # @example withw_es
210
+ # {
211
+ # "status":"1",
212
+ # "message":"OK",
213
+ # "result":[
214
+ # {
215
+ # "withdrawalIndex":"14",
216
+ # "validatorIndex":"119023",
217
+ # "address":"0xb9d7934878b5fb9610b3fe8a5e441e8fad7e293f",
218
+ # "amount":"3244098967",
219
+ # "blockNumber":"17034877",
220
+ # "timestamp":"1681338599"
221
+ # }
222
+ # ]
223
+ # }
224
+ # @param (see norml_es)
225
+ # @return [Array<Hash>] lista blocos etherscan
226
+ def withw_es(add, pag = 0, aes = [])
227
+ res = JSON.parse(
228
+ conn_es.get(
229
+ '/api',
230
+ action: 'txsBeaconWithdrawal',
231
+ address: add,
232
+ offset: 10_000,
233
+ page: pag += 1
234
+ ).body,
235
+ symbolize_names: true
236
+ )[:result]
237
+ aes += res
238
+ res.count < 10_000 ? aes : withw_es(add, pag, aes)
239
+ rescue StandardError
240
+ aes
241
+ end
242
+
209
243
  # @example token_es
210
244
  # {
211
245
  # status: '1',
data/lib/cns/bigquery1.rb CHANGED
@@ -34,21 +34,21 @@ module Cns
34
34
  def mostra_tudo
35
35
  apius.mostra_resumo
36
36
  apide.mostra_resumo
37
- apifr.mostra_resumo
38
- apimt.mostra_resumo
37
+ #apifr.mostra_resumo
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
45
45
  def processa_tudo
46
46
  processa_us
47
47
  processa_de
48
- processa_frmt
48
+ #processa_frmt
49
49
  processa_eth
50
50
  processa_eos
51
- # processa_bc
51
+ #processa_bc
52
52
  end
53
53
 
54
54
  # insere transacoes blockchain novas nas tabelas etht (norml), ethi (internas), ethp (block), ethk (token)
@@ -56,6 +56,7 @@ module Cns
56
56
  puts(format("%<n>4i TRANSACOES ETH NORMAIS\tINSERIDAS etht", n: apies.novtx.empty? ? 0 : dml(etht_ins)))
57
57
  puts(format("%<n>4i TRANSACOES ETH INTERNAS\tINSERIDAS ethi", n: apies.novix.empty? ? 0 : dml(ethi_ins)))
58
58
  puts(format("%<n>4i TRANSACOES ETH BLOCK\tINSERIDAS ethp", n: apies.novpx.empty? ? 0 : dml(ethp_ins)))
59
+ puts(format("%<n>4i TRANSACOES ETH WITHDRAWALS\tINSERIDAS ethw", n: apies.novwx.empty? ? 0 : dml(ethw_ins)))
59
60
  puts(format("%<n>4i TOKENS\tETH\t\tINSERIDAS ethk", n: apies.novkx.empty? ? 0 : dml(ethk_ins)))
60
61
  end
61
62
 
data/lib/cns/bigquery2.rb CHANGED
@@ -26,6 +26,7 @@ module Cns
26
26
  nt: sql("select itx,iax from #{BD}.ethtx"),
27
27
  ni: sql("select itx,iax from #{BD}.ethix"),
28
28
  np: sql("select itx,iax from #{BD}.ethpx"),
29
+ nw: sql("select itx,iax from #{BD}.ethwx"),
29
30
  nk: sql("select itx,iax from #{BD}.ethkx")
30
31
  },
31
32
  ops
data/lib/cns/bigquery3.rb CHANGED
@@ -29,6 +29,12 @@ module Cns
29
29
  ") VALUES#{apies.novpx.map { |obj| ethp_1val(obj) }.join(',')}"
30
30
  end
31
31
 
32
+ # @return [String] comando insert SQL formatado ethw (withdrawals)
33
+ def ethw_ins
34
+ "insert #{BD}.ethw(withdrawalindex,validatorindex,address,amount,blocknumber,timestamp" \
35
+ ") VALUES#{apies.novwx.map { |obj| ethw_1val(obj) }.join(',')}"
36
+ end
37
+
32
38
  # @return [String] comando insert SQL formatado ethk (token)
33
39
  def ethk_ins
34
40
  "insert #{BD}.ethk(blocknumber,timestamp,txhash,nonce,blockhash,transactionindex,axfrom,axto,iax," \
@@ -132,6 +138,18 @@ module Cns
132
138
  "'#{htx[:iax]}')"
133
139
  end
134
140
 
141
+ # @example (see Apibc#block_es)
142
+ # @param [Hash] htx transacao withdrawals etherscan
143
+ # @return [String] valores formatados ethi (withdrawals parte1)
144
+ def ethw_1val(htx)
145
+ "(#{Integer(htx[:withdrawalIndex])}," \
146
+ "#{Integer(htx[:validatorIndex])}," \
147
+ "'#{htx[:address]}'," \
148
+ "cast('#{htx[:amount]}' as numeric)," \
149
+ "#{Integer(htx[:blockNumber])}," \
150
+ "#{Integer(htx[:timestamp])})"
151
+ end
152
+
135
153
  # @example (see Apibc#token_es)
136
154
  # @param [Hash] hkx token event etherscan
137
155
  # @return [String] valores formatados ethk (token parte1)
@@ -42,6 +42,11 @@ module Cns
42
42
  @novpx ||= bcd.map { |obc| obc[:px].select { |obj| idp.include?(obj[:itx]) } }.flatten
43
43
  end
44
44
 
45
+ # @return [Array<Hash>] lista transacoes withdrawals novas
46
+ def novwx
47
+ @novwx ||= bcd.map { |obc| obc[:wx].select { |obj| idw.include?(obj[:itx]) } }.flatten
48
+ end
49
+
45
50
  # @return [Array<Hash>] lista transacoes token novas
46
51
  def novkx
47
52
  @novkx ||= bcd.map { |obc| obc[:kx].select { |obj| idk.include?(obj[:itx]) } }.flatten
@@ -80,6 +85,12 @@ module Cns
80
85
  (ops[:t] ? [] : bqd[:np].map { |obq| obq[:itx] })
81
86
  end
82
87
 
88
+ # @return [Array<Integer>] lista indices transacoes withdrawals novas
89
+ def idw
90
+ @idw ||= bcd.map { |obc| obc[:wx].map { |obj| obj[:itx] } }.flatten -
91
+ (ops[:t] ? [] : bqd[:nw].map { |obq| obq[:itx] })
92
+ end
93
+
83
94
  # @return [Array<Integer>] lista indices transacoes token novas
84
95
  def idk
85
96
  @idk ||= bcd.map { |obc| obc[:kx].map { |obj| obj[:itx] } }.flatten -
@@ -97,6 +108,7 @@ module Cns
97
108
  tx: filtrar_tx(acc, api.norml_es(acc)),
98
109
  ix: filtrar_tx(acc, api.inter_es(acc)),
99
110
  px: filtrar_px(acc, api.block_es(acc)),
111
+ wx: filtrar_px(acc, api.withw_es(acc)),
100
112
  kx: filtrar_tx(acc, api.token_es(acc))
101
113
  }
102
114
  end
@@ -112,11 +124,13 @@ module Cns
112
124
  bt: bqd[:nt].select { |ont| ont[:iax] == xbq },
113
125
  bi: bqd[:ni].select { |oni| oni[:iax] == xbq },
114
126
  bp: bqd[:np].select { |onp| onp[:iax] == xbq },
127
+ bw: bqd[:nw].select { |onw| onw[:iax] == xbq },
115
128
  bk: bqd[:nk].select { |onk| onk[:iax] == xbq },
116
129
  es: hbc[:sl],
117
130
  et: hbc[:tx],
118
131
  ei: hbc[:ix],
119
132
  ep: hbc[:px],
133
+ ew: hbc[:wx],
120
134
  ek: hbc[:kx]
121
135
  }
122
136
  end
@@ -154,6 +168,11 @@ module Cns
154
168
  novpx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
155
169
  end
156
170
 
171
+ # @return [Array<Hash>] lista ordenada transacoes withdrawals novas
172
+ def sorwx
173
+ novwx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
174
+ end
175
+
157
176
  # @return [Array<Hash>] lista ordenada transacoes token novas
158
177
  def sorkx
159
178
  novkx.sort { |ant, prx| ant[:itx] <=> prx[:itx] }
@@ -8,12 +8,13 @@ module Cns
8
8
  def mostra_resumo
9
9
  return unless dados.count.positive?
10
10
 
11
- puts("\nid address etherscan tn ti tb tk bigquery tn ti tb tk")
11
+ puts("\nid address etherscan tn ti tb tk tw bigquery tn ti tb tk tw")
12
12
  dados.each { |obj| puts(formata_carteira(obj)) }
13
13
  mostra_transacao_norml
14
14
  mostra_transacao_inter
15
15
  mostra_transacao_block
16
16
  mostra_transacao_token
17
+ mostra_transacao_withw
17
18
  mostra_configuracao_ajuste_dias
18
19
  end
19
20
 
@@ -21,9 +22,9 @@ module Cns
21
22
  # @return [String] texto formatado duma carteira
22
23
  def formata_carteira(hjn)
23
24
  format(
24
- '%<s1>-6.6s %<s2>-20.20s ',
25
+ '%<s1>-6.6s %<s2>-16.16s ',
25
26
  s1: hjn[:id],
26
- s2: formata_enderec1(hjn[:ax], 20)
27
+ s2: formata_enderec1(hjn[:ax], 16)
27
28
  ) + formata_valores(hjn)
28
29
  end
29
30
 
@@ -31,17 +32,19 @@ module Cns
31
32
  # @return [String] texto formatado valores duma carteira
32
33
  def formata_valores(hjn)
33
34
  format(
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',
35
+ '%<v1>12.6f %<n1>3i %<n2>2i %<n3>2i %<n4>2i %<w1>3i %<v2>12.6f %<n5>3i %<n6>2i %<n7>2i %<n8>2i %<w2>3i %<ok>-3s',
35
36
  v1: hjn[:es],
36
37
  n1: hjn[:et].count,
37
38
  n2: hjn[:ei].count,
38
39
  n3: hjn[:ep].count,
39
40
  n4: hjn[:ek].count,
41
+ w1: hjn[:ew].count,
40
42
  v2: hjn[:bs],
41
43
  n5: hjn[:bt].count,
42
44
  n6: hjn[:bi].count,
43
45
  n7: hjn[:bp].count,
44
46
  n8: hjn[:bk].count,
47
+ w2: hjn[:bw].count,
45
48
  ok: ok?(hjn) ? 'OK' : 'NOK'
46
49
  )
47
50
  end
@@ -49,7 +52,7 @@ module Cns
49
52
  # @param (see formata_carteira)
50
53
  # @return [Boolean] carteira tem transacoes novas(sim=NOK, nao=OK)?
51
54
  def ok?(hjn)
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
55
+ 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 && hjn[:bw].count == hjn[:ew].count
53
56
  end
54
57
 
55
58
  # @example ether address inicio..fim
@@ -61,7 +64,7 @@ module Cns
61
64
  return 'erro' if max < 7
62
65
 
63
66
  max -= 2
64
- ini = Integer(max / 2)
67
+ ini = Integer(max / 2) + 3
65
68
  inf = max % 2
66
69
  "#{add[0, ini - 3]}..#{add[-inf - ini - 3..]}"
67
70
  end
@@ -124,6 +127,19 @@ module Cns
124
127
  )
125
128
  end
126
129
 
130
+ # @example (see Apibc#block_es)
131
+ # @param [Hash] htx transacao withdrawals etherscan
132
+ # @return [String] texto formatado transacao withdrawals etherscan
133
+ def formata_transacao_withw(htx)
134
+ format(
135
+ '%<vi>9i %<bn>9i %<dt>10.10s %<vl>10.6f',
136
+ vi: htx[:validatorIndex],
137
+ bn: htx[:blockNumber],
138
+ dt: Time.at(Integer(htx[:timestamp])),
139
+ vl: (htx[:amount].to_d / 10**9).round(10)
140
+ )
141
+ end
142
+
127
143
  # @return [String] texto transacoes normais
128
144
  def mostra_transacao_norml
129
145
  return unless ops[:v] && novtx.count.positive?
@@ -156,6 +172,14 @@ module Cns
156
172
  sorkx.each { |obj| puts(formata_transacao_token(obj)) }
157
173
  end
158
174
 
175
+ # @return [String] texto transacoes withdrawals
176
+ def mostra_transacao_withw
177
+ return unless ops[:v] && novwx.count.positive?
178
+
179
+ puts("\nvalidator block data valor")
180
+ sorwx.each { |obj| puts(formata_transacao_withw(obj)) }
181
+ end
182
+
159
183
  # @return [String] texto configuracao ajuste dias das transacoes (normais & token)
160
184
  def mostra_configuracao_ajuste_dias
161
185
  return unless (novtx.count + novkx.count).positive?
data/lib/cns/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cns
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.4'
5
5
  end
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.2
4
+ version: 0.3.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: 2022-11-14 00:00:00.000000000 Z
11
+ date: 2023-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler