cns 0.7.8 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +55 -1
- data/Gemfile.lock +79 -43
- data/cns.gemspec +1 -2
- data/lib/cns/apibc.rb +3 -13
- data/lib/cns/apice.rb +12 -24
- data/lib/cns/bigquery.rb +163 -370
- data/lib/cns/bitcoinde.rb +1 -5
- data/lib/cns/etherscan.rb +15 -23
- data/lib/cns/greymass.rb +1 -1
- data/lib/cns/kraken.rb +3 -7
- data/lib/cns/version.rb +1 -1
- metadata +4 -35
- data/ruby-lint.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da09bc00042879c60ab8a13b28b3dbe0a3d94cc7ed2ff59140dd77cce58b15ef
|
4
|
+
data.tar.gz: 71e31f61372c2b3038fad8f8193540716d4ec6c180aae4a9165080da5716a654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863ef89dc981204b33cd4967d3c040fa5b70e6697d954ed77397d8b2e18da2bb4023f2eb359c762c6656c746215b46637bb075649fc4239c3b228a19ece0481a
|
7
|
+
data.tar.gz: 98bf85c399dd0b99d5bed870ce696ee5c8e302e2402ab1c84f7109cff35ad0f591a3f39dbe4d55ebda45692625b76facd052d6879711df416ce5a5cbde379ef7
|
data/.rubocop.yml
CHANGED
@@ -2,12 +2,66 @@
|
|
2
2
|
AllCops:
|
3
3
|
TargetRubyVersion: 3.1
|
4
4
|
EnabledByDefault: true
|
5
|
+
NewCops: enable # Automatically enable new cops introduced in updates
|
5
6
|
|
7
|
+
Metrics/ClassLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/ParameterLists:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Max: 25
|
15
|
+
|
16
|
+
Metrics/AbcSize:
|
17
|
+
Max: 40
|
18
|
+
|
19
|
+
# Formatting Rules
|
20
|
+
Layout/LineLength:
|
21
|
+
Max: 160
|
22
|
+
AllowHeredoc: true
|
23
|
+
AllowURI: true
|
24
|
+
|
25
|
+
Layout/IndentationWidth:
|
26
|
+
Width: 2
|
27
|
+
|
28
|
+
Layout/SpaceInsideHashLiteralBraces:
|
29
|
+
EnforcedStyle: space
|
30
|
+
|
31
|
+
Layout/SingleLineBlockChain:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Layout/SpaceInsideParens:
|
35
|
+
Enabled: true
|
36
|
+
|
37
|
+
# Style Preferences
|
6
38
|
Style/Copyright:
|
7
39
|
Enabled: false
|
8
40
|
|
9
|
-
|
41
|
+
Style/Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/RequireOrder:
|
10
45
|
Enabled: false
|
11
46
|
|
12
47
|
Style/ConstantVisibility:
|
13
48
|
Enabled: false
|
49
|
+
|
50
|
+
Style/OptionHash:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/StringLiterals:
|
54
|
+
EnforcedStyle: single_quotes
|
55
|
+
|
56
|
+
Style/NumericLiterals:
|
57
|
+
MinDigits: 5
|
58
|
+
|
59
|
+
# Linting
|
60
|
+
Lint/UselessAssignment:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Lint/AmbiguousOperatorPrecedence:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Lint/ConstantResolution:
|
67
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cns (0.
|
4
|
+
cns (0.8.0)
|
5
5
|
curb
|
6
6
|
faraday
|
7
7
|
google-cloud-bigquery
|
@@ -18,9 +18,38 @@ GEM
|
|
18
18
|
benchmark (0.4.0)
|
19
19
|
bigdecimal (3.1.9)
|
20
20
|
concurrent-ruby (1.3.5)
|
21
|
-
curb (1.0.
|
21
|
+
curb (1.0.9)
|
22
22
|
declarative (0.0.20)
|
23
|
-
|
23
|
+
diff-lcs (1.6.0)
|
24
|
+
dry-configurable (1.3.0)
|
25
|
+
dry-core (~> 1.1)
|
26
|
+
zeitwerk (~> 2.6)
|
27
|
+
dry-core (1.1.0)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
logger
|
30
|
+
zeitwerk (~> 2.6)
|
31
|
+
dry-inflector (1.2.0)
|
32
|
+
dry-initializer (3.2.0)
|
33
|
+
dry-logic (1.6.0)
|
34
|
+
bigdecimal
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
dry-core (~> 1.1)
|
37
|
+
zeitwerk (~> 2.6)
|
38
|
+
dry-schema (1.13.4)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
41
|
+
dry-core (~> 1.0, < 2)
|
42
|
+
dry-initializer (~> 3.0)
|
43
|
+
dry-logic (>= 1.4, < 2)
|
44
|
+
dry-types (>= 1.7, < 2)
|
45
|
+
zeitwerk (~> 2.6)
|
46
|
+
dry-types (1.8.2)
|
47
|
+
bigdecimal (~> 3.0)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
dry-core (~> 1.0)
|
50
|
+
dry-inflector (~> 1.0)
|
51
|
+
dry-logic (~> 1.4)
|
52
|
+
zeitwerk (~> 2.6)
|
24
53
|
faraday (2.12.2)
|
25
54
|
faraday-net_http (>= 2.0, < 3.5)
|
26
55
|
json
|
@@ -69,75 +98,81 @@ GEM
|
|
69
98
|
rexml (>= 3.3.9)
|
70
99
|
kramdown-parser-gfm (1.1.0)
|
71
100
|
kramdown (~> 2.0)
|
72
|
-
|
73
|
-
|
101
|
+
language_server-protocol (3.17.0.4)
|
102
|
+
lint_roller (1.1.0)
|
103
|
+
logger (1.6.6)
|
74
104
|
mini_mime (1.1.5)
|
75
|
-
mini_portile2 (2.8.8)
|
76
105
|
multi_json (1.15.0)
|
77
106
|
mutex_m (0.3.0)
|
78
107
|
net-http (0.6.0)
|
79
108
|
uri
|
80
|
-
nokogiri (1.18.2)
|
81
|
-
mini_portile2 (~> 2.8.2)
|
109
|
+
nokogiri (1.18.2-x86_64-linux-gnu)
|
82
110
|
racc (~> 1.4)
|
111
|
+
observer (0.1.2)
|
83
112
|
os (1.1.4)
|
113
|
+
ostruct (0.6.1)
|
84
114
|
parallel (1.26.3)
|
85
|
-
parser (
|
115
|
+
parser (3.3.7.1)
|
86
116
|
ast (~> 2.4.1)
|
87
|
-
|
117
|
+
racc
|
88
118
|
public_suffix (6.0.1)
|
89
119
|
racc (1.8.1)
|
90
120
|
rainbow (3.1.1)
|
91
121
|
rake (12.3.3)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
122
|
+
rbs (3.8.1)
|
123
|
+
logger
|
124
|
+
reek (6.4.0)
|
125
|
+
dry-schema (~> 1.13.0)
|
126
|
+
logger (~> 1.6)
|
127
|
+
parser (~> 3.3.0)
|
96
128
|
rainbow (>= 2.0, < 4.0)
|
129
|
+
rexml (~> 3.1)
|
97
130
|
regexp_parser (2.10.0)
|
98
131
|
representable (3.2.0)
|
99
132
|
declarative (< 0.1.0)
|
100
133
|
trailblazer-option (>= 0.1.1, < 0.2.0)
|
101
134
|
uber (< 0.2.0)
|
102
135
|
retriable (3.1.2)
|
103
|
-
reverse_markdown (
|
136
|
+
reverse_markdown (3.0.0)
|
104
137
|
nokogiri
|
105
|
-
rexml (3.4.
|
106
|
-
rubocop (1.
|
138
|
+
rexml (3.4.1)
|
139
|
+
rubocop (1.72.1)
|
140
|
+
json (~> 2.3)
|
141
|
+
language_server-protocol (~> 3.17.0.2)
|
142
|
+
lint_roller (~> 1.1.0)
|
107
143
|
parallel (~> 1.10)
|
108
|
-
parser (>=
|
144
|
+
parser (>= 3.3.0.2)
|
109
145
|
rainbow (>= 2.2.2, < 4.0)
|
110
|
-
regexp_parser (>=
|
111
|
-
|
112
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
146
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
147
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
113
148
|
ruby-progressbar (~> 1.7)
|
114
|
-
unicode-display_width (>=
|
115
|
-
rubocop-ast (1.
|
116
|
-
parser (>=
|
117
|
-
rubocop-rake (0.
|
118
|
-
|
119
|
-
|
120
|
-
parser (~> 2.2)
|
121
|
-
slop (~> 3.4, >= 3.4.7)
|
149
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
150
|
+
rubocop-ast (1.38.0)
|
151
|
+
parser (>= 3.3.1.0)
|
152
|
+
rubocop-rake (0.7.1)
|
153
|
+
lint_roller (~> 1.1)
|
154
|
+
rubocop (>= 1.72.1)
|
122
155
|
ruby-progressbar (1.13.0)
|
123
|
-
rufo (0.18.0)
|
124
156
|
signet (0.19.0)
|
125
157
|
addressable (~> 2.8)
|
126
158
|
faraday (>= 0.17.5, < 3.a)
|
127
159
|
jwt (>= 1.5, < 3.0)
|
128
160
|
multi_json (~> 1.10)
|
129
|
-
|
130
|
-
|
131
|
-
backport (~> 1.1)
|
161
|
+
solargraph (0.51.2)
|
162
|
+
backport (~> 1.2)
|
132
163
|
benchmark
|
133
|
-
bundler (
|
134
|
-
|
135
|
-
jaro_winkler (~> 1.
|
164
|
+
bundler (~> 2.0)
|
165
|
+
diff-lcs (~> 1.4)
|
166
|
+
jaro_winkler (~> 1.6)
|
136
167
|
kramdown (~> 2.3)
|
137
168
|
kramdown-parser-gfm (~> 1.1)
|
138
|
-
|
139
|
-
|
140
|
-
|
169
|
+
logger (~> 1.6)
|
170
|
+
observer (~> 0.1)
|
171
|
+
ostruct (~> 0.6)
|
172
|
+
parser (~> 3.0)
|
173
|
+
rbs (~> 3.0)
|
174
|
+
reverse_markdown (>= 2.0, < 4)
|
175
|
+
rubocop (~> 1.38)
|
141
176
|
thor (~> 1.0)
|
142
177
|
tilt (~> 2.0)
|
143
178
|
yard (~> 0.9, >= 0.9.24)
|
@@ -145,9 +180,12 @@ GEM
|
|
145
180
|
tilt (2.6.0)
|
146
181
|
trailblazer-option (0.1.2)
|
147
182
|
uber (0.1.0)
|
148
|
-
unicode-display_width (1.
|
183
|
+
unicode-display_width (3.1.4)
|
184
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
185
|
+
unicode-emoji (4.0.4)
|
149
186
|
uri (1.0.2)
|
150
187
|
yard (0.9.37)
|
188
|
+
zeitwerk (2.6.18)
|
151
189
|
|
152
190
|
PLATFORMS
|
153
191
|
x86_64-linux
|
@@ -159,10 +197,8 @@ DEPENDENCIES
|
|
159
197
|
reek
|
160
198
|
rubocop
|
161
199
|
rubocop-rake
|
162
|
-
ruby-lint
|
163
|
-
rufo
|
164
200
|
solargraph
|
165
201
|
yard
|
166
202
|
|
167
203
|
BUNDLED WITH
|
168
|
-
2.3
|
204
|
+
2.6.3
|
data/cns.gemspec
CHANGED
@@ -31,8 +31,6 @@ 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')
|
35
|
-
spec.add_development_dependency('rufo')
|
36
34
|
spec.add_development_dependency('solargraph')
|
37
35
|
spec.add_development_dependency('yard')
|
38
36
|
|
@@ -40,4 +38,5 @@ Gem::Specification.new do |spec|
|
|
40
38
|
spec.add_dependency('faraday')
|
41
39
|
spec.add_dependency('google-cloud-bigquery')
|
42
40
|
spec.add_dependency('thor')
|
41
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
43
42
|
end
|
data/lib/cns/apibc.rb
CHANGED
@@ -12,7 +12,7 @@ module Cns
|
|
12
12
|
# @return [Array<Hash>] List of addresses with balances
|
13
13
|
def account_es(addresses)
|
14
14
|
response = etherscan_req('balancemulti', addresses.join(','), 1, tag: 'latest')
|
15
|
-
response[:status] == '1' ? response
|
15
|
+
response[:status] == '1' ? response[:result] : []
|
16
16
|
end
|
17
17
|
|
18
18
|
# Get EOS account information
|
@@ -80,24 +80,14 @@ module Cns
|
|
80
80
|
# Reusable Faraday connection
|
81
81
|
def connection(base_url)
|
82
82
|
Faraday.new(base_url) do |conn|
|
83
|
-
conn.headers = {
|
84
|
-
content_type: 'application/json',
|
85
|
-
accept: 'application/json',
|
86
|
-
user_agent: 'blockchain-api-client'
|
87
|
-
}
|
83
|
+
conn.headers = { content_type: 'application/json', accept: 'application/json', user_agent: 'blockchain-api-client' }
|
88
84
|
conn.adapter(Faraday.default_adapter)
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
88
|
# Generic Etherscan API request handler
|
93
89
|
def etherscan_req(action, address, page = 1, params = {})
|
94
|
-
params = {
|
95
|
-
module: 'account',
|
96
|
-
action: action,
|
97
|
-
address: address,
|
98
|
-
page: page,
|
99
|
-
apikey: ENV.fetch('ETHERSCAN_API_KEY')
|
100
|
-
}.merge(params)
|
90
|
+
params = { module: 'account', action: action, address: address, page: page, apikey: ENV.fetch('ETHERSCAN_API_KEY') }.merge(params)
|
101
91
|
parse_json(connection('https://api.etherscan.io').get('/api', params).body)
|
102
92
|
rescue Faraday::Error, JSON::ParserError
|
103
93
|
{ status: '0', result: [] }
|
data/lib/cns/apice.rb
CHANGED
@@ -55,10 +55,7 @@ module Cns
|
|
55
55
|
# @param non (see hde)
|
56
56
|
# @return [Hash] saldos no kraken
|
57
57
|
def account_us(urb = 'https://api.kraken.com/0/private', uri = 'Balance', non = nnc)
|
58
|
-
JSON.parse(
|
59
|
-
Curl.post("#{urb}/#{uri}", nonce: non) { |obj| obj.headers = hus(uri, nonce: non) }.body,
|
60
|
-
symbolize_names: true
|
61
|
-
)[:result]
|
58
|
+
JSON.parse(Curl.post("#{urb}/#{uri}", nonce: non) { |obj| obj.headers = hus(uri, nonce: non) }.body, symbolize_names: true)[:result]
|
62
59
|
rescue StandardError
|
63
60
|
{}
|
64
61
|
end
|
@@ -158,12 +155,7 @@ module Cns
|
|
158
155
|
# ]
|
159
156
|
# @return [Hash] deposit uniformizado bitcoinde
|
160
157
|
def deposit_unif(has)
|
161
|
-
{
|
162
|
-
add: has[:address],
|
163
|
-
time: Time.parse(has[:created_at]),
|
164
|
-
qt: has[:amount],
|
165
|
-
txid: Integer(has[:deposit_id])
|
166
|
-
}.merge(tp: 'deposit', moe: 'btc', fee: '0')
|
158
|
+
{ add: has[:address], time: Time.parse(has[:created_at]), qt: has[:amount], txid: Integer(has[:deposit_id]) }.merge(tp: 'deposit', moe: 'btc', fee: '0')
|
167
159
|
end
|
168
160
|
|
169
161
|
# @example withdrawals_de
|
@@ -249,16 +241,14 @@ module Cns
|
|
249
241
|
# @param [Hash] has acumulador dos dados
|
250
242
|
# @param (see account_us)
|
251
243
|
# @return [Hash] dados trades kraken
|
252
|
-
def trades_us(ofs = 0, has = {}, urb = 'https://api.kraken.com/0/private')
|
253
|
-
uri = 'TradesHistory'
|
254
|
-
non = nnc
|
244
|
+
def trades_us(ofs = 0, has = {}, urb = 'https://api.kraken.com/0/private', uri = 'TradesHistory', non = nnc)
|
255
245
|
res = JSON.parse(
|
256
246
|
Curl.post("#{urb}/#{uri}", nonce: non, ofs: ofs) { |obj| obj.headers = hus(uri, nonce: non, ofs: ofs) }.body,
|
257
247
|
symbolize_names: true
|
258
248
|
)[:result]
|
259
249
|
has.merge!(res[:trades])
|
260
|
-
sleep
|
261
|
-
res[:trades].count
|
250
|
+
sleep(2)
|
251
|
+
res[:trades].count.positive? ? trades_us(ofs + res[:trades].count, has) : has
|
262
252
|
rescue StandardError
|
263
253
|
has
|
264
254
|
end
|
@@ -286,16 +276,14 @@ module Cns
|
|
286
276
|
# }
|
287
277
|
# @param (see trades_us)
|
288
278
|
# @return [Hash] dados ledger kraken
|
289
|
-
def ledger_us(ofs = 0, has = {}, urb = 'https://api.kraken.com/0/private')
|
290
|
-
uri = 'Ledgers'
|
291
|
-
non = nnc
|
279
|
+
def ledger_us(ofs = 0, has = {}, urb = 'https://api.kraken.com/0/private', uri = 'Ledgers', non = nnc)
|
292
280
|
res = JSON.parse(
|
293
281
|
Curl.post("#{urb}/#{uri}", nonce: non, ofs: ofs) { |obj| obj.headers = hus(uri, nonce: non, ofs: ofs) }.body,
|
294
282
|
symbolize_names: true
|
295
283
|
)[:result]
|
296
284
|
has.merge!(res[:ledger])
|
297
|
-
sleep
|
298
|
-
res[:ledger].count
|
285
|
+
sleep(2)
|
286
|
+
res[:ledger].count.positive? ? ledger_us(ofs + res[:ledger].count, has) : has
|
299
287
|
rescue StandardError
|
300
288
|
has
|
301
289
|
end
|
@@ -434,13 +422,13 @@ module Cns
|
|
434
422
|
# @param [Integer] non continually-increasing unsigned integer
|
435
423
|
# @return [Hash] headers necessarios para pedido HTTP da exchange bitcoinde
|
436
424
|
def hde(qde, non = nnc)
|
437
|
-
key = ENV
|
425
|
+
key = ENV.fetch('BITCOINDE_API_KEY', nil)
|
438
426
|
{
|
439
427
|
'X-API-KEY': key,
|
440
428
|
'X-API-NONCE': non,
|
441
429
|
'X-API-SIGNATURE': OpenSSL::HMAC.hexdigest(
|
442
430
|
'sha256',
|
443
|
-
ENV
|
431
|
+
ENV.fetch('BITCOINDE_API_SECRET', nil),
|
444
432
|
['GET', qde, key, non, Digest::MD5.hexdigest('')].join('#')
|
445
433
|
)
|
446
434
|
}
|
@@ -476,11 +464,11 @@ module Cns
|
|
476
464
|
# @return [Hash] headers necessarios para pedido HTTP da exchange kraken
|
477
465
|
def hus(qus, ops)
|
478
466
|
{
|
479
|
-
'api-key': ENV
|
467
|
+
'api-key': ENV.fetch('KRAKEN_API_KEY', nil),
|
480
468
|
'api-sign': Base64.strict_encode64(
|
481
469
|
OpenSSL::HMAC.digest(
|
482
470
|
'sha512',
|
483
|
-
Base64.decode64(ENV
|
471
|
+
Base64.decode64(ENV.fetch('KRAKEN_API_SECRET', nil)),
|
484
472
|
['/0/private/', qus, Digest::SHA256.digest("#{ops[:nonce]}#{URI.encode_www_form(ops)}")].join
|
485
473
|
)
|
486
474
|
)
|