cns 0.9.8 → 0.10.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: f44706093bb37569dad944e52da3becb0d1bb8ab34e48c9dd30c2f2cd6599f3c
4
- data.tar.gz: 1cb9e471623d4abbf526a77278e5ff27614e52093d3a79a56229a9c9bf39783f
3
+ metadata.gz: e659c6ea2d194d128a8f5d7f2b5a3936e780b3fa24a5370bbaf3ea8a42e6b791
4
+ data.tar.gz: 0feb359a2e34f4787deb3a87bb512ad42f37be6a3fcc20a14f32878e5f13e018
5
5
  SHA512:
6
- metadata.gz: 99c1e87bc81a61b9c8e572807b133daf02e54b42bbdea7b2d1997711fc4a98984eae1320ebc6764ce15cd586dee29f88716fa49bc07bb91f136f9a4dd4bf3d55
7
- data.tar.gz: 0ed7c0a9c0b40fcb5d18cf7271a5208ddd62e2e0643c0ae2134d74538fb6993c6756ba962e7de754751feae71873e2cb22644c74d5e6b999f78bda6336714e94
6
+ metadata.gz: 5acfb6285923d1ab121d52d51ba7f0e142a58433db9475270fbfd148b660bc26807397806c90f1f4f3c6bdd29ce7f56f56f2bf9f58729ac53eb26a9b54b15425
7
+ data.tar.gz: 54e13e8ed1a51d8f8a4f2114959d20f1754eb304d8b5daacc1dc77552708427be55073d670bf272a3b1f7fd0d066745d43ff1de40ef3a43ab639fae9028ae12c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cns (0.9.8)
4
+ cns (0.10.0)
5
5
  curb
6
6
  faraday
7
7
  faraday-retry
data/lib/cns/apibc.rb CHANGED
@@ -21,7 +21,7 @@ module Cns
21
21
  # @param [Array<String>] addresses List of ETH addresses (max 20)
22
22
  # @return [Array<Hash>] List of addresses with balances
23
23
  def account_es(addresses)
24
- return [] if addresses.empty?
24
+ return [] if addresses.nil? || addresses.empty?
25
25
 
26
26
  # Batch addresses into groups of 20 (Etherscan limit) and fetch balances
27
27
  addresses.each_slice(20).flat_map do |b|
@@ -146,7 +146,7 @@ module Cns
146
146
  # @param [Faraday::Response] res API response
147
147
  # @return [Hash] Parsed JSON or empty hash on error
148
148
  def parse_json(res)
149
- return {} if res.body.to_s.empty?
149
+ return {} if res.nil? || res.body.to_s.empty?
150
150
 
151
151
  JSON.parse(res.body, symbolize_names: true) || {}
152
152
  rescue JSON::ParserError
@@ -162,7 +162,7 @@ module Cns
162
162
  c.headers = {accept: 'application/json', user_agent: 'blockchain-api-client'}
163
163
  c.options.timeout = 30
164
164
  c.options.open_timeout = 10
165
- c.use(Faraday::Retry::Middleware, max: 3, interval: 1)
165
+ c.use(Faraday::Retry::Middleware, max: 3, interval: 1, backoff_factor: 2)
166
166
  c.adapter(Faraday.default_adapter)
167
167
  end
168
168
  end
data/lib/cns/apice.rb CHANGED
@@ -7,10 +7,10 @@ require('json')
7
7
 
8
8
  # @author Hernani Rodrigues Vaz
9
9
  module Cns
10
- API = {de: 'https://api.bitcoin.de/v4', us: 'https://api.kraken.com/0/private'}.freeze
11
-
12
10
  # classe para acesso dados centralized exchanges
13
11
  class Apice
12
+ API = {de: 'https://api.bitcoin.de/v4', us: 'https://api.kraken.com/0/private'}.freeze
13
+
14
14
  def initialize
15
15
  @curl = Curl::Easy.new
16
16
  @curl.timeout = 30
data/lib/cns/bigquery.rb CHANGED
@@ -5,49 +5,48 @@ require('bigdecimal/util')
5
5
 
6
6
  # @author Hernani Rodrigues Vaz
7
7
  module Cns
8
- BD = 'hernanirvaz.coins'
9
- FO = File.expand_path("~/#{File.basename($PROGRAM_NAME)}.log")
10
- EM = %i[EOS XETH ZEUR btc eth]
11
- TB = {
12
- netht: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value gas gasprice gasused iserror txreceipt_status input contractaddress dias],
13
- hetht: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value gas gasPrice gasUsed isError txreceipt_status input contractAddress],
14
- nethi: %w[txhash blocknumber timestamp axfrom axto iax value contractaddress input type gas gasused traceid iserror errcode dias],
15
- hethi: %i[hash blockNumber timeStamp from to iax value contractAddress input type gas gasUsed traceId isError errCode],
16
- nethp: %w[blocknumber timestamp blockreward iax dias],
17
- hethp: %i[blockNumber timeStamp blockReward iax],
18
- nethw: %w[withdrawalindex validatorindex address amount blocknumber timestamp dias],
19
- hethw: %i[withdrawalIndex validatorIndex address amount blockNumber timeStamp],
20
- nethk: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value tokenname tokensymbol tokendecimal gas gasprice gasused input contractaddress dias],
21
- hethk: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value tokenName tokenSymbol tokenDecimal gas gasPrice gasUsed input contractAddress],
22
- neost: %w[gseq aseq bnum time contract action acfrom acto iax amount moeda memo dias],
23
- heost: %i[global_action_seq account_action_seq block_num block_time account name from to iax quantity moe memo],
24
- cdet: %w[txid time tp user btc eur dtc dias],
25
- hdet: %i[trade_id successfully_finished_at type username btc eur trade_marked_as_paid_at],
26
- cdel: %w[txid time tp add moe qt fee],
27
- hdel: %i[nxid time tp add moe qtd fee],
28
- cust: %w[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers dias],
29
- hust: %i[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers],
30
- cusl: %w[txid refid time type aclass asset amount fee],
31
- husl: %i[txid refid time type aclass asset amount fee]
32
- }.freeze
33
- # para testes bigquery
34
- TL = {
35
- ins: 'INSERT',
36
- exo: false,
37
- est: '', # ' limit 226',
38
- esi: '', # ' limit 22',
39
- esp: '', # ' limit 72',
40
- esw: '', # ' limit 2320',
41
- esk: '', # ' limit 20',
42
- gmt: '', # ' limit 1091',
43
- ust: '', # ' limit 182',
44
- usl: '', # ' limit 448',
45
- det: '', # ' limit 27',
46
- del: '' # ' limit 16'
47
- }.freeze
48
-
49
8
  # classe para processar bigquery
