peatio-bitgo 2.6.3 → 2.6.8

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: 20d80a146fee8a7c1589467c5dd7e2eb29797b31bc5f4568c0bc5ef404b92706
4
- data.tar.gz: ca3c7ada85a2ab0e01c3abd2ecb28cd79cb368a6b5ec4c659eb27dba6f9b3742
3
+ metadata.gz: 2211b51065371d015f3adcd9edcad1e6222a39a2fd8bc86ebe9eb0ff88986108
4
+ data.tar.gz: 9e66976ae7c61e5afa145f958d0ada67e6f232a70f7b9d06e3891237309f8727
5
5
  SHA512:
6
- metadata.gz: 063d9d8857083966a250daf77e4476c095b4b420b79f01a727006de559a7dba9dbdf4e3cfd057ef4fc734cd8dd79bfe2e659e5d6b6dc9dab37afca731d21ba8b
7
- data.tar.gz: dd0d0752690f189809ccc531d6938c03af16e38b37b97a67066b0d993759ae81a6f7505136bdf498eab187e9913fc117490e61114df5ddf34ad01f85714013cc
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.3)
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.4.3)
16
- activesupport (= 5.2.4.3)
17
- activesupport (5.2.4.3)
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.16.1)
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.7)
37
- connection_pool (2.2.3)
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.3.1)
42
+ daemons (1.4.0)
42
43
  diff-lcs (1.4.4)
43
- em-http-request (1.1.6)
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.1)
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.3)
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.0)
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.5)
75
+ i18n (1.8.10)
75
76
  concurrent-ruby (~> 1.0)
76
- jwt (2.2.2)
77
+ jwt (2.2.3)
77
78
  memoist (0.16.2)
78
79
  method_source (1.0.0)
79
- minitest (5.14.1)
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.1)
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
- thin (1.7.2)
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.7)
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.3)
141
+ websocket-driver (0.7.5)
136
142
  websocket-extensions (>= 0.1.0)
137
143
  websocket-extensions (0.1.5)
138
144
 
@@ -1,5 +1,5 @@
1
1
  module Peatio
2
2
  module Bitgo
3
- VERSION = "2.6.3".freeze
3
+ VERSION = "2.6.8".freeze
4
4
  end
5
5
  end
@@ -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(:erc20_contract_address).present?
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(event)
135
+ def trigger_webhook_event(request)
123
136
  currency = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
124
- return unless currency == event['coin'] && @wallet.fetch(:wallet_id) == event['wallet']
125
-
126
- if event['type'] == 'transfer'
127
- transactions = fetch_transfer!(event['transfer'])
128
- return { transfers: transactions }
129
- elsif event['type'] == 'address_confirmation'
130
- address_id = fetch_address_id(event['address'])
131
- return { address_id: address_id, currency_id: currency_id }
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
- # TODO: Add sendmany support
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.3
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: 2020-08-24 00:00:00.000000000 Z
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.