cns 0.8.10 → 0.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 867a92f29645226b50d14524ebe09fac049968d037d99427778742a92e8fba1c
4
- data.tar.gz: '03930aae6c757152fcaf20f6c02c509819b6b53b0941e8f4ddfa9b05370c1d22'
3
+ metadata.gz: fff5558da7a0b92a4511bf3f73b8330d3ad59d92d46c76b64a70bfd19e3dfd1e
4
+ data.tar.gz: eafa8884b41f68f83fa20b547474c7a0717281f8c47d0a948805e9d0a7ae19f4
5
5
  SHA512:
6
- metadata.gz: e014d93d603bb89e74cbe9f17f814c2f717183d77c654688fba7417bc9c2685e1d318b01c013d341d69addba0793c9497e84a5e56bf30272dea76569a005e473
7
- data.tar.gz: 86f502cca84614606f28f025723be61b0acfa289072590890b39aa1e6c4aa5f6e3ebaa5aab12f207eb4ac7751dac8d7656b19fc43ca54bb8e89d0b34226c51b8
6
+ metadata.gz: 8409acef5de4ce834e309710521c44cfe35414e3ec6c3d11b8dce9173720414d828fb320c6865c693867bdac1bf14c41e8f6ac5ac5172dc11253ff77683cd307
7
+ data.tar.gz: 072e66dc223d7c14c20248f25e2c5a72f5e918314881c60faf3b8377cb77d11534d9c5b6d0eaf8e2ab2c7966c4956414d3bfdf433b98e57eb3691fa0b46e78ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cns (0.8.10)
4
+ cns (0.9.0)
5
5
  curb
6
6
  faraday
7
7
  google-cloud-bigquery
@@ -137,7 +137,7 @@ GEM
137
137
  reverse_markdown (3.0.0)
138
138
  nokogiri
139
139
  rexml (3.4.1)
140
- rubocop (1.72.2)
140
+ rubocop (1.73.1)
141
141
  json (~> 2.3)
142
142
  language_server-protocol (~> 3.17.0.2)
143
143
  lint_roller (~> 1.1.0)
@@ -159,7 +159,7 @@ GEM
159
159
  faraday (>= 0.17.5, < 3.a)
160
160
  jwt (>= 1.5, < 3.0)
161
161
  multi_json (~> 1.10)
162
- solargraph (0.51.2)
162
+ solargraph (0.52.0)
163
163
  backport (~> 1.2)
164
164
  benchmark
165
165
  bundler (~> 2.0)
@@ -177,6 +177,7 @@ GEM
177
177
  thor (~> 1.0)
178
178
  tilt (~> 2.0)
179
179
  yard (~> 0.9, >= 0.9.24)
180
+ yard-solargraph (~> 0.1)
180
181
  thor (1.3.2)
181
182
  tilt (2.6.0)
182
183
  trailblazer-option (0.1.2)
@@ -184,8 +185,10 @@ GEM
184
185
  unicode-display_width (3.1.4)
185
186
  unicode-emoji (~> 4.0, >= 4.0.4)
186
187
  unicode-emoji (4.0.4)
187
- uri (1.0.2)
188
+ uri (1.0.3)
188
189
  yard (0.9.37)
190
+ yard-solargraph (0.1.0)
191
+ yard (~> 0.9)
189
192
  zeitwerk (2.6.18)
190
193
 
191
194
  PLATFORMS
data/lib/cns/etherscan.rb CHANGED
@@ -16,6 +16,44 @@ module Cns
16
16
  # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
17
17
  attr_reader :ops
18
18
 
19
+ TT = {
20
+ normal: {
21
+ new: :novnetht,
22
+ sort_key: :srx,
23
+ format: :formata_tx_ti,
24
+ header: "\ntx normal from to data valor",
25
+ adjustment_key: :hash
26
+ },
27
+ internal: {
28
+ new: :novnethi,
29
+ sort_key: :srx,
30
+ format: :formata_tx_ti,
31
+ header: "\ntx intern from to data valor",
32
+ adjustment_key: :hash
33
+ },
34
+ block: {
35
+ new: :novnethp,
36
+ sort_key: :itx,
37
+ format: :formata_tx_block,
38
+ header: "\ntx block address data valor",
39
+ adjustment_key: :blockNumber
40
+ },
41
+ token: {
42
+ new: :novnethk,
43
+ sort_key: :srx,
44
+ format: :formata_tx_token,
45
+ header: "\ntx token from to data valor moeda",
46
+ adjustment_key: :hash
47
+ },
48
+ withdrawal: {
49
+ new: :novnethw,
50
+ sort_key: :itx,
51
+ format: :formata_tx_withw,
52
+ header: "\nwithdrawal validator data valor",
53
+ adjustment_key: :withdrawalIndex
54
+ }
55
+ }
56
+
19
57
  # @param [Hash] dad todos os dados bigquery
