peatio-bitgo 1.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a34d3e594f4aae64bc53a35b59dadd67910a9e3d815eee4e3dd9efa647390e4
4
- data.tar.gz: 7aa28dfabb7d3d38c6fe97d8cd33a0f925c2aab1f96b264ae8cb2e771cd6148e
3
+ metadata.gz: 8ae724cff419d17080fe3eab88cf0f3f8d31c3d41e787f350d8b5773f93f2078
4
+ data.tar.gz: 434d994c43c8e60a29d71078098114412946c994467e0f1790db2c390d7dd651
5
5
  SHA512:
6
- metadata.gz: 58e8eded29b3926165b4007c85034ac36f90c61bfba87b9d655cab1f14dc192e69dfe1bb1250c5e3e0a11c5e77ce43be9e4b5d7f10a34884be62a04371cbb18e
7
- data.tar.gz: 0c2910b5e815efe56c0e1e46da0bf1e2b50d48571ca5a0f2aee4b2b9d55135a18755789d59045c1ae93ccad5b40358700b49f823ace670e117d7f7129f49b626
6
+ metadata.gz: 641b57188eebb0f220733bd31db3a6ec27d17a2329e66038e6d2c1f25986d571d67cd94e5f177518057e096efe9ad775c9afb68e64a82a222d43b21fd0c72f2b
7
+ data.tar.gz: 87ef8015868f4a01f34242d7b111a2d35ccf0144da50c859216dc611e028c9378c4cd310213463983ce4b5fcb8c9125fd01a2abbfcd8cbf2a996ca371d78b0e2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio-bitgo (1.1.0)
4
+ peatio-bitgo (1.1.5)
5
5
  activesupport (~> 5.2.3)
6
6
  better-faraday (~> 1.0.5)
7
7
  faraday (~> 0.15.4)
@@ -12,75 +12,108 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (5.2.4.1)
16
- activesupport (= 5.2.4.1)
17
- activesupport (5.2.4.1)
15
+ activemodel (5.2.4.2)
16
+ activesupport (= 5.2.4.2)
17
+ activesupport (5.2.4.2)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 0.7, < 2)
20
20
  minitest (~> 5.1)
21
21
  tzinfo (~> 1.1)
22
22
  addressable (2.7.0)
23
23
  public_suffix (>= 2.0.2, < 5.0)
24
- amq-protocol (2.3.0)
24
+ amq-protocol (2.3.1)
25
25
  amqp (1.8.0)
26
26
  amq-protocol (>= 2.2.0)
27
27
  eventmachine
28
28
  better-faraday (1.0.8)
29
29
  activesupport (>= 4.0, < 6.0)
30
30
  faraday (~> 0.12)
31
- bunny (2.14.4)
32
- amq-protocol (~> 2.3, >= 2.3.0)
31
+ bunny (2.15.0)
32
+ amq-protocol (~> 2.3, >= 2.3.1)
33
33
  byebug (11.1.1)
34
34
  clamp (1.3.1)
35
35
  coderay (1.1.2)
36
36
  concurrent-ruby (1.1.6)
37
37
  connection_pool (2.2.2)
38
+ cookiejar (0.3.3)
38
39
  crack (0.4.3)
39
40
  safe_yaml (~> 1.0.0)
41
+ daemons (1.3.1)
40
42
  diff-lcs (1.3)
43
+ em-http-request (1.1.5)
44
+ addressable (>= 2.3.4)
45
+ cookiejar (!= 0.3.1)
46
+ em-socksify (>= 0.3)
47
+ eventmachine (>= 1.0.3)
48
+ http_parser.rb (>= 0.6.0)
49
+ em-socksify (0.3.2)
50
+ eventmachine (>= 1.0.0.beta.4)
51
+ em-synchrony (1.0.6)
52
+ eventmachine (>= 1.0.0.beta.1)
41
53
  em-websocket (0.5.1)
42
54
  eventmachine (>= 0.12.9)
43
55
  http_parser.rb (~> 0.6.0)
44
56
  eventmachine (1.2.7)
45
57
  faraday (0.15.4)
