peatio-coinpaymentnew 0.0.4 → 0.0.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
  SHA1:
3
- metadata.gz: '080072a6b070772a02d7ae5d8117707c31c32fc2'
4
- data.tar.gz: 30da7883e604329675f3e93f58b76db0fa98fbfa
3
+ metadata.gz: 0a0842764cc5aac0fa320c966685b729d4132d5e
4
+ data.tar.gz: f5aadac1423d0c5dbde96faa1fceb8101ec9eef8
5
5
  SHA512:
6
- metadata.gz: d01c939e82efa40840947c22b04ebddbe422f29940298a95bafae318df39083b4d791b2c9b4347eb90dfa1e7534f84a96c06e8a4c2678f0040f35988bf2379f4
7
- data.tar.gz: 845114166d6268000d462a967a350809a6a6d8079bc33e50ed74266324e10866710b6bb27303ae32b5c69a63eb982fff8ade9268180bf0d289a00282cec28497
6
+ metadata.gz: 491ec36d7ba9d862e6c2db3d6c89dcbe214a2c997021bd7d427c6ac2dcd8193b5767e9ac46273fb987743f649bc4d097e868d4c2ba2f405bbd1abc5b7c68852a
7
+ data.tar.gz: 62e0cc7c60f2cdbbbe23d9c0316aeb90b844b478643d3622d6e448a36c6fa2b9b2b40766ce992a6935abe24da5c305902646df49202da590bb5d9852b1c9f7c8
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in peatio-coinpaymentnew.gemspec
6
6
  gemspec
7
7
 
8
- gem 'coinpayments'
8
+ # gem 'coinpayments'
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio-coinpaymentnew (0.0.2)
4
+ peatio-coinpaymentnew (0.0.5)
5
5
  activesupport (~> 5.2.3)
6
6
  better-faraday (~> 1.0.5)
7
+ coinpayments (~> 0.0.4)
7
8
  faraday (~> 0.17)
8
9
  memoist (~> 0.16.0)
9
- peatio (~> 0.6.3)
10
+ peatio (~> 2.6.3)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
@@ -37,22 +38,47 @@ GEM
37
38
  hashie
38
39
  httparty
39
40
  concurrent-ruby (1.1.9)
41
+ cookiejar (0.3.3)
40
42
  crack (0.4.5)
41
43
  rexml
44
+ daemons (1.4.1)
42
45
  diff-lcs (1.4.4)
43
- em-websocket (0.5.2)
46
+ em-http-request (1.1.7)
47
+ addressable (>= 2.3.4)
48
+ cookiejar (!= 0.3.1)
49
+ em-socksify (>= 0.3)
50
+ eventmachine (>= 1.0.3)
51
+ http_parser.rb (>= 0.6.0)
52
+ em-socksify (0.3.2)
53
+ eventmachine (>= 1.0.0.beta.4)
54
+ em-synchrony (1.0.6)
55
+ eventmachine (>= 1.0.0.beta.1)
56
+ em-websocket (0.5.3)
44
57
  eventmachine (>= 0.12.9)
45
- http_parser.rb (~> 0.6.0)
58
+ http_parser.rb (~> 0)
46
59
  eventmachine (1.2.7-x64-mingw32)
47
60
  faraday (0.17.4)
48
61
  multipart-post (>= 1.2, < 3)
62
+ faraday_middleware (0.13.1)
63
+ faraday (>= 0.7.4, < 1.0)
64
+ faye (1.4.0)
65
+ cookiejar (>= 0.3.0)
66
+ em-http-request (>= 1.1.6)
67
+ eventmachine (>= 0.12.0)
68
+ faye-websocket (>= 0.11.0)
69
+ multi_json (>= 1.0.0)
70
+ rack (>= 1.0.0)
71
+ websocket-driver (>= 0.5.1)
72
+ faye-websocket (0.11.1)
73
+ eventmachine (>= 0.12.0)
74
+ websocket-driver (>= 0.5.1)
49
75
  hashdiff (1.0.1)
50
76
  hashie (4.1.0)
51
- http_parser.rb (0.6.0)
77
+ http_parser.rb (0.8.0)
52
78
  httparty (0.20.0)
53
79
  mime-types (~> 3.0)
54
80
  multi_xml (>= 0.5.2)
55
- i18n (1.8.10)
81
+ i18n (1.8.11)
56
82
  concurrent-ruby (~> 1.0)
57
83
  jwt (2.3.0)
58
84
  memoist (0.16.2)
@@ -62,18 +88,25 @@ GEM
62
88
  mime-types-data (3.2021.0901)
63
89
  minitest (5.14.4)
64
90
  mocha (1.13.0)
91
+ multi_json (1.15.0)
65
92
  multi_xml (0.6.0)
66
93
  multipart-post (2.1.1)
67
94
  mysql2 (0.5.3-x64-mingw32)
68
- peatio (0.6.3)
95
+ peatio (2.6.5)
69
96
  activemodel (> 5.2, <= 6.0.0)
70
97
  amqp
71
98
  bunny
72
99
  clamp
100
+ em-synchrony (~> 1.0)
73
101
  em-websocket
74
102
  eventmachine
103
+ faraday_middleware (~> 0.13.1)
104
+ faye (~> 1.2)
75
105
  jwt
76
106
  mysql2
107
+ prometheus-client
108
+ thin
109
+ prometheus-client (2.1.0)
77
110
  pry (0.13.1)
78
111
  coderay (~> 1.1)
79
112
  method_source (~> 1.0)
@@ -81,6 +114,7 @@ GEM
81
114
  byebug (~> 11.0)
82
115
  pry (~> 0.13.0)
83
116
  public_suffix (4.0.6)
117
+ rack (2.2.3)
84
118
  rake (13.0.6)
85
119
  rbtree (0.4.4)
86
120
  rexml (3.2.5)
@@ -101,6 +135,10 @@ GEM
101
135
  sorted_set (1.0.3)
102
136
  rbtree
103
137
  set (~> 1.0)
138
+ thin (1.8.1)
139
+ daemons (~> 1.0, >= 1.0.9)
140
+ eventmachine (~> 1.0, >= 1.0.4)
141
+ rack (>= 1, < 3)
104
142
  thread_safe (0.3.6)
105
143
  tzinfo (1.2.9)
106
144
  thread_safe (~> 0.1)
@@ -108,13 +146,15 @@ GEM
108
146
  addressable (>= 2.8.0)
109
147
  crack (>= 0.3.2)
110
148
  hashdiff (>= 0.4.0, < 2.0.0)
149
+ websocket-driver (0.7.5)
150
+ websocket-extensions (>= 0.1.0)
151
+ websocket-extensions (0.1.5)
111
152
 
112
153
  PLATFORMS
113
154
  x64-mingw32
114
155
 
115
156
  DEPENDENCIES
116
157
  bundler (~> 1.16)
117
- coinpayments
118
158
  mocha (~> 1.8)
119
159
  peatio-coinpaymentnew!
120
160
  pry-byebug
@@ -123,4 +163,4 @@ DEPENDENCIES
123
163
  webmock (~> 3.5)
124
164
 
125
165
  BUNDLED WITH
126
- 1.17.2
166
+ 1.17.3
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peatio
4
+ module Coinpaymentnew
5
+ class Client
6
+ Error = Class.new(StandardError)
7
+ ConnectionError = Class.new(Error)
8
+
9
+ class ResponseError < Error
10
+ def initialize(msg)
11
+ super "#{msg}"
12
+ end
13
+ end
14
+
15
+ def initialize(endpoint, access_token, access_token2)
16
+ @endpoint = URI.parse(endpoint)
17
+ @access_token = access_token
18
+ @access_token2 = access_token2
19
+ end
20
+ def self.hmac(body)
21
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), @access_token2, HTTParty::HashConversions.to_params(body))
22
+ end
23
+
24
+ def self.required_params
25
+ { version: 1, key: @access_token }
26
+ end
27
+
28
+ # def rest_api(verb, path, data = nil)
29
+ def rest_api(args)
30
+ # args = [@endpoint.to_s + path]
31
+
32
+ # if data
33
+ # if %i[post put patch].include?(verb)
34
+ # args << data.compact.to_json
35
+ # args << { 'Content-Type' => 'application/json' }
36
+ # else
37
+ # args << data.compact
38
+ # args << {}
39
+ # end
40
+ # else
41
+ # args << nil
42
+ # args << {}
43
+ # end
44
+ body = required_params.merge!(args)
45
+ # args.last['Accept'] = 'application/json'
46
+ # args.last['hmac'] = hmac(body)
47
+
48
+ # body = required_params.merge!(cmd: caller[0][/`.*'/][1..-2]).merge!(args)
49
+ response = HTTParty.post(@endpoint.to_s, body: body, headers: {'hmac' => hmac(body)})
50
+ response['error'] == 'ok' ? Hashie::Mash.new(response['result']) : response['error']
51
+
52
+ # response = Faraday.send(verb, *args)
53
+ # response.assert_success!
54
+ # response = JSON.parse(response.body)
55
+ # response['error'].tap { |error| raise ResponseError.new(error) if error }
56
+ # response
57
+ rescue Faraday::Error => e
58
+ if e.is_a?(Faraday::ConnectionFailed) || e.is_a?(Faraday::TimeoutError)
59
+ raise ConnectionError, e
60
+ else
61
+ raise ConnectionError, JSON.parse(e.response.body)['message']
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Peatio
4
4
  module Coinpaymentnew
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ module Peatio
2
2
  module Coinpaymentnew
3
3
  class Wallet < Peatio::Wallet::Abstract
4
4
  TIME_DIFFERENCE_IN_MINUTES = 10
5
- # XLM_MEMO_TYPES = { 'memoId': 'id', 'memoText': 'text', 'memoHash': 'hash', 'memoReturn': 'return' }
5
+ XLM_MEMO_TYPES = { 'memoId': 'id', 'memoText': 'text', 'memoHash': 'hash', 'memoReturn': 'return' }
6
6
 
7
7
  DEFAULT_FEATURES = { skip_deposit_collection: false }.freeze
8
8
 
@@ -19,7 +19,7 @@ module Peatio
19
19
 
20
20
  @wallet = @settings.fetch(:wallet) do
21
21
  raise Peatio::Wallet::MissingSettingError, :wallet
22
- end.slice(:uri, :address, :secret, :access_token, :wallet_id, :testnet)
22
+ end.slice(:uri, :address, :secret, :access_token, :access_token2, :wallet_id, :testnet)
23
23
 
24
24
  @currency = @settings.fetch(:currency) do
25
25
  raise Peatio::Wallet::MissingSettingError, :currency
@@ -29,19 +29,20 @@ module Peatio
29
29
  def create_address!(options = {})
30
30
  currency = erc20_currency_id
31
31
  options.deep_symbolize_keys!
32
- response = WalletApi.get_deposit_address(currency.upcase)
33
- { address: response[:address], secret: coinpayment_wallet_passphrase, details: { address_id: response[:address] }}
34
- # if options.dig(:pa_details, :address_id).present? &&
35
- # options.dig(:pa_details, :updated_at).present? &&
36
- # time_difference_in_minutes(options.dig(:pa_details, :updated_at)) >= TIME_DIFFERENCE_IN_MINUTES
37
- #
38
- # response = client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{options.dig(:pa_details, :address_id)}")
39
- # { address: response['address'], secret: bitgo_wallet_passphrase }
40
- # elsif options.dig(:pa_details, :address_id).blank?
41
- # response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
42
- # { address: response['address'], secret: bitgo_wallet_passphrase, details: { address_id: response['id'] }}
43
- # end
44
- rescue Coinpaymentnew::Client::Error => e
32
+
33
+ if options.dig(:pa_details, :address_id).present? &&
34
+ options.dig(:pa_details, :updated_at).present? &&
35
+ time_difference_in_minutes(options.dig(:pa_details, :updated_at)) >= TIME_DIFFERENCE_IN_MINUTES
36
+ args = { cmd: 'get_deposit_address', currency: currency.code }.merge!(options)
37
+ response = client.rest_api(args)
38
+ { address: response['address'], secret: coinpayment_wallet_passphrase }
39
+ elsif options.dig(:pa_details, :address_id).blank?
40
+ args = { cmd: 'get_deposit_address', currency: currency.code }.merge!(options)
41
+ response = client.rest_api(args)
42
+ # response = client.rest_api(:post, "#{currency}/wallet/#{wallet_id}/address")
43
+ { address: response['address'], secret: coinpayment_wallet_passphrase, details: { address_id: response['address'] }}
44
+ end
45
+ rescue Coinpayment::Client::Error => e
45
46
  raise Peatio::Wallet::ClientError, e
46
47
  end
47
48
 
@@ -56,112 +57,118 @@ module Peatio
56
57
 
57
58
  # if options[:subtract_fee].to_s == 'true'
58
59
  # fee = build_raw_transaction(transaction)
59
- # baseFeeInfo = fee.dig('feeInfo','fee')
60
- # fee = baseFeeInfo.present? ? baseFeeInfo : fee.dig('txInfo','Fee')
60
+ # baseFeeInfo = fee['tx_fee']
61
+ # # fee = baseFeeInfo.present? ? baseFeeInfo : fee.dig('txInfo','Fee')
61
62
  # amount -= fee.to_i
62
63
  # end
63
- response = WalletApi.createTransaction(transaction.amount.to_s, "USD",currency_id.upcase, transaction.to_address.to_s)
64
+
65
+ args = { cmd: "create_transaction", amount: amount, currency1: "USD", currency2: currency.code, buyer_email: "joshirockstar007@gmail.com", address: normalize_address(transaction.to_address.to_s) }
66
+ response = client.rest_api(args)
64
67
  # response = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
65
68
  # address: normalize_address(transaction.to_address.to_s),
66
69
  # amount: amount.to_s,
67
- # walletPassphrase: bitgo_wallet_passphrase,
70
+ # walletPassphrase: coinpayment_wallet_passphrase,
68
71
  # memo: xlm_memo(transaction.to_address.to_s)
69
72
  # }.compact)
70
- #
71
- # if response['feeString'].present?
72
- # fee = convert_from_base_unit(response['feeString'])
73
- # transaction.fee = fee
74
- # end
75
73
 
76
- transaction.hash = normalize_txid(response[:txn_id])
74
+ if response['feeString'].present?
75
+ fee = convert_from_base_unit(response['feeString'])
76
+ transaction.fee = fee
77
+ end
78
+
79
+ transaction.hash = normalize_txid(response['txn_id'])
77
80
  transaction.fee_currency_id = erc20_currency_id
78
81
  transaction
79
82
  # end
80
- rescue Coinpaymentnew::Client::Error => e
83
+ rescue Coinpayment::Client::Error => e
81
84
  raise Peatio::Wallet::ClientError, e
82
85
  end
83
86
 
84
- #
85
- # def build_raw_transaction(transaction)
86
- # client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/tx/build", {
87
- # recipients: [{
88
- # address: transaction.to_address,
89
- # amount: convert_to_base_unit(transaction.amount).to_s
90
- # }]
91
- # }.compact)
92
- # end
87
+
88
+ def build_raw_transaction(transaction)
89
+ args = { cmd: "rates" }
90
+ response = client.rest_api(args)
91
+ response[currency.code]
92
+ # client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/tx/build", {
93
+ # recipients: [{
94
+ # address: transaction.to_address,
95
+ # amount: convert_to_base_unit(transaction.amount).to_s
96
+ # }]
97
+ # }.compact)
98
+ end
93
99
 
94
100
  # def create_eth_transaction(transaction, options = {})
95
101
  # amount = convert_to_base_unit(transaction.amount)
96
102
  # hop = true unless options.slice(:gas_price).present?
97
- #
103
+
98
104
  # fee_estimate = fee_estimate(amount.to_s, hop)
99
- #
105
+
100
106
  # if transaction.options.present? && transaction.options[:gas_price].present?
101
107
  # options[:gas_price] = transaction.options[:gas_price]
102
108
  # else
103
109
  # options[:gas_price] = fee_estimate['minGasPrice'].to_i
104
110
  # end
105
- #
111
+
106
112
  # response = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
107
113
  # address: transaction.to_address.to_s,
108
114
  # amount: amount.to_s,
109
- # walletPassphrase: bitgo_wallet_passphrase,
115
+ # walletPassphrase: coinpayment_wallet_passphrase,
110
116
  # gas: options.fetch(:gas_limit).to_i,
111
117
  # gasPrice: options.fetch(:gas_price).to_i,
112
118
  # hop: hop
113
119
  # }.compact)
114
- #
120
+
115
121
  # if response['feeString'].present?
116
122
  # fee = convert_from_base_unit(response['feeString'])
117
123
  # transaction.fee = fee
118
124
  # end
119
- #
125
+
120
126
  # transaction.hash = normalize_txid(response['txid'])
121
127
  # transaction.fee_currency_id = erc20_currency_id
122
128
  # transaction.options = options
123
129
  # transaction
124
130
  # end
125
131
 
126
- def fee_estimate(amount, hop)
127
- client.rest_api(:get, "#{erc20_currency_id}/tx/fee", { amount: amount, hop: hop }.compact)
128
- end
132
+ # def fee_estimate(amount, hop)
133
+ # client.rest_api(:get, "#{erc20_currency_id}/tx/fee", { amount: amount, hop: hop }.compact)
134
+ # end
129
135
 
130
136
  def load_balance!
137
+ args = { cmd: "balances" }
138
+ response = client.rest_api(args)
139
+ response[currency.code]['balancef']
131
140
  # if @currency.fetch(:options).slice(:erc20_contract_address).present?
132
141
  # load_erc20_balance!
133
142
  # else
134
143
  # response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}")
135
- response = WalletApi.balance
136
- response = response.fetch(currency_id)
137
- convert_from_base_unit(response["balance"])
144
+ # convert_from_base_unit(response.fetch('balanceString'))
138
145
  # end
139
- rescue Coinpaymentnew::Client::Error => e
146
+ rescue Coinpayment::Client::Error => e
140
147
  raise Peatio::Wallet::ClientError, e
141
148
  end
142
149
 
143
150
  # def load_erc20_balance!
144
151
  # response = client.rest_api(:get, "#{erc20_currency_id}/wallet/#{wallet_id}?allTokens=true")
145
152
  # convert_from_base_unit(response.dig('tokens', currency_id, 'balanceString'))
146
- # rescue Coinpaymentnew::Client::Error => e
153
+ # rescue Coinpayment::Client::Error => e
147
154
  # raise Peatio::Wallet::ClientError, e
148
155
  # end
149
156
 
150
157
  def trigger_webhook_event(request)
151
158
  currency = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
152
- if request.params['type'] == 'transfer'
159
+ if request.params['ipn_type'] == 'transfer'
153
160
  return unless currency == request.params['coin'] &&
154
161
  @wallet.fetch(:wallet_id) == request.params['wallet']
155
162
  else
156
163
  return unless @wallet.fetch(:wallet_id) == request.params['walletId']
157
164
  end
158
165
 
159
- if request.params['type'] == 'transfer'
160
- transactions = fetch_transfer!(request.params['transfer'])
166
+ if request.params['ipn_type'] == 'transfer'
167
+ transactions = fetch_transfer!(request.params['txn_id'])
161
168
  return transactions
162
- elsif request.params['type'] == 'address_confirmation'
163
- address_id = fetch_address_id(request.params['address'])
164
- return { address_id: address_id, address: request.params['address'], currency_id: currency_id }
169
+ # elsif request.params['type'] == 'address_confirmation'
170
+ # address_id = fetch_address_id(request.params['address'])
171
+ # return { address_id: address_id, address: request.params['address'], currency_id: currency_id }
165
172
  end
166
173
  end
167
174
 
@@ -174,46 +181,49 @@ module Peatio
174
181
  # currency = erc20_currency_id
175
182
  # client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{address}")
176
183
  # .fetch('id')