20
58
  # @param [Thor::CoreExt::HashWithIndifferentAccess] pop opcoes trabalho
21
59
  # @option pop [Hash] :h ({}) configuracao dias ajuste reposicionamento temporal
@@ -33,11 +71,7 @@ module Cns
33
71
 
34
72
  puts("\nid address etherscan bigquery")
35
73
  dados.each { |obj| puts(formata_carteira_simples(obj)) }
36
- mtx_norml
37
- mtx_inter
38
- mtx_block
39
- mtx_token
40
- mtx_withw
74
+ mtransacoes_novas
41
75
  mconfiguracao_ajuste_dias
42
76
  end
43
77
 
@@ -47,11 +81,7 @@ module Cns
47
81
 
48
82
  puts("\nid address etherscan tn ti tb tk tw bigquery tn ti tb tk tw")
49
83
  dados.each { |obj| puts(formata_carteira(obj)) }
50
- mtx_norml
51
- mtx_inter
52
- mtx_block
53
- mtx_token
54
- mtx_withw
84
+ mtransacoes_novas
55
85
  mconfiguracao_ajuste_dias
56
86
  end
57
87
 
@@ -133,7 +163,7 @@ module Cns
133
163
  max -= 2
134
164
  ini = Integer(max / 2)
135
165
  inf = max % 2
136
- hid = bqd[:wb].select { |obj| obj[:ax] == add }.first
166
+ hid = bqd[:wb].find { |obj| obj[:ax] == add }
137
167
  ndd = hid ? "#{hid[:id]}-#{add}" : add
138
168
  "#{ndd[0, ini]}..#{ndd[-inf - ini..]}"
139
169
  end
@@ -187,53 +217,25 @@ module Cns
187
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))
188
218
  end
189
219
 
190
- # @return [String] texto transacoes normais
191
- def mtx_norml
192
- return unless ops[:v] && novnetht.any?
193
-
194
- puts("\ntx normal from to data valor")
195
- sortx.each { |obj| puts(formata_tx_ti(obj)) }
196
- end
197
-
198
- # @return [String] texto transacoes internas
199
- def mtx_inter
200
- return unless ops[:v] && novnethi.any?
201
-
202
- puts("\ntx intern from to data valor")
203
- sorix.each { |obj| puts(formata_tx_ti(obj)) }
204
- end
205
-
206
- # @return [String] texto transacoes block
207
- def mtx_block
208
- return unless ops[:v] && novnethp.any?
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?
209
225
 
210
- puts("\ntx block address data valor")
211
- sorpx.each { |obj| puts(formata_tx_block(obj)) }
226
+ puts(cfg[:header])
227
+ ntx.sort_by { |s| -s[cfg[:sort_key]] }.each { |t| puts(send(cfg[:format], t)) }
228
+ end
212
229
  end
213
230
 
214
- # @return [String] texto transacoes token
215
- def mtx_token
216
- return unless ops[:v] && novnethk.any?
217
-
218
- puts("\ntx token from to data valor moeda")
219
- sorkx.each { |obj| puts(formata_tx_token(obj)) }
220
- end
221
-
222
- # @return [String] texto transacoes withdrawals
223
- def mtx_withw
224
- return unless ops[:v] && novnethw.any?
225
-
226
- puts("\nwithdrawal validator data valor")
227
- sorwx.each { |obj| puts(formata_tx_withw(obj)) }
228
- end
229
-
230
- # @return [String] texto configuracao ajuste dias das transacoes (normais & token)
231
+ # @return [String] Configuration text for adjusting transaction days
231
232
  def mconfiguracao_ajuste_dias