46
58
  multipart-post (>= 1.2, < 3)
59
+ faraday_middleware (0.13.1)
60
+ faraday (>= 0.7.4, < 1.0)
61
+ faye (1.2.5)
62
+ cookiejar (>= 0.3.0)
63
+ em-http-request (>= 0.3.0)
64
+ eventmachine (>= 0.12.0)
65
+ faye-websocket (>= 0.9.1)
66
+ multi_json (>= 1.0.0)
67
+ rack (>= 1.0.0)
68
+ websocket-driver (>= 0.5.1)
69
+ faye-websocket (0.10.9)
70
+ eventmachine (>= 0.12.0)
71
+ websocket-driver (>= 0.5.1)
47
72
  hashdiff (1.0.1)
48
73
  http_parser.rb (0.6.0)
49
74
  i18n (1.8.2)
50
75
  concurrent-ruby (~> 1.0)
51
76
  jwt (2.2.1)
52
77
  memoist (0.16.2)
53
- method_source (0.9.2)
78
+ method_source (1.0.0)
54
79
  minitest (5.14.0)
55
80
  mocha (1.11.2)
81
+ multi_json (1.14.1)
56
82
  multipart-post (2.1.1)
57
83
  mysql2 (0.5.3)
58
84
  net-http-persistent (3.0.1)
59
85
  connection_pool (~> 2.2)
60
- peatio (0.6.3)
86
+ peatio (2.4.4)
61
87
  activemodel (> 5.2, <= 6.0.0)
62
88
  amqp
63
89
  bunny
64
90
  clamp
91
+ em-synchrony (~> 1.0)
65
92
  em-websocket
66
93
  eventmachine
94
+ faraday_middleware (~> 0.13.1)
95
+ faye (~> 1.2)
67
96
  jwt
68
97
  mysql2
69
- pry (0.12.2)
70
- coderay (~> 1.1.0)
71
- method_source (~> 0.9.0)
72
- pry-byebug (3.8.0)
98
+ prometheus-client
99
+ thin
100
+ prometheus-client (2.0.0)
101
+ pry (0.13.0)
102
+ coderay (~> 1.1)
103
+ method_source (~> 1.0)
104
+ pry-byebug (3.9.0)
73
105
  byebug (~> 11.0)
74
- pry (~> 0.10)
75
- public_suffix (4.0.3)
76
- rake (10.5.0)
106
+ pry (~> 0.13.0)
107
+ public_suffix (4.0.4)
108
+ rack (2.2.2)
109
+ rake (13.0.1)
77
110
  rspec (3.9.0)
78
111
  rspec-core (~> 3.9.0)
79
112
  rspec-expectations (~> 3.9.0)
80
113
  rspec-mocks (~> 3.9.0)
81
114
  rspec-core (3.9.1)
82
115
  rspec-support (~> 3.9.1)
83
- rspec-expectations (3.9.0)
116
+ rspec-expectations (3.9.1)
84
117
  diff-lcs (>= 1.2.0, < 2.0)
85
118
  rspec-support (~> 3.9.0)
86
119
  rspec-mocks (3.9.1)
@@ -88,13 +121,20 @@ GEM
88
121
  rspec-support (~> 3.9.0)
89
122
  rspec-support (3.9.2)
90
123
  safe_yaml (1.0.5)
124
+ thin (1.7.2)
125
+ daemons (~> 1.0, >= 1.0.9)
126
+ eventmachine (~> 1.0, >= 1.0.4)
127
+ rack (>= 1, < 3)
91
128
  thread_safe (0.3.6)
92
- tzinfo (1.2.6)
129
+ tzinfo (1.2.7)
93
130
  thread_safe (~> 0.1)
94
- webmock (3.8.2)
131
+ webmock (3.8.3)
95
132
  addressable (>= 2.3.6)
96
133
  crack (>= 0.3.2)
97
134
  hashdiff (>= 0.4.0, < 2.0.0)
135
+ websocket-driver (0.7.1)
136
+ websocket-extensions (>= 0.1.0)
137
+ websocket-extensions (0.1.4)
98
138
 
99
139
  PLATFORMS
100
140
  ruby
@@ -104,7 +144,7 @@ DEPENDENCIES
104
144
  mocha (~> 1.8)
105
145
  peatio-bitgo!
106
146
  pry-byebug
107
- rake (~> 10.0)
147
+ rake (~> 13.0)
108
148
  rspec (~> 3.0)
109
149
  webmock (~> 3.5)
110
150
 
@@ -13,9 +13,9 @@
13
13
  # Geth gateway client settings.
14
14
  uri: http://127.0.0.1:8545
15
15
  secret: 'changeme'
16
- bitgo_test_net: true
17
- bitgo_access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
18
- bitgo_wallet_id: '5e5388ad80334347ceb3540c741d'
16
+ testnet: true
17
+ access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
18
+ wallet_id: '5e5388ad80334347ceb3540c741d'
19
19
 
20
20
  - name: Ethereum Hot Wallet
21
21
  blockchain_key: eth-rinkeby
@@ -31,9 +31,9 @@
31
31
  # Geth gateway client settings.
32
32
  uri: http://127.0.0.1:8545
33
33
  secret: 'test'
34
- bitgo_test_net: true
35
- bitgo_access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
36
- bitgo_wallet_id: '5e5388ad80334347ceb3540c741d'
34
+ testnet: true
35
+ access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
36
+ wallet_id: '5e5388ad80334347ceb3540c741d'
37
37
 
38
38
  - name: Ethereum Warm Wallet
39
39
  blockchain_key: eth-rinkeby
@@ -49,6 +49,6 @@
49
49
  # Geth gateway client settings.
50
50
  uri: http://127.0.0.1:8545
51
51
  secret: 'test'
52
- bitgo_test_net: true
53
- bitgo_access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
54
- bitgo_wallet_id: '5e5388ad80334347ceb3540c741d'
52
+ testnet: true
53
+ access_token: 'v2x659261647b540ee3acda5c50ae4e878we323474eea5cbff9b9615139629'
54
+ wallet_id: '5e5388ad80334347ceb3540c741d'
@@ -0,0 +1,36 @@
1
+ ## Bitgo wallet configuration
2
+
3
+ 1. Login to your bitgo account
4
+ 2. Click in create wallet button
5
+ ![scheme](images/create_wallet.png)
6
+ 3. Choose wallet for appropriate currency
7
+ ![scheme](images/choose_wallet.png)
8
+ 4. Setup your wallet
9
+ ![scheme](images/setup_wallet.png)
10
+ 5. Put name of your wallet
11
+ ![scheme](images/wallet_name.png)
12
+ 6. Put password of your wallet
13
+ ![scheme](images/wallet_secret.png)
14
+ P.S. You should save this password for future wallet configuration
15
+
16
+ ## Peatio BITGO wallet configuration
17
+
18
+ 1. Go to tower admin panel Settings -> Wallets -> Add wallet
19
+ * Uri == Bitgo service URI
20
+ * Secret == Wallet password
21
+ * Bitgo Wallet Id
22
+ ![scheme](images/wallet_id.png)
23
+ * Bitgo Access Token
24
+ ![scheme](images/wallet_access_token.png)
25
+ ![scheme](images/create_wallet_access_token.png)
26
+ ![scheme](images/access_token.png)
27
+
28
+ ## Webhook configuration
29
+
30
+ ![scheme](images/webhook.png)
31
+ ![scheme](images/webhook_creating.png)
32
+
33
+ Where url should be "https://{host_url}/api/v2/peatio/public/webhooks/{event}"
34
+
35
+ * For deposit wallets event should be 'deposit'
36
+ * For hot wallets event should be 'withdraw'
Binary file
Binary file
Binary file
@@ -43,7 +43,11 @@ module Peatio
43
43
  response['error'].tap { |error| raise ResponseError.new(error) if error }
44
44
  response
45
45
  rescue Faraday::Error => e
46
- raise ConnectionError, e
46
+ if e.is_a?(Faraday::ConnectionFailed) || e.is_a?(Faraday::TimeoutError)
47
+ raise ConnectionError, e
48
+ else
49
+ raise ConnectionError, JSON.parse(e.response.body)['message']
50
+ end
47
51
  rescue StandardError => e