177
- # rescue Coinpaymentnew::Client::Error => e
184
+ # rescue Coinpayment::Client::Error => e
178
185
  # raise Peatio::Wallet::ClientError, e
179
186
  # end
180
187
 
181
188
  def fetch_transfer!(id)
182
- response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
183
- parse_entries(response['entries']).map do |entry|
184
- to_address = if response.dig('coinSpecific', 'memo').present?
185
- memo = response.dig('coinSpecific', 'memo')
186
- memo_type = memo.kind_of?(Array) ? memo.first : memo
187
- build_address(entry['address'], memo_type)
188
- else
189
- entry['address']
190
- end
191
- state = define_transaction_state(response['state'])
192
-
193
- if response['outputs'].present?
194
- output = response['outputs'].find { |out| out['address'] == to_address }
195
- txout = output['index'] if output.present?
196
- end
189
+ args = { cmd: "get_tx_info", txid: id }
190
+ response = client.rest_api(args)
191
+ # response[currency.code]['balancef']
192
+ # response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
193
+ # parse_entries(response['entries']).map do |entry|
194
+ # to_address = if response.dig('coinSpecific', 'memo').present?
195
+ # memo = response.dig('coinSpecific', 'memo')
196
+ # memo_type = memo.kind_of?(Array) ? memo.first : memo
197
+ # build_address(entry['address'], memo_type)
198
+ # else
199
+ # entry['address']
200
+ # end
201
+ state = define_transaction_state(response['status'])
202
+
203
+ # if response['outputs'].present?
204
+ # output = response['outputs'].find { |out| out['address'] == to_address }
205
+ # txout = output['index'] if output.present?
206
+ # end
197
207
 
198
- if response['feeString'].present?
199
- fee = convert_from_base_unit(response['feeString']) / response['entries'].count
200
- end
208
+ # if response['feeString'].present?
209
+ # fee = convert_from_base_unit(response['feeString']) / response['entries'].count
210
+ # end
201
211
 
202
212
  transaction = Peatio::Transaction.new(
203
213
  currency_id: @currency.fetch(:id),
204
- amount: convert_from_base_unit(entry['valueString']),
205
- fee: fee,
206
- fee_currency_id: erc20_currency_id,
214
+ amount: convert_from_base_unit(response['amountf']),
215
+ fee: 0,
216
+ fee_currency_id: response["coin"],
207
217
  hash: normalize_txid(response['txid']),
208
- to_address: to_address,
209
- block_number: response['height'],
210
- txout: txout.to_i,
218
+ to_address: response["payment_address"],
219
+ block_number: 0,
220
+ txout: 0,
211
221
  status: state
212
222
  )
213
223
 
214
224
  transaction if transaction.valid?
215
- end.compact
216
- rescue Coinpaymentnew::Client::Error => e
225
+ # end.compact
226
+ rescue Coinpayment::Client::Error => e
217
227
  raise Peatio::Wallet::ClientError, e
218
228
  end
219
229
 
@@ -248,10 +258,11 @@ module Peatio
248
258
  def client
249
259
  uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
250
260
  access_token = @wallet.fetch(:access_token) { raise Peatio::Wallet::MissingSettingError, :access_token }
261
+ access_token2 = @wallet.fetch(:access_token2) { raise Peatio::Wallet::MissingSettingError, :access_token2 }
251
262
 
252
263
  currency_code_prefix = @wallet.fetch(:testnet) ? 't' : ''
253
264
  uri = uri.gsub(/\/+\z/, '') + '/' + currency_code_prefix
254
- @client ||= Client.new(uri, access_token)
265
+ @client ||= Client.new(uri, access_token, access_token2)
255
266
  end
256
267
 
257
268
  def build_address(address, memo)
@@ -314,7 +325,7 @@ module Peatio
314
325
 
315
326
  def convert_from_base_unit(value)
316
327
  value.to_d / @currency.fetch(:base_factor)
317
- end
328
+ endf
318
329
 
319
330
  def convert_to_base_unit(value)
320
331
  x = value.to_d * @currency.fetch(:base_factor)
@@ -331,12 +342,11 @@ module Peatio
331
342
  end
332
343
 
333
344
  def define_transaction_state(state)
334
- case state
335
- when 'unconfirmed'
345
+ if state >= 100)
346
+ "success"
347
+ if else state >= 0 && state <= 99
336
348
  'pending'
337
- when 'confirmed'
338
- 'success'
339
- when 'failed','rejected'
349
+ else
340
350
  'failed'
341
351
  end
342
352
  end
@@ -2,7 +2,6 @@
2
2
  require 'em/pure_ruby'
3
3
  require "peatio"
4
4
  require "coinpayments"
5
- require_relative "../../config/initializers/coinpayments"
6
5
  require_relative "coinpaymentnew/version"
7
6
 
8
7
  module Peatio
@@ -13,6 +12,7 @@ module Peatio
13
12
  require "bigdecimal/util"
14
13
 
15
14
  require_relative "coinpaymentnew/blockchain"
15
+ require_relative "coinpaymentnew/client"
16
16
  require_relative "coinpaymentnew/wallet"
17
17
 
18
18
  require_relative "coinpaymentnew/hooks"
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peatio-coinpaymentnew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harishankar Joshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-01 00:00:00.000000000 Z
11
+ date: 2021-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -205,14 +205,16 @@ files:
205
205
  - Rakefile
206
206
  - bin/console
207
207
  - bin/setup
208
- - config/initializers/coinpayments.rb
209
208
  - lib/peatio/coinpaymentnew.rb
210
209
  - lib/peatio/coinpaymentnew/blockchain.rb
210
+ - lib/peatio/coinpaymentnew/client.rb
211
211
  - lib/peatio/coinpaymentnew/hooks.rb
212
212
  - lib/peatio/coinpaymentnew/railtie.rb
213
213
  - lib/peatio/coinpaymentnew/version.rb
214
214
  - lib/peatio/coinpaymentnew/wallet.rb
215
- - lib/peatio/coinpaymentnew/walletApi.rb
215
+ - peatio-coinpaymentnew-0.0.2.gem
216
+ - peatio-coinpaymentnew-0.0.3.gem
217
+ - peatio-coinpaymentnew-0.0.4.gem
216
218
  - peatio-coinpaymentnew.gemspec
217
219
  homepage: https://openware.com/
218
220
  licenses:
@@ -1,6 +0,0 @@
1
- Coinpayments.configure do |config|
2
- config.merchant_id = '81584a734276162e589fb2a5c19d1114'
3
- config.public_api_key = '1c68e7c5cd7f03d79325bc63e2985d3dc604847242a22d682673f531af4cadcb'
4
- config.private_api_key = '13F4855BFDa330B43063F07961CA373CfF3bb141d8ccCdF83B5e92ac2ad0f78b'
5
- config.secret_phrase = '@hari123'
6
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Peatio
4
- module Coinpaymentnew
5
- class WalletApi
6
- public
7
- def self.balance
8
- Coinpayments.balances
9
- end
10
- def self.rate
11
- Coinpayments.rates
12
- end
13
- def self.createTransaction(amount, currency1, currency2, address)
14
- Coinpayments.create_transaction(amount, currency1, currency2, {address: address, buyer_email: "joshirockstar007@gmail.com"})
15
- end
16
- def self.createWithdrawal(amount, currency, address)
17
- Coinpayments.create_withdrawal(amount, currency, address)
18
- end
19
- def self.cancelWithdrawal(id)
20
- Coinpayments.cancel_withdrawal(id)
21
- end
22
- def self.getTxInfo(txid)
23
- Coinpayments.get_tx_info(txid)
24
- end
25
- def self.getCallbackAddress(currency)
26
- Coinpayments.get_callback_address(currency)
27
- end
28
- def self.get_deposit_address(currency, options = {})
29
- args = { currency: currency }.merge!(options)
30
- Coinpayments.api_call(args)
31
- end
32
- def self.getWithdrawalInfo(id)
33
- Coinpayments.get_withdrawal_info(id)
34
- end
35
- def self.Sign(secretPhrase)
36
- Coinpayments.sign(secretPhrase)
37
- end
38
- end
39
- end
40
- end
41
-