peatio-ndc 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcdfa5787e2d9335d2c7ae05b6cfab3766e02c48ff573e8cf2370b6ac6df444b
4
- data.tar.gz: 2134ef963edadc80ece9ba10a36a0ebff4acf87469b86e0b6f2c9b48c159f7ba
3
+ metadata.gz: ca92d7872c52df3e6caab7a8dc0f10f970b753d4aab007f0676275d731c38603
4
+ data.tar.gz: 98dc57297a2285be0dce49550a9e0410393c34ceaf6f48aaa908144ac429b692
5
5
  SHA512:
6
- metadata.gz: 143306fe99d88f6ace1b5b2aadf0921e70378ed74950cddb8ba6472e5807245ef8285ed9d4a88b1892470f5eeffe444fb704fa6dd3ade071352698eb948ebc81
7
- data.tar.gz: 7a5626f155c8bce791e10775bc432c1d471d2e1a97a34c8c39ab55f0cabb39142bd39882ae8c10bd8ce2246c73dd9a31d59eeebd15f481b803b39b1704c11bc2
6
+ metadata.gz: 46cf47e863f7cc790f2d4dcd2c464daf02ff1f32bceee479fe1416086d0132284600618419f1c1b90a6126b33310c2b5083c1c542525435103ace2de836c2b3b
7
+ data.tar.gz: 38cab011b4fca422f717ea3d8d4a7839489dedefdf6ad111f8c085f9c5f7fd01b8af2e0ea51b001f5d6ef2ed07924a90e735a9cf025aaaf1929f43b36d80c1e8
@@ -1,8 +1,6 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
6
- - 2.5.3
7
5
  - 2.6.5
8
- before_install: gem install bundler -v 1.17.0
6
+ before_install: gem install bundler -v 2.1.2
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tanvirtex@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in peatio-umbru.gemspec
3
+ # Specify your gem's dependencies in peatio-ndc.gemspec
6
4
  gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio-ndc (0.2.1)
4
+ peatio-ndc (0.2.2)
5
5
  activesupport (~> 5.2.3)
6
6
  better-faraday (~> 1.0.5)
7
- faraday (~> 0.15.4)
7
+ faraday (~> 0.17)
8
8
  memoist (~> 0.16.0)
9
- peatio (= 0.6.3)
9
+ net-http-persistent (~> 3.0.1)
10
+ peatio (>= 0.6.3)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
@@ -24,6 +25,7 @@ GEM
24
25
  amqp (1.8.0)
25
26
  amq-protocol (>= 2.2.0)
26
27
  eventmachine
28
+ ast (2.4.0)
27
29
  better-faraday (1.0.8)
28
30
  activesupport (>= 4.0, < 6.0)
29
31
  faraday (~> 0.12)
@@ -33,35 +35,78 @@ GEM
33
35
  clamp (1.3.1)
34
36
  coderay (1.1.2)
35
37
  concurrent-ruby (1.1.6)
38
+ connection_pool (2.2.2)
39
+ cookiejar (0.3.3)
36
40
  crack (0.4.3)
37
41
  safe_yaml (~> 1.0.0)
42
+ daemons (1.3.1)
38
43
  diff-lcs (1.3)
44
+ docile (1.3.2)
45
+ em-http-request (1.1.5)
46
+ addressable (>= 2.3.4)
47
+ cookiejar (!= 0.3.1)
48
+ em-socksify (>= 0.3)
49
+ eventmachine (>= 1.0.3)
50
+ http_parser.rb (>= 0.6.0)
51
+ em-socksify (0.3.2)
52
+ eventmachine (>= 1.0.0.beta.4)
53
+ em-synchrony (1.0.6)
54
+ eventmachine (>= 1.0.0.beta.1)
39
55
  em-websocket (0.5.1)
40
56
  eventmachine (>= 0.12.9)
41
57
  http_parser.rb (~> 0.6.0)
42
58
  eventmachine (1.2.7)
43
- faraday (0.15.4)
59
+ faraday (0.17.3)
44
60
  multipart-post (>= 1.2, < 3)
61
+ faraday_middleware (0.13.1)
62
+ faraday (>= 0.7.4, < 1.0)
63
+ faye (1.2.5)
64
+ cookiejar (>= 0.3.0)
65
+ em-http-request (>= 0.3.0)
66
+ eventmachine (>= 0.12.0)
67
+ faye-websocket (>= 0.9.1)
68
+ multi_json (>= 1.0.0)
69
+ rack (>= 1.0.0)
70
+ websocket-driver (>= 0.5.1)
71
+ faye-websocket (0.10.9)
72
+ eventmachine (>= 0.12.0)
73
+ websocket-driver (>= 0.5.1)
45
74
  hashdiff (1.0.1)
46
75
  http_parser.rb (0.6.0)
47
76
  i18n (1.8.2)
48
77
  concurrent-ruby (~> 1.0)
78
+ io-console (0.5.6)
79
+ irb (1.2.4)
80
+ reline (>= 0.0.1)
81
+ jaro_winkler (1.5.4)
49
82
  jwt (2.2.1)
50
83
  memoist (0.16.2)
51
84
  method_source (1.0.0)
52
85
  minitest (5.14.1)
53
86
  mocha (1.11.2)
87
+ multi_json (1.14.1)
54
88
  multipart-post (2.1.1)
55
89
  mysql2 (0.5.3)
56
- peatio (0.6.3)
90
+ net-http-persistent (3.0.1)
91
+ connection_pool (~> 2.2)
92
+ parallel (1.19.1)
93
+ parser (2.7.1.3)
94
+ ast (~> 2.4.0)
95
+ peatio (2.4.4)
57
96
  activemodel (> 5.2, <= 6.0.0)
58
97
  amqp
59
98
  bunny
60
99
  clamp
100
+ em-synchrony (~> 1.0)
61
101
  em-websocket
62
102
  eventmachine
103
+ faraday_middleware (~> 0.13.1)
104
+ faye (~> 1.2)
63
105
  jwt
64
106
  mysql2
107
+ prometheus-client
108
+ thin
109
+ prometheus-client (2.0.0)
65
110
  pry (0.13.1)
66
111
  coderay (~> 1.1)
67
112
  method_source (~> 1.0)
@@ -69,7 +114,12 @@ GEM
69
114
  byebug (~> 11.0)
70
115
  pry (~> 0.13.0)
71
116
  public_suffix (4.0.5)
72
- rake (10.5.0)
117
+ rack (2.2.2)
118
+ rainbow (3.0.0)
119
+ rake (12.3.3)
120
+ reline (0.1.4)
121
+ io-console (~> 0.5)
122
+ rexml (3.2.4)
73
123
  rspec (3.9.0)
74
124
  rspec-core (~> 3.9.0)
75
125
  rspec-expectations (~> 3.9.0)
@@ -83,26 +133,60 @@ GEM
83
133
  diff-lcs (>= 1.2.0, < 2.0)
84
134
  rspec-support (~> 3.9.0)
85
135
  rspec-support (3.9.3)
136
+ rubocop (0.82.0)
137
+ jaro_winkler (~> 1.5.1)
138
+ parallel (~> 1.10)
139
+ parser (>= 2.7.0.1)
140
+ rainbow (>= 2.2.2, < 4.0)
141
+ rexml
142
+ ruby-progressbar (~> 1.7)
143
+ unicode-display_width (>= 1.4.0, < 2.0)
144
+ rubocop-github (0.16.0)
145
+ rubocop (<= 0.82.0)
146
+ rubocop-performance (~> 1.0)
147
+ rubocop-rails (~> 2.0)
148
+ rubocop-performance (1.6.0)
149
+ rubocop (>= 0.71.0)
150
+ rubocop-rails (2.5.2)
151
+ activesupport
152
+ rack (>= 1.1)
153
+ rubocop (>= 0.72.0)
154
+ ruby-progressbar (1.10.1)
86
155
  safe_yaml (1.0.5)
156
+ simplecov (0.18.5)
157
+ docile (~> 1.1)
158
+ simplecov-html (~> 0.11)
159
+ simplecov-html (0.12.2)
160
+ thin (1.7.2)
161
+ daemons (~> 1.0, >= 1.0.9)
162
+ eventmachine (~> 1.0, >= 1.0.4)
163
+ rack (>= 1, < 3)
87
164
  thread_safe (0.3.6)
88
165
  tzinfo (1.2.7)
89
166
  thread_safe (~> 0.1)
167
+ unicode-display_width (1.7.0)
90
168
  webmock (3.8.3)
91
169
  addressable (>= 2.3.6)
92
170
  crack (>= 0.3.2)
93
171
  hashdiff (>= 0.4.0, < 2.0.0)
172
+ websocket-driver (0.7.2)
173
+ websocket-extensions (>= 0.1.0)
174
+ websocket-extensions (0.1.4)
94
175
 
95
176
  PLATFORMS
96
177
  ruby
97
178
 
98
179
  DEPENDENCIES
99
- bundler (~> 2.1.2)
180
+ bundler (~> 1.17)
181
+ irb
100
182
  mocha (~> 1.8)
101
183
  peatio-ndc!
102
- pry-byebug (~> 3.7)
103
- rake (~> 10.0)
184
+ pry-byebug
185
+ rake (~> 12.0)
104
186
  rspec (~> 3.0)
187
+ rubocop-github
188
+ simplecov
105
189
  webmock (~> 3.5)
106
190
 
107
191
  BUNDLED WITH
108
- 2.1.2
192
+ 1.17.3
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Md Tanvir Rahaman, NEXBIT.IO
3
+ Copyright (c) 2020 Md Tanvir Rahaman
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Peatio::NDC
1
+ # Peatio::Ndc
2
2
 
3
- Peatio ndc plugin for Rubykube stack
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/ndc`. 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
4
6
 
5
7
  ## Installation
6
8
 
@@ -12,7 +14,7 @@ gem 'peatio-ndc'
12
14
 
13
15
  And then execute:
14
16
 
15
- $ bundle
17
+ $ bundle install
16
18
 
17
19
  Or install it yourself as:
18
20
 
@@ -20,48 +22,23 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- For Peatio NDC plugin integration you need to do the following steps:
24
-
25
- ### Image Build.
26
-
27
- 1. Add peatio-ndc gem into your Gemfile.plugin
28
- ```ruby
29
- gem 'peatio-ndc', '~> 0.1.3'
30
- ```
31
-
32
- 2. Run `bundle install` for updating Gemfile.lock
33
-
34
- 3. Build custom Peatio [docker image with NDC plugin](https://github.com/nexbitio/peatio/blob/master/docs/plugins.md#build)
35
-
36
- 4. Push your image using `docker push`
37
-
38
- 5. Update your deployment to use image with peatio-ndc gem
39
-
40
- ### Peatio Configuration.
41
-
42
- 1. Create NDC Blockchain [config example](../config/blockchains.yml).
43
- * No additional steps are needed
44
-
45
- 2. Create NDC Currency [config example](../config/currencies.yml).
46
- * No additional steps are needed
47
-
48
- 3. Create NDC Wallets [config example](../config/wallets.yml)(deposit and hot wallets are required).
49
- * No additional steps are needed
50
-
25
+ TODO: Write usage instructions here
51
26
 
52
27
  ## Development
53
28
 
54
- Plugin development [example](https://github.com/nexbitio/peatio/blob/master/docs/coins/development.md).
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).
55
32
 
56
33
  ## Contributing
57
34
 
58
- Bug reports and pull requests are welcome on GitHub at https://github.com/nexbitio/peatio-ndc.
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/peatio-ndc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/peatio-ndc/blob/master/CODE_OF_CONDUCT.md).
36
+
59
37
 
60
38
  ## License
61
39
 
62
40
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
63
41
 
64
- ## Consulting
42
+ ## Code of Conduct
65
43
 
66
- You can contact Openware for finding certified vendors:
67
- [NEXBIT.IO](https://www.nexbit.io)
44
+ Everyone interacting in the Peatio::Ndc project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/peatio-ndc/blob/master/CODE_OF_CONDUCT.md).
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/object/blank"
2
4
  require "active_support/core_ext/enumerable"
3
5
  require "peatio"
@@ -6,10 +8,13 @@ module Peatio
6
8
  module Ndc
7
9
  require "bigdecimal"
8
10
  require "bigdecimal/util"
11
+
9
12
  require "peatio/ndc/blockchain"
10
13
  require "peatio/ndc/client"
11
14
  require "peatio/ndc/wallet"
15
+
12
16
  require "peatio/ndc/hooks"
17
+
13
18
  require "peatio/ndc/version"
14
19
  end
15
20
  end
@@ -1,17 +1,17 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Peatio
3
4
  module Ndc
4
5
  # TODO: Processing of unconfirmed transactions from mempool isn't supported now.
5
6
  class Blockchain < Peatio::Blockchain::Abstract
6
-
7
7
  DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
8
8
 
9
- def initialize(custom_features = {})
9
+ def initialize(custom_features={})
10
10
  @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
11
11
  @settings = {}
12
12
  end
13
13
 
14
- def configure(settings = {})
14
+ def configure(settings={})
15
15
  # Clean client state during configure.
16
16
  @client = nil
17
17
  @settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
@@ -20,13 +20,15 @@ module Peatio
20
20
  def fetch_block!(block_number)
21
21
  block_hash = client.json_rpc(:getblockhash, [block_number])
22
22
 
23
- client.json_rpc(:getblock, [block_hash, 2])
24
- .fetch('tx').each_with_object([]) do |tx, txs_array|
23
+ block_txs = client.json_rpc(:getblock, [block_hash, 2])
24
+ .fetch("tx").each_with_object([]) do |tx, txs_array|
25
25
  txs = build_transaction(tx).map do |ntx|
26
26
  Peatio::Transaction.new(ntx.merge(block_number: block_number))
27
27
  end
28
28
  txs_array.append(*txs)
29
- end.yield_self { |txs_array| Peatio::Block.new(block_number, txs_array) }
29
+ end
30
+
31
+ Peatio::Block.new(block_number, block_txs)
30
32
  rescue Client::Error => e
31
33
  raise Peatio::Blockchain::ClientError, e
32
34
  end
@@ -39,12 +41,10 @@ module Peatio
39
41
 
40
42
  def load_balance_of_address!(address, _currency_id)
41
43
  address_with_balance = client.json_rpc(:listaddressgroupings)
42
- .flatten(1)
43
- .find { |addr| addr[0] == address }
44
+ .flatten(1)
45
+ .find {|addr| addr[0] == address }
44
46
 
45
- if address_with_balance.blank?
46
- raise Peatio::Blockchain::UnavailableAddressBalanceError, address
47
- end
47
+ raise Peatio::Blockchain::UnavailableAddressBalanceError, address if address_with_balance.blank?
48
48
 
49
49
  address_with_balance[1].to_d
50
50
  rescue Client::Error => e
@@ -53,18 +53,18 @@ module Peatio
53
53
 
54
54
  private
55
55
 
56
- def build_transaction(tx_hash)
57
- tx_hash.fetch('vout')
58
- .select do |entry|
59
- entry.fetch('value').to_d > 0 &&
60
- entry['scriptPubKey'].has_key?('addresses')
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")
61
59
  end
62
- .each_with_object([]) do |entry, formatted_txs|
63
- no_currency_tx =
64
- { hash: tx_hash['txid'], txout: entry['n'],
65
- to_address: entry['scriptPubKey']['addresses'][0],
66
- amount: entry.fetch('value').to_d,
67
- status: 'success' }
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
68
 
69
69
  # Build transaction for each currency belonging to blockchain.
70
70
  settings_fetch(:currencies).pluck(:id).each do |currency_id|
@@ -83,3 +83,4 @@ module Peatio
83
83
  end
84
84
  end
85
85
  end
86
+
@@ -1,12 +1,14 @@
1
- require 'memoist'
2
- require 'faraday'
3
- require 'better-faraday'
1
+ # frozen_string_literal: true
2
+
3
+ require "memoist"
4
+ require "faraday"
5
+ require "better-faraday"
4
6
 
5
7
  module Peatio
6
8
  module Ndc
7
9
  class Client
8
10
  Error = Class.new(StandardError)
9
- class ConnectionError < Error; end
11
+ ConnectionError = Class.new(Error)
10
12
 
11
13
  class ResponseError < Error
12
14
  def initialize(code, msg)
@@ -25,37 +27,39 @@ module Peatio
25
27
  @json_rpc_endpoint = URI.parse(endpoint)
26
28
  end
27
29
 
28
- def json_rpc(method, params = [])
29
- response = connection.post \
30
- '/',
31
- { jsonrpc: '1.0', method: method, params: params }.to_json,
32
- { 'Accept' => 'application/json',
33
- 'Content-Type' => 'application/json' }
30
+ def json_rpc(method, params=[])
31
+ response = post(method, params)
32
+
34
33
  response.assert_2xx!
35
34
  response = JSON.parse(response.body)
36
- response['error'].tap { |e| raise ResponseError.new(e['code'], e['message']) if e }
37
- response.fetch('result')
38
- rescue => e
39
- if e.is_a?(Error)
40
- raise e
41
- elsif e.is_a?(Faraday::Error)
42
- raise ConnectionError, e
43
- else
44
- raise Error, e
35
+
36
+ response["error"].tap do |e|
37
+ raise ResponseError.new(e["code"], e["message"]) if e
45
38
  end
39
+
40
+ response.fetch("result")
41
+ rescue Faraday::Error => e
42
+ raise ConnectionError, e
46
43
  end
47
44
 
48
45
  private
49
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
+
50
52
  def connection
51
- Faraday.new(@json_rpc_endpoint).tap do |connection|
53
+ @connection ||= Faraday.new(@json_rpc_endpoint) do |f|
54
+ f.adapter :net_http_persistent, pool_size: 5
55
+ end.tap do |connection|
52
56
  unless @json_rpc_endpoint.user.blank?
53
57
  connection.basic_auth(@json_rpc_endpoint.user,
54
58
  @json_rpc_endpoint.password)
55
59
  end
56
60
  end
57
61
  end
58
- memoize :connection
59
62
  end
60
63
  end
61
64
  end
65
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Peatio
2
4
  module Ndc
3
5
  module Hooks
@@ -12,7 +14,7 @@ module Peatio
12
14
  "Ndc blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
13
15
  "Ndc blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
14
16
  "Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
15
- ].join('\n').tap { |s| Kernel.abort s }
17
+ ].join('\n').tap {|s| Kernel.abort s }
16
18
  end
17
19
 
18
20
  unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
@@ -21,13 +23,13 @@ module Peatio
21
23
  "Ndc wallet version requiremnt was not suttisfied by Peatio::Wallet.",
22
24
  "Ndc wallet requires #{WALLET_VERSION_REQUIREMENT}.",
23
25
  "Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
24
- ].join('\n').tap { |s| Kernel.abort s }
26
+ ].join('\n').tap {|s| Kernel.abort s }
25
27
  end
26
28
  end
27
29
 
28
30
  def register
29
- Peatio::Blockchain.registry[:ndc] = Ndc::Blockchain.new
30
- Peatio::Wallet.registry[:ndcd] = Ndc::Wallet.new
31
+ Peatio::Blockchain.registry[:ndc] = Ndc::Blockchain
32
+ Peatio::Wallet.registry[:ndcd] = Ndc::Wallet
31
33
  end
32
34
  end
33
35
 
@@ -40,3 +42,4 @@ module Peatio
40
42
  end
41
43
  end
42
44
  end
45
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Peatio
2
4
  module Ndc
3
5
  class Railtie < Rails::Railtie
@@ -11,3 +13,4 @@ module Peatio
11
13
  end
12
14
  end
13
15
  end
16
+
@@ -1,5 +1,5 @@
1
1
  module Peatio
2
2
  module Ndc
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -1,40 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Peatio
2
4
  module Ndc
3
5
  class Wallet < Peatio::Wallet::Abstract
4
-
5
- def initialize(settings = {})
6
+ def initialize(settings={})
6
7
  @settings = settings
7
8
  end
8
9
 
9
- def configure(settings = {})
10
+ def configure(settings={})
10
11
  # Clean client state during configure.
11
12
  @client = nil
12
13
 
13
14
  @settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
14
15
 
15
- @wallet = @settings.fetch(:wallet) do
16
+ @wallet = @settings.fetch(:wallet) {
16
17
  raise Peatio::Wallet::MissingSettingError, :wallet
17
- end.slice(:uri, :address)
18
+ }.slice(:uri, :address)
18
19
 
19
- @currency = @settings.fetch(:currency) do
20
+ @currency = @settings.fetch(:currency) {
20
21
  raise Peatio::Wallet::MissingSettingError, :currency
21
- end.slice(:id, :base_factor, :options)
22
+ }.slice(:id, :base_factor, :options)
22
23
  end
23
24
 
24
- def create_address!(_options = {})
25
- { address: client.json_rpc(:getnewaddress) }
25
+ def create_address!(_options={})
26
+ {address: client.json_rpc(:getnewaddress)}
26
27
  rescue Ndc::Client::Error => e
27
28
  raise Peatio::Wallet::ClientError, e
28
29
  end
29
30
 
30
- def create_transaction!(transaction, options = {})
31
+ def create_transaction!(transaction, options={})
31
32
  txid = client.json_rpc(:sendtoaddress,
32
33
  [
33
34
  transaction.to_address,
34
35
  transaction.amount,
35
- '',
36
- '',
37
- options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
36
+ "",
37
+ "",
38
+ options[:subtract_fee].to_s == "true" # subtract fee from transaction amount.
38
39
  ])
39
40
  transaction.hash = txid
40
41
  transaction
@@ -44,7 +45,6 @@ module Peatio
44
45
 
45
46
  def load_balance!
46
47
  client.json_rpc(:getbalance).to_d
47
-
48
48
  rescue Ndc::Client::Error => e
49
49
  raise Peatio::Wallet::ClientError, e
50
50
  end
@@ -58,3 +58,4 @@ module Peatio
58
58
  end
59
59
  end
60
60
  end
61
+
@@ -1,18 +1,19 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "peatio/ndc/version"
1
+ require_relative 'lib/peatio/ndc/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
4
  spec.name = "peatio-ndc"
8
5
  spec.version = Peatio::Ndc::VERSION
9
- spec.authors = ["BitBD"]
10
- spec.email = ["me@bitbd.co"]
6
+ spec.authors = ["Md Tanvir Rahaman"]
7
+ spec.email = ["tanvirtex@gmail.com"]
11
8
 
12
- spec.summary = %q{Gem for extending Peatio plugable system with Ndc implementation.}
13
- spec.description = %q{Ndc Peatio gem which implements Peatio::Blockchain::Abstract & Peatio::Wallet::Abstract.}
14
- spec.homepage = "https://ndcwallet.pro/"
9
+ spec.summary = %q{Peatio Blockchain Gem for NDC Wallet.}
10
+ spec.description = %q{Peatio Blockchain Plugin for easy integration of NDC Wallet Blockchain platform.}
11
+ spec.homepage = "https://ndcwallet.pro."
15
12
  spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/ndcwallet/peatio-ndc"
16
+ spec.metadata["changelog_uri"] = "https://github.com/ndcwallet/peatio-ndc/blob/master/CHANGELOG.md"
16
17
 
17
18
  # Specify which files should be added to the gem when it is released.
18
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -25,15 +26,18 @@ Gem::Specification.new do |spec|
25
26
 
26
27
  spec.add_dependency "activesupport", "~> 5.2.3"
27
28
  spec.add_dependency "better-faraday", "~> 1.0.5"
28
- spec.add_dependency "faraday", "~> 0.15.4"
29
+ spec.add_dependency "faraday", "~> 0.17"
29
30
  spec.add_dependency "memoist", "~> 0.16.0"
30
- spec.add_dependency "peatio", "= 0.6.3"
31
-
31
+ spec.add_dependency "peatio", ">= 0.6.3"
32
+ spec.add_dependency 'net-http-persistent', '~> 3.0.1'
32
33
 
33
- spec.add_development_dependency "bundler", "~> 2.1.2"
34
+ spec.add_development_dependency "bundler", "~> 1.17"
35
+ spec.add_development_dependency "irb"
34
36
  spec.add_development_dependency "mocha", "~> 1.8"
35
- spec.add_development_dependency "pry-byebug", "~> 3.7"
36
- spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "pry-byebug"
38
+ spec.add_development_dependency "rake", "~> 13.0"
37
39
  spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "rubocop-github"
41
+ spec.add_development_dependency "simplecov"
38
42
  spec.add_development_dependency "webmock", "~> 3.5"
39
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peatio-ndc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
- - BitBD
7
+ - Md Tanvir Rahaman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.15.4
47
+ version: '0.17'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.15.4
54
+ version: '0.17'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: memoist
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,30 +70,58 @@ dependencies:
70
70
  name: peatio
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.6.3
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.6.3
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: 3.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: 3.0.1
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 2.1.2
103
+ version: '1.17'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 2.1.2
110
+ version: '1.17'
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'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: mocha
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -112,30 +140,30 @@ dependencies:
112
140
  name: pry-byebug
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
- - - "~>"
143
+ - - ">="
116
144
  - !ruby/object:Gem::Version
117
- version: '3.7'
145
+ version: '0'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
- - - "~>"
150
+ - - ">="
123
151
  - !ruby/object:Gem::Version
124
- version: '3.7'
152
+ version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: rake
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: '10.0'
159
+ version: '13.0'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: '10.0'
166
+ version: '13.0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: rspec
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +178,34 @@ dependencies:
150
178
  - - "~>"
151
179
  - !ruby/object:Gem::Version
152
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'
153
209
  - !ruby/object:Gem::Dependency
154
210
  name: webmock
155
211
  requirement: !ruby/object:Gem::Requirement
@@ -164,9 +220,10 @@ dependencies:
164
220
  - - "~>"
165
221
  - !ruby/object:Gem::Version
166
222
  version: '3.5'
167
- description: Ndc Peatio gem which implements Peatio::Blockchain::Abstract & Peatio::Wallet::Abstract.
223
+ description: Peatio Blockchain Plugin for easy integration of NDC Wallet Blockchain
224
+ platform.
168
225
  email:
169
- - me@bitbd.co
226
+ - tanvirtex@gmail.com
170
227
  executables: []
171
228
  extensions: []
172
229
  extra_rdoc_files: []
@@ -174,6 +231,8 @@ files:
174
231
  - ".gitignore"
175
232
  - ".rspec"
176
233
  - ".travis.yml"
234
+ - CHANGELOG.md
235
+ - CODE_OF_CONDUCT.md
177
236
  - Gemfile
178
237
  - Gemfile.lock
179
238
  - LICENSE.txt
@@ -181,11 +240,6 @@ files:
181
240
  - Rakefile
182
241
  - bin/console
183
242
  - bin/setup
184
- - config/blockchains.yml
185
- - config/currencies.yml
186
- - config/wallets.yml
187
- - docs/integration.md
188
- - docs/json-rpc.md
189
243
  - lib/peatio/ndc.rb
190
244
  - lib/peatio/ndc/blockchain.rb
191
245
  - lib/peatio/ndc/client.rb
@@ -193,15 +247,14 @@ files:
193
247
  - lib/peatio/ndc/railtie.rb
194
248
  - lib/peatio/ndc/version.rb
195
249
  - lib/peatio/ndc/wallet.rb
196
- - peatio-ndc-0.1.0.gem
197
- - peatio-ndc-0.1.1.gem
198
- - peatio-ndc-0.1.2.gem
199
- - peatio-ndc-0.1.3.gem
200
250
  - peatio-ndc.gemspec
201
- homepage: https://ndcwallet.pro/
251
+ homepage: https://ndcwallet.pro.
202
252
  licenses:
203
253
  - MIT
204
- metadata: {}
254
+ metadata:
255
+ homepage_uri: https://ndcwallet.pro.
256
+ source_code_uri: https://github.com/ndcwallet/peatio-ndc
257
+ changelog_uri: https://github.com/ndcwallet/peatio-ndc/blob/master/CHANGELOG.md
205
258
  post_install_message:
206
259
  rdoc_options: []
207
260
  require_paths:
@@ -210,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
263
  requirements:
211
264
  - - ">="
212
265
  - !ruby/object:Gem::Version
213
- version: '0'
266
+ version: 2.3.0
214
267
  required_rubygems_version: !ruby/object:Gem::Requirement
215
268
  requirements:
216
269
  - - ">="
@@ -220,5 +273,5 @@ requirements: []
220
273
  rubygems_version: 3.0.6
221
274
  signing_key:
222
275
  specification_version: 4
223
- summary: Gem for extending Peatio plugable system with Ndc implementation.
276
+ summary: Peatio Blockchain Gem for NDC Wallet.
224
277
  test_files: []
@@ -1,10 +0,0 @@
1
- - key: ndc-mainet
2
- name: NDC Mainet
3
- client: ndc # API client name.
4
- server: http://user:password@127.0.0.1:17798 # Public ndc node endpoint.
5
- height: 5000 # Initial block number from which sync will be started.
6
- min_confirmations: 6 # Minimal confirmations needed for withdraw and deposit confirmation.
7
- explorer:
8
- address: https://explorer.ndcwallet.pro/address/#{address}
9
- transaction: https://explorer.ndcwallet.pro/tx/#{txid}
10
- status: active
@@ -1,18 +0,0 @@
1
- - id: ndc
2
- name: NDC
3
- blockchain_key: ndc-mainet
4
- symbol: 'C'
5
- type: coin
6
- precision: 8
7
- base_factor: 100_000_000
8
- enabled: true
9
- # Deposits with less amount are skipped during blockchain synchronization.
10
- # We advise to set value 10 times bigger than the network fee to prevent losses.
11
- min_deposit_amount: 0.0004488
12
- min_collection_amount: 0.0004488
13
- withdraw_limit_24h: 0.5
14
- withdraw_limit_72h: 1.2
15
- deposit_fee: 0
16
- withdraw_fee: 0
17
- position: 5
18
- options: {}
@@ -1,44 +0,0 @@
1
- - name: NDC Deposit Wallet
2
- blockchain_key: ndc-mainet
3
- currency_id: ndc
4
- # Address where deposits will be collected to.
5
- address: 'NrR24vjA6AwoLw9w34hCpJKytUiAJnpSTP' # IMPORTANT: Always wrap this value in quotes!
6
- kind: deposit # Wallet kind (deposit, hot, warm, cold or fee).
7
- nsig: 1 # Number of signatures required for performing withdraw.
8
- max_balance: 0.0
9
- status: active
10
- gateway: ndcd # Gateway client name.
11
- settings:
12
- #
13
- # NDCd gateway client settings.
14
- uri: http://user:password@127.0.0.1:17798
15
-
16
- - name: NDC Hot Wallet
17
- blockchain_key: ndc-mainet
18
- currency_id: ndc
19
- # Address where deposits will be collected to.
20
- address: 'NrR24vjA6AwoLw9w34hCpJKytUiAJnpSTP' # IMPORTANT: Always wrap this value in quotes!
21
- kind: hot # Wallet kind (deposit, hot, warm, cold or fee).
22
- nsig: 1 # Number of signatures required for performing withdraw.
23
- max_balance: 5.0
24
- status: active
25
- gateway: ndcd # Gateway client name.
26
- settings:
27
- #
28
- # NDC gateway client settings.
29
- uri: http://user:password@127.0.0.1:17798
30
-
31
- - name: NDC Warm Wallet
32
- blockchain_key: ndc-mainet
33
- currency_id: ndc
34
- # Address where deposits will be collected to.
35
- address: 'NrR24vjA6AwoLw9w34hCpJKytUiAJnpSTP' # IMPORTANT: Always wrap this value in quotes!
36
- kind: warm # Wallet kind (deposit, hot, warm, cold or fee).
37
- nsig: 1 # Number of signatures required for performing withdraw.
38
- max_balance: 50.0
39
- status: active
40
- gateway: ndcd # Gateway client name.
41
- settings:
42
- #
43
- # NDCd gateway client settings.
44
- uri: http://user:password@127.0.0.1:17798
@@ -1,29 +0,0 @@
1
- # Integration.
2
-
3
- For Peatio NDC plugin integration you need to do the following steps:
4
-
5
- ## Image Build.
6
-
7
- 1. Add peatio-ndc gem into your Gemfile.plugin
8
- ```ruby
9
- gem 'peatio-ndc', '~> 0.1.3'
10
- ```
11
-
12
- 2. Run `bundle install` for updating Gemfile.lock
13
-
14
- 3. Build custom Peatio [docker image with NDC plugin](https://github.com/nexbitio/peatio/blob/master/docs/plugins.md#build)
15
-
16
- 4. Push your image using `docker push`
17
-
18
- 5. Update your deployment to use image with peatio-ndc gem
19
-
20
- ## Peatio Configuration.
21
-
22
- 1. Create NDC Blockchain [config example](../config/blockchains.yml).
23
- * No additional steps are needed
24
-
25
- 2. Create NDC Currency [config example](../config/currencies.yml).
26
- * No additional steps are needed
27
-
28
- 3. Create NDC Wallets [config example](../config/wallets.yml)(deposit and hot wallets are required).
29
- * No additional steps are needed
@@ -1,29 +0,0 @@
1
- # JSON RPC
2
-
3
- The next list of JSON RPC calls where used for plugin development.
4
- For response examples see spec/resources:
5
-
6
- * getbalance
7
-
8
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbalance", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
9
- * getblock
10
-
11
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["51c209db5f7eaad7aee6983579a463eb49f03b9970d8cd852dc687a7380d3abb", 2] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
12
- * getblockcount
13
-
14
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
15
- * getblockhash
16
-
17
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockhash", "params": [40500] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798 `
18
- * getnewaddress
19
-
20
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798 `
21
- * listaddressgroupings
22
-
23
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listaddressgroupings", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
24
- * sendtoaddress
25
-
26
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["NrR24vjA6AwoLw9w34hCpJKytUiAJnpSTP", 0.11] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
27
- * methodnotfound
28
-
29
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "methodnotfound", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:17798`
Binary file
Binary file
Binary file
Binary file