peatio-thought 2.6.2 → 2.6.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +47 -41
- data/lib/peatio/thought/blockchain.rb +43 -42
- data/lib/peatio/thought/client.rb +37 -52
- data/lib/peatio/thought/hooks.rb +2 -2
- data/lib/peatio/thought/version.rb +1 -1
- data/lib/peatio/thought/wallet.rb +5 -2
- data/peatio-thought.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '028099f7c3681bca1f3e0cbcc689b09447007eed1b75c449d1fc39604ff829aa'
|
4
|
+
data.tar.gz: aa7b100a98151601f2ceb2388994b42bd004f69782161cd2e87ca611ae854c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1104b0c7a12c5b0586b70a0de5ab0d9f6b8f5202dbf3d4b3a0220323e4d3eef4d593ba9483e7f7cc9e06de5cdecace596a8618512bb42b877b485e0fc3f345a5
|
7
|
+
data.tar.gz: fd65fe7716dead037367225c4447d287b7b54dcfcaf43d9ae6372bbda7ed32db658038410afd1c3d3c270ed16a7ab1ab638508edcd46056922f05ee35d6b7c96
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
peatio-thought (2.6
|
4
|
+
peatio-thought (2.6.7.2)
|
5
5
|
activesupport (~> 5.2.3)
|
6
6
|
better-faraday (~> 1.0.5)
|
7
|
-
faraday (~> 0.
|
7
|
+
faraday (~> 0.17)
|
8
8
|
memoist (~> 0.16.0)
|
9
9
|
net-http-persistent (~> 3.0.1)
|
10
10
|
peatio (>= 0.6.3)
|
@@ -25,22 +25,21 @@ GEM
|
|
25
25
|
amqp (1.8.0)
|
26
26
|
amq-protocol (>= 2.2.0)
|
27
27
|
eventmachine
|
28
|
-
ast (2.4.
|
28
|
+
ast (2.4.1)
|
29
29
|
better-faraday (1.0.8)
|
30
30
|
activesupport (>= 4.0, < 6.0)
|
31
31
|
faraday (~> 0.12)
|
32
32
|
bunny (2.17.0)
|
33
33
|
amq-protocol (~> 2.3, >= 2.3.1)
|
34
|
-
byebug (11.1.
|
34
|
+
byebug (11.1.3)
|
35
35
|
clamp (1.3.2)
|
36
|
-
coderay (1.1.
|
36
|
+
coderay (1.1.3)
|
37
37
|
concurrent-ruby (1.1.7)
|
38
38
|
connection_pool (2.2.3)
|
39
39
|
cookiejar (0.3.3)
|
40
|
-
crack (0.4.
|
41
|
-
safe_yaml (~> 1.0.0)
|
40
|
+
crack (0.4.4)
|
42
41
|
daemons (1.3.1)
|
43
|
-
diff-lcs (1.
|
42
|
+
diff-lcs (1.4.4)
|
44
43
|
docile (1.3.2)
|
45
44
|
em-http-request (1.1.7)
|
46
45
|
addressable (>= 2.3.4)
|
@@ -56,7 +55,7 @@ GEM
|
|
56
55
|
eventmachine (>= 0.12.9)
|
57
56
|
http_parser.rb (~> 0.6.0)
|
58
57
|
eventmachine (1.2.7)
|
59
|
-
faraday (0.
|
58
|
+
faraday (0.17.3)
|
60
59
|
multipart-post (>= 1.2, < 3)
|
61
60
|
faraday_middleware (0.13.1)
|
62
61
|
faraday (>= 0.7.4, < 1.0)
|
@@ -76,8 +75,8 @@ GEM
|
|
76
75
|
i18n (1.8.5)
|
77
76
|
concurrent-ruby (~> 1.0)
|
78
77
|
io-console (0.5.6)
|
79
|
-
irb (1.2.
|
80
|
-
reline (>= 0.
|
78
|
+
irb (1.2.7)
|
79
|
+
reline (>= 0.1.5)
|
81
80
|
jaro_winkler (1.5.4)
|
82
81
|
jwt (2.2.2)
|
83
82
|
memoist (0.16.2)
|
@@ -89,9 +88,9 @@ GEM
|
|
89
88
|
mysql2 (0.5.3)
|
90
89
|
net-http-persistent (3.0.1)
|
91
90
|
connection_pool (~> 2.2)
|
92
|
-
parallel (1.
|
93
|
-
parser (2.7.0
|
94
|
-
ast (~> 2.4.
|
91
|
+
parallel (1.20.0)
|
92
|
+
parser (2.7.2.0)
|
93
|
+
ast (~> 2.4.1)
|
95
94
|
peatio (2.6.2)
|
96
95
|
activemodel (> 5.2, <= 6.0.0)
|
97
96
|
amqp
|
@@ -107,48 +106,55 @@ GEM
|
|
107
106
|
prometheus-client
|
108
107
|
thin
|
109
108
|
prometheus-client (2.1.0)
|
110
|
-
pry (0.13.
|
109
|
+
pry (0.13.1)
|
111
110
|
coderay (~> 1.1)
|
112
111
|
method_source (~> 1.0)
|
113
112
|
pry-byebug (3.9.0)
|
114
113
|
byebug (~> 11.0)
|
115
114
|
pry (~> 0.13.0)
|
116
|
-
public_suffix (4.0.
|
115
|
+
public_suffix (4.0.6)
|
117
116
|
rack (2.2.3)
|
118
117
|
rainbow (3.0.0)
|
119
|
-
rake (
|
120
|
-
reline (0.1.
|
118
|
+
rake (13.0.1)
|
119
|
+
reline (0.1.8)
|
121
120
|
io-console (~> 0.5)
|
122
121
|
rexml (3.2.4)
|
123
|
-
rspec (3.
|
124
|
-
rspec-core (~> 3.
|
125
|
-
rspec-expectations (~> 3.
|
126
|
-
rspec-mocks (~> 3.
|
127
|
-
rspec-core (3.
|
128
|
-
rspec-support (~> 3.
|
129
|
-
rspec-expectations (3.
|
122
|
+
rspec (3.10.0)
|
123
|
+
rspec-core (~> 3.10.0)
|
124
|
+
rspec-expectations (~> 3.10.0)
|
125
|
+
rspec-mocks (~> 3.10.0)
|
126
|
+
rspec-core (3.10.0)
|
127
|
+
rspec-support (~> 3.10.0)
|
128
|
+
rspec-expectations (3.10.0)
|
130
129
|
diff-lcs (>= 1.2.0, < 2.0)
|
131
|
-
rspec-support (~> 3.
|
132
|
-
rspec-mocks (3.
|
130
|
+
rspec-support (~> 3.10.0)
|
131
|
+
rspec-mocks (3.10.0)
|
133
132
|
diff-lcs (>= 1.2.0, < 2.0)
|
134
|
-
rspec-support (~> 3.
|
135
|
-
rspec-support (3.
|
136
|
-
rubocop (0.
|
133
|
+
rspec-support (~> 3.10.0)
|
134
|
+
rspec-support (3.10.0)
|
135
|
+
rubocop (0.82.0)
|
137
136
|
jaro_winkler (~> 1.5.1)
|
138
137
|
parallel (~> 1.10)
|
139
138
|
parser (>= 2.7.0.1)
|
140
139
|
rainbow (>= 2.2.2, < 4.0)
|
141
140
|
rexml
|
142
141
|
ruby-progressbar (~> 1.7)
|
143
|
-
unicode-display_width (>= 1.4.0, <
|
144
|
-
rubocop-github (0.
|
145
|
-
rubocop (
|
142
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
143
|
+
rubocop-github (0.16.0)
|
144
|
+
rubocop (<= 0.82.0)
|
145
|
+
rubocop-performance (~> 1.0)
|
146
|
+
rubocop-rails (~> 2.0)
|
147
|
+
rubocop-performance (1.7.1)
|
148
|
+
rubocop (>= 0.82.0)
|
149
|
+
rubocop-rails (2.6.0)
|
150
|
+
activesupport (>= 4.2.0)
|
151
|
+
rack (>= 1.1)
|
152
|
+
rubocop (>= 0.82.0)
|
146
153
|
ruby-progressbar (1.10.1)
|
147
|
-
|
148
|
-
simplecov (0.18.5)
|
154
|
+
simplecov (0.19.1)
|
149
155
|
docile (~> 1.1)
|
150
156
|
simplecov-html (~> 0.11)
|
151
|
-
simplecov-html (0.12.
|
157
|
+
simplecov-html (0.12.3)
|
152
158
|
thin (1.8.0)
|
153
159
|
daemons (~> 1.0, >= 1.0.9)
|
154
160
|
eventmachine (~> 1.0, >= 1.0.4)
|
@@ -156,8 +162,8 @@ GEM
|
|
156
162
|
thread_safe (0.3.6)
|
157
163
|
tzinfo (1.2.8)
|
158
164
|
thread_safe (~> 0.1)
|
159
|
-
unicode-display_width (1.
|
160
|
-
webmock (3.
|
165
|
+
unicode-display_width (1.7.0)
|
166
|
+
webmock (3.10.0)
|
161
167
|
addressable (>= 2.3.6)
|
162
168
|
crack (>= 0.3.2)
|
163
169
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -169,16 +175,16 @@ PLATFORMS
|
|
169
175
|
ruby
|
170
176
|
|
171
177
|
DEPENDENCIES
|
172
|
-
bundler (~> 1.
|
178
|
+
bundler (~> 2.1.3)
|
173
179
|
irb
|
174
180
|
mocha (~> 1.8)
|
175
181
|
peatio-thought!
|
176
182
|
pry-byebug
|
177
|
-
rake (~>
|
183
|
+
rake (~> 13.0)
|
178
184
|
rspec (~> 3.0)
|
179
185
|
rubocop-github
|
180
186
|
simplecov
|
181
187
|
webmock (~> 3.5)
|
182
188
|
|
183
189
|
BUNDLED WITH
|
184
|
-
1.
|
190
|
+
2.1.4
|
@@ -29,9 +29,10 @@ module Peatio
|
|
29
29
|
end
|
30
30
|
|
31
31
|
Peatio::Block.new(block_number, block_txs)
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
rescue Client::Error => e
|
33
|
+
raise Peatio::Blockchain::ClientError, e
|
34
|
+
end
|
35
|
+
|
35
36
|
|
36
37
|
def latest_block_number
|
37
38
|
client.json_rpc(:getblockcount)
|
@@ -44,42 +45,42 @@ module Peatio
|
|
44
45
|
.flatten(1)
|
45
46
|
.find {|addr| addr[0] == address }
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
48
|
+
raise Peatio::Blockchain::UnavailableAddressBalanceError, address if address_with_balance.blank?
|
49
|
+
|
50
|
+
address_with_balance[1].to_d
|
51
|
+
rescue Client::Error => e
|
52
|
+
raise Peatio::Blockchain::ClientError, e
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def filter_vout(tx_hash)
|
58
|
+
tx_hash.fetch("vout").select do |entry|
|
59
|
+
entry.fetch("value").to_d.positive? && entry["scriptPubKey"].has_key?("addresses")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def build_transaction(tx_hash)
|
64
|
+
filter_vout(tx_hash).each_with_object([]) do |entry, formatted_txs|
|
65
|
+
no_currency_tx = {hash: tx_hash["txid"], txout: entry["n"],
|
66
|
+
to_address: entry["scriptPubKey"]["addresses"][0],
|
67
|
+
amount: entry.fetch("value").to_d,
|
68
|
+
status: "success"}
|
69
|
+
|
70
|
+
# Build transaction for each currency belonging to blockchain.
|
71
|
+
settings_fetch(:currencies).pluck(:id).each do |currency_id|
|
72
|
+
formatted_txs << no_currency_tx.merge(currency_id: currency_id)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def client
|
78
|
+
@client ||= Client.new(settings_fetch(:server))
|
79
|
+
end
|
80
|
+
|
81
|
+
def settings_fetch(key)
|
82
|
+
@settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,71 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'memoist'
|
4
|
+
require 'faraday'
|
5
|
+
require 'better-faraday'
|
6
6
|
|
7
7
|
module Peatio
|
8
8
|
module Thought
|
9
9
|
class Client
|
10
|
-
|
11
|
-
class ConnectionError < Error; end
|
10
|
+
Error = Class.new(StandardError)
|
12
11
|
|
13
|
-
|
14
|
-
def initialize(code, msg)
|
15
|
-
@code = code
|
16
|
-
@msg = msg
|
17
|
-
end
|
18
|
-
|
19
|
-
def message
|
20
|
-
"#{@msg} (#{@code})"
|
21
|
-
end
|
22
|
-
end
|
12
|
+
class ConnectionError < Error; end
|
23
13
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@json_rpc_endpoint = URI.parse(endpoint)
|
14
|
+
class ResponseError < Error
|
15
|
+
def initialize(code, msg)
|
16
|
+
super "#{msg} (#{code})"
|
28
17
|
end
|
18
|
+
end
|
29
19
|
|
30
|
-
|
31
|
-
response = post(method, params)
|
32
|
-
|
33
|
-
response.assert_2xx!
|
34
|
-
response = JSON.parse(response.body)
|
20
|
+
extend Memoist
|
35
21
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
response.fetch("result")
|
41
|
-
rescue StandardError => e
|
42
|
-
case e
|
43
|
-
when Faraday::Error
|
44
|
-
raise ConnectionError, e
|
45
|
-
when Error
|
46
|
-
raise e
|
47
|
-
else
|
48
|
-
raise Error, e
|
49
|
-
end
|
50
|
-
end
|
22
|
+
def initialize(endpoint, idle_timeout: 5)
|
23
|
+
@json_rpc_endpoint = URI.parse(endpoint)
|
24
|
+
@idle_timeout = idle_timeout
|
25
|
+
end
|
51
26
|
|
52
|
-
|
27
|
+
def json_rpc(method, params = [])
|
28
|
+
response = connection.post \
|
29
|
+
'/',
|
30
|
+
{jsonrpc: '1.0', method: method, params: params}.to_json,
|
31
|
+
{'Accept' => 'application/json',
|
32
|
+
'Content-Type' => 'application/json'}
|
33
|
+
response.assert_success!
|
34
|
+
response = JSON.parse(response.body)
|
35
|
+
response['error'].tap { |error| raise ResponseError.new(error['code'], error['message']) if error }
|
36
|
+
response.fetch('result')
|
37
|
+
rescue Faraday::Error => e
|
38
|
+
raise ConnectionError, e
|
39
|
+
rescue StandardError => e
|
40
|
+
raise Error, e
|
41
|
+
end
|
53
42
|
|
54
|
-
|
55
|
-
connection.post("/", {jsonrpc: "1.0", method: method, params: params}.to_json,
|
56
|
-
"Accept" => "application/json", "Content-Type" => "application/json")
|
57
|
-
end
|
43
|
+
private
|
58
44
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
@json_rpc_endpoint.password)
|
66
|
-
end
|
45
|
+
def connection
|
46
|
+
@connection ||= Faraday.new(@json_rpc_endpoint) do |f|
|
47
|
+
f.adapter :net_http_persistent, pool_size: 5, idle_timeout: @idle_timeout
|
48
|
+
end.tap do |connection|
|
49
|
+
unless @json_rpc_endpoint.user.blank?
|
50
|
+
connection.basic_auth(@json_rpc_endpoint.user, @json_rpc_endpoint.password)
|
67
51
|
end
|
68
52
|
end
|
69
53
|
end
|
70
54
|
end
|
71
55
|
end
|
56
|
+
end
|
data/lib/peatio/thought/hooks.rb
CHANGED
@@ -28,8 +28,8 @@ module Peatio
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def register
|
31
|
-
Peatio::Blockchain.registry[:thought] = Thought::Blockchain
|
32
|
-
Peatio::Wallet.registry[:thoughtd] = Thought::Wallet
|
31
|
+
Peatio::Blockchain.registry[:thought] = Thought::Blockchain
|
32
|
+
Peatio::Wallet.registry[:thoughtd] = Thought::Wallet
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -3,8 +3,11 @@
|
|
3
3
|
module Peatio
|
4
4
|
module Thought
|
5
5
|
class Wallet < Peatio::Wallet::Abstract
|
6
|
-
|
7
|
-
|
6
|
+
DEFAULT_FEATURES = { skip_deposit_collection: false }.freeze
|
7
|
+
|
8
|
+
def initialize(custom_features = {})
|
9
|
+
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
10
|
+
@settings = {}
|
8
11
|
end
|
9
12
|
|
10
13
|
def configure(settings={})
|
data/peatio-thought.gemspec
CHANGED
@@ -43,11 +43,11 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_dependency "peatio", ">= 0.6.3"
|
44
44
|
spec.add_dependency 'net-http-persistent', '~> 3.0.1'
|
45
45
|
|
46
|
-
spec.add_development_dependency "bundler", "~> 1.
|
46
|
+
spec.add_development_dependency "bundler", "~> 2.1.3"
|
47
47
|
spec.add_development_dependency "irb"
|
48
48
|
spec.add_development_dependency "mocha", "~> 1.8"
|
49
49
|
spec.add_development_dependency "pry-byebug"
|
50
|
-
spec.add_development_dependency "rake", "~>
|
50
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
51
51
|
spec.add_development_dependency "rspec", "~> 3.0"
|
52
52
|
spec.add_development_dependency "rubocop-github"
|
53
53
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio-thought
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.2
|
4
|
+
version: 2.6.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew@Thought
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.1.3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.1.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: irb
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '13.0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '13.0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rspec
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|