peatio-dash-jruby 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +193 -0
- data/LICENSE.txt +12 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/peatio/dash.rb +20 -0
- data/lib/peatio/dash/blockchain.rb +96 -0
- data/lib/peatio/dash/client.rb +71 -0
- data/lib/peatio/dash/hooks.rb +44 -0
- data/lib/peatio/dash/railtie.rb +15 -0
- data/lib/peatio/dash/version.rb +7 -0
- data/lib/peatio/dash/wallet.rb +60 -0
- data/peatio-dash.gemspec +55 -0
- metadata +260 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cc795b7352dc0d8e5a9d5a8d170c2b8f953ac905ce6ccef012de4da6d1a9c68
|
4
|
+
data.tar.gz: 856dff3398aa271ded0216dd2824f9ff77ed51602318b8087e11c17990830734
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 343265f8f9f2e3199a5885e02d3a89ef893e1e8c0a6db17e2cab1e0556e1bcf49bbe17dbce298d45b7aafc6bca86bbd371d3ead67f179ff0f9d7976aa72c7442
|
7
|
+
data.tar.gz: 5c1260304e6f1e517846f8de0854827e029f5a0bc142a2126ea4ab4ee9a2f15d4931fc9666730defd2c2268b44773fb18f91c8f924e29b2a8cc784084e41b044
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
peatio-dash-jruby (2.5.4)
|
5
|
+
activesupport (~> 5.2.3)
|
6
|
+
better-faraday (~> 1.0.5)
|
7
|
+
faraday (~> 0.17)
|
8
|
+
memoist (~> 0.16.0)
|
9
|
+
net-http-persistent (~> 3.0.1)
|
10
|
+
peatio-jruby (>= 2.6.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activemodel (5.2.4.4)
|
16
|
+
activesupport (= 5.2.4.4)
|
17
|
+
activerecord (5.2.4.4)
|
18
|
+
activemodel (= 5.2.4.4)
|
19
|
+
activesupport (= 5.2.4.4)
|
20
|
+
arel (>= 9.0)
|
21
|
+
activerecord-jdbc-adapter (50.0)
|
22
|
+
activerecord (>= 2.2)
|
23
|
+
activerecord-jdbcmysql-adapter (50.0)
|
24
|
+
activerecord-jdbc-adapter (~> 50.0)
|
25
|
+
jdbc-mysql (~> 5.1.36)
|
26
|
+
activesupport (5.2.4.4)
|
27
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
|
+
i18n (>= 0.7, < 2)
|
29
|
+
minitest (~> 5.1)
|
30
|
+
tzinfo (~> 1.1)
|
31
|
+
addressable (2.7.0)
|
32
|
+
public_suffix (>= 2.0.2, < 5.0)
|
33
|
+
amq-protocol (2.3.2)
|
34
|
+
amqp (1.8.0)
|
35
|
+
amq-protocol (>= 2.2.0)
|
36
|
+
eventmachine
|
37
|
+
arel (9.0.0)
|
38
|
+
ast (2.4.0)
|
39
|
+
better-faraday (1.0.8)
|
40
|
+
activesupport (>= 4.0, < 6.0)
|
41
|
+
faraday (~> 0.12)
|
42
|
+
bunny (2.17.0)
|
43
|
+
amq-protocol (~> 2.3, >= 2.3.1)
|
44
|
+
clamp (1.3.2)
|
45
|
+
concurrent-ruby (1.1.8)
|
46
|
+
connection_pool (2.2.3)
|
47
|
+
cookiejar (0.3.3)
|
48
|
+
crack (0.4.3)
|
49
|
+
safe_yaml (~> 1.0.0)
|
50
|
+
diff-lcs (1.3)
|
51
|
+
docile (1.3.2)
|
52
|
+
em-http-request (1.1.7)
|
53
|
+
addressable (>= 2.3.4)
|
54
|
+
cookiejar (!= 0.3.1)
|
55
|
+
em-socksify (>= 0.3)
|
56
|
+
eventmachine (>= 1.0.3)
|
57
|
+
http_parser.rb (>= 0.6.0)
|
58
|
+
em-socksify (0.3.2)
|
59
|
+
eventmachine (>= 1.0.0.beta.4)
|
60
|
+
em-synchrony (1.0.6)
|
61
|
+
eventmachine (>= 1.0.0.beta.1)
|
62
|
+
em-websocket (0.5.2)
|
63
|
+
eventmachine (>= 0.12.9)
|
64
|
+
http_parser.rb (~> 0.6.0)
|
65
|
+
eventmachine (1.2.7)
|
66
|
+
eventmachine (1.2.7-java)
|
67
|
+
faraday (0.17.3)
|
68
|
+
multipart-post (>= 1.2, < 3)
|
69
|
+
faraday_middleware (0.13.1)
|
70
|
+
faraday (>= 0.7.4, < 1.0)
|
71
|
+
faye (1.4.0)
|
72
|
+
cookiejar (>= 0.3.0)
|
73
|
+
em-http-request (>= 1.1.6)
|
74
|
+
eventmachine (>= 0.12.0)
|
75
|
+
faye-websocket (>= 0.11.0)
|
76
|
+
multi_json (>= 1.0.0)
|
77
|
+
rack (>= 1.0.0)
|
78
|
+
websocket-driver (>= 0.5.1)
|
79
|
+
faye-websocket (0.11.0)
|
80
|
+
eventmachine (>= 0.12.0)
|
81
|
+
websocket-driver (>= 0.5.1)
|
82
|
+
hashdiff (1.0.1)
|
83
|
+
http_parser.rb (0.6.0)
|
84
|
+
http_parser.rb (0.6.0-java)
|
85
|
+
i18n (1.8.7)
|
86
|
+
concurrent-ruby (~> 1.0)
|
87
|
+
io-console (0.5.6)
|
88
|
+
irb (1.2.3)
|
89
|
+
reline (>= 0.0.1)
|
90
|
+
jaro_winkler (1.5.4)
|
91
|
+
jaro_winkler (1.5.4-java)
|
92
|
+
jdbc-mysql (5.1.47)
|
93
|
+
jruby-rack (1.1.21)
|
94
|
+
jwt (2.2.2)
|
95
|
+
memoist (0.16.2)
|
96
|
+
minitest (5.14.3)
|
97
|
+
mocha (1.11.2)
|
98
|
+
multi_json (1.15.0)
|
99
|
+
multipart-post (2.1.1)
|
100
|
+
net-http-persistent (3.0.1)
|
101
|
+
connection_pool (~> 2.2)
|
102
|
+
parallel (1.19.1)
|
103
|
+
parser (2.7.0.5)
|
104
|
+
ast (~> 2.4.0)
|
105
|
+
peatio-jruby (2.6.2)
|
106
|
+
activemodel (> 5.2, <= 6.0.0)
|
107
|
+
activerecord-jdbc-adapter
|
108
|
+
activerecord-jdbcmysql-adapter
|
109
|
+
amqp
|
110
|
+
bunny
|
111
|
+
clamp
|
112
|
+
em-synchrony (~> 1.0)
|
113
|
+
em-websocket
|
114
|
+
eventmachine
|
115
|
+
faraday_middleware (~> 0.13.1)
|
116
|
+
faye (~> 1.2)
|
117
|
+
jdbc-mysql
|
118
|
+
jwt
|
119
|
+
prometheus-client
|
120
|
+
trinidad
|
121
|
+
prometheus-client (2.1.0)
|
122
|
+
public_suffix (4.0.4)
|
123
|
+
rack (2.2.3)
|
124
|
+
rainbow (3.0.0)
|
125
|
+
rake (13.0.1)
|
126
|
+
reline (0.1.3)
|
127
|
+
io-console (~> 0.5)
|
128
|
+
rexml (3.2.4)
|
129
|
+
rspec (3.9.0)
|
130
|
+
rspec-core (~> 3.9.0)
|
131
|
+
rspec-expectations (~> 3.9.0)
|
132
|
+
rspec-mocks (~> 3.9.0)
|
133
|
+
rspec-core (3.9.1)
|
134
|
+
rspec-support (~> 3.9.1)
|
135
|
+
rspec-expectations (3.9.1)
|
136
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
137
|
+
rspec-support (~> 3.9.0)
|
138
|
+
rspec-mocks (3.9.1)
|
139
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
140
|
+
rspec-support (~> 3.9.0)
|
141
|
+
rspec-support (3.9.2)
|
142
|
+
rubocop (0.80.1)
|
143
|
+
jaro_winkler (~> 1.5.1)
|
144
|
+
parallel (~> 1.10)
|
145
|
+
parser (>= 2.7.0.1)
|
146
|
+
rainbow (>= 2.2.2, < 4.0)
|
147
|
+
rexml
|
148
|
+
ruby-progressbar (~> 1.7)
|
149
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
150
|
+
rubocop-github (0.14.0)
|
151
|
+
rubocop (~> 0.59)
|
152
|
+
ruby-progressbar (1.10.1)
|
153
|
+
safe_yaml (1.0.5)
|
154
|
+
simplecov (0.18.5)
|
155
|
+
docile (~> 1.1)
|
156
|
+
simplecov-html (~> 0.11)
|
157
|
+
simplecov-html (0.12.2)
|
158
|
+
thread_safe (0.3.6)
|
159
|
+
thread_safe (0.3.6-java)
|
160
|
+
trinidad (1.4.6)
|
161
|
+
jruby-rack (~> 1.1.13)
|
162
|
+
trinidad_jars (>= 1.3.0, < 1.5.0)
|
163
|
+
trinidad_jars (1.4.2)
|
164
|
+
tzinfo (1.2.9)
|
165
|
+
thread_safe (~> 0.1)
|
166
|
+
unicode-display_width (1.6.1)
|
167
|
+
webmock (3.8.3)
|
168
|
+
addressable (>= 2.3.6)
|
169
|
+
crack (>= 0.3.2)
|
170
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
171
|
+
websocket-driver (0.7.3)
|
172
|
+
websocket-extensions (>= 0.1.0)
|
173
|
+
websocket-driver (0.7.3-java)
|
174
|
+
websocket-extensions (>= 0.1.0)
|
175
|
+
websocket-extensions (0.1.5)
|
176
|
+
|
177
|
+
PLATFORMS
|
178
|
+
java
|
179
|
+
ruby
|
180
|
+
|
181
|
+
DEPENDENCIES
|
182
|
+
bundler (~> 1.17)
|
183
|
+
irb
|
184
|
+
mocha (~> 1.8)
|
185
|
+
peatio-dash-jruby!
|
186
|
+
rake (~> 13.0)
|
187
|
+
rspec (~> 3.0)
|
188
|
+
rubocop-github
|
189
|
+
simplecov
|
190
|
+
webmock (~> 3.5)
|
191
|
+
|
192
|
+
BUNDLED WITH
|
193
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Copyright (C) Openware SAS - All Rights Reserved
|
2
|
+
|
3
|
+
NOTICE: All information contained herein is, and remains
|
4
|
+
the property of Openware SAS and its suppliers, if any.
|
5
|
+
The intellectual and technical concepts contained herein are proprietary to Openware SAS
|
6
|
+
and its suppliers and may be covered by U.S. and Foreign Patents,
|
7
|
+
patents in process, and are protected by trade secret or copyright law.
|
8
|
+
Dissemination of this information or reproduction of this material
|
9
|
+
is strictly forbidden unless prior written permission is obtained
|
10
|
+
from Openware SAS.
|
11
|
+
|
12
|
+
Proprietary and confidential
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Peatio::Dash
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/peatio/dash`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'peatio-dash'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install peatio-dash
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/peatio-dash.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "peatio/dash"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/peatio/dash.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/object/blank"
|
4
|
+
require "active_support/core_ext/enumerable"
|
5
|
+
require "peatio"
|
6
|
+
|
7
|
+
module Peatio
|
8
|
+
module Dash
|
9
|
+
require "bigdecimal"
|
10
|
+
require "bigdecimal/util"
|
11
|
+
|
12
|
+
require "peatio/dash/blockchain"
|
13
|
+
require "peatio/dash/client"
|
14
|
+
require "peatio/dash/wallet"
|
15
|
+
|
16
|
+
require "peatio/dash/hooks"
|
17
|
+
|
18
|
+
require "peatio/dash/version"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Peatio
|
4
|
+
module Dash
|
5
|
+
# TODO: Processing of unconfirmed transactions from mempool isn't supported now.
|
6
|
+
class Blockchain < Peatio::Blockchain::Abstract
|
7
|
+
DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
|
8
|
+
|
9
|
+
def initialize(custom_features={})
|
10
|
+
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
11
|
+
@settings = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(settings={})
|
15
|
+
# Clean client state during configure.
|
16
|
+
@client = nil
|
17
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
18
|
+
end
|
19
|
+
|
20
|
+
def fetch_block!(block_number)
|
21
|
+
block_hash = client.json_rpc(:getblockhash, [block_number])
|
22
|
+
|
23
|
+
block_txs = client.json_rpc(:getblock, [block_hash, 2])
|
24
|
+
.fetch("tx").each_with_object([]) do |tx, txs_array|
|
25
|
+
txs = build_transaction(tx).map do |ntx|
|
26
|
+
Peatio::Transaction.new(ntx.merge(block_number: block_number))
|
27
|
+
end
|
28
|
+
txs_array.append(*txs)
|
29
|
+
end
|
30
|
+
|
31
|
+
Peatio::Block.new(block_number, block_txs)
|
32
|
+
rescue Client::Error => e
|
33
|
+
raise Peatio::Blockchain::ClientError, e
|
34
|
+
end
|
35
|
+
|
36
|
+
def latest_block_number
|
37
|
+
client.json_rpc(:getblockcount)
|
38
|
+
rescue Client::Error => e
|
39
|
+
raise Peatio::Blockchain::ClientError, e
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_balance_of_address!(address, _currency_id)
|
43
|
+
address_with_balance = client.json_rpc(:listaddressgroupings)
|
44
|
+
.flatten(1)
|
45
|
+
.find {|addr| addr[0] == address }
|
46
|
+
|
47
|
+
raise Peatio::Blockchain::UnavailableAddressBalanceError, address if address_with_balance.blank?
|
48
|
+
|
49
|
+
address_with_balance[1].to_d
|
50
|
+
rescue Client::Error => e
|
51
|
+
raise Peatio::Blockchain::ClientError, e
|
52
|
+
end
|
53
|
+
|
54
|
+
def transaction_sources(transaction)
|
55
|
+
transaction_hash = client.json_rpc(:getrawtransaction, [transaction.hash, 1])
|
56
|
+
transaction_hash['vin'].each_with_object([]) do |vin, source_addresses|
|
57
|
+
next if vin['txid'].blank?
|
58
|
+
|
59
|
+
vin_transaction = client.json_rpc(:getrawtransaction, [vin['txid'], 1])
|
60
|
+
source = vin_transaction['vout'].find { |hash| hash['n'] == vin['vout'] }
|
61
|
+
source_addresses << source['scriptPubKey']['addresses'][0]
|
62
|
+
end.compact.uniq
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def filter_vout(tx_hash)
|
68
|
+
tx_hash.fetch("vout").select do |entry|
|
69
|
+
entry.fetch("value").to_d.positive? && entry["scriptPubKey"].has_key?("addresses")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def build_transaction(tx_hash)
|
74
|
+
filter_vout(tx_hash).each_with_object([]) do |entry, formatted_txs|
|
75
|
+
no_currency_tx = {hash: tx_hash["txid"], txout: entry["n"],
|
76
|
+
to_address: entry["scriptPubKey"]["addresses"][0],
|
77
|
+
amount: entry.fetch("value").to_d,
|
78
|
+
status: "success"}
|
79
|
+
|
80
|
+
# Build transaction for each currency belonging to blockchain.
|
81
|
+
settings_fetch(:currencies).pluck(:id).each do |currency_id|
|
82
|
+
formatted_txs << no_currency_tx.merge(currency_id: currency_id)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def client
|
88
|
+
@client ||= Client.new(settings_fetch(:server))
|
89
|
+
end
|
90
|
+
|
91
|
+
def settings_fetch(key)
|
92
|
+
@settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "memoist"
|
4
|
+
require "faraday"
|
5
|
+
require "better-faraday"
|
6
|
+
|
7
|
+
module Peatio
|
8
|
+
module Dash
|
9
|
+
class Client
|
10
|
+
Error = Class.new(StandardError)
|
11
|
+
class ConnectionError < Error; end
|
12
|
+
|
13
|
+
class ResponseError < Error
|
14
|
+
def initialize(code, msg)
|
15
|
+
@code = code
|
16
|
+
@msg = msg
|
17
|
+
end
|
18
|
+
|
19
|
+
def message
|
20
|
+
"#{@msg} (#{@code})"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
extend Memoist
|
25
|
+
|
26
|
+
def initialize(endpoint)
|
27
|
+
@json_rpc_endpoint = URI.parse(endpoint)
|
28
|
+
end
|
29
|
+
|
30
|
+
def json_rpc(method, params=[])
|
31
|
+
response = post(method, params)
|
32
|
+
|
33
|
+
response.assert_2xx!
|
34
|
+
response = JSON.parse(response.body)
|
35
|
+
|
36
|
+
response["error"].tap do |e|
|
37
|
+
raise ResponseError.new(e["code"], e["message"]) if e
|
38
|
+
end
|
39
|
+
|
40
|
+
response.fetch("result")
|
41
|
+
rescue StandardError => e
|
42
|
+
case e
|
43
|
+
when Faraday::Error
|
44
|
+
raise ConnectionError, e
|
45
|
+
when Error
|
46
|
+
raise e
|
47
|
+
else
|
48
|
+
raise Error, e
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def post(method, params)
|
55
|
+
connection.post("/", {jsonrpc: "1.0", method: method, params: params}.to_json,
|
56
|
+
"Accept" => "application/json", "Content-Type" => "application/json")
|
57
|
+
end
|
58
|
+
|
59
|
+
def connection
|
60
|
+
@connection ||= Faraday.new(@json_rpc_endpoint) do |f|
|
61
|
+
f.adapter :net_http_persistent, pool_size: 5
|
62
|
+
end.tap do |connection|
|
63
|
+
unless @json_rpc_endpoint.user.blank?
|
64
|
+
connection.basic_auth(@json_rpc_endpoint.user,
|
65
|
+
@json_rpc_endpoint.password)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Peatio
|
4
|
+
module Dash
|
5
|
+
module Hooks
|
6
|
+
BLOCKCHAIN_VERSION_REQUIREMENT = "~> 1.0.0"
|
7
|
+
WALLET_VERSION_REQUIREMENT = "~> 1.0.0"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def check_compatibility
|
11
|
+
unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
|
12
|
+
.satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
|
13
|
+
[
|
14
|
+
"Dash blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
|
15
|
+
"Dash blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
|
16
|
+
"Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
|
17
|
+
].join('\n').tap {|s| Kernel.abort s }
|
18
|
+
end
|
19
|
+
|
20
|
+
unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
|
21
|
+
.satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
|
22
|
+
[
|
23
|
+
"Dash wallet version requiremnt was not suttisfied by Peatio::Wallet.",
|
24
|
+
"Dash wallet requires #{WALLET_VERSION_REQUIREMENT}.",
|
25
|
+
"Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
|
26
|
+
].join('\n').tap {|s| Kernel.abort s }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def register
|
31
|
+
Peatio::Blockchain.registry[:dash] = Dash::Blockchain
|
32
|
+
Peatio::Wallet.registry[:dashd] = Dash::Wallet
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(Rails::Railtie)
|
37
|
+
require "peatio/dash/railtie"
|
38
|
+
else
|
39
|
+
check_compatibility
|
40
|
+
register
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Peatio
|
4
|
+
module Dash
|
5
|
+
class Wallet < Peatio::Wallet::Abstract
|
6
|
+
def initialize(settings={})
|
7
|
+
@settings = settings
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure(settings={})
|
11
|
+
# Clean client state during configure.
|
12
|
+
@client = nil
|
13
|
+
|
14
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
15
|
+
|
16
|
+
@wallet = @settings.fetch(:wallet) {
|
17
|
+
raise Peatio::Wallet::MissingSettingError, :wallet
|
18
|
+
}.slice(:uri, :address)
|
19
|
+
|
20
|
+
@currency = @settings.fetch(:currency) {
|
21
|
+
raise Peatio::Wallet::MissingSettingError, :currency
|
22
|
+
}.slice(:id, :base_factor, :options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_address!(_options={})
|
26
|
+
{address: client.json_rpc(:getnewaddress)}
|
27
|
+
rescue Dash::Client::Error => e
|
28
|
+
raise Peatio::Wallet::ClientError, e
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_transaction!(transaction, options={})
|
32
|
+
txid = client.json_rpc(:sendtoaddress,
|
33
|
+
[
|
34
|
+
transaction.to_address,
|
35
|
+
transaction.amount,
|
36
|
+
"",
|
37
|
+
"",
|
38
|
+
options[:subtract_fee].to_s == "true" # subtract fee from transaction amount.
|
39
|
+
])
|
40
|
+
transaction.hash = txid
|
41
|
+
transaction
|
42
|
+
rescue Dash::Client::Error => e
|
43
|
+
raise Peatio::Wallet::ClientError, e
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_balance!
|
47
|
+
client.json_rpc(:getbalance).to_d
|
48
|
+
rescue Dash::Client::Error => e
|
49
|
+
raise Peatio::Wallet::ClientError, e
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def client
|
55
|
+
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
56
|
+
@client ||= Client.new(uri)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/peatio-dash.gemspec
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "peatio/dash/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "peatio-dash-jruby"
|
9
|
+
spec.version = Peatio::Dash::VERSION
|
10
|
+
spec.authors = ["MoD"]
|
11
|
+
spec.email = ["mod@websys.io"]
|
12
|
+
|
13
|
+
spec.summary = "Peatio Blockchain Plugin"
|
14
|
+
spec.description = "Peatio Blockchain Plugin for Rubykube"
|
15
|
+
spec.homepage = "https://www.openware.com"
|
16
|
+
spec.license = "Proprietary"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/openware/peatio-contrib"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/openware/peatio-contrib/blob/master/CHANGELOG.md"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_dependency "activesupport", "~> 5.2.3"
|
40
|
+
spec.add_dependency "better-faraday", "~> 1.0.5"
|
41
|
+
spec.add_dependency "faraday", "~> 0.17"
|
42
|
+
spec.add_dependency "memoist", "~> 0.16.0"
|
43
|
+
spec.add_dependency "peatio-jruby", ">= 2.6.0"
|
44
|
+
spec.add_dependency 'net-http-persistent', '~> 3.0.1'
|
45
|
+
|
46
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
47
|
+
spec.add_development_dependency "irb"
|
48
|
+
spec.add_development_dependency "mocha", "~> 1.8"
|
49
|
+
# spec.add_development_dependency "pry-byebug"
|
50
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
51
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
52
|
+
spec.add_development_dependency "rubocop-github"
|
53
|
+
spec.add_development_dependency "simplecov"
|
54
|
+
spec.add_development_dependency "webmock", "~> 3.5"
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: peatio-dash-jruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MoD
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 5.2.3
|
19
|
+
name: activesupport
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.5
|
33
|
+
name: better-faraday
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.17'
|
47
|
+
name: faraday
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.17'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.16.0
|
61
|
+
name: memoist
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.16.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.6.0
|
75
|
+
name: peatio-jruby
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.6.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 3.0.1
|
89
|
+
name: net-http-persistent
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.17'
|
103
|
+
name: bundler
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.17'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
name: irb
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.8'
|
131
|
+
name: mocha
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.8'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '13.0'
|
145
|
+
name: rake
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '13.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '3.0'
|
159
|
+
name: rspec
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
name: rubocop-github
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
requirement: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
name: simplecov
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '3.5'
|
201
|
+
name: webmock
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '3.5'
|
209
|
+
description: Peatio Blockchain Plugin for Rubykube
|
210
|
+
email:
|
211
|
+
- mod@websys.io
|
212
|
+
executables: []
|
213
|
+
extensions: []
|
214
|
+
extra_rdoc_files: []
|
215
|
+
files:
|
216
|
+
- ".gitignore"
|
217
|
+
- ".rspec"
|
218
|
+
- ".travis.yml"
|
219
|
+
- Gemfile
|
220
|
+
- Gemfile.lock
|
221
|
+
- LICENSE.txt
|
222
|
+
- README.md
|
223
|
+
- Rakefile
|
224
|
+
- bin/console
|
225
|
+
- bin/setup
|
226
|
+
- lib/peatio/dash.rb
|
227
|
+
- lib/peatio/dash/blockchain.rb
|
228
|
+
- lib/peatio/dash/client.rb
|
229
|
+
- lib/peatio/dash/hooks.rb
|
230
|
+
- lib/peatio/dash/railtie.rb
|
231
|
+
- lib/peatio/dash/version.rb
|
232
|
+
- lib/peatio/dash/wallet.rb
|
233
|
+
- peatio-dash.gemspec
|
234
|
+
homepage: https://www.openware.com
|
235
|
+
licenses:
|
236
|
+
- Proprietary
|
237
|
+
metadata:
|
238
|
+
homepage_uri: https://www.openware.com
|
239
|
+
source_code_uri: https://github.com/openware/peatio-contrib
|
240
|
+
changelog_uri: https://github.com/openware/peatio-contrib/blob/master/CHANGELOG.md
|
241
|
+
post_install_message:
|
242
|
+
rdoc_options: []
|
243
|
+
require_paths:
|
244
|
+
- lib
|
245
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ">="
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
250
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
|
+
requirements:
|
252
|
+
- - ">="
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
version: '0'
|
255
|
+
requirements: []
|
256
|
+
rubygems_version: 3.0.6
|
257
|
+
signing_key:
|
258
|
+
specification_version: 4
|
259
|
+
summary: Peatio Blockchain Plugin
|
260
|
+
test_files: []
|