232
- puts("\najuste dias transacoes normais \n-h=#{sortx.map { |obj| "#{obj[:hash]}:0" }.join(' ')}") if novnetht.any?
233
- puts("\najuste dias transacoes internas \n-h=#{sorix.map { |obj| "#{obj[:hash]}:0" }.join(' ')}") if novnethi.any?
234
- puts("\najuste dias transacoes block \n-h=#{sorpx.map { |obj| "#{obj[:blockNumber]}:0" }.join(' ')}") if novnethp.any?
235
- puts("\najuste dias transacoes token \n-h=#{sorkx.map { |obj| "#{obj[:hash]}:0" }.join(' ')}") if novnethk.any?
236
- puts("\najuste dias transacoes withdrawals\n-h=#{sorwx.map { |obj| "#{obj[:withdrawalIndex]}:0" }.join(' ')}") if novnethw.any?
233
+ TT.each do |typ, cfg|
234
+ ntx = send(cfg[:new])
235
+ next unless ntx.any?
236
+
237
+ puts("\najuste dias transacoes #{typ}\n-h=#{ntx.map { |t| "#{t[cfg[:adjustment_key]]}:0" }.join(' ')}")
238
+ end
237
239
  end
238
240
 
239
241
  # @return [Array<String>] lista dos meus enderecos
@@ -248,7 +250,7 @@ module Cns
248
250
 
249
251
  # @return [Array<Hash>] todos os dados juntos bigquery & etherscan
250
252
  def dados
251
- @dados ||= bqd[:wb].map { |obq| bq_bc(obq, bcd.select { |obc| obq[:ax] == obc[:ax] }.first) }
253
+ @dados ||= bqd[:wb].map { |b| bq_bc(b, bcd.find { |e| b[:ax] == e[:ax] }) }
252
254
  end
253
255
 
254
256
  def show_all?
@@ -320,9 +322,10 @@ module Cns
320
322
  # @param [Hash] hbc dados etherscan - address, saldo & transacoes
321
323
  # @return [Hash] dados juntos bigquery & etherscan
322
324
  def bq_bc(wbq, hbc)
325
+ xbq = wbq[:ax]
323
326
  {
324
327
  id: wbq[:id],
325
- ax: xbq = wbq[:ax],
328
+ ax: xbq,
326
329
  bs: wbq[:sl],
327
330
  bt: bqd[:nt].select { |ont| ont[:iax].casecmp?(xbq) },
328
331
  bi: bqd[:ni].select { |oni| oni[:iax].casecmp?(xbq) },
data/lib/cns/greymass.rb CHANGED
@@ -25,6 +25,14 @@ module Cns
25
25
  @ops = pop.transform_keys(&:to_sym)
26
26
  end
27
27
 
28
+ TT = {
29
+ new: :novneost,
30
+ sort_key: :itx,
31
+ format: :formata_ledger,
32
+ header: "\nsequence num from to accao data valor moeda",
33
+ adjustment_key: :itx
34
+ }
35
+
28
36
  # @return [String] texto carteiras & transacoes & ajuste dias
29
37
  def mresumo
30
38
  return unless dados.any?
@@ -73,19 +81,21 @@ module Cns
73
81
  )
74
82
  end
75
83
 
76
- # @return [String] texto transacoes
84
+ # @return [String] Display new transactions based on verbose option
77
85
  def mtransacoes_novas
78
- return unless ops[:v] && novneost.any?
86
+ ntx = send(TT[:new])
87
+ return unless ops[:v] && ntx.any?
79
88
 
80
- puts("\nsequence num from to accao data valor moeda")
81
- soreost.each { |obj| puts(formata_ledger(obj)) }
89
+ puts(TT[:header])
90
+ ntx.sort_by { |s| -s[TT[:sort_key]] }.each { |t| puts(send(TT[:format], t)) }
82
91
  end
83
92
 
84
93
  # @return [String] texto configuracao ajuste dias das transacoes
85
94
  def mconfiguracao_ajuste_dias
86
- return unless novneost.any?
95
+ ntx = send(TT[:new])
96
+ return unless ntx.any?
87
97
 
88
- puts("\nstring ajuste dias\n-h=#{soreost.map { |obj| "#{obj[:itx]}:0" }.join(' ')}")
98
+ puts("\nstring ajuste dias\n-h=#{ntx.map { |t| "#{t[TT[:adjustment_key]]}:0" }.join(' ')}")
89
99
  end
90
100
 
91
101
  # @return [Array<Hash>] todos os dados greymass - saldos & transacoes
@@ -95,7 +105,7 @@ module Cns
95
105
 
96
106
  # @return [Array<Hash>] todos os dados juntos bigquery & greymass
97
107
  def dados
98
- @dados ||= bqd[:wb].map { |obq| bq_bc(obq, bcd.select { |obj| obq[:ax] == obj[:ax] }.first) }
108
+ @dados ||= bqd[:wb].map { |b| bq_bc(b, bcd.find { |g| b[:ax] == g[:ax] }) }
99
109
  end
100
110
 
101
111
  def show_all?
@@ -156,10 +166,13 @@ module Cns
156
166
  # @return [Array<Hash>] lista transacoes filtrada
157
167
  def peost(add, ary)
158
168
  ary.map do |omp|
169
+ act = omp[:action_trace][:act]
170
+ adt = act[:data]
171
+ qtd = adt[:quantity].to_s
159
172
  omp.merge(
160
- name: (act = omp[:action_trace][:act])[:name],
161
- from: (adt = act[:data])[:from],
162
- quantity: (qtd = adt[:quantity].to_s).to_d,
173
+ name: act[:name],
174
+ from: adt[:from],
175
+ quantity: qtd.to_d,
163
176
  account: act[:account],
164
177
  to: adt[:to],
165
178
  memo: String(adt[:memo]).gsub(/\p{C}/, ''), # remove Non-Printable Characters
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.8.10'
4
+ VERSION = '0.9.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.10
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-25 00:00:00.000000000 Z
10
+ date: 2025-03-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler