peatio-bitgo 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77fecc938decb7012e77db67d8334287226c3a3761d0fa6f075c0e93119418d8
4
- data.tar.gz: fb16e7373708ebdf0b08fa85580d335853f64164854cad3ea1744a09277c15b1
3
+ metadata.gz: 3562bf66638262a55143d4586f07f5946a9dea93fa2dc7efbb57e7b5cab26ca3
4
+ data.tar.gz: da0c1795b7df4f31a89437634a92e2cc4049b9c0dad21db8763bb4ebe1fd27b3
5
5
  SHA512:
6
- metadata.gz: b5a7d4d96979e76c524ba8b5e67304cb497d3f911ed05873b20bbe2df94bda0bd192d7f3896e8437e86889db41844a4b56cbd04246dd71d7058dcf9be7c188c5
7
- data.tar.gz: b86529c189d9399b28b35d493c8db850c9fc6187f50508d9df3131be329b9097fdc2431edbcc579275eda2d2f0cdef31f7455644dc7fc0d81f3ef39cb19b3382
6
+ metadata.gz: 13b857602c498e74b48f0e671321d146fa55c2ce59eca63e3a2ca74775432e9d8957f19f780dc241ca6919a4654652678088bdb30f4285eb697e0d0447bda623
7
+ data.tar.gz: 79ba6ba0074fc9beffa667ebcc1fa9c2ead7c416785e664e8f2f73a0f14ca826f8b857401a700cccd088034ea0ed4bcadd18417ddcd718a159ad266df526aed9
@@ -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.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -54,7 +54,8 @@ module Peatio
54
54
  txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
55
55
  address: transaction.to_address.to_s,
56
56
  amount: amount.to_s,
57
- walletPassphrase: bitgo_wallet_passphrase
57
+ walletPassphrase: bitgo_wallet_passphrase,
58
+ memo: xlm_memo(transaction.to_address.to_s)
58
59
  }.compact).fetch('txid')
59
60
 
60
61
  transaction.hash = normalize_txid(txid)
@@ -129,15 +130,13 @@ module Peatio
129
130
  response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
130
131
  parse_entries(response['entries']).map do |entry|
131
132
  to_address = if response.dig('coinSpecific', 'memo').present?
132
- build_address(response.dig('coinSpecific', 'memo').first)
133
+ memo = response.dig('coinSpecific', 'memo')
134
+ memo_type = memo.kind_of?(Array) ? memo.first : memo
135
+ build_address(entry['address'], memo_type)
133
136
  else
134
137
  entry['address']
135
138
  end
136
- state = if response['state'] == 'unconfrimed'
137
- 'pending'
138
- elsif response['state'] == 'confirmed'
139
- 'success'
140
- end
139
+ state = define_transaction_state(response['state'])
141
140
 
142
141
  transaction = Peatio::Transaction.new(
143
142
  currency_id: @currency.fetch(:id),
@@ -193,8 +192,8 @@ module Peatio
193
192
  @client ||= Client.new(uri, access_token)
194
193
  end
195
194
 
196
- def build_address(memo)
197
- "#{memo['address']}?memoId=#{memo['value']}"
195
+ def build_address(address, memo)
196
+ "#{address}?memoId=#{memo['value']}"
198
197
  end
199
198
 
200
199
  # All these functions will have to be done with the coin set to eth or teth
@@ -205,6 +204,22 @@ module Peatio
205
204
  currency_id
206
205
  end
207
206
 
207
+ def xlm_memo(address)
208
+ if @currency.fetch(:id) == 'xlm'
209
+ {
210
+ type: "id",
211
+ value: "#{memo_id_from(address)}"
212
+ }
213
+ end
214
+ end
215
+
216
+ def memo_id_from(address)
217
+ memo_id = address.partition('memoId=').last
218
+ memo_id = 0 if memo_id.empty?
219
+
220
+ memo_id
221
+ end
222
+
208
223
  def currency_id
209
224
  @currency.fetch(:id) { raise Peatio::Wallet::MissingSettingError, :id }
210
225
  end
@@ -234,6 +249,17 @@ module Peatio
234
249
  end
235
250
  x.to_i
236
251
  end
252
+
253
+ def define_transaction_state(state)
254
+ case state
255
+ when 'unconfrimed'
256
+ 'pending'
257
+ when 'confirmed'
258
+ 'success'
259
+ when 'failed','rejected'
260
+ 'failed'
261
+ end
262
+ end
237
263
  end
238
264
  end
239
265
  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.1
4
+ version: 1.1.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-03-26 00:00:00.000000000 Z
11
+ date: 2020-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport