peatio-bitgo 1.1.4 → 2.6.2
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 +14 -14
- data/lib/peatio/bitgo/client.rb +2 -4
- data/lib/peatio/bitgo/hooks.rb +2 -2
- data/lib/peatio/bitgo/version.rb +1 -1
- data/lib/peatio/bitgo/wallet.rb +31 -10
- data/peatio-bitgo.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863d387c7b57c73ce93ec4157f024f866ae5535605c4e65806b2becfe9251015
|
4
|
+
data.tar.gz: 59513ea996a0a5fb87abe27492d8944b7ce2d8557a89f75814622f437b189ffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9b4ea980fe2f0fa19c4f10991b3017d0e4cbff8273fe411c945d0a82004578ec1b12fd9d31f8081544a914509bd92d246083c36cd9444b75ab82f591f7a8cd8
|
7
|
+
data.tar.gz: 2987a6430253bb2e6882980760f5a14423b102f47d8b3daa07d8daaa094c6ec41cfb443fe4fe39471a1be647855096608176d0caf547a2e41876ebe57c5c685f
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
peatio-bitgo (
|
4
|
+
peatio-bitgo (2.6.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)
|
@@ -12,9 +12,9 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (5.2.4.
|
16
|
-
activesupport (= 5.2.4.
|
17
|
-
activesupport (5.2.4.
|
15
|
+
activemodel (5.2.4.3)
|
16
|
+
activesupport (= 5.2.4.3)
|
17
|
+
activesupport (5.2.4.3)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
@@ -34,13 +34,13 @@ GEM
|
|
34
34
|
clamp (1.3.1)
|
35
35
|
coderay (1.1.2)
|
36
36
|
concurrent-ruby (1.1.6)
|
37
|
-
connection_pool (2.2.
|
37
|
+
connection_pool (2.2.3)
|
38
38
|
cookiejar (0.3.3)
|
39
39
|
crack (0.4.3)
|
40
40
|
safe_yaml (~> 1.0.0)
|
41
41
|
daemons (1.3.1)
|
42
42
|
diff-lcs (1.3)
|
43
|
-
em-http-request (1.1.
|
43
|
+
em-http-request (1.1.6)
|
44
44
|
addressable (>= 2.3.4)
|
45
45
|
cookiejar (!= 0.3.1)
|
46
46
|
em-socksify (>= 0.3)
|
@@ -54,11 +54,11 @@ GEM
|
|
54
54
|
eventmachine (>= 0.12.9)
|
55
55
|
http_parser.rb (~> 0.6.0)
|
56
56
|
eventmachine (1.2.7)
|
57
|
-
faraday (0.
|
57
|
+
faraday (0.17.3)
|
58
58
|
multipart-post (>= 1.2, < 3)
|
59
59
|
faraday_middleware (0.13.1)
|
60
60
|
faraday (>= 0.7.4, < 1.0)
|
61
|
-
faye (1.
|
61
|
+
faye (1.3.0)
|
62
62
|
cookiejar (>= 0.3.0)
|
63
63
|
em-http-request (>= 0.3.0)
|
64
64
|
eventmachine (>= 0.12.0)
|
@@ -71,19 +71,19 @@ GEM
|
|
71
71
|
websocket-driver (>= 0.5.1)
|
72
72
|
hashdiff (1.0.1)
|
73
73
|
http_parser.rb (0.6.0)
|
74
|
-
i18n (1.8.
|
74
|
+
i18n (1.8.3)
|
75
75
|
concurrent-ruby (~> 1.0)
|
76
76
|
jwt (2.2.1)
|
77
77
|
memoist (0.16.2)
|
78
78
|
method_source (1.0.0)
|
79
|
-
minitest (5.14.
|
79
|
+
minitest (5.14.1)
|
80
80
|
mocha (1.11.2)
|
81
81
|
multi_json (1.14.1)
|
82
82
|
multipart-post (2.1.1)
|
83
83
|
mysql2 (0.5.3)
|
84
84
|
net-http-persistent (3.0.1)
|
85
85
|
connection_pool (~> 2.2)
|
86
|
-
peatio (2.
|
86
|
+
peatio (2.6.1)
|
87
87
|
activemodel (> 5.2, <= 6.0.0)
|
88
88
|
amqp
|
89
89
|
bunny
|
@@ -132,9 +132,9 @@ GEM
|
|
132
132
|
addressable (>= 2.3.6)
|
133
133
|
crack (>= 0.3.2)
|
134
134
|
hashdiff (>= 0.4.0, < 2.0.0)
|
135
|
-
websocket-driver (0.7.
|
135
|
+
websocket-driver (0.7.2)
|
136
136
|
websocket-extensions (>= 0.1.0)
|
137
|
-
websocket-extensions (0.1.
|
137
|
+
websocket-extensions (0.1.5)
|
138
138
|
|
139
139
|
PLATFORMS
|
140
140
|
ruby
|
data/lib/peatio/bitgo/client.rb
CHANGED
@@ -5,7 +5,7 @@ module Peatio
|
|
5
5
|
module Bitgo
|
6
6
|
class Client
|
7
7
|
Error = Class.new(StandardError)
|
8
|
-
|
8
|
+
ConnectionError = Class.new(Error)
|
9
9
|
|
10
10
|
class ResponseError < Error
|
11
11
|
def initialize(msg)
|
@@ -22,7 +22,7 @@ module Peatio
|
|
22
22
|
args = [@endpoint.to_s + path]
|
23
23
|
|
24
24
|
if data
|
25
|
-
if %i[
|
25
|
+
if %i[post put patch].include?(verb)
|
26
26
|
args << data.compact.to_json
|
27
27
|
args << { 'Content-Type' => 'application/json' }
|
28
28
|
else
|
@@ -48,8 +48,6 @@ module Peatio
|
|
48
48
|
else
|
49
49
|
raise ConnectionError, JSON.parse(e.response.body)['message']
|
50
50
|
end
|
51
|
-
rescue StandardError => e
|
52
|
-
raise Error, e
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
data/lib/peatio/bitgo/hooks.rb
CHANGED
@@ -9,7 +9,7 @@ module Peatio
|
|
9
9
|
unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
|
10
10
|
.satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
|
11
11
|
[
|
12
|
-
"Bitgo blockchain version
|
12
|
+
"Bitgo blockchain version requirement was not satisfied by Peatio::Blockchain.",
|
13
13
|
"Bitgo blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
|
14
14
|
"Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
|
15
15
|
].join('\n').tap { |s| Kernel.abort s }
|
@@ -18,7 +18,7 @@ module Peatio
|
|
18
18
|
unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
|
19
19
|
.satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
|
20
20
|
[
|
21
|
-
"Bitgo wallet version
|
21
|
+
"Bitgo wallet version requirement was not satisfied by Peatio::Wallet.",
|
22
22
|
"Bitgo wallet requires #{WALLET_VERSION_REQUIREMENT}.",
|
23
23
|
"Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
|
24
24
|
].join('\n').tap { |s| Kernel.abort s }
|
data/lib/peatio/bitgo/version.rb
CHANGED
data/lib/peatio/bitgo/wallet.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Peatio
|
2
2
|
module Bitgo
|
3
3
|
class Wallet < Peatio::Wallet::Abstract
|
4
|
+
TIME_DIFFERENCE_IN_MINUTES = 10
|
4
5
|
|
5
|
-
|
6
|
-
|
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 = {}
|
7
11
|
end
|
8
12
|
|
9
13
|
def configure(settings = {})
|
@@ -24,10 +28,14 @@ module Peatio
|
|
24
28
|
def create_address!(options = {})
|
25
29
|
currency = erc20_currency_id
|
26
30
|
options.deep_symbolize_keys!
|
27
|
-
|
31
|
+
|
32
|
+
if options.dig(:pa_details, :address_id).present? &&
|
33
|
+
options.dig(:pa_details, :updated_at).present? &&
|
34
|
+
time_difference_in_minutes(options.dig(:pa_details, :updated_at)) >= TIME_DIFFERENCE_IN_MINUTES
|
35
|
+
|
28
36
|
response = client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{options.dig(:pa_details, :address_id)}")
|
29
37
|
{ address: response['address'], secret: bitgo_wallet_passphrase }
|
30
|
-
|
38
|
+
elsif options.dig(:pa_details, :address_id).blank?
|
31
39
|
response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
|
32
40
|
{ address: response['address'], secret: bitgo_wallet_passphrase, details: { address_id: response['id'] }}
|
33
41
|
end
|
@@ -111,14 +119,15 @@ module Peatio
|
|
111
119
|
end
|
112
120
|
|
113
121
|
def trigger_webhook_event(event)
|
114
|
-
|
115
|
-
return unless
|
122
|
+
currency = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
|
123
|
+
return unless currency == event['coin'] && @wallet.fetch(:wallet_id) == event['wallet']
|
116
124
|
|
117
125
|
if event['type'] == 'transfer'
|
118
126
|
transactions = fetch_transfer!(event['transfer'])
|
119
127
|
return { transfers: transactions }
|
120
|
-
elsif event['address_confirmation'
|
121
|
-
|
128
|
+
elsif event['type'] == 'address_confirmation'
|
129
|
+
address_id = fetch_address_id(event['address'])
|
130
|
+
return { address_id: address_id, currency_id: currency_id }
|
122
131
|
end
|
123
132
|
end
|
124
133
|
|
@@ -127,6 +136,14 @@ module Peatio
|
|
127
136
|
address_confirmation_webhook(url)
|
128
137
|
end
|
129
138
|
|
139
|
+
def fetch_address_id(address)
|
140
|
+
currency = erc20_currency_id
|
141
|
+
client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{address}")
|
142
|
+
.fetch('id')
|
143
|
+
rescue Bitgo::Client::Error => e
|
144
|
+
raise Peatio::Wallet::ClientError, e
|
145
|
+
end
|
146
|
+
|
130
147
|
def fetch_transfer!(id)
|
131
148
|
# TODO: Add Rspecs for this one
|
132
149
|
response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
|
@@ -169,7 +186,7 @@ module Peatio
|
|
169
186
|
|
170
187
|
def address_confirmation_webhook(url)
|
171
188
|
client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
|
172
|
-
type: '
|
189
|
+
type: 'address_confirmation',
|
173
190
|
allToken: true,
|
174
191
|
url: url,
|
175
192
|
label: "webhook for #{url}",
|
@@ -252,9 +269,13 @@ module Peatio
|
|
252
269
|
x.to_i
|
253
270
|
end
|
254
271
|
|
272
|
+
def time_difference_in_minutes(updated_at)
|
273
|
+
(Time.now - updated_at)/60
|
274
|
+
end
|
275
|
+
|
255
276
|
def define_transaction_state(state)
|
256
277
|
case state
|
257
|
-
when '
|
278
|
+
when 'unconfirmed'
|
258
279
|
'pending'
|
259
280
|
when 'confirmed'
|
260
281
|
'success'
|
data/peatio-bitgo.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_dependency "activesupport", "~> 5.2.3"
|
27
27
|
spec.add_dependency "better-faraday", "~> 1.0.5"
|
28
|
-
spec.add_dependency "faraday", "~> 0.
|
28
|
+
spec.add_dependency "faraday", "~> 0.17"
|
29
29
|
spec.add_dependency "memoist", "~> 0.16.0"
|
30
30
|
spec.add_dependency "peatio", ">= 0.6.3"
|
31
31
|
spec.add_dependency 'net-http-persistent', '~> 3.0.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio-bitgo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nadia Ch., Maksym N.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.17'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: memoist
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|