peatio-ndc 0.1.0 → 2.0.1

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: 6ec659bbb61d542ea3bd80a5ab799b6e1e623f46f74982f7b9100251126790f6
4
- data.tar.gz: 37e6574e95a0b8b50bf8d728199652ec9150b0860dab2cff39ab61dfbcf4a3cf
3
+ metadata.gz: 5b115bfa1d2bfbbde4782507f437726d32ad2762a042ce6ea8cbf993cba73215
4
+ data.tar.gz: 929f8c09596e296b36a6f52cd8bb4acbb6be4310e74df8b4bccb022530299595
5
5
  SHA512:
6
- metadata.gz: d0db6b3dad66efb4ee7bcc00e82bfe0ca377e8b1fd15ff9d802c2192991b869b268c633e9250926c238dde2be68cee4e6156d7ae30ed40ae065ce9ea4cc728aa
7
- data.tar.gz: 5ee0d9c7f304222f3a43cb9b184ae2ddd9f3e063ad12e7fd26fc9986c5d55806aa4751a32ef23d6df1a8cb068ad912e2fb0e64dd0fa9a6d7ae8c10cdddb0ce5b
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.1.0
4
+ version: 2.0.1
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-04-04 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
@@ -80,20 +80,48 @@ dependencies:
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: '1.17'
103
+ version: 2.1.4
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: '1.17'
110
+ version: 2.1.4
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
@@ -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,44 +220,21 @@ 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
168
- to make NDC easy integration in peatio platform
223
+ description: Peatio Blockchain Plugin for easy integration of NDC Wallet Blockchain
224
+ platform.
169
225
  email:
170
- - developers@nexbit.io
226
+ - tanvirtex@gmail.com
171
227
  executables: []
172
228
  extensions: []
173
229
  extra_rdoc_files: []
174
- files:
175
- - ".gitignore"
176
- - ".rspec"
177
- - ".travis.yml"
178
- - Gemfile
179
- - Gemfile.lock
180
- - LICENSE.txt
181
- - README.md
182
- - Rakefile
183
- - bin/console
184
- - bin/setup
185
- - config/blockchains.yml
186
- - config/currencies.yml
187
- - config/wallets.yml
188
- - docs/integration.md
189
- - docs/json-rpc.md
190
- - lib/peatio/ndc.rb
191
- - lib/peatio/ndc/blockchain.rb
192
- - lib/peatio/ndc/client.rb
193
- - lib/peatio/ndc/hooks.rb
194
- - lib/peatio/ndc/railtie.rb
195
- - lib/peatio/ndc/version.rb
196
- - lib/peatio/ndc/wallet.rb
197
- - peatio-ndc.gemspec
198
- homepage: https://ndexnetwork.com/
230
+ files: []
231
+ homepage: https://ndcwallet.pro.
199
232
  licenses:
200
233
  - MIT
201
234
  metadata:
202
- homepage_uri: https://ndexnetwork.com/
203
- source_code_uri: https://github.com/ndexnetwork/peatio-ndc
204
- changelog_uri: https://github.com/ndexnetwork/peatio-ndc/blob/master/CHANGELOG.md
235
+ homepage_uri: https://ndcwallet.pro.
236
+ source_code_uri: https://github.com/ndcwallet/peatio-ndc
237
+ changelog_uri: https://github.com/ndcwallet/peatio-ndc/blob/master/CHANGELOG.md
205
238
  post_install_message:
206
239
  rdoc_options: []
207
240
  require_paths:
@@ -217,9 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
250
  - !ruby/object:Gem::Version
218
251
  version: '0'
219
252
  requirements: []
220
- rubyforge_project:
221
- rubygems_version: 2.7.6
253
+ rubygems_version: 3.1.3
222
254
  signing_key:
223
255
  specification_version: 4
224
- summary: Gem for extending Peatio plugable system with Ndc implementation.
256
+ summary: Peatio Blockchain Gem for NDC Wallet.
225
257
  test_files: []