48
52
  raise Error, e
49
53
  end
@@ -1,5 +1,5 @@
1
1
  module Peatio
2
2
  module Bitgo
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.5"
4
4
  end
5
5
  end
@@ -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
@@ -14,7 +15,7 @@ module Peatio
14
15
 
15
16
  @wallet = @settings.fetch(:wallet) do
16
17
  raise Peatio::Wallet::MissingSettingError, :wallet
17
- end.slice(:uri, :address, :secret, :bitgo_access_token, :bitgo_wallet_id, :bitgo_test_net)
18
+ end.slice(:uri, :address, :secret, :access_token, :wallet_id, :testnet)
18
19
 
19
20
  @currency = @settings.fetch(:currency) do
20
21
  raise Peatio::Wallet::MissingSettingError, :currency
@@ -22,11 +23,17 @@ module Peatio
22
23
  end
23
24
 
24
25
  def create_address!(options = {})
25
- if options[:address_id].present?
26
- response = client.rest_api(:get, "/wallet/#{bitgo_wallet_id}/address/#{options[:address_id]}")
26
+ currency = erc20_currency_id
27
+ options.deep_symbolize_keys!
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
+
33
+ response = client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{options.dig(:pa_details, :address_id)}")
27
34
  { address: response['address'], secret: bitgo_wallet_passphrase }
28
- else
29
- response = client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/address")
35
+ elsif options.dig(:pa_details, :address_id).blank?
36
+ response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
30
37
  { address: response['address'], secret: bitgo_wallet_passphrase, details: { address_id: response['id'] }}
31
38
  end
32
39
  rescue Bitgo::Client::Error => e
@@ -34,7 +41,7 @@ module Peatio
34
41
  end
35
42
 
36
43
  def create_transaction!(transaction, options = {})
37
- currency_options = @currency.fetch(:options).slice(:gas_limit, :gas_price)
44
+ currency_options = @currency.fetch(:options).slice(:gas_limit, :gas_price, :erc20_contract_address)
38
45
 
39
46
  if currency_options[:gas_limit].present? && currency_options[:gas_price].present?
40
47
  options.merge!(currency_options)
@@ -49,10 +56,11 @@ module Peatio
49
56
  amount -= fee.to_i
50
57
  end
51
58
 
52
- txid = client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/sendcoins", {
59
+ txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
53
60
  address: transaction.to_address.to_s,
54
61
  amount: amount.to_s,
55
- walletPassphrase: bitgo_wallet_passphrase
62
+ walletPassphrase: bitgo_wallet_passphrase,
63
+ memo: xlm_memo(transaction.to_address.to_s)
56
64
  }.compact).fetch('txid')
57
65
 
58
66
  transaction.hash = normalize_txid(txid)
@@ -64,7 +72,7 @@ module Peatio
64
72
 
65
73
 
66
74
  def build_raw_transaction(transaction)
67
- client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/tx/build", {
75
+ client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/tx/build", {
68
76
  recipients: [{
69
77
  address: transaction.to_address,
70
78
  amount: convert_to_base_unit(transaction.amount).to_s
@@ -74,14 +82,15 @@ module Peatio
74
82
 
75
83
  def create_eth_transaction(transaction, options = {})
76
84
  amount = convert_to_base_unit(transaction.amount)
77
- amount -= options.fetch(:gas_limit).to_i * options.fetch(:gas_price).to_i if options.dig(:subtract_fee)
85
+ hop = true unless options.slice(:erc20_contract_address).present?
78
86
 
79
- txid = client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/sendcoins", {
87
+ txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
80
88
  address: transaction.to_address.to_s,
81
89
  amount: amount.to_s,
82
90
  walletPassphrase: bitgo_wallet_passphrase,
83
91
  gas: options.fetch(:gas_limit).to_i,
84
- gasPrice: options.fetch(:gas_price).to_i
92
+ gasPrice: options.fetch(:gas_price).to_i,
93
+ hop: hop
85
94
  }.compact).fetch('txid')
86
95
 
87
96
  transaction.hash = normalize_txid(txid)
@@ -89,21 +98,33 @@ module Peatio
89
98
  end
90
99
 
91
100
  def load_balance!
92
- response = client.rest_api(:get, "/wallet/#{bitgo_wallet_id}")
93
- convert_from_base_unit(response.fetch('balanceString'))
101
+ if @currency.fetch(:options).slice(:erc20_contract_address).present?
102
+ load_erc20_balance!
103
+ else
104
+ response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}")
105
+ convert_from_base_unit(response.fetch('balanceString'))
106
+ end
107
+ rescue Bitgo::Client::Error => e
108
+ raise Peatio::Wallet::ClientError, e
109
+ end
110
+
111
+ def load_erc20_balance!
112
+ response = client.rest_api(:get, "#{erc20_currency_id}/wallet/#{wallet_id}?allTokens=true")
113
+ convert_from_base_unit(response.dig('tokens', currency_id, 'balanceString'))
94
114
  rescue Bitgo::Client::Error => e
95
115
  raise Peatio::Wallet::ClientError, e
96
116
  end
97
117
 
98
118
  def trigger_webhook_event(event)
99
- currency_id = @wallet.fetch(:bitgo_test_net).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
100
- return unless currency_id == event['coin'] && @wallet.fetch(:bitgo_wallet_id) == event['wallet']
119
+ currency_id = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
120
+ return unless currency_id == event['coin'] && @wallet.fetch(:wallet_id) == event['wallet']
101
121
 
102
122
  if event['type'] == 'transfer'
103
123
  transactions = fetch_transfer!(event['transfer'])
104
124
  return { transfers: transactions }
105
- elsif event['address_confirmation']
106
- # TODO Add Address confirmation
125
+ elsif event['type'] == 'address_confirmation'
126
+ address_id = fetch_address_id(event['address'])
127
+ return { address_id: address_id}
107
128
  end
108
129
  end
109
130
 
@@ -112,20 +133,26 @@ module Peatio
112
133
  address_confirmation_webhook(url)
113
134
  end
114
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
+
115
144
  def fetch_transfer!(id)
116
145
  # TODO: Add Rspecs for this one
117
- response = client.rest_api(:get, "/wallet/#{bitgo_wallet_id}/transfer/#{id}")
146
+ response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
118
147
  parse_entries(response['entries']).map do |entry|
119
148
  to_address = if response.dig('coinSpecific', 'memo').present?
120
- build_address(response.dig('coinSpecific', 'memo').first)
149
+ memo = response.dig('coinSpecific', 'memo')
150
+ memo_type = memo.kind_of?(Array) ? memo.first : memo
151
+ build_address(entry['address'], memo_type)
121
152
  else
122
153
  entry['address']
123
154
  end
124
- state = if response['state'] == 'unconfrimed'
125
- 'pending'
126
- elsif response['state'] == 'confirmed'
127
- 'success'
128
- end
155
+ state = define_transaction_state(response['state'])
129
156
 
