cns 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +64 -0
- data/.rubocop.yml +4 -3
- data/Gemfile.lock +19 -13
- data/cns.gemspec +1 -0
- data/lib/cns/apibc.rb +34 -48
- data/lib/cns/apice1.rb +22 -72
- data/lib/cns/apice2.rb +82 -39
- data/lib/cns/bigquery1.rb +5 -4
- data/lib/cns/bigquery3.rb +62 -47
- data/lib/cns/bigquery4.rb +51 -54
- data/lib/cns/bitcoinde.rb +21 -20
- data/lib/cns/etherscan1.rb +21 -19
- data/lib/cns/etherscan2.rb +7 -7
- data/lib/cns/greymass1.rb +23 -18
- data/lib/cns/greymass2.rb +8 -26
- data/lib/cns/kraken.rb +21 -20
- data/lib/cns/paymium.rb +15 -15
- data/lib/cns/therock.rb +16 -15
- data/lib/cns/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef054c95506b8f32415f3c3f47b2272886ac824f10666c91a4bd0f3b118b3ffb
|
4
|
+
data.tar.gz: c18711c2d3ffcdf131218d3509f954f163046fa5b498e39b47e15332b3fb53a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef30f7f2617710c765d6dd8d4a21e673a55da5aa59ee4bb1ac15343c70a9ee5cfa7b9e26ccc01019c53cbd69d571fd07981e3bba35fbc53a04d308ccd61d118c
|
7
|
+
data.tar.gz: df9e5fbe45744df8bb75dc5b8145fe8f875a6085877d8709e9cc7d2cf5a907ec797a9cad8f3c557b7599bfc079873822e7c4aa390334e8696dd3b21aa57c0db5
|
data/.reek.yml
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
detectors:
|
3
|
+
TooManyStatements:
|
4
|
+
exclude:
|
5
|
+
- initialize
|
6
|
+
max_statements: 10
|
7
|
+
RepeatedConditional:
|
8
|
+
exclude:
|
9
|
+
- "Cns::Apice"
|
10
|
+
FeatureEnvy:
|
11
|
+
exclude:
|
12
|
+
- "Cns::Apice#deposit_unif"
|
13
|
+
- "Cns::Apice#withdrawal_unif"
|
14
|
+
- "Cns::Bigquery#etht_1val"
|
15
|
+
- "Cns::Bigquery#etht_2val"
|
16
|
+
- "Cns::Bigquery#etht_3val"
|
17
|
+
- "Cns::Bigquery#ethk_1val"
|
18
|
+
- "Cns::Bigquery#ethk_2val"
|
19
|
+
- "Cns::Bigquery#ethk_3val"
|
20
|
+
- "Cns::Bigquery#eost_1val"
|
21
|
+
- "Cns::Bigquery#eost_2val"
|
22
|
+
- "Cns::Bigquery#det_1val"
|
23
|
+
- "Cns::Bigquery#det_2val"
|
24
|
+
- "Cns::Bigquery#mtl_1val"
|
25
|
+
- "Cns::Bigquery#ust_1val"
|
26
|
+
- "Cns::Bigquery#frl_val"
|
27
|
+
- "Cns::Bigquery#usl_val"
|
28
|
+
- "Cns::Bitcoinde#formata_ledger"
|
29
|
+
- "Cns::Bitcoinde#formata_trades"
|
30
|
+
- "Cns::Etherscan#bq_bc"
|
31
|
+
- "Cns::Etherscan#formata_valores"
|
32
|
+
- "Cns::Etherscan#formata_endereco"
|
33
|
+
- "Cns::Etherscan#formata_transacao_norml"
|
34
|
+
- "Cns::Etherscan#formata_transacao_token"
|
35
|
+
- "Cns::Greymass#bq_bc"
|
36
|
+
- "Cns::Greymass#greymass_sl"
|
37
|
+
- "Cns::Greymass#formata_carteira"
|
38
|
+
- "Cns::Greymass#formata_ledger"
|
39
|
+
- "Cns::Greymass#filtrar_tx"
|
40
|
+
- "Cns::Kraken#formata_ledger"
|
41
|
+
- "Cns::Kraken#formata_trades"
|
42
|
+
- "Cns::Paymium#formata_ledger"
|
43
|
+
- "Cns::Paymium#formata_uuid"
|
44
|
+
- "Cns::TheRock#formata_ledger"
|
45
|
+
- "Cns::TheRock#formata_saldos"
|
46
|
+
UtilityFunction:
|
47
|
+
exclude:
|
48
|
+
- "Cns::Apice#hus"
|
49
|
+
- "Cns::Bigquery#del_val"
|
50
|
+
- "Cns::Etherscan#ok?"
|
51
|
+
- "Cns::Greymass#ok?"
|
52
|
+
NestedIterators:
|
53
|
+
exclude:
|
54
|
+
- "Cns::Etherscan#idk"
|
55
|
+
- "Cns::Etherscan#idt"
|
56
|
+
- "Cns::Etherscan#novtx"
|
57
|
+
- "Cns::Etherscan#novkx"
|
58
|
+
- "Cns::Etherscan#dados"
|
59
|
+
- "Cns::Etherscan#filtrar_tx"
|
60
|
+
- "Cns::Greymass#novax"
|
61
|
+
- "Cns::Greymass#idt"
|
62
|
+
- "Cns::Greymass#dados"
|
63
|
+
- "Cns::Paymium#kyl"
|
64
|
+
- "Cns::Paymium#ledger"
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
---
|
1
2
|
AllCops:
|
2
3
|
TargetRubyVersion: 2.7
|
3
4
|
EnabledByDefault: true
|
4
5
|
|
5
6
|
Style/Copyright:
|
6
|
-
|
7
|
+
Enabled: false
|
7
8
|
|
8
9
|
Lint/ConstantResolution:
|
9
|
-
|
10
|
+
Enabled: false
|
10
11
|
|
11
12
|
Style/ConstantVisibility:
|
12
|
-
|
13
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cns (0.1.
|
4
|
+
cns (0.1.6)
|
5
5
|
curb
|
6
6
|
faraday
|
7
7
|
google-cloud-bigquery
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
faraday (1.1.0)
|
24
24
|
multipart-post (>= 1.2, < 3)
|
25
25
|
ruby2_keywords
|
26
|
-
google-api-client (0.
|
26
|
+
google-api-client (0.52.0)
|
27
27
|
addressable (~> 2.5, >= 2.5.1)
|
28
28
|
googleauth (~> 0.9)
|
29
29
|
httpclient (>= 2.8.1, < 3.0)
|
@@ -54,8 +54,11 @@ GEM
|
|
54
54
|
httpclient (2.8.3)
|
55
55
|
jaro_winkler (1.5.4)
|
56
56
|
jwt (2.2.2)
|
57
|
+
kramdown (2.3.0)
|
58
|
+
rexml
|
59
|
+
kramdown-parser-gfm (1.1.0)
|
60
|
+
kramdown (~> 2.0)
|
57
61
|
kwalify (0.7.2)
|
58
|
-
maruku (0.7.3)
|
59
62
|
memoist (0.16.2)
|
60
63
|
mini_mime (1.0.2)
|
61
64
|
mini_portile2 (2.4.0)
|
@@ -67,7 +70,7 @@ GEM
|
|
67
70
|
parallel (1.20.1)
|
68
71
|
parser (2.7.2.0)
|
69
72
|
ast (~> 2.4.1)
|
70
|
-
psych (3.2.
|
73
|
+
psych (3.2.1)
|
71
74
|
public_suffix (4.0.6)
|
72
75
|
rainbow (3.0.0)
|
73
76
|
rake (12.3.3)
|
@@ -76,7 +79,7 @@ GEM
|
|
76
79
|
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
77
80
|
psych (~> 3.1)
|
78
81
|
rainbow (>= 2.0, < 4.0)
|
79
|
-
regexp_parser (2.0.
|
82
|
+
regexp_parser (2.0.1)
|
80
83
|
representable (3.0.4)
|
81
84
|
declarative (< 0.1.0)
|
82
85
|
declarative-option (< 0.2.0)
|
@@ -85,17 +88,19 @@ GEM
|
|
85
88
|
reverse_markdown (2.0.0)
|
86
89
|
nokogiri
|
87
90
|
rexml (3.2.4)
|
88
|
-
rubocop (
|
91
|
+
rubocop (1.6.1)
|
89
92
|
parallel (~> 1.10)
|
90
93
|
parser (>= 2.7.1.5)
|
91
94
|
rainbow (>= 2.2.2, < 4.0)
|
92
|
-
regexp_parser (>= 1.8)
|
95
|
+
regexp_parser (>= 1.8, < 3.0)
|
93
96
|
rexml
|
94
|
-
rubocop-ast (>=
|
97
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
95
98
|
ruby-progressbar (~> 1.7)
|
96
99
|
unicode-display_width (>= 1.4.0, < 2.0)
|
97
|
-
rubocop-ast (1.
|
100
|
+
rubocop-ast (1.3.0)
|
98
101
|
parser (>= 2.7.1.5)
|
102
|
+
rubocop-rake (0.5.1)
|
103
|
+
rubocop
|
99
104
|
ruby-progressbar (1.10.1)
|
100
105
|
ruby2_keywords (0.0.2)
|
101
106
|
signet (0.14.0)
|
@@ -103,17 +108,17 @@ GEM
|
|
103
108
|
faraday (>= 0.17.3, < 2.0)
|
104
109
|
jwt (>= 1.5, < 3.0)
|
105
110
|
multi_json (~> 1.10)
|
106
|
-
solargraph (0.
|
111
|
+
solargraph (0.40.0)
|
107
112
|
backport (~> 1.1)
|
108
113
|
benchmark
|
109
114
|
bundler (>= 1.17.2)
|
110
115
|
e2mmap
|
111
116
|
jaro_winkler (~> 1.5)
|
112
|
-
|
113
|
-
|
117
|
+
kramdown (~> 2.3)
|
118
|
+
kramdown-parser-gfm (~> 1.1)
|
114
119
|
parser (~> 2.3)
|
115
120
|
reverse_markdown (>= 1.0.5, < 3)
|
116
|
-
rubocop (
|
121
|
+
rubocop (>= 0.52)
|
117
122
|
thor (~> 1.0)
|
118
123
|
tilt (~> 2.0)
|
119
124
|
yard (~> 0.9, >= 0.9.24)
|
@@ -132,6 +137,7 @@ DEPENDENCIES
|
|
132
137
|
rake (~> 12.0)
|
133
138
|
reek
|
134
139
|
rubocop
|
140
|
+
rubocop-rake
|
135
141
|
solargraph
|
136
142
|
yard
|
137
143
|
|
data/cns.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency('rake')
|
31
31
|
spec.add_development_dependency('reek')
|
32
32
|
spec.add_development_dependency('rubocop')
|
33
|
+
spec.add_development_dependency('rubocop-rake')
|
33
34
|
spec.add_development_dependency('solargraph')
|
34
35
|
spec.add_development_dependency('yard')
|
35
36
|
|
data/lib/cns/apibc.rb
CHANGED
@@ -17,14 +17,10 @@ module Cns
|
|
17
17
|
# ]
|
18
18
|
# }
|
19
19
|
# @param [String] ads lista enderecos ETH (max 20)
|
20
|
-
# @param [Hash] par parametros base do pedido HTTP
|
21
20
|
# @return [Array<Hash>] lista enderecos e seus saldos
|
22
|
-
def account_es(ads
|
21
|
+
def account_es(ads)
|
23
22
|
JSON.parse(
|
24
|
-
|
25
|
-
o.headers = { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
26
|
-
o.params = par.merge(address: ads.join(','), apikey: ENV['ETHERSCAN_API_KEY'])
|
27
|
-
end).body,
|
23
|
+
conn_es.get('api', action: 'balancemulti', tag: 'latest', address: ads.join(',')).body,
|
28
24
|
symbolize_names: true
|
29
25
|
)[:result]
|
30
26
|
rescue StandardError
|
@@ -82,15 +78,9 @@ module Cns
|
|
82
78
|
# rex_info: nil
|
83
79
|
# }
|
84
80
|
# @param [String] add endereco EOS
|
85
|
-
# @param [String] uri Uniform Resource Identifier do pedido HTTP
|
86
81
|
# @return [Hash] endereco e seus saldo/recursos
|
87
|
-
def account_gm(add
|
88
|
-
JSON.parse(
|
89
|
-
conn_gm.post(
|
90
|
-
uri, { account_name: add }.to_json, content_type: 'application/json'
|
91
|
-
).body,
|
92
|
-
symbolize_names: true
|
93
|
-
)
|
82
|
+
def account_gm(add)
|
83
|
+
JSON.parse(conn_gm.post('/v1/chain/get_account', { account_name: add }.to_json).body, symbolize_names: true)
|
94
84
|
rescue StandardError
|
95
85
|
{ core_liquid_balance: 0, total_resources: { net_weight: 0, cpu_weight: 0 } }
|
96
86
|
end
|
@@ -125,20 +115,17 @@ module Cns
|
|
125
115
|
# }
|
126
116
|
# @param [String] add endereco ETH
|
127
117
|
# @param [Integer] pag pagina transacoes
|
128
|
-
# @param [Array<Hash>]
|
129
|
-
# @param par (see account_es)
|
118
|
+
# @param [Array<Hash>] aes acumulador transacoes
|
130
119
|
# @return [Array<Hash>] lista completa transacoes etherscan
|
131
|
-
def norml_es(add, pag = 0,
|
132
|
-
|
133
|
-
|
134
|
-
o.headers = { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
135
|
-
o.params = par.merge(address: add, page: pag + 1, apikey: ENV['ETHERSCAN_API_KEY'])
|
136
|
-
end).body,
|
120
|
+
def norml_es(add, pag = 0, aes = [])
|
121
|
+
res = JSON.parse(
|
122
|
+
conn_es.get('api', action: 'txlist', offset: 10_000, address: add, page: pag += 1).body,
|
137
123
|
symbolize_names: true
|
138
124
|
)[:result]
|
139
|
-
|
125
|
+
aes += res
|
126
|
+
res.count < 10_000 ? aes : norml_es(add, pag, aes)
|
140
127
|
rescue StandardError
|
141
|
-
|
128
|
+
aes
|
142
129
|
end
|
143
130
|
|
144
131
|
# @example token_es
|
@@ -172,20 +159,18 @@ module Cns
|
|
172
159
|
# }
|
173
160
|
# @param (see norml_es)
|
174
161
|
# @return [Array<Hash>] lista completa token transfer events etherscan
|
175
|
-
def token_es(add, pag = 0,
|
162
|
+
def token_es(add, pag = 0, aes = [])
|
176
163
|
# registos duplicados aparecem em token events (ver exemplo acima)
|
177
164
|
# -quando ha erros na blockchain (acho)
|
178
165
|
# -quando ha token events identicos no mesmo block (acho)
|
179
|
-
|
180
|
-
|
181
|
-
o.headers = { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
182
|
-
o.params = par.merge(address: add, page: pag + 1, apikey: ENV['ETHERSCAN_API_KEY'])
|
183
|
-
end).body,
|
166
|
+
res = JSON.parse(
|
167
|
+
conn_es.get('api', action: 'tokentx', offset: 10_000, address: add, page: pag += 1).body,
|
184
168
|
symbolize_names: true
|
185
169
|
)[:result]
|
186
|
-
|
170
|
+
aes += res
|
171
|
+
res.count < 10_000 ? aes : token_es(add, pag, aes)
|
187
172
|
rescue StandardError
|
188
|
-
|
173
|
+
aes
|
189
174
|
end
|
190
175
|
|
191
176
|
# @example ledger_gm
|
@@ -236,20 +221,17 @@ module Cns
|
|
236
221
|
# last_irreversible_block: 141_721_371
|
237
222
|
# }
|
238
223
|
# @param add (see account_gm)
|
239
|
-
# @param [
|
240
|
-
# @param [Array<Hash>] ary acumulador transacoes
|
241
|
-
# @param uri (see account_gm)
|
224
|
+
# @param [Array<Hash>] agm acumulador transacoes
|
242
225
|
# @return [Array<Hash>] lista completa transacoes greymass
|
243
|
-
def ledger_gm(add,
|
244
|
-
|
245
|
-
conn_gm.post(
|
246
|
-
uri, { account_name: add, pos: pos, offset: 100 }.to_json, content_type: 'application/json'
|
247
|
-
).body,
|
226
|
+
def ledger_gm(add, agm = [])
|
227
|
+
res = JSON.parse(
|
228
|
+
conn_gm.post('/v1/history/get_actions', { account_name: add, pos: agm.count, offset: 100 }.to_json).body,
|
248
229
|
symbolize_names: true
|
249
230
|
)[:actions]
|
250
|
-
|
231
|
+
agm += res
|
232
|
+
res.count < 100 ? agm : ledger_gm(add, agm)
|
251
233
|
rescue StandardError
|
252
|
-
|
234
|
+
agm
|
253
235
|
end
|
254
236
|
|
255
237
|
private
|
@@ -262,18 +244,22 @@ module Cns
|
|
262
244
|
# @return [<Faraday::Connection>] connection object for etherscan
|
263
245
|
def conn_es
|
264
246
|
@conn_es ||=
|
265
|
-
Faraday.new(
|
266
|
-
|
267
|
-
|
247
|
+
Faraday.new(
|
248
|
+
url: 'https://api.etherscan.io/',
|
249
|
+
params: { module: 'account', apikey: ENV['ETHERSCAN_API_KEY'] },
|
250
|
+
headers: { content_type: 'application/json', accept: 'application/json', user_agent: 'etherscan;ruby' }
|
251
|
+
) do |con|
|
252
|
+
con.request(:url_encoded)
|
253
|
+
con.adapter(adapter)
|
268
254
|
end
|
269
255
|
end
|
270
256
|
|
271
257
|
# @return [<Faraday::Connection>] connection object for greymass
|
272
258
|
def conn_gm
|
273
259
|
@conn_gm ||=
|
274
|
-
Faraday.new(url: 'https://eos.greymass.com') do |
|
275
|
-
|
276
|
-
|
260
|
+
Faraday.new(url: 'https://eos.greymass.com', headers: { content_type: 'application/json' }) do |con|
|
261
|
+
con.request(:url_encoded)
|
262
|
+
con.adapter(adapter)
|
277
263
|
end
|
278
264
|
end
|
279
265
|
end
|
data/lib/cns/apice1.rb
CHANGED
@@ -31,7 +31,7 @@ module Cns
|
|
31
31
|
# @return [Hash] saldos no bitcoinde
|
32
32
|
def account_de(uri = 'https://api.bitcoin.de/v4/account')
|
33
33
|
JSON.parse(
|
34
|
-
Curl.get(uri) { |
|
34
|
+
Curl.get(uri) { |obj| obj.headers = hde(uri) }.body,
|
35
35
|
symbolize_names: true
|
36
36
|
)[:data][:balances]
|
37
37
|
rescue StandardError
|
@@ -56,7 +56,7 @@ module Cns
|
|
56
56
|
# @return [Hash] saldos no paymium
|
57
57
|
def account_fr(uri = 'https://paymium.com/api/v1/user')
|
58
58
|
JSON.parse(
|
59
|
-
Curl.get(uri) { |
|
59
|
+
Curl.get(uri) { |obj| obj.headers = hfr(uri) }.body,
|
60
60
|
symbolize_names: true
|
61
61
|
)
|
62
62
|
rescue StandardError
|
@@ -76,11 +76,11 @@ module Cns
|
|
76
76
|
# @return [Array<Hash>] lista saldos no therock
|
77
77
|
def account_mt(uri = 'https://api.therocktrading.com/v1/balances')
|
78
78
|
JSON.parse(
|
79
|
-
Curl.get(uri) { |
|
79
|
+
Curl.get(uri) { |obj| obj.headers = hmt(uri) }.body,
|
80
80
|
symbolize_names: true
|
81
81
|
)[:balances]
|
82
|
-
.delete_if { |
|
83
|
-
.sort { |
|
82
|
+
.delete_if { |del| DC.include?(del[:currency]) }
|
83
|
+
.sort { |oba, obb| oba[:currency] <=> obb[:currency] }
|
84
84
|
rescue StandardError
|
85
85
|
[]
|
86
86
|
end
|
@@ -103,7 +103,7 @@ module Cns
|
|
103
103
|
# @return [Hash] saldos no kraken
|
104
104
|
def account_us(urb = 'https://api.kraken.com/0/private', uri = 'Balance', non = nnc)
|
105
105
|
JSON.parse(
|
106
|
-
Curl.post("#{urb}/#{uri}", nonce: non) { |
|
106
|
+
Curl.post("#{urb}/#{uri}", nonce: non) { |obj| obj.headers = hus(uri, nonce: non) }.body,
|
107
107
|
symbolize_names: true
|
108
108
|
)[:result]
|
109
109
|
rescue StandardError
|
@@ -112,113 +112,63 @@ module Cns
|
|
112
112
|
|
113
113
|
private
|
114
114
|
|
115
|
-
# @example deposits_unif_de
|
116
|
-
# [
|
117
|
-
# {
|
118
|
-
# txid: 177_245,
|
119
|
-
# time: '2014-01-31T22:01:30+01:00',
|
120
|
-
# tp: 'deposit',
|
121
|
-
# add: '1KK6HhG3quojFS4CY1mPcbyrjQ8BMDQxmT',
|
122
|
-
# qt: '0.13283',
|
123
|
-
# moe: 'btc',
|
124
|
-
# fee: '0'
|
125
|
-
# },
|
126
|
-
# {}
|
127
|
-
# ]
|
128
|
-
# @param [Hash] hde pagina depositos bitcoinde
|
129
|
-
# @return [Array<Hash>] lista uniformizada pagina depositos bitcoinde
|
130
|
-
def deposits_unif_de(hde)
|
131
|
-
hde[:deposits].map do |h|
|
132
|
-
{
|
133
|
-
add: h[:address],
|
134
|
-
time: Time.parse(h[:created_at]),
|
135
|
-
qt: h[:amount],
|
136
|
-
txid: Integer(h[:deposit_id])
|
137
|
-
}.merge(tp: 'deposit', moe: 'btc', fee: '0')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# @example withdrawals_unif_de
|
142
|
-
# [
|
143
|
-
# {
|
144
|
-
# txid: 136_605,
|
145
|
-
# time: '2014-02-05T13:05:17+01:00',
|
146
|
-
# tp: 'withdrawal',
|
147
|
-
# add: '1K9YMDDrmMV25EoYNqi7KUEK57Kn3TCNUJ',
|
148
|
-
# qt: '0.120087',
|
149
|
-
# fee: '0',
|
150
|
-
# moe: 'btc'
|
151
|
-
# },
|
152
|
-
# {}
|
153
|
-
# ]
|
154
|
-
# @param [Hash] hwi pagina withdrawals bitcoinde
|
155
|
-
# @return [Array<Hash>] lista uniformizada pagina withdrawals bitcoinde
|
156
|
-
def withdrawals_unif_de(hwi)
|
157
|
-
hwi[:withdrawals].map do |h|
|
158
|
-
{
|
159
|
-
add: h[:address],
|
160
|
-
time: Time.parse(h[:transferred_at]),
|
161
|
-
qt: h[:amount],
|
162
|
-
fee: h[:network_fee],
|
163
|
-
txid: Integer(h[:withdrawal_id])
|
164
|
-
}.merge(tp: 'withdrawal', moe: 'btc')
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
115
|
# @return [Integer] continually-increasing unsigned integer nonce from the current Unix Time
|
169
116
|
def nnc
|
170
117
|
Integer(Float(Time.now) * 1e6)
|
171
118
|
end
|
172
119
|
|
173
|
-
# @param [String]
|
120
|
+
# @param [String] qde query a incluir no pedido HTTP
|
174
121
|
# @param [Integer] non continually-increasing unsigned integer
|
175
122
|
# @return [Hash] headers necessarios para pedido HTTP da exchange bitcoinde
|
176
|
-
def hde(
|
123
|
+
def hde(qde, non = nnc)
|
124
|
+
key = ENV['BITCOINDE_API_KEY']
|
177
125
|
{
|
178
|
-
'X-API-KEY':
|
126
|
+
'X-API-KEY': key,
|
179
127
|
'X-API-NONCE': non,
|
180
128
|
'X-API-SIGNATURE': OpenSSL::HMAC.hexdigest(
|
181
129
|
'sha256',
|
182
130
|
ENV['BITCOINDE_API_SECRET'],
|
183
|
-
['GET',
|
131
|
+
['GET', qde, key, non, Digest::MD5.hexdigest('')].join('#')
|
184
132
|
)
|
185
133
|
}
|
186
134
|
end
|
187
135
|
|
188
|
-
# @param
|
136
|
+
# @param [String] qfr query a incluir no pedido HTTP
|
137
|
+
# @param non (see hde)
|
189
138
|
# @return [Hash] headers necessarios para pedido HTTP da exchange paymium
|
190
|
-
def hfr(
|
139
|
+
def hfr(qfr, non = nnc)
|
191
140
|
{
|
192
141
|
content_type: 'application/json',
|
193
142
|
'Api-Key': ENV['PAYMIUM_API_KEY'],
|
194
143
|
'Api-Nonce': non,
|
195
|
-
'Api-Signature': OpenSSL::HMAC.hexdigest('sha256', ENV['PAYMIUM_API_SECRET'], [non,
|
144
|
+
'Api-Signature': OpenSSL::HMAC.hexdigest('sha256', ENV['PAYMIUM_API_SECRET'], [non, qfr].join)
|
196
145
|
}
|
197
146
|
end
|
198
147
|
|
199
|
-
# @param
|
148
|
+
# @param [String] qmt query a incluir no pedido HTTP
|
149
|
+
# @param non (see hde)
|
200
150
|
# @return [Hash] headers necessarios para pedido HTTP da exchange therock
|
201
|
-
def hmt(
|
151
|
+
def hmt(qmt, non = nnc)
|
202
152
|
{
|
203
153
|
content_type: 'application/json',
|
204
154
|
'X-TRT-KEY': ENV['THEROCK_API_KEY'],
|
205
155
|
'X-TRT-NONCE': non,
|
206
|
-
'X-TRT-SIGN': OpenSSL::HMAC.hexdigest('sha512', ENV['THEROCK_API_SECRET'], [non,
|
156
|
+
'X-TRT-SIGN': OpenSSL::HMAC.hexdigest('sha512', ENV['THEROCK_API_SECRET'], [non, qmt].join)
|
207
157
|
}
|
208
158
|
end
|
209
159
|
|
210
|
-
# @param
|
160
|
+
# @param [String] qus query a incluir no pedido HTTP
|
211
161
|
# @param [Hash] ops opcoes trabalho
|
212
162
|
# @option ops [Hash] :nonce continually-increasing unsigned integer
|
213
163
|
# @return [Hash] headers necessarios para pedido HTTP da exchange kraken
|
214
|
-
def hus(
|
164
|
+
def hus(qus, ops)
|
215
165
|
{
|
216
166
|
'api-key': ENV['KRAKEN_API_KEY'],
|
217
167
|
'api-sign': Base64.strict_encode64(
|
218
168
|
OpenSSL::HMAC.digest(
|
219
169
|
'sha512',
|
220
170
|
Base64.decode64(ENV['KRAKEN_API_SECRET']),
|
221
|
-
['/0/private/',
|
171
|
+
['/0/private/', qus, Digest::SHA256.digest("#{ops[:nonce]}#{URI.encode_www_form(ops)}")].join
|
222
172
|
)
|
223
173
|
)
|
224
174
|
}
|