data/.gitignore DELETED
@@ -1,12 +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
12
- *.gem
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1,8 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.3
7
- - 2.6.2
8
- before_install: gem install bundler -v 1.16.3
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in peatio-cpuchain.gemspec
6
- gemspec
@@ -1,110 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- peatio-nexbit (0.1.1)
5
- activesupport (~> 5.2.3)
6
- better-faraday (~> 1.0.5)
7
- faraday (~> 0.15.4)
8
- memoist (~> 0.16.0)
9
- peatio (~> 0.6.1)
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- activemodel (5.2.3)
15
- activesupport (= 5.2.3)
16
- activesupport (5.2.3)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- addressable (2.6.0)
22
- public_suffix (>= 2.0.2, < 4.0)
23
- amq-protocol (2.3.0)
24
- amqp (1.8.0)
25
- amq-protocol (>= 2.2.0)
26
- eventmachine
27
- better-faraday (1.0.5)
28
- activesupport (>= 4.0, < 6.0)
29
- faraday (~> 0.12)
30
- bunny (2.14.2)
31
- amq-protocol (~> 2.3, >= 2.3.0)
32
- byebug (11.0.1)
33
- clamp (1.3.0)
34
- coderay (1.1.2)
35
- concurrent-ruby (1.1.5)
36
- crack (0.4.3)
37
- safe_yaml (~> 1.0.0)
38
- diff-lcs (1.3)
39
- em-websocket (0.5.1)
40
- eventmachine (>= 0.12.9)
41
- http_parser.rb (~> 0.6.0)
42
- eventmachine (1.2.7)
43
- faraday (0.15.4)
44
- multipart-post (>= 1.2, < 3)
45
- hashdiff (0.3.9)
46
- http_parser.rb (0.6.0)
47
- i18n (1.6.0)
48
- concurrent-ruby (~> 1.0)
49
- jwt (2.2.1)
50
- memoist (0.16.0)
51
- metaclass (0.0.4)
52
- method_source (0.9.2)
53
- minitest (5.11.3)
54
- mocha (1.8.0)
55
- metaclass (~> 0.0.1)
56
- multipart-post (2.1.1)
57
- mysql2 (0.5.2)
58
- peatio (0.6.1)
59
- activemodel (~> 5.2.3)
60
- amqp
61
- bunny
62
- clamp
63
- em-websocket
64
- eventmachine
65
- jwt
66
- mysql2
67
- pry (0.12.2)
68
- coderay (~> 1.1.0)
69
- method_source (~> 0.9.0)
70
- pry-byebug (3.7.0)
71
- byebug (~> 11.0)
72
- pry (~> 0.10)
73
- public_suffix (3.0.3)
74
- rake (10.5.0)
75
- rspec (3.8.0)
76
- rspec-core (~> 3.8.0)
77
- rspec-expectations (~> 3.8.0)
78
- rspec-mocks (~> 3.8.0)
79
- rspec-core (3.8.0)
80
- rspec-support (~> 3.8.0)
81
- rspec-expectations (3.8.2)
82
- diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.8.0)
84
- rspec-mocks (3.8.0)
85
- diff-lcs (>= 1.2.0, < 2.0)
86
- rspec-support (~> 3.8.0)
87
- rspec-support (3.8.0)
88
- safe_yaml (1.0.5)
89
- thread_safe (0.3.6)
90
- tzinfo (1.2.5)
91
- thread_safe (~> 0.1)
92
- webmock (3.5.1)
93
- addressable (>= 2.3.6)
94
- crack (>= 0.3.2)
95
- hashdiff
96
-
97
- PLATFORMS
98
- ruby
99
-
100
- DEPENDENCIES
101
- bundler (~> 1.16)
102
- mocha (~> 1.8)
103
- peatio-nexbit!
104
- pry-byebug
105
- rake (~> 10.0)
106
- rspec (~> 3.0)
107
- webmock (~> 3.5)
108
-
109
- BUNDLED WITH
110
- 1.16.3
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Tanvir Rahaman aka BitBD
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,61 +0,0 @@
1
- # Peatio::NDC
2
-
3
- Peatio ndc plugin for nPro [peatio] stack
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'peatio-ndc'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install peatio-ndc
20
-
21
- ## Usage
22
-
23
- For Peatio CPUchain 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.0'
30
- ```
31
-
32
- 2. Run `bundle install` for updating Gemfile.lock
33
-
34
- 3. Build custom Peatio
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
-
51
-
52
-
53
-
54
- ## License
55
-
56
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
57
-
58
- ## Consulting
59
-
60
- You can contact Openware for finding certified vendors:
61
- [platform.ndc.io](https://platform.ndc.io)
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,10 +0,0 @@
1
- - key: ndc-mainnet
2
- name: Ndc Mainnet
3
- client: ndcd # API client name.
4
- server: http://user:password@127.0.0.1:13519 # Public Nexbit node endpoint.
5
- height: 1200 # 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-mainnet
4
- symbol: 'n'
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.0003
12
- min_collection_amount: 0.0003
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-mainnet
3
- currency_id: ndc
4
- # Address where deposits will be collected to.
5
- address: 'NyWkTPkNRdpTDSfPw7gxUt9cEaC5PSsP3Y' # 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:13519
15
-
16
- - name: NDC Hot Wallet
17
- blockchain_key: ndc-mainnet
18
- currency_id: ndc
19
- # Address where deposits will be collected to.
20
- address: 'NyWkTPkNRdpTDSfPw7gxUt9cEaC5PSsP3Y' # 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: 500000.0
24
- status: active
25
- gateway: ndcd # Gateway client name.
26
- settings:
27
- #
28
- # NDCd gateway client settings.
29
- uri: http://user:password@127.0.0.1:13519
30
-
31
- - name: NDC Warm Wallet
32
- blockchain_key: ndc-mainnet
33
- currency_id: ndc
34
- # Address where deposits will be collected to.
35
- address: 'NyWkTPkNRdpTDSfPw7gxUt9cEaC5PSsP3Y' # 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: 500000.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:13519
@@ -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-ndcd gem into your Gemfile.plugin
8
- ```ruby
9
- gem 'peatio-ndcd', '~> 0.1.0'
10
- ```
11
-
12
- 2. Run `bundle install` for updating Gemfile.lock
13
-
14
- 3. Build custom Peatio
15
-
16
- 4. Push your image using `docker push`
17
-
18
- 5. Update your deployment to use image with peatio-ndcd gem
19
-
20
- ## Peatio Configuration.
21
-
22
- 1. Create CPUchain Blockchain [config example](../config/blockchains.yml).
23
- * No additional steps are needed
24
-
25
- 2. Create CPUchain Currency [config example](../config/currencies.yml).
26
- * No additional steps are needed
27
-
28
- 3. Create CPUchain 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:13519`
9
- * getblock
10
-
11
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["5a471d4fd13d8bc3351e4d3a618fa55993326014b925346d8e9272e271e97c4e", 2] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:13519`
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:13519`
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:13519 `
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:13519 `
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:13519`
24
- * sendtoaddress
25
-
26
- `curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["NRnrwkUBQ2E4ZJ3bj8jvn4Nwx4nJ2U7wXF", 0.11] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:13519`
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:13519`
@@ -1,18 +0,0 @@
1
- require "active_support/core_ext/object/blank"
2
- require "active_support/core_ext/enumerable"
3
- require "peatio"
4
-
5
- module Peatio
6
- module Ndc
7
- require "bigdecimal"
8
- require "bigdecimal/util"
9
-
10
- require "peatio/ndc/blockchain"
11
- require "peatio/ndc/client"
12
- require "peatio/ndc/wallet"
13
-
14
- require "peatio/ndc/hooks"
15
-
16
- require "peatio/ndc/version"
17
- end
18
- end
@@ -1,82 +0,0 @@
1
- module Ndc
2
- # TODO: Processing of unconfirmed transactions from mempool isn't supported now.
3
- class Blockchain < Peatio::Blockchain::Abstract
4
-
5
- DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
6
-
7
- def initialize(custom_features = {})
8
- @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
9
- @settings = {}
10
- end
11
-
12
- def configure(settings = {})
13
- # Clean client state during configure.
14
- @client = nil
15
- @settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
16
- end
17
-
18
- def fetch_block!(block_number)
19
- block_hash = client.json_rpc(:getblockhash, [block_number])
20
-
21
- client.json_rpc(:getblock, [block_hash, 2])
22
- .fetch('tx').each_with_object([]) do |tx, txs_array|
23
- txs = build_transaction(tx).map do |ntx|
24
- Peatio::Transaction.new(ntx.merge(block_number: block_number))
25
- end
26
- txs_array.append(*txs)
27
- end.yield_self { |txs_array| Peatio::Block.new(block_number, txs_array) }
28
- rescue Ndc::Client::Error => e
29
- raise Peatio::Blockchain::ClientError, e
30
- end
31
-
32
- def latest_block_number
33
- client.json_rpc(:getblockcount)
34
- rescue Ndc::Client::Error => e
35
- raise Peatio::Blockchain::ClientError, e
36
- end
37
-
38
- def load_balance_of_address!(address, _currency_id)
39
- address_with_balance = client.json_rpc(:listaddressgroupings)
40
- .flatten(1)
41
- .find { |addr| addr[0] == address }
42
-
43
- if address_with_balance.blank?
44
- raise Peatio::Blockchain::UnavailableAddressBalanceError, address
45
- end
46
-
47
- address_with_balance[1].to_d
48
- rescue Ndc::Client::Error => e
49
- raise Peatio::Blockchain::ClientError, e
50
- end
51
-
52
- private
53
-
54
- def build_transaction(tx_hash)
55
- tx_hash.fetch('vout')
56
- .select do |entry|
57
- entry.fetch('value').to_d > 0 &&
58
- entry['scriptPubKey'].has_key?('addresses')
59
- end
60
- .each_with_object([]) do |entry, formatted_txs|
61
- no_currency_tx =
62
- { hash: tx_hash['txid'], txout: entry['n'],
63
- to_address: entry['scriptPubKey']['addresses'][0],
64
- amount: entry.fetch('value').to_d,
65
- status: 'success' }
66
-
67
- # Build transaction for each currency belonging to blockchain.
68
- settings_fetch(:currencies).pluck(:id).each do |currency_id|
69
- formatted_txs << no_currency_tx.merge(currency_id: currency_id)
70
- end
71
- end
72
- end
73
-
74
- def client
75
- @client ||= Ndc::Client.new(settings_fetch(:server))
76
- end
77
-
78
- def settings_fetch(key)
79
- @settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
80
- end
81
- end
82
- end
@@ -1,48 +0,0 @@
1
- module Ndc
2
- class Client
3
- Error = Class.new(StandardError)
4
-
5
- class ConnectionError < Error; end
6
-
7
- class ResponseError < Error
8
- def initialize(code, msg)
9
- super "#{msg} (#{code})"
10
- end
11
- end
12
-
13
- extend Memoist
14
-
15
- def initialize(endpoint, idle_timeout: 5)
16
- @json_rpc_endpoint = URI.parse(endpoint)
17
- @idle_timeout = idle_timeout
18
- end
19
-
20
- def json_rpc(method, params = [])
21
- response = connection.post \
22
- '/',
23
- {jsonrpc: '1.0', method: method, params: params}.to_json,
24
- {'Accept' => 'application/json',
25
- 'Content-Type' => 'application/json'}
26
- response.assert_success!
27
- response = JSON.parse(response.body)
28
- response['error'].tap { |error| raise ResponseError.new(error['code'], error['message']) if error }
29
- response.fetch('result')
30
- rescue Faraday::Error => e
31
- raise ConnectionError, e
32
- rescue StandardError => e
33
- raise Error, e
34
- end
35
-
36
- private
37
-
38
- def connection
39
- @connection ||= Faraday.new(@json_rpc_endpoint) do |f|
40
- f.adapter :net_http_persistent, pool_size: 5, idle_timeout: @idle_timeout
41
- end.tap do |connection|
42
- unless @json_rpc_endpoint.user.blank?
43
- connection.basic_auth(@json_rpc_endpoint.user, @json_rpc_endpoint.password)
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,42 +0,0 @@
1
- module Peatio
2
- module Ndc
3
- module Hooks
4
- BLOCKCHAIN_VERSION_REQUIREMENT = "~> 1.0.0"
5
- WALLET_VERSION_REQUIREMENT = "~> 1.0.0"
6
-
7
- class << self
8
- def check_compatibility
9
- unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
10
- .satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
11
- [
12
- "Ndc blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
13
- "Ndc blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
14
- "Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
15
- ].join('\n').tap { |s| Kernel.abort s }
16
- end
17
-
18
- unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
19
- .satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
20
- [
21
- "Ndc wallet version requiremnt was not suttisfied by Peatio::Wallet.",
22
- "Ndc wallet requires #{WALLET_VERSION_REQUIREMENT}.",
23
- "Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
24
- ].join('\n').tap { |s| Kernel.abort s }
25
- end
26
- end
27
-
28
- def register
29
- Peatio::Blockchain.registry[:Ndc] = Ndc::Blockchain.new
30
- Peatio::Wallet.registry[:ndcd] = Ndc::Wallet.new
31
- end
32
- end
33
-
34
- if defined?(Rails::Railtie)
35
- require "peatio/ndc/railtie"
36
- else
37
- check_compatibility
38
- register
39
- end
40
- end
41
- end
42
- end
@@ -1,13 +0,0 @@
1
- module Peatio
2
- module Ndc
3
- class Railtie < Rails::Railtie
4
- config.before_initialize do
5
- Hooks.check_compatibility
6
- end
7
-
8
- config.after_initialize do
9
- Hooks.register
10
- end
11
- end
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- module Peatio
2
- module Ndc
3
- VERSION = "0.1.0".freeze
4
- end
5
- end
@@ -1,58 +0,0 @@
1
- module Ndc
2
- class Wallet < Peatio::Wallet::Abstract
3
-
4
- def initialize(settings = {})
5
- @settings = settings
6
- end
7
-
8
- def configure(settings = {})
9
- # Clean client state during configure.
10
- @client = nil
11
-
12
- @settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
13
-
14
- @wallet = @settings.fetch(:wallet) do
15
- raise Peatio::Wallet::MissingSettingError, :wallet
16
- end.slice(:uri, :address)
17
-
18
- @currency = @settings.fetch(:currency) do
19
- raise Peatio::Wallet::MissingSettingError, :currency
20
- end.slice(:id, :base_factor, :options)
21
- end
22
-
23
- def create_address!(_options = {})
24
- { address: client.json_rpc(:getnewaddress) }
25
- rescue Ndc::Client::Error => e
26
- raise Peatio::Wallet::ClientError, e
27
- end
28
-
29
- def create_transaction!(transaction, options = {})
30
- txid = client.json_rpc(:sendtoaddress,
31
- [
32
- transaction.to_address,
33
- transaction.amount,
34
- '',
35
- '',
36
- options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
37
- ])
38
- transaction.hash = txid
39
- transaction
40
- rescue Ndc::Client::Error => e
41
- raise Peatio::Wallet::ClientError, e
42
- end
43
-
44
- def load_balance!
45
- client.json_rpc(:getbalance).to_d
46
-
47
- rescue Ndc::Client::Error => e
48
- raise Peatio::Wallet::ClientError, e
49
- end
50
-
51
- private
52
-
53
- def client
54
- uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
55
- @client ||= Client.new(uri, idle_timeout: 1)
56
- end
57
- end
58
- end
@@ -1,49 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "peatio/ndc/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "peatio-ndc"
8
- spec.version = Peatio::Ndc::VERSION
9
- spec.authors = ["BitBD"]
10
- spec.email = ["developers@nexbit.io"]
11
-
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 to make NDC easy integration in peatio platform}
14
- spec.homepage = "https://ndexnetwork.com/"
15
- spec.license = "MIT"
16
-
17
- # Specify which files should be added to the gem when it is released.
18
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
- if spec.respond_to?(:metadata)
20
-
21
- spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = "https://github.com/ndexnetwork/peatio-ndc"
23
- spec.metadata["changelog_uri"] = "https://github.com/ndexnetwork/peatio-ndc/blob/master/CHANGELOG.md"
24
- else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
27
- end
28
- # Specify which files should be added to the gem when it is released.
29
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
- end
33
- spec.bindir = "exe"
34
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
- spec.require_paths = ["lib"]
36
-
37
- spec.add_dependency "activesupport", "~> 5.2.3"
38
- spec.add_dependency "better-faraday", "~> 1.0.5"
39
- spec.add_dependency "faraday", "~> 0.15.4"
40
- spec.add_dependency "memoist", "~> 0.16.0"
41
- spec.add_dependency "peatio", "~> 0.6.3"
42
-
43
- spec.add_development_dependency "bundler", "~> 1.17"
44
- spec.add_development_dependency "mocha", "~> 1.8"
45
- spec.add_development_dependency "pry-byebug"
46
- spec.add_development_dependency "rake", "~> 10.0"
47
- spec.add_development_dependency "rspec", "~> 3.0"
48
- spec.add_development_dependency "webmock", "~> 3.5"
49
- end