peatio-bitgo 2.6.3 → 2.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +25 -19
- data/lib/peatio/bitgo/version.rb +1 -1
- data/lib/peatio/bitgo/wallet.rb +34 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2211b51065371d015f3adcd9edcad1e6222a39a2fd8bc86ebe9eb0ff88986108
|
4
|
+
data.tar.gz: 9e66976ae7c61e5afa145f958d0ada67e6f232a70f7b9d06e3891237309f8727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea675bbcf7bd62678248ac5a1abd951e79f5a7bf00f4ce53cafec12571897dc55be601dc02979a6aad1148df5d0d3e840d97b7bfa8e1dfb83fd76dd5193a621
|
7
|
+
data.tar.gz: 139f9d18ee51b88cd4936eae40c7d70868ccc3984cc9cefcf06d2b5c75af73ecb551f4dba073aef03ec73afb1c74b895784e7486f1eb34929d08aab44b0511d3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
peatio-bitgo (2.6.
|
4
|
+
peatio-bitgo (2.6.8)
|
5
5
|
activesupport (~> 5.2.3)
|
6
6
|
better-faraday (~> 1.0.5)
|
7
7
|
faraday (~> 0.17)
|
@@ -12,9 +12,9 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (5.2.
|
16
|
-
activesupport (= 5.2.
|
17
|
-
activesupport (5.2.
|
15
|
+
activemodel (5.2.6)
|
16
|
+
activesupport (= 5.2.6)
|
17
|
+
activesupport (5.2.6)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
@@ -28,19 +28,20 @@ GEM
|
|
28
28
|
better-faraday (1.0.8)
|
29
29
|
activesupport (>= 4.0, < 6.0)
|
30
30
|
faraday (~> 0.12)
|
31
|
-
bunny (2.
|
31
|
+
bunny (2.18.0)
|
32
32
|
amq-protocol (~> 2.3, >= 2.3.1)
|
33
|
+
sorted_set (~> 1, >= 1.0.2)
|
33
34
|
byebug (11.1.3)
|
34
35
|
clamp (1.3.2)
|
35
36
|
coderay (1.1.3)
|
36
|
-
concurrent-ruby (1.1.
|
37
|
-
connection_pool (2.2.
|
37
|
+
concurrent-ruby (1.1.9)
|
38
|
+
connection_pool (2.2.5)
|
38
39
|
cookiejar (0.3.3)
|
39
40
|
crack (0.4.3)
|
40
41
|
safe_yaml (~> 1.0.0)
|
41
|
-
daemons (1.
|
42
|
+
daemons (1.4.0)
|
42
43
|
diff-lcs (1.4.4)
|
43
|
-
em-http-request (1.1.
|
44
|
+
em-http-request (1.1.7)
|
44
45
|
addressable (>= 2.3.4)
|
45
46
|
cookiejar (!= 0.3.1)
|
46
47
|
em-socksify (>= 0.3)
|
@@ -50,11 +51,11 @@ GEM
|
|
50
51
|
eventmachine (>= 1.0.0.beta.4)
|
51
52
|
em-synchrony (1.0.6)
|
52
53
|
eventmachine (>= 1.0.0.beta.1)
|
53
|
-
em-websocket (0.5.
|
54
|
+
em-websocket (0.5.2)
|
54
55
|
eventmachine (>= 0.12.9)
|
55
56
|
http_parser.rb (~> 0.6.0)
|
56
57
|
eventmachine (1.2.7)
|
57
|
-
faraday (0.17.
|
58
|
+
faraday (0.17.4)
|
58
59
|
multipart-post (>= 1.2, < 3)
|
59
60
|
faraday_middleware (0.13.1)
|
60
61
|
faraday (>= 0.7.4, < 1.0)
|
@@ -66,24 +67,24 @@ GEM
|
|
66
67
|
multi_json (>= 1.0.0)
|
67
68
|
rack (>= 1.0.0)
|
68
69
|
websocket-driver (>= 0.5.1)
|
69
|
-
faye-websocket (0.11.
|
70
|
+
faye-websocket (0.11.1)
|
70
71
|
eventmachine (>= 0.12.0)
|
71
72
|
websocket-driver (>= 0.5.1)
|
72
73
|
hashdiff (1.0.1)
|
73
74
|
http_parser.rb (0.6.0)
|
74
|
-
i18n (1.8.
|
75
|
+
i18n (1.8.10)
|
75
76
|
concurrent-ruby (~> 1.0)
|
76
|
-
jwt (2.2.
|
77
|
+
jwt (2.2.3)
|
77
78
|
memoist (0.16.2)
|
78
79
|
method_source (1.0.0)
|
79
|
-
minitest (5.14.
|
80
|
+
minitest (5.14.4)
|
80
81
|
mocha (1.11.2)
|
81
82
|
multi_json (1.15.0)
|
82
83
|
multipart-post (2.1.1)
|
83
84
|
mysql2 (0.5.3)
|
84
85
|
net-http-persistent (3.0.1)
|
85
86
|
connection_pool (~> 2.2)
|
86
|
-
peatio (2.6.
|
87
|
+
peatio (2.6.4)
|
87
88
|
activemodel (> 5.2, <= 6.0.0)
|
88
89
|
amqp
|
89
90
|
bunny
|
@@ -107,6 +108,7 @@ GEM
|
|
107
108
|
public_suffix (4.0.5)
|
108
109
|
rack (2.2.3)
|
109
110
|
rake (13.0.1)
|
111
|
+
rbtree (0.4.4)
|
110
112
|
rspec (3.9.0)
|
111
113
|
rspec-core (~> 3.9.0)
|
112
114
|
rspec-expectations (~> 3.9.0)
|
@@ -121,18 +123,22 @@ GEM
|
|
121
123
|
rspec-support (~> 3.9.0)
|
122
124
|
rspec-support (3.9.3)
|
123
125
|
safe_yaml (1.0.5)
|
124
|
-
|
126
|
+
set (1.0.1)
|
127
|
+
sorted_set (1.0.3)
|
128
|
+
rbtree
|
129
|
+
set (~> 1.0)
|
130
|
+
thin (1.8.1)
|
125
131
|
daemons (~> 1.0, >= 1.0.9)
|
126
132
|
eventmachine (~> 1.0, >= 1.0.4)
|
127
133
|
rack (>= 1, < 3)
|
128
134
|
thread_safe (0.3.6)
|
129
|
-
tzinfo (1.2.
|
135
|
+
tzinfo (1.2.9)
|
130
136
|
thread_safe (~> 0.1)
|
131
137
|
webmock (3.8.3)
|
132
138
|
addressable (>= 2.3.6)
|
133
139
|
crack (>= 0.3.2)
|
134
140
|
hashdiff (>= 0.4.0, < 2.0.0)
|
135
|
-
websocket-driver (0.7.
|
141
|
+
websocket-driver (0.7.5)
|
136
142
|
websocket-extensions (>= 0.1.0)
|
137
143
|
websocket-extensions (0.1.5)
|
138
144
|
|
data/lib/peatio/bitgo/version.rb
CHANGED
data/lib/peatio/bitgo/wallet.rb
CHANGED
@@ -86,7 +86,15 @@ module Peatio
|
|
86
86
|
|
87
87
|
def create_eth_transaction(transaction, options = {})
|
88
88
|
amount = convert_to_base_unit(transaction.amount)
|
89
|
-
hop = true unless options.slice(:
|
89
|
+
hop = true unless options.slice(:gas_price).present?
|
90
|
+
|
91
|
+
fee_estimate = fee_estimate(amount.to_s, hop)
|
92
|
+
|
93
|
+
if transaction.options.present? && transaction.options[:gas_price].present?
|
94
|
+
options[:gas_price] = transaction.options[:gas_price]
|
95
|
+
else
|
96
|
+
options[:gas_price] = fee_estimate['minGasPrice'].to_i
|
97
|
+
end
|
90
98
|
|
91
99
|
txid = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
|
92
100
|
address: transaction.to_address.to_s,
|
@@ -98,9 +106,14 @@ module Peatio
|
|
98
106
|
}.compact).fetch('txid')
|
99
107
|
|
100
108
|
transaction.hash = normalize_txid(txid)
|
109
|
+
transaction.options = options
|
101
110
|
transaction
|
102
111
|
end
|
103
112
|
|
113
|
+
def fee_estimate(amount, hop)
|
114
|
+
client.rest_api(:get, "#{erc20_currency_id}/tx/fee", { amount: amount, hop: hop }.compact)
|
115
|
+
end
|
116
|
+
|
104
117
|
def load_balance!
|
105
118
|
if @currency.fetch(:options).slice(:erc20_contract_address).present?
|
106
119
|
load_erc20_balance!
|
@@ -119,16 +132,21 @@ module Peatio
|
|
119
132
|
raise Peatio::Wallet::ClientError, e
|
120
133
|
end
|
121
134
|
|
122
|
-
def trigger_webhook_event(
|
135
|
+
def trigger_webhook_event(request)
|
123
136
|
currency = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
return
|
129
|
-
|
130
|
-
|
131
|
-
|
137
|
+
if request.params['type'] == 'transfer'
|
138
|
+
return unless currency == request.params['coin'] &&
|
139
|
+
@wallet.fetch(:wallet_id) == request.params['wallet']
|
140
|
+
else
|
141
|
+
return unless @wallet.fetch(:wallet_id) == request.params['walletId']
|
142
|
+
end
|
143
|
+
|
144
|
+
if request.params['type'] == 'transfer'
|
145
|
+
transactions = fetch_transfer!(request.params['transfer'])
|
146
|
+
return transactions
|
147
|
+
elsif request.params['type'] == 'address_confirmation'
|
148
|
+
address_id = fetch_address_id(request.params['address'])
|
149
|
+
return { address_id: address_id, address: request.params['address'], currency_id: currency_id }
|
132
150
|
end
|
133
151
|
end
|
134
152
|
|
@@ -146,7 +164,6 @@ module Peatio
|
|
146
164
|
end
|
147
165
|
|
148
166
|
def fetch_transfer!(id)
|
149
|
-
# TODO: Add Rspecs for this one
|
150
167
|
response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
|
151
168
|
parse_entries(response['entries']).map do |entry|
|
152
169
|
to_address = if response.dig('coinSpecific', 'memo').present?
|
@@ -158,14 +175,18 @@ module Peatio
|
|
158
175
|
end
|
159
176
|
state = define_transaction_state(response['state'])
|
160
177
|
|
178
|
+
if response['outputs'].present?
|
179
|
+
output = response['outputs'].find { |out| out['address'] == to_address }
|
180
|
+
txout = output['index'] if output.present?
|
181
|
+
end
|
182
|
+
|
161
183
|
transaction = Peatio::Transaction.new(
|
162
184
|
currency_id: @currency.fetch(:id),
|
163
185
|
amount: convert_from_base_unit(entry['valueString']),
|
164
186
|
hash: normalize_txid(response['txid']),
|
165
187
|
to_address: to_address,
|
166
188
|
block_number: response['height'],
|
167
|
-
|
168
|
-
txout: 0,
|
189
|
+
txout: txout.to_i,
|
169
190
|
status: state
|
170
191
|
)
|
171
192
|
|
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: 2.6.
|
4
|
+
version: 2.6.8
|
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:
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
- !ruby/object:Gem::Version
|
240
240
|
version: '0'
|
241
241
|
requirements: []
|
242
|
-
rubygems_version: 3.0.3
|
242
|
+
rubygems_version: 3.0.3.1
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: Gem for extending Peatio plugable system with Bitgo implementation.
|