130
157
  transaction = Peatio::Transaction.new(
131
158
  currency_id: @currency.fetch(:id),
@@ -145,7 +172,7 @@ module Peatio
145
172
  end
146
173
 
147
174
  def transfer_webhook(url)
148
- client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/webhooks", {
175
+ client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
149
176
  type: 'transfer',
150
177
  allToken: true,
151
178
  url: url,
@@ -155,8 +182,8 @@ module Peatio
155
182
  end
156
183
 
157
184
  def address_confirmation_webhook(url)
158
- client.rest_api(:post, "/wallet/#{bitgo_wallet_id}/webhooks", {
159
- type: 'address_confirmation_webhook',
185
+ client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
186
+ type: 'address_confirmation',
160
187
  allToken: true,
161
188
  url: url,
162
189
  label: "webhook for #{url}",
@@ -173,25 +200,52 @@ module Peatio
173
200
  private
174
201
 
175
202
  def client
176
- currency_id = @currency.fetch(:id) { raise Peatio::Wallet::MissingSettingError, :id }
177
203
  uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
178
- access_token = @wallet.fetch(:bitgo_access_token) { raise Peatio::Wallet::MissingSettingError, :bitgo_access_token }
204
+ access_token = @wallet.fetch(:access_token) { raise Peatio::Wallet::MissingSettingError, :access_token }
179
205
 
180
- currency_code_prefix = @wallet.fetch(:bitgo_test_net) ? 't' : ''
181
- uri = uri.gsub(/\/+\z/, '') + '/' + currency_code_prefix + currency_id
206
+ currency_code_prefix = @wallet.fetch(:testnet) ? 't' : ''
207
+ uri = uri.gsub(/\/+\z/, '') + '/' + currency_code_prefix
182
208
  @client ||= Client.new(uri, access_token)
183
209
  end
184
210
 
185
- def build_address(memo)
186
- "#{memo['address']}?memoId=#{memo['value']}"
211
+ def build_address(address, memo)
212
+ "#{address}?memoId=#{memo['value']}"
213
+ end
214
+
215
+ # All these functions will have to be done with the coin set to eth or teth
216
+ # since that is the actual coin type being used.
217
+ def erc20_currency_id
218
+ return 'eth' if @currency.fetch(:options).slice(:erc20_contract_address).present?
219
+
220
+ currency_id
221
+ end
222
+
223
+ def xlm_memo(address)
224
+ if @currency.fetch(:id) == 'xlm'
225
+ {
226
+ type: "id",
227
+ value: "#{memo_id_from(address)}"
228
+ }
229
+ end
230
+ end
231
+
232
+ def memo_id_from(address)
233
+ memo_id = address.partition('memoId=').last
234
+ memo_id = 0 if memo_id.empty?
235
+
236
+ memo_id
237
+ end
238
+
239
+ def currency_id
240
+ @currency.fetch(:id) { raise Peatio::Wallet::MissingSettingError, :id }
187
241
  end
188
242
 
189
243
  def bitgo_wallet_passphrase
190
244
  @wallet.fetch(:secret)
191
245
  end
192
246
 
193
- def bitgo_wallet_id
194
- @wallet.fetch(:bitgo_wallet_id)
247
+ def wallet_id
248
+ @wallet.fetch(:wallet_id)
195
249
  end
196
250
 
197
251
  def normalize_txid(txid)
@@ -211,6 +265,21 @@ module Peatio
211
265
  end
212
266
  x.to_i
213
267
  end
268
+
269
+ def time_difference_in_minutes(updated_at)
270
+ (Time.now - updated_at)/60
271
+ end
272
+
273
+ def define_transaction_state(state)
274
+ case state
275
+ when 'unconfirmed'
276
+ 'pending'
277
+ when 'confirmed'
278
+ 'success'
279
+ when 'failed','rejected'
280
+ 'failed'
281
+ end
282
+ end
214
283
  end
215
284
  end
216
285
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 1.16"
34
34
  spec.add_development_dependency "mocha", "~> 1.8"
35
35
  spec.add_development_dependency "pry-byebug"
36
- spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rake", "~> 13.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.0"
38
38
  spec.add_development_dependency "webmock", "~> 3.5"
39
39
  end
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.0
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-03-06 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '10.0'
145
+ version: '13.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '10.0'
152
+ version: '13.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +198,19 @@ files:
198
198
  - configs/blockchains.yml
199
199
  - configs/currencies.yml
200
200
  - configs/wallets.yml
201
+ - docs/configuration.md
202
+ - docs/images/.DS_Store
203
+ - docs/images/access_token.png
204
+ - docs/images/choose_wallet.png
205
+ - docs/images/create_wallet.png
206
+ - docs/images/create_wallet_access_token.png
207
+ - docs/images/setup_wallet.png
208
+ - docs/images/wallet_access_token.png
209
+ - docs/images/wallet_id.png
210
+ - docs/images/wallet_name.png
211
+ - docs/images/wallet_secret.png
212
+ - docs/images/webhook.png
213
+ - docs/images/webhook_creating.png
201
214
  - docs/integration.md
202
215
  - lib/peatio/bitgo.rb
203
216
  - lib/peatio/bitgo/blockchain.rb