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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cns/apibc.rb +3 -3
- data/lib/cns/apice.rb +2 -2
- data/lib/cns/bigquery.rb +40 -41
- data/lib/cns/bitcoinde.rb +1 -1
- data/lib/cns/kraken.rb +1 -1
- data/lib/cns/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e659c6ea2d194d128a8f5d7f2b5a3936e780b3fa24a5370bbaf3ea8a42e6b791
|
4
|
+
data.tar.gz: 0feb359a2e34f4787deb3a87bb512ad42f37be6a3fcc20a14f32878e5f13e018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5acfb6285923d1ab121d52d51ba7f0e142a58433db9475270fbfd148b660bc26807397806c90f1f4f3c6bdd29ce7f56f56f2bf9f58729ac53eb26a9b54b15425
|
7
|
+
data.tar.gz: 54e13e8ed1a51d8f8a4f2114959d20f1754eb304d8b5daacc1dc77552708427be55073d670bf272a3b1f7fd0d066745d43ff1de40ef3a43ab639fae9028ae12c
|
data/Gemfile.lock
CHANGED
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, _|
|
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, _|
|
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
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.
|
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-
|
10
|
+
date: 2025-03-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|