ouroboros-peatio-dash 3.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d06f0fb4c3cb4ac1731f144a44b9cbf555fe4edd81d063f768b9baa603e71e30
4
+ data.tar.gz: 04d4b2d3a0f2eb0c034f9ca59771b8f146e28b9ff8f4d4ce6dd687a0bacf5879
5
+ SHA512:
6
+ metadata.gz: 89b945fe87bad3eecdf60c0bb26d2285be8b8b357213c877b39a5229803740e363dbdf116d51a35769da8d123bc713dce0f8a814df81fee86745d1ff9443ce03
7
+ data.tar.gz: 5ca94c403f7b9b0ef4c8bd76f765125e95734b9620f6c20fc0a00bb3fa9b23b18ff513c2ed4e16d3931f8477ee730617ae9d4b1f121a6cdaaff8de761d011895
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.2
7
+ before_install: gem install bundler -v 1.17.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in peatio-dash.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,226 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ peatio-dash (3.1.0)
5
+ activesupport (~> 6.1.0)
6
+ better-faraday (~> 2.0.1)
7
+ faraday (~> 1.10)
8
+ memoist (~> 0.16.0)
9
+ net-http-persistent (~> 4.0.1)
10
+ peatio (>= 3.1.1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activemodel (6.1.7.2)
16
+ activesupport (= 6.1.7.2)
17
+ activesupport (6.1.7.2)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ tzinfo (~> 2.0)
22
+ zeitwerk (~> 2.3)
23
+ addressable (2.8.1)
24
+ public_suffix (>= 2.0.2, < 6.0)
25
+ amq-protocol (2.3.2)
26
+ amqp (1.8.0)
27
+ amq-protocol (>= 2.2.0)
28
+ eventmachine
29
+ ast (2.4.2)
30
+ better-faraday (2.0.1)
31
+ activesupport (>= 4.0, < 7.0)
32
+ faraday (>= 1.0, < 3.0)
33
+ bunny (2.20.3)
34
+ amq-protocol (~> 2.3, >= 2.3.1)
35
+ sorted_set (~> 1, >= 1.0.2)
36
+ byebug (11.1.3)
37
+ clamp (1.3.2)
38
+ coderay (1.1.3)
39
+ concurrent-ruby (1.2.2)
40
+ connection_pool (2.3.0)
41
+ cookiejar (0.3.3)
42
+ crack (0.4.5)
43
+ rexml
44
+ daemons (1.4.1)
45
+ diff-lcs (1.5.0)
46
+ docile (1.4.0)
47
+ em-http-request (1.1.7)
48
+ addressable (>= 2.3.4)
49
+ cookiejar (!= 0.3.1)
50
+ em-socksify (>= 0.3)
51
+ eventmachine (>= 1.0.3)
52
+ http_parser.rb (>= 0.6.0)
53
+ em-socksify (0.3.2)
54
+ eventmachine (>= 1.0.0.beta.4)
55
+ em-synchrony (1.0.6)
56
+ eventmachine (>= 1.0.0.beta.1)
57
+ em-websocket (0.5.3)
58
+ eventmachine (>= 0.12.9)
59
+ http_parser.rb (~> 0)
60
+ eventmachine (1.2.7)
61
+ faraday (1.10.3)
62
+ faraday-em_http (~> 1.0)
63
+ faraday-em_synchrony (~> 1.0)
64
+ faraday-excon (~> 1.1)
65
+ faraday-httpclient (~> 1.0)
66
+ faraday-multipart (~> 1.0)
67
+ faraday-net_http (~> 1.0)
68
+ faraday-net_http_persistent (~> 1.0)
69
+ faraday-patron (~> 1.0)
70
+ faraday-rack (~> 1.0)
71
+ faraday-retry (~> 1.0)
72
+ ruby2_keywords (>= 0.0.4)
73
+ faraday-em_http (1.0.0)
74
+ faraday-em_synchrony (1.0.0)
75
+ faraday-excon (1.1.0)
76
+ faraday-httpclient (1.0.1)
77
+ faraday-multipart (1.0.4)
78
+ multipart-post (~> 2)
79
+ faraday-net_http (1.0.1)
80
+ faraday-net_http_persistent (1.2.0)
81
+ faraday-patron (1.0.0)
82
+ faraday-rack (1.0.0)
83
+ faraday-retry (1.0.3)
84
+ faye (1.4.0)
85
+ cookiejar (>= 0.3.0)
86
+ em-http-request (>= 1.1.6)
87
+ eventmachine (>= 0.12.0)
88
+ faye-websocket (>= 0.11.0)
89
+ multi_json (>= 1.0.0)
90
+ rack (>= 1.0.0)
91
+ websocket-driver (>= 0.5.1)
92
+ faye-websocket (0.11.1)
93
+ eventmachine (>= 0.12.0)
94
+ websocket-driver (>= 0.5.1)
95
+ hashdiff (1.0.1)
96
+ http_parser.rb (0.8.0)
97
+ i18n (1.12.0)
98
+ concurrent-ruby (~> 1.0)
99
+ io-console (0.6.0)
100
+ irb (1.6.2)
101
+ reline (>= 0.3.0)
102
+ json (2.6.3)
103
+ jwt (2.7.0)
104
+ memoist (0.16.2)
105
+ method_source (1.0.0)
106
+ minitest (5.17.0)
107
+ mocha (1.16.1)
108
+ multi_json (1.15.0)
109
+ multipart-post (2.3.0)
110
+ mysql2 (0.5.5)
111
+ net-http-persistent (4.0.1)
112
+ connection_pool (~> 2.2)
113
+ parallel (1.22.1)
114
+ parser (3.2.1.0)
115
+ ast (~> 2.4.1)
116
+ peatio (3.1.1)
117
+ activemodel (> 5.2)
118
+ amqp
119
+ bunny
120
+ clamp
121
+ em-synchrony (~> 1.0)
122
+ em-websocket
123
+ eventmachine
124
+ faraday (~> 1.10)
125
+ faye (~> 1.2)
126
+ jwt
127
+ mysql2
128
+ prometheus-client
129
+ thin
130
+ prometheus-client (4.0.0)
131
+ pry (0.14.2)
132
+ coderay (~> 1.1)
133
+ method_source (~> 1.0)
134
+ pry-byebug (3.10.1)
135
+ byebug (~> 11.0)
136
+ pry (>= 0.13, < 0.15)
137
+ public_suffix (5.0.1)
138
+ rack (2.2.6.2)
139
+ rainbow (3.1.1)
140
+ rake (13.0.6)
141
+ rbtree (0.4.6)
142
+ regexp_parser (2.7.0)
143
+ reline (0.3.2)
144
+ io-console (~> 0.5)
145
+ rexml (3.2.5)
146
+ rspec (3.12.0)
147
+ rspec-core (~> 3.12.0)
148
+ rspec-expectations (~> 3.12.0)
149
+ rspec-mocks (~> 3.12.0)
150
+ rspec-core (3.12.1)
151
+ rspec-support (~> 3.12.0)
152
+ rspec-expectations (3.12.2)
153
+ diff-lcs (>= 1.2.0, < 2.0)
154
+ rspec-support (~> 3.12.0)
155
+ rspec-mocks (3.12.3)
156
+ diff-lcs (>= 1.2.0, < 2.0)
157
+ rspec-support (~> 3.12.0)
158
+ rspec-support (3.12.0)
159
+ rubocop (1.47.0)
160
+ json (~> 2.3)
161
+ parallel (~> 1.10)
162
+ parser (>= 3.2.0.0)
163
+ rainbow (>= 2.2.2, < 4.0)
164
+ regexp_parser (>= 1.8, < 3.0)
165
+ rexml (>= 3.2.5, < 4.0)
166
+ rubocop-ast (>= 1.26.0, < 2.0)
167
+ ruby-progressbar (~> 1.7)
168
+ unicode-display_width (>= 2.4.0, < 3.0)
169
+ rubocop-ast (1.27.0)
170
+ parser (>= 3.2.1.0)
171
+ rubocop-github (0.20.0)
172
+ rubocop (>= 1.37)
173
+ rubocop-performance (>= 1.15)
174
+ rubocop-rails (>= 2.17)
175
+ rubocop-performance (1.16.0)
176
+ rubocop (>= 1.7.0, < 2.0)
177
+ rubocop-ast (>= 0.4.0)
178
+ rubocop-rails (2.18.0)
179
+ activesupport (>= 4.2.0)
180
+ rack (>= 1.1)
181
+ rubocop (>= 1.33.0, < 2.0)
182
+ ruby-progressbar (1.12.0)
183
+ ruby2_keywords (0.0.5)
184
+ set (1.0.3)
185
+ simplecov (0.22.0)
186
+ docile (~> 1.1)
187
+ simplecov-html (~> 0.11)
188
+ simplecov_json_formatter (~> 0.1)
189
+ simplecov-html (0.12.3)
190
+ simplecov_json_formatter (0.1.4)
191
+ sorted_set (1.0.3)
192
+ rbtree
193
+ set (~> 1.0)
194
+ thin (1.8.1)
195
+ daemons (~> 1.0, >= 1.0.9)
196
+ eventmachine (~> 1.0, >= 1.0.4)
197
+ rack (>= 1, < 3)
198
+ tzinfo (2.0.6)
199
+ concurrent-ruby (~> 1.0)
200
+ unicode-display_width (2.4.2)
201
+ webmock (3.18.1)
202
+ addressable (>= 2.8.0)
203
+ crack (>= 0.3.2)
204
+ hashdiff (>= 0.4.0, < 2.0.0)
205
+ websocket-driver (0.7.5)
206
+ websocket-extensions (>= 0.1.0)
207
+ websocket-extensions (0.1.5)
208
+ zeitwerk (2.6.7)
209
+
210
+ PLATFORMS
211
+ arm64-darwin-21
212
+
213
+ DEPENDENCIES
214
+ bundler (~> 2.4.7)
215
+ irb
216
+ mocha (~> 1.8)
217
+ peatio-dash!
218
+ pry-byebug
219
+ rake (~> 13.0)
220
+ rspec (~> 3.0)
221
+ rubocop-github
222
+ simplecov
223
+ webmock (~> 3.5)
224
+
225
+ BUNDLED WITH
226
+ 2.4.7
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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,85 @@
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
+ private
55
+
56
+ def filter_vout(tx_hash)
57
+ tx_hash.fetch("vout").select do |entry|
58
+ entry.fetch("value").to_d.positive? && entry["scriptPubKey"].has_key?("addresses")
59
+ end
60
+ end
61
+
62
+ def build_transaction(tx_hash)
63
+ filter_vout(tx_hash).each_with_object([]) do |entry, formatted_txs|
64
+ no_currency_tx = {hash: tx_hash["txid"], txout: entry["n"],
65
+ to_address: entry["scriptPubKey"]["addresses"][0],
66
+ amount: entry.fetch("value").to_d,
67
+ status: "success"}
68
+
69
+ # Build transaction for each currency belonging to blockchain.
70
+ settings_fetch(:currencies).pluck(:id).each do |currency_id|
71
+ formatted_txs << no_currency_tx.merge(currency_id: currency_id)
72
+ end
73
+ end
74
+ end
75
+
76
+ def client
77
+ @client ||= Client.new(settings_fetch(:server))
78
+ end
79
+
80
+ def settings_fetch(key)
81
+ @settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,64 @@
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
+ ConnectionError = Class.new(Error)
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 Faraday::Error => e
42
+ raise ConnectionError, e
43
+ end
44
+
45
+ private
46
+
47
+ def post(method, params)
48
+ connection.post("/", {jsonrpc: "1.0", method: method, params: params}.to_json,
49
+ "Accept" => "application/json", "Content-Type" => "application/json")
50
+ end
51
+
52
+ def connection
53
+ @connection ||= Faraday.new(@json_rpc_endpoint) do |f|
54
+ f.adapter :net_http_persistent, pool_size: 5
55
+ end.tap do |connection|
56
+ unless @json_rpc_endpoint.user.blank?
57
+ connection.basic_auth(@json_rpc_endpoint.user,
58
+ @json_rpc_endpoint.password)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ 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,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peatio
4
+ module Dash
5
+ class Railtie < Rails::Railtie
6
+ config.before_initialize do
7
+ Hooks.check_compatibility
8
+ end
9
+
10
+ config.after_initialize do
11
+ Hooks.register
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peatio
4
+ module Dash
5
+ VERSION = "3.1.2".freeze
6
+ end
7
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peatio
4
+ module Dash
5
+ class Wallet < Peatio::Wallet::Abstract
6
+ DEFAULT_FEATURES = { skip_deposit_collection: false }.freeze
7
+
8
+ def initialize(custom_features = {})
9
+ @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
10
+ @settings = {}
11
+ end
12
+
13
+ def configure(settings={})
14
+ # Clean client state during configure.
15
+ @client = nil
16
+
17
+ @settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
18
+
19
+ @wallet = @settings.fetch(:wallet) {
20
+ raise Peatio::Wallet::MissingSettingError, :wallet
21
+ }.slice(:uri, :address)
22
+
23
+ @currency = @settings.fetch(:currency) {
24
+ raise Peatio::Wallet::MissingSettingError, :currency
25
+ }.slice(:id, :base_factor, :options)
26
+ end
27
+
28
+ def create_address!(_options={})
29
+ {address: client.json_rpc(:getnewaddress)}
30
+ rescue Dash::Client::Error => e
31
+ raise Peatio::Wallet::ClientError, e
32
+ end
33
+
34
+ def create_transaction!(transaction, options={})
35
+ txid = client.json_rpc(:sendtoaddress,
36
+ [
37
+ transaction.to_address,
38
+ transaction.amount,
39
+ "",
40
+ "",
41
+ options[:subtract_fee].to_s == "true" # subtract fee from transaction amount.
42
+ ])
43
+ transaction.hash = txid
44
+ transaction
45
+ rescue Dash::Client::Error => e
46
+ raise Peatio::Wallet::ClientError, e
47
+ end
48
+
49
+ def load_balance!
50
+ client.json_rpc(:getbalance).to_d
51
+ rescue Dash::Client::Error => e
52
+ raise Peatio::Wallet::ClientError, e
53
+ end
54
+
55
+ private
56
+
57
+ def client
58
+ uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
59
+ @client ||= Client.new(uri)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -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,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 = "ouroboros-peatio-dash"
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", "~> 6.1.0"
40
+ spec.add_dependency "better-faraday", "~> 2.0.1"
41
+ spec.add_dependency "faraday", "~> 1.10"
42
+ spec.add_dependency "memoist", "~> 0.16.0"
43
+ spec.add_dependency "peatio", ">= 3.1.1"
44
+ spec.add_dependency 'net-http-persistent', '~> 4.0.1'
45
+
46
+ spec.add_development_dependency "bundler", "~> 2.4.7"
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,274 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ouroboros-peatio-dash
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.2
5
+ platform: ruby
6
+ authors:
7
+ - MoD
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: better-faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: memoist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.16.0
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
+ name: peatio
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: net-http-persistent
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 4.0.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 4.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.7
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.7
111
+ - !ruby/object:Gem::Dependency
112
+ name: irb
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
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
+ name: mocha
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.8'
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
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rake
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '13.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '13.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-github
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
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
+ name: simplecov
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: webmock
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '3.5'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '3.5'
223
+ description: Peatio Blockchain Plugin for Rubykube
224
+ email:
225
+ - mod@websys.io
226
+ executables: []
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - ".gitignore"
231
+ - ".rspec"
232
+ - ".travis.yml"
233
+ - Gemfile
234
+ - Gemfile.lock
235
+ - LICENSE.txt
236
+ - README.md
237
+ - Rakefile
238
+ - bin/console
239
+ - bin/setup
240
+ - lib/peatio/dash.rb
241
+ - lib/peatio/dash/blockchain.rb
242
+ - lib/peatio/dash/client.rb
243
+ - lib/peatio/dash/hooks.rb
244
+ - lib/peatio/dash/railtie.rb
245
+ - lib/peatio/dash/version.rb
246
+ - lib/peatio/dash/wallet.rb
247
+ - ouroboros-peatio-dash.gemspec
248
+ homepage: https://www.openware.com
249
+ licenses:
250
+ - Proprietary
251
+ metadata:
252
+ homepage_uri: https://www.openware.com
253
+ source_code_uri: https://github.com/openware/peatio-contrib
254
+ changelog_uri: https://github.com/openware/peatio-contrib/blob/master/CHANGELOG.md
255
+ post_install_message:
256
+ rdoc_options: []
257
+ require_paths:
258
+ - lib
259
+ required_ruby_version: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
265
+ requirements:
266
+ - - ">="
267
+ - !ruby/object:Gem::Version
268
+ version: '0'
269
+ requirements: []
270
+ rubygems_version: 3.1.6
271
+ signing_key:
272
+ specification_version: 4
273
+ summary: Peatio Blockchain Plugin
274
+ test_files: []