peatio-bitgo 1.1.1 → 1.1.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/lib/peatio/bitgo/client.rb +5 -1
- data/lib/peatio/bitgo/version.rb +1 -1
- data/lib/peatio/bitgo/wallet.rb +35 -9
- 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: 3562bf66638262a55143d4586f07f5946a9dea93fa2dc7efbb57e7b5cab26ca3
|
4
|
+
data.tar.gz: da0c1795b7df4f31a89437634a92e2cc4049b9c0dad21db8763bb4ebe1fd27b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13b857602c498e74b48f0e671321d146fa55c2ce59eca63e3a2ca74775432e9d8957f19f780dc241ca6919a4654652678088bdb30f4285eb697e0d0447bda623
|
7
|
+
data.tar.gz: 79ba6ba0074fc9beffa667ebcc1fa9c2ead7c416785e664e8f2f73a0f14ca826f8b857401a700cccd088034ea0ed4bcadd18417ddcd718a159ad266df526aed9
|
data/lib/peatio/bitgo/client.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/peatio/bitgo/version.rb
CHANGED
data/lib/peatio/bitgo/wallet.rb
CHANGED
@@ -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
|
-
|
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 =
|
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
|
-
"#{
|
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.
|
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-
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|