peatio-bitgo 1.1.4 → 1.1.5
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/peatio/bitgo/version.rb +1 -1
- data/lib/peatio/bitgo/wallet.rb +24 -6
- 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: 8ae724cff419d17080fe3eab88cf0f3f8d31c3d41e787f350d8b5773f93f2078
|
4
|
+
data.tar.gz: 434d994c43c8e60a29d71078098114412946c994467e0f1790db2c390d7dd651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641b57188eebb0f220733bd31db3a6ec27d17a2329e66038e6d2c1f25986d571d67cd94e5f177518057e096efe9ad775c9afb68e64a82a222d43b21fd0c72f2b
|
7
|
+
data.tar.gz: 87ef8015868f4a01f34242d7b111a2d35ccf0144da50c859216dc611e028c9378c4cd310213463983ce4b5fcb8c9125fd01a2abbfcd8cbf2a996ca371d78b0e2
|
data/Gemfile.lock
CHANGED
data/lib/peatio/bitgo/version.rb
CHANGED
data/lib/peatio/bitgo/wallet.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
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
|
def initialize(settings = {})
|
6
7
|
@settings = settings
|
@@ -24,10 +25,14 @@ module Peatio
|
|
24
25
|
def create_address!(options = {})
|
25
26
|
currency = erc20_currency_id
|
26
27
|
options.deep_symbolize_keys!
|
27
|
-
|
28
|
+
|
29
|
+
if options.dig(:pa_details, :address_id).present? &&
|
30
|
+
options.dig(:pa_details, :updated_at).present? &&
|
31
|
+
time_difference_in_minutes(options.dig(:pa_details, :updated_at)) >= TIME_DIFFERENCE_IN_MINUTES
|
32
|
+
|
28
33
|
response = client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{options.dig(:pa_details, :address_id)}")
|
29
34
|
{ address: response['address'], secret: bitgo_wallet_passphrase }
|
30
|
-
|
35
|
+
elsif options.dig(:pa_details, :address_id).blank?
|
31
36
|
response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
|
32
37
|
{ address: response['address'], secret: bitgo_wallet_passphrase, details: { address_id: response['id'] }}
|
33
38
|
end
|
@@ -117,8 +122,9 @@ module Peatio
|
|
117
122
|
if event['type'] == 'transfer'
|
118
123
|
transactions = fetch_transfer!(event['transfer'])
|
119
124
|
return { transfers: transactions }
|
120
|
-
elsif event['address_confirmation'
|
121
|
-
|
125
|
+
elsif event['type'] == 'address_confirmation'
|
126
|
+
address_id = fetch_address_id(event['address'])
|
127
|
+
return { address_id: address_id}
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
@@ -127,6 +133,14 @@ module Peatio
|
|
127
133
|
address_confirmation_webhook(url)
|
128
134
|
end
|
129
135
|
|
136
|
+
def fetch_address_id(address)
|
137
|
+
currency = erc20_currency_id
|
138
|
+
client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{address}")
|
139
|
+
.fetch('id')
|
140
|
+
rescue Bitgo::Client::Error => e
|
141
|
+
raise Peatio::Wallet::ClientError, e
|
142
|
+
end
|
143
|
+
|
130
144
|
def fetch_transfer!(id)
|
131
145
|
# TODO: Add Rspecs for this one
|
132
146
|
response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
|
@@ -169,7 +183,7 @@ module Peatio
|
|
169
183
|
|
170
184
|
def address_confirmation_webhook(url)
|
171
185
|
client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
|
172
|
-
type: '
|
186
|
+
type: 'address_confirmation',
|
173
187
|
allToken: true,
|
174
188
|
url: url,
|
175
189
|
label: "webhook for #{url}",
|
@@ -252,9 +266,13 @@ module Peatio
|
|
252
266
|
x.to_i
|
253
267
|
end
|
254
268
|
|
269
|
+
def time_difference_in_minutes(updated_at)
|
270
|
+
(Time.now - updated_at)/60
|
271
|
+
end
|
272
|
+
|
255
273
|
def define_transaction_state(state)
|
256
274
|
case state
|
257
|
-
when '
|
275
|
+
when 'unconfirmed'
|
258
276
|
'pending'
|
259
277
|
when 'confirmed'
|
260
278
|
'success'
|
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: 1.1.
|
4
|
+
version: 1.1.5
|
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-05
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|