50
9
  class Bigquery
10
+ BD = 'hernanirvaz.coins'
11
+ FO = File.expand_path("~/#{File.basename($PROGRAM_NAME)}.log")
12
+ TB = {
13
+ netht: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value gas gasprice gasused iserror txreceipt_status input contractaddress dias],
14
+ hetht: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value gas gasPrice gasUsed isError txreceipt_status input contractAddress],
15
+ nethi: %w[txhash blocknumber timestamp axfrom axto iax value contractaddress input type gas gasused traceid iserror errcode dias],
16
+ hethi: %i[hash blockNumber timeStamp from to iax value contractAddress input type gas gasUsed traceId isError errCode],
17
+ nethp: %w[blocknumber timestamp blockreward iax dias],
18
+ hethp: %i[blockNumber timeStamp blockReward iax],
19
+ nethw: %w[withdrawalindex validatorindex address amount blocknumber timestamp dias],
20
+ hethw: %i[withdrawalIndex validatorIndex address amount blockNumber timeStamp],
21
+ nethk: %w[txhash blocknumber timestamp nonce blockhash transactionindex axfrom axto iax value tokenname tokensymbol tokendecimal gas gasprice gasused input contractaddress dias],
22
+ hethk: %i[hash blockNumber timeStamp nonce blockHash transactionIndex from to iax value tokenName tokenSymbol tokenDecimal gas gasPrice gasUsed input contractAddress],
23
+ neost: %w[gseq aseq bnum time contract action acfrom acto iax amount moeda memo dias],
24
+ heost: %i[global_action_seq account_action_seq block_num block_time account name from to iax quantity moe memo],
25
+ cdet: %w[txid time tp user btc eur dtc dias],
26
+ hdet: %i[trade_id successfully_finished_at type username btc eur trade_marked_as_paid_at],
27
+ cdel: %w[txid time tp add moe qt fee],
28
+ hdel: %i[nxid time tp add moe qtd fee],
29
+ cust: %w[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers dias],
30
+ hust: %i[txid ordertxid pair time type ordertype price cost fee vol margin misc ledgers],
31
+ cusl: %w[txid refid time type aclass asset amount fee],
32
+ husl: %i[txid refid time type aclass asset amount fee]
33
+ }.freeze
34
+ # para testes bigquery
35
+ TL = {
36
+ ins: 'INSERT',
37
+ exo: false,
38
+ est: '', # ' limit 226',
39
+ esi: '', # ' limit 22',
40
+ esp: '', # ' limit 72',
41
+ esw: '', # ' limit 2320',
42
+ esk: '', # ' limit 20',
43
+ gmt: '', # ' limit 1091',
44
+ ust: '', # ' limit 182',
45
+ usl: '', # ' limit 448',
46
+ det: '', # ' limit 27',
47
+ del: '' # ' limit 16'
48
+ }.freeze
49
+
51
50
  # @return [Google::Cloud::Bigquery] API bigquery
52
51
  # @return [Google::Cloud::Bigquery::QueryJob] job bigquery
53
52
  # @return [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
data/lib/cns/bitcoinde.rb CHANGED
@@ -115,7 +115,7 @@ module Cns
115
115
  # @param [Hash] itm recursos bitcoinde
116
116
  # @return [Hash<BigDecimal>] moedas & sados
117
117
  def pdea(itm)
118
- itm.select { |k, _| EM.include?(k) }.transform_values { |o| o.merge(total_amount: o[:total_amount].to_d) }
118
+ itm.select { |k, _| %i[btc eth].include?(k) }.transform_values { |o| o.merge(total_amount: o[:total_amount].to_d) }
119
119
  end
120
120
 
121
121
  # @param [Object] val time bitcoinde
data/lib/cns/kraken.rb CHANGED
@@ -119,7 +119,7 @@ module Cns
119
119
  # @param [Hash] itm recursos kraken
120
120
  # @return [Hash<BigDecimal>] moedas & sados
121
121
  def pusa(itm)
122
- itm.select { |k, _| EM.include?(k) }.transform_values { |v| v.to_d }
122
+ itm.select { |k, _| %i[EOS XETH ZEUR].include?(k) }.transform_values { |v| v.to_d }
123
123
  end
124
124
 
125
125
  # @param [Array<Hash>] htx trades kraken
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.9.8'
4
+ VERSION = '0.10.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.9.8
4
+ version: 0.10.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-03-07 00:00:00.000000000 Z
10
+ date: 2025-03-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler