peatio-ndc 0.2.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca92d7872c52df3e6caab7a8dc0f10f970b753d4aab007f0676275d731c38603
4
- data.tar.gz: 98dc57297a2285be0dce49550a9e0410393c34ceaf6f48aaa908144ac429b692
3
+ metadata.gz: 5b115bfa1d2bfbbde4782507f437726d32ad2762a042ce6ea8cbf993cba73215
4
+ data.tar.gz: 929f8c09596e296b36a6f52cd8bb4acbb6be4310e74df8b4bccb022530299595
5
5
  SHA512:
6
- metadata.gz: 46cf47e863f7cc790f2d4dcd2c464daf02ff1f32bceee479fe1416086d0132284600618419f1c1b90a6126b33310c2b5083c1c542525435103ace2de836c2b3b
7
- data.tar.gz: 38cab011b4fca422f717ea3d8d4a7839489dedefdf6ad111f8c085f9c5f7fd01b8af2e0ea51b001f5d6ef2ed07924a90e735a9cf025aaaf1929f43b36d80c1e8
6
+ metadata.gz: 790a1b5044d23a7f75d2a721c4890d5f4b8050e672749a323c02c873d395abe886f157801bab6d424bd2e8fab267b84d270eafa5575f938e7745e4cd714a0682
7
+ data.tar.gz: 025a4e8cabb23b18d50f0fc30a4e52e0323789b74c93bad7896e8b127ad1d7dfb437c1231d2b8323f831f5156f4df513da925a61009fa79c9e3e3e8238d56785
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.2
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Md Tanvir Rahaman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-06-11 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.17'
47
+ version: 0.15.4
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.17'
54
+ version: 0.15.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: memoist
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +70,14 @@ 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
83
  - !ruby/object:Gem::Dependency
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.17'
103
+ version: 2.1.4
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.17'
110
+ version: 2.1.4
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: irb
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '13.0'
159
+ version: '10.0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '13.0'
166
+ version: '10.0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -227,27 +227,7 @@ email:
227
227
  executables: []
228
228
  extensions: []
229
229
  extra_rdoc_files: []
230
- files:
231
- - ".gitignore"
232
- - ".rspec"
233
- - ".travis.yml"
234
- - CHANGELOG.md
235
- - CODE_OF_CONDUCT.md
236
- - Gemfile
237
- - Gemfile.lock
238
- - LICENSE.txt
239
- - README.md
240
- - Rakefile
241
- - bin/console
242
- - bin/setup
243
- - lib/peatio/ndc.rb
244
- - lib/peatio/ndc/blockchain.rb
245
- - lib/peatio/ndc/client.rb
246
- - lib/peatio/ndc/hooks.rb
247
- - lib/peatio/ndc/railtie.rb
248
- - lib/peatio/ndc/version.rb
249
- - lib/peatio/ndc/wallet.rb
250
- - peatio-ndc.gemspec
230
+ files: []
251
231
  homepage: https://ndcwallet.pro.
252
232
  licenses:
253
233
  - MIT
@@ -263,14 +243,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
243
  requirements:
264
244
  - - ">="
265
245
  - !ruby/object:Gem::Version
266
- version: 2.3.0
246
+ version: '0'
267
247
  required_rubygems_version: !ruby/object:Gem::Requirement
268
248
  requirements:
269
249
  - - ">="
270
250
  - !ruby/object:Gem::Version
271
251
  version: '0'
272
252
  requirements: []
273
- rubygems_version: 3.0.6
253
+ rubygems_version: 3.1.3
274
254
  signing_key:
275
255
  specification_version: 4
276
256
  summary: Peatio Blockchain Gem for NDC Wallet.
data/.gitignore DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.5
6
- before_install: gem install bundler -v 2.1.2
File without changes
@@ -1,74 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in peatio-ndc.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -1,192 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- peatio-ndc (0.2.2)
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 (>= 0.6.3)
11
-
12
- GEM
13
- remote: https://rubygems.org/
14
- specs:
15
- activemodel (5.2.4.3)
16
- activesupport (= 5.2.4.3)
17
- activesupport (5.2.4.3)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (>= 0.7, < 2)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- addressable (2.7.0)
23
- public_suffix (>= 2.0.2, < 5.0)
24
- amq-protocol (2.3.1)
25
- amqp (1.8.0)
26
- amq-protocol (>= 2.2.0)
27
- eventmachine
28
- ast (2.4.0)
29
- better-faraday (1.0.8)
30
- activesupport (>= 4.0, < 6.0)
31
- faraday (~> 0.12)
32
- bunny (2.15.0)
33
- amq-protocol (~> 2.3, >= 2.3.1)
34
- byebug (11.1.3)
35
- clamp (1.3.1)
36
- coderay (1.1.2)
37
- concurrent-ruby (1.1.6)
38
- connection_pool (2.2.2)
39
- cookiejar (0.3.3)
40
- crack (0.4.3)
41
- safe_yaml (~> 1.0.0)
42
- daemons (1.3.1)
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)
55
- em-websocket (0.5.1)
56
- eventmachine (>= 0.12.9)
57
- http_parser.rb (~> 0.6.0)
58
- eventmachine (1.2.7)
59
- faraday (0.17.3)
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)
74
- hashdiff (1.0.1)
75
- http_parser.rb (0.6.0)
76
- i18n (1.8.2)
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)
82
- jwt (2.2.1)
83
- memoist (0.16.2)
84
- method_source (1.0.0)
85
- minitest (5.14.1)
86
- mocha (1.11.2)
87
- multi_json (1.14.1)
88
- multipart-post (2.1.1)
89
- mysql2 (0.5.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)
96
- activemodel (> 5.2, <= 6.0.0)
97
- amqp
98
- bunny
99
- clamp
100
- em-synchrony (~> 1.0)
101
- em-websocket
102
- eventmachine
103
- faraday_middleware (~> 0.13.1)
104
- faye (~> 1.2)
105
- jwt
106
- mysql2
107
- prometheus-client
108
- thin
109
- prometheus-client (2.0.0)
110
- pry (0.13.1)
111
- coderay (~> 1.1)
112
- method_source (~> 1.0)
113
- pry-byebug (3.9.0)
114
- byebug (~> 11.0)
115
- pry (~> 0.13.0)
116
- public_suffix (4.0.5)
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)
123
- rspec (3.9.0)
124
- rspec-core (~> 3.9.0)
125
- rspec-expectations (~> 3.9.0)
126
- rspec-mocks (~> 3.9.0)
127
- rspec-core (3.9.2)
128
- rspec-support (~> 3.9.3)
129
- rspec-expectations (3.9.2)
130
- diff-lcs (>= 1.2.0, < 2.0)
131
- rspec-support (~> 3.9.0)
132
- rspec-mocks (3.9.1)
133
- diff-lcs (>= 1.2.0, < 2.0)
134
- rspec-support (~> 3.9.0)
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)
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)
164
- thread_safe (0.3.6)
165
- tzinfo (1.2.7)
166
- thread_safe (~> 0.1)
167
- unicode-display_width (1.7.0)
168
- webmock (3.8.3)
169
- addressable (>= 2.3.6)
170
- crack (>= 0.3.2)
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)
175
-
176
- PLATFORMS
177
- ruby
178
-
179
- DEPENDENCIES
180
- bundler (~> 1.17)
181
- irb
182
- mocha (~> 1.8)
183
- peatio-ndc!
184
- pry-byebug
185
- rake (~> 12.0)
186
- rspec (~> 3.0)
187
- rubocop-github
188
- simplecov
189
- webmock (~> 3.5)
190
-
191
- BUNDLED WITH
192
- 1.17.3
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 Md Tanvir Rahaman
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,44 +0,0 @@
1
- # Peatio::Ndc
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/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
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'peatio-ndc'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install peatio-ndc
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-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
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
-
42
- ## Code of Conduct
43
-
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).
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "peatio/ndc"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,20 +0,0 @@
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 Ndc
9
- require "bigdecimal"
10
- require "bigdecimal/util"
11
-
12
- require "peatio/ndc/blockchain"
13
- require "peatio/ndc/client"
14
- require "peatio/ndc/wallet"
15
-
16
- require "peatio/ndc/hooks"
17
-
18
- require "peatio/ndc/version"
19
- end
20
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Peatio
4
- module Ndc
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
86
-
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "memoist"
4
- require "faraday"
5
- require "better-faraday"
6
-
7
- module Peatio
8
- module Ndc
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
65
-
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Peatio
4
- module Ndc
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
- "Ndc blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
15
- "Ndc 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
- "Ndc wallet version requiremnt was not suttisfied by Peatio::Wallet.",
24
- "Ndc 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[:ndc] = Ndc::Blockchain
32
- Peatio::Wallet.registry[:ndcd] = Ndc::Wallet
33
- end
34
- end
35
-
36
- if defined?(Rails::Railtie)
37
- require "peatio/ndc/railtie"
38
- else
39
- check_compatibility
40
- register
41
- end
42
- end
43
- end
44
- end
45
-
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Peatio
4
- module Ndc
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
16
-
@@ -1,5 +0,0 @@
1
- module Peatio
2
- module Ndc
3
- VERSION = "0.2.2"
4
- end
5
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Peatio
4
- module Ndc
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 Ndc::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 Ndc::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 Ndc::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
61
-
@@ -1,43 +0,0 @@
1
- require_relative 'lib/peatio/ndc/version'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "peatio-ndc"
5
- spec.version = Peatio::Ndc::VERSION
6
- spec.authors = ["Md Tanvir Rahaman"]
7
- spec.email = ["tanvirtex@gmail.com"]
8
-
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."
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"
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
- end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
26
-
27
- spec.add_dependency "activesupport", "~> 5.2.3"
28
- spec.add_dependency "better-faraday", "~> 1.0.5"
29
- spec.add_dependency "faraday", "~> 0.17"
30
- spec.add_dependency "memoist", "~> 0.16.0"
31
- spec.add_dependency "peatio", ">= 0.6.3"
32
- spec.add_dependency 'net-http-persistent', '~> 3.0.1'
33
-
34
- spec.add_development_dependency "bundler", "~> 1.17"
35
- spec.add_development_dependency "irb"
36
- spec.add_development_dependency "mocha", "~> 1.8"
37
- spec.add_development_dependency "pry-byebug"
38
- spec.add_development_dependency "rake", "~> 13.0"
39
- spec.add_development_dependency "rspec", "~> 3.0"
40
- spec.add_development_dependency "rubocop-github"
41
- spec.add_development_dependency "simplecov"
42
- spec.add_development_dependency "webmock", "~> 3.5"
43
- end