peatio-dao 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.drone.yml +30 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +148 -0
  6. data/.simplecov +17 -0
  7. data/.travis.yml +18 -0
  8. data/Gemfile +8 -0
  9. data/Gemfile.lock +190 -0
  10. data/README.md +47 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +14 -0
  13. data/bin/peatio +12 -0
  14. data/bin/setup +8 -0
  15. data/lib/peatio/adapter_registry.rb +25 -0
  16. data/lib/peatio/auth/error.rb +18 -0
  17. data/lib/peatio/auth/jwt_authenticator.rb +127 -0
  18. data/lib/peatio/block.rb +29 -0
  19. data/lib/peatio/blockchain/abstract.rb +161 -0
  20. data/lib/peatio/blockchain/error.rb +37 -0
  21. data/lib/peatio/blockchain/registry.rb +16 -0
  22. data/lib/peatio/command/base.rb +11 -0
  23. data/lib/peatio/command/db.rb +20 -0
  24. data/lib/peatio/command/inject.rb +13 -0
  25. data/lib/peatio/command/root.rb +14 -0
  26. data/lib/peatio/command/security.rb +29 -0
  27. data/lib/peatio/command/service.rb +40 -0
  28. data/lib/peatio/error.rb +18 -0
  29. data/lib/peatio/executor.rb +64 -0
  30. data/lib/peatio/injectors/peatio_events.rb +240 -0
  31. data/lib/peatio/logger.rb +39 -0
  32. data/lib/peatio/metrics/server.rb +15 -0
  33. data/lib/peatio/mq/client.rb +51 -0
  34. data/lib/peatio/ranger/connection.rb +117 -0
  35. data/lib/peatio/ranger/events.rb +11 -0
  36. data/lib/peatio/ranger/router.rb +234 -0
  37. data/lib/peatio/ranger/web_socket.rb +68 -0
  38. data/lib/peatio/security/key_generator.rb +26 -0
  39. data/lib/peatio/sql/client.rb +19 -0
  40. data/lib/peatio/sql/schema.rb +72 -0
  41. data/lib/peatio/transaction.rb +137 -0
  42. data/lib/peatio/upstream/base.rb +116 -0
  43. data/lib/peatio/upstream/registry.rb +14 -0
  44. data/lib/peatio/version.rb +3 -0
  45. data/lib/peatio/wallet/abstract.rb +189 -0
  46. data/lib/peatio/wallet/error.rb +37 -0
  47. data/lib/peatio/wallet/registry.rb +16 -0
  48. data/lib/peatio.rb +47 -0
  49. data/peatio-dao.gemspec +53 -0
  50. metadata +455 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d2cbd60fdee90aaa5b9edbb7d51a1fbfea752a7c5a25889228b22501394f811
4
+ data.tar.gz: 01e61280d6a4c2fc72c6fa2f02cb5c22089b370fe0bbf2b9b8fdba0ff7e0613b
5
+ SHA512:
6
+ metadata.gz: 3d296b6bec028cc17144feeb6d1e6340d8c3f4c84f295f772801cec469293b8fce5bcea3b7adfca15b6d00771f476d8f9c6aba861bb4a3d1783563423557fa2d
7
+ data.tar.gz: 1cec8a6789fc900ba560e786d258c26fec9701b16c3cdb491141186dd69ccb05af44337b5ac1787e9e7519ff4987a7cef5e365ba69b665c1a691c784f3fa7fdf
data/.drone.yml ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ kind: pipeline
3
+ name: default
4
+
5
+ steps:
6
+ - name: Run rspec for each library
7
+ image: ruby:2.6
8
+ commands:
9
+ - gem install bundler:2.4.7
10
+ - bundle install
11
+ - bundle exec rspec
12
+
13
+ - name: Release gems
14
+ image: ruby:2.6
15
+ environment:
16
+ GEM_CREDENTIALS:
17
+ from_secret: gem_credentials
18
+ commands:
19
+ - mkdir -p ~/.gem
20
+ - echo $GEM_CREDENTIALS | base64 -d > ~/.gem/credentials
21
+ - chmod 0600 ~/.gem/credentials
22
+ - gem build peatio-dao.gemspec
23
+ - gem push peatio-*.gem
24
+ when:
25
+ branch:
26
+ - master
27
+
28
+ trigger:
29
+ event:
30
+ - push
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /*.gem
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ # Ignore RubyMine files
15
+ .idea
16
+ /secrets
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,148 @@
1
+ # Commonly used screens these days easily fit more than 80 characters.
2
+ Metrics/LineLength:
3
+ Max: 120
4
+
5
+ # Too short methods lead to extraction of single-use methods, which can make
6
+ # the code easier to read (by naming things), but can also clutter the class
7
+ Metrics/MethodLength:
8
+ Max: 20
9
+
10
+ # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
11
+ Metrics/ClassLength:
12
+ Max: 1500
13
+
14
+ # No space makes the method definition shorter and differentiates
15
+ # from a regular assignment.
16
+ Layout/SpaceAroundEqualsInParameterDefault:
17
+ EnforcedStyle: no_space
18
+
19
+ # Single quotes being faster is hardly measurable and only affects parse time.
20
+ # Enforcing double quotes reduces the times where you need to change them
21
+ # when introducing an interpolation. Use single quotes only if their semantics
22
+ # are needed.
23
+ Style/StringLiterals:
24
+ EnforcedStyle: double_quotes
25
+
26
+ # We do not need to support Ruby 1.9, so this is good to use.
27
+ Style/SymbolArray:
28
+ Enabled: true
29
+
30
+ # Most readable form.
31
+ Layout/AlignHash:
32
+ EnforcedHashRocketStyle: table
33
+ EnforcedColonStyle: table
34
+
35
+ # Mixing the styles looks just silly.
36
+ Style/HashSyntax:
37
+ EnforcedStyle: ruby19_no_mixed_keys
38
+
39
+ # has_key? and has_value? are far more readable than key? and value?
40
+ Style/PreferredHashMethods:
41
+ Enabled: false
42
+
43
+ # String#% is by far the least verbose and only object oriented variant.
44
+ Style/FormatString:
45
+ EnforcedStyle: percent
46
+
47
+ Style/CollectionMethods:
48
+ Enabled: true
49
+ PreferredMethods:
50
+ # inject seems more common in the community.
51
+ reduce: "inject"
52
+
53
+
54
+ # Either allow this style or don't. Marking it as safe with parenthesis
55
+ # is silly. Let's try to live without them for now.
56
+ Style/ParenthesesAroundCondition:
57
+ AllowSafeAssignment: false
58
+ Lint/AssignmentInCondition:
59
+ AllowSafeAssignment: false
60
+
61
+ # A specialized exception class will take one or more arguments and construct the message from it.
62
+ # So both variants make sense.
63
+ Style/RaiseArgs:
64
+ Enabled: false
65
+
66
+ # Indenting the chained dots beneath each other is not supported by this cop,
67
+ # see https://github.com/bbatsov/rubocop/issues/1633
68
+ Layout/MultilineOperationIndentation:
69
+ Enabled: false
70
+
71
+ # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
72
+ # The argument that fail should be used to abort the program is wrong too,
73
+ # there's Kernel#abort for that.
74
+ Style/SignalException:
75
+ EnforcedStyle: only_raise
76
+
77
+ # Suppressing exceptions can be perfectly fine, and be it to avoid to
78
+ # explicitly type nil into the rescue since that's what you want to return,
79
+ # or suppressing LoadError for optional dependencies
80
+ Lint/HandleExceptions:
81
+ Enabled: false
82
+
83
+ Layout/SpaceInsideBlockBraces:
84
+ # The space here provides no real gain in readability while consuming
85
+ # horizontal space that could be used for a better parameter name.
86
+ # Also {| differentiates better from a hash than { | does.
87
+ SpaceBeforeBlockParameters: false
88
+
89
+ # No trailing space differentiates better from the block:
90
+ # foo} means hash, foo } means block.
91
+ Layout/SpaceInsideHashLiteralBraces:
92
+ EnforcedStyle: no_space
93
+
94
+ # { ... } for multi-line blocks is okay, follow Weirichs rule instead:
95
+ # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
96
+ Style/BlockDelimiters:
97
+ Enabled: false
98
+
99
+ # do / end blocks should be used for side effects,
100
+ # methods that run a block for side effects and have
101
+ # a useful return value are rare, assign the return
102
+ # value to a local variable for those cases.
103
+ Style/MethodCalledOnDoEndBlock:
104
+ Enabled: true
105
+
106
+ # Enforcing the names of variables? To single letter ones? Just no.
107
+ Style/SingleLineBlockParams:
108
+ Enabled: false
109
+
110
+ # Shadowing outer local variables with block parameters is often useful
111
+ # to not reinvent a new name for the same thing, it highlights the relation
112
+ # between the outer variable and the parameter. The cases where it's actually
113
+ # confusing are rare, and usually bad for other reasons already, for example
114
+ # because the method is too long.
115
+ Lint/ShadowingOuterLocalVariable:
116
+ Enabled: false
117
+
118
+ # Check with yard instead.
119
+ Style/Documentation:
120
+ Enabled: false
121
+
122
+ # This is just silly. Calling the argument `other` in all cases makes no sense.
123
+ Naming/BinaryOperatorParameterName:
124
+ Enabled: false
125
+
126
+ # There are valid cases, for example debugging Cucumber steps,
127
+ # also they'll fail CI anyway
128
+ Lint/Debugger:
129
+ Enabled: false
130
+
131
+ # Style preference
132
+ Style/MethodDefParentheses:
133
+ Enabled: false
134
+
135
+ Style/TrailingCommaInArrayLiteral:
136
+ Enabled: false
137
+
138
+ Style/TrailingCommaInHashLiteral:
139
+ Enabled: false
140
+
141
+ Style/ClassAndModuleChildren:
142
+ EnforcedStyle: compact
143
+
144
+ Layout/IndentHeredoc:
145
+ Enabled: false
146
+
147
+ Style/MethodCallWithoutArgsParentheses:
148
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+ require 'simplecov-json'
3
+
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ end
7
+
8
+ SimpleCov.formatters = [
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ SimpleCov::Formatter::JSONFormatter,
11
+ ]
12
+
13
+ # save to CircleCI's artifacts directory if we're on CircleCI
14
+ if ENV['CIRCLE_ARTIFACTS']
15
+ dir = File.join(ENV['CIRCLE_ARTIFACTS'], "coverage")
16
+ SimpleCov.coverage_dir(dir)
17
+ end
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.1
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.17.3
8
+ env:
9
+ - WEBSOCKET_HOST: localhost
10
+ WEBSOCKET_PORT: 8081
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: MTlSs+/1/+djQBx9UpZBoPdkLb9j9tx31CxoJ2uw3a429cj9qhJc+qZL9Gbim4kqdDhWAlfIFKDn2aeVPHIcd3VAP3dBUkG2gMxC440gx7rBJXSGpo+zwS9pnsFNQb9RnFZ4OI0dDr0VvYyctZh2h4VVTKhP2m7U59A6yNeNhW8K5HzUZ3+QvykiEQVQUrT29BRpf+9vEISVDPk3o0S0HO+RRvWXOBe5F2M/5hhJUdxUZ2/Pikg3PFJGhS1+g23YhLiEvMN6TiHz/PbUdLN1hnAVgmE86t/DU2lRzhDHNX3CetEhEhtElkTlbpIitmfy8309G0lUMZkN4Z6qKjuYKjuGYXYjXS6nEq6oy5U0HK2Ljo6ka4WZC5u08t5+I12jzCJ5Nq3kdqJkYZwMODgzvcyw4EKNHejyYLGGIbrXgbuYtR6wwvIYz7hz/j/fFxFDawBYC9s92/gvthtHNTzosBi/I07DYYhdF7Rt4TMfdPpasctV8ijTQ+ePH76cNPaDBqupemZUMSJRuuPOXS8SXS1xLDrPviffok/a3zmHDHgYWjqqBzktjCZ5C2PIeVo3o+ClSiWu8tJ3UquqdQ2ug60LK6ttbKxvDk/De3JcV4SEpqJBroSWD84hp0IiyQMEAhl/SxCVLXn9m5xF3evqH168p/Tgr5pklFUDw/tpSh8=
15
+ gem: peatio
16
+ on:
17
+ tags: true
18
+ repo: rubykube/peatio-core
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in peatio.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,190 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ peatio-dao (3.1.1)
5
+ activemodel (> 5.2)
6
+ amqp
7
+ bunny
8
+ clamp
9
+ em-synchrony (~> 1.0)
10
+ em-websocket
11
+ eventmachine
12
+ faraday (>= 1.10)
13
+ jwt
14
+ mysql2
15
+ prometheus-client
16
+ thin
17
+ websocket-client-simple (~> 0.9.0)
18
+
19
+ GEM
20
+ remote: https://rubygems.org/
21
+ specs:
22
+ activemodel (6.1.7.1)
23
+ activesupport (= 6.1.7.1)
24
+ activesupport (6.1.7.1)
25
+ concurrent-ruby (~> 1.0, >= 1.0.2)
26
+ i18n (>= 1.6, < 2)
27
+ minitest (>= 5.1)
28
+ tzinfo (~> 2.0)
29
+ zeitwerk (~> 2.3)
30
+ amq-protocol (2.3.2)
31
+ amqp (1.8.0)
32
+ amq-protocol (>= 2.2.0)
33
+ eventmachine
34
+ ast (2.4.2)
35
+ base64 (0.2.0)
36
+ bump (0.10.0)
37
+ bunny (2.20.3)
38
+ amq-protocol (~> 2.3, >= 2.3.1)
39
+ sorted_set (~> 1, >= 1.0.2)
40
+ bunny-mock (1.7.0)
41
+ bunny (>= 1.7)
42
+ byebug (11.1.3)
43
+ clamp (1.3.2)
44
+ coderay (1.1.3)
45
+ concurrent-ruby (1.2.0)
46
+ daemons (1.4.1)
47
+ diff-lcs (1.5.0)
48
+ docile (1.4.0)
49
+ em-spec (0.2.7)
50
+ eventmachine
51
+ em-synchrony (1.0.6)
52
+ eventmachine (>= 1.0.0.beta.1)
53
+ em-websocket (0.5.3)
54
+ eventmachine (>= 0.12.9)
55
+ http_parser.rb (~> 0)
56
+ em-websocket-client (0.1.2)
57
+ eventmachine
58
+ websocket
59
+ event_emitter (0.2.6)
60
+ eventmachine (1.2.7)
61
+ faraday (2.13.0)
62
+ faraday-net_http (>= 2.0, < 3.5)
63
+ json
64
+ logger
65
+ faraday-net_http (3.4.0)
66
+ net-http (>= 0.5.0)
67
+ http_parser.rb (0.8.0)
68
+ i18n (1.12.0)
69
+ concurrent-ruby (~> 1.0)
70
+ io-console (0.6.0)
71
+ irb (1.6.2)
72
+ reline (>= 0.3.0)
73
+ json (2.6.3)
74
+ jwt (2.10.1)
75
+ base64
76
+ logger (1.7.0)
77
+ method_source (1.0.0)
78
+ minitest (5.17.0)
79
+ mutex_m (0.3.0)
80
+ mysql2 (0.5.6)
81
+ net-http (0.6.0)
82
+ uri
83
+ parallel (1.22.1)
84
+ parser (3.2.1.0)
85
+ ast (~> 2.4.1)
86
+ prometheus-client (4.2.4)
87
+ base64
88
+ pry (0.14.2)
89
+ coderay (~> 1.1)
90
+ method_source (~> 1.0)
91
+ pry-byebug (3.10.1)
92
+ byebug (~> 11.0)
93
+ pry (>= 0.13, < 0.15)
94
+ rack (2.2.6.2)
95
+ rainbow (3.1.1)
96
+ rake (13.0.6)
97
+ rbtree (0.4.6)
98
+ regexp_parser (2.7.0)
99
+ reline (0.3.2)
100
+ io-console (~> 0.5)
101
+ rexml (3.2.5)
102
+ rspec (3.12.0)
103
+ rspec-core (~> 3.12.0)
104
+ rspec-expectations (~> 3.12.0)
105
+ rspec-mocks (~> 3.12.0)
106
+ rspec-core (3.12.1)
107
+ rspec-support (~> 3.12.0)
108
+ rspec-expectations (3.12.2)
109
+ diff-lcs (>= 1.2.0, < 2.0)
110
+ rspec-support (~> 3.12.0)
111
+ rspec-mocks (3.12.3)
112
+ diff-lcs (>= 1.2.0, < 2.0)
113
+ rspec-support (~> 3.12.0)
114
+ rspec-support (3.12.0)
115
+ rspec_junit_formatter (0.6.0)
116
+ rspec-core (>= 2, < 4, != 2.12.0)
117
+ rubocop (1.45.1)
118
+ json (~> 2.3)
119
+ parallel (~> 1.10)
120
+ parser (>= 3.2.0.0)
121
+ rainbow (>= 2.2.2, < 4.0)
122
+ regexp_parser (>= 1.8, < 3.0)
123
+ rexml (>= 3.2.5, < 4.0)
124
+ rubocop-ast (>= 1.24.1, < 2.0)
125
+ ruby-progressbar (~> 1.7)
126
+ unicode-display_width (>= 2.4.0, < 3.0)
127
+ rubocop-ast (1.26.0)
128
+ parser (>= 3.2.1.0)
129
+ rubocop-github (0.20.0)
130
+ rubocop (>= 1.37)
131
+ rubocop-performance (>= 1.15)
132
+ rubocop-rails (>= 2.17)
133
+ rubocop-performance (1.16.0)
134
+ rubocop (>= 1.7.0, < 2.0)
135
+ rubocop-ast (>= 0.4.0)
136
+ rubocop-rails (2.17.4)
137
+ activesupport (>= 4.2.0)
138
+ rack (>= 1.1)
139
+ rubocop (>= 1.33.0, < 2.0)
140
+ ruby-progressbar (1.11.0)
141
+ set (1.0.3)
142
+ simplecov (0.22.0)
143
+ docile (~> 1.1)
144
+ simplecov-html (~> 0.11)
145
+ simplecov_json_formatter (~> 0.1)
146
+ simplecov-html (0.12.3)
147
+ simplecov-json (0.2.3)
148
+ json
149
+ simplecov
150
+ simplecov_json_formatter (0.1.4)
151
+ sorted_set (1.0.3)
152
+ rbtree
153
+ set (~> 1.0)
154
+ thin (1.8.2)
155
+ daemons (~> 1.0, >= 1.0.9)
156
+ eventmachine (~> 1.0, >= 1.0.4)
157
+ rack (>= 1, < 3)
158
+ tzinfo (2.0.6)
159
+ concurrent-ruby (~> 1.0)
160
+ unicode-display_width (2.4.2)
161
+ uri (1.0.3)
162
+ websocket (1.2.9)
163
+ websocket-client-simple (0.9.0)
164
+ base64
165
+ event_emitter
166
+ mutex_m
167
+ websocket
168
+ zeitwerk (2.6.7)
169
+
170
+ PLATFORMS
171
+ ruby
172
+
173
+ DEPENDENCIES
174
+ bump
175
+ bundler (~> 2.4.7)
176
+ bunny-mock
177
+ em-spec
178
+ em-websocket-client
179
+ irb
180
+ peatio-dao!
181
+ pry-byebug
182
+ rake (~> 13.0)
183
+ rspec (~> 3.0)
184
+ rspec_junit_formatter
185
+ rubocop-github
186
+ simplecov
187
+ simplecov-json
188
+
189
+ BUNDLED WITH
190
+ 2.4.7
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ ![Cryptocurrency Exchange Platform - OpenDAX](https://github.com/openware/meta/raw/main/images/github_opendax.png)
2
+
3
+ <h3 align="center">
4
+ <a href="https://www.openware.com/sdk">Guide</a> <span>&vert;</span>
5
+ <a href="https://www.openware.com/sdk/api.html">API Docs</a> <span>&vert;</span>
6
+ <a href="https://www.openware.com/">Consulting</a> <span>&vert;</span>
7
+ <a href="https://t.me/peatio">Community</a>
8
+ </h3>
9
+ <h6 align="center">Peatio is part of <a href="https://github.com/openware/opendax">OpenDAX Trading Platform</a></h6>
10
+
11
+ ---
12
+
13
+ # Peatio
14
+
15
+ 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`. To experiment with that code, run `bin/console` for an interactive prompt.
16
+
17
+ TODO: Delete this and the text above, and describe your gem
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'peatio'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install peatio
34
+
35
+ ## Usage
36
+
37
+ TODO: Write usage instructions here
38
+
39
+ ## Development
40
+
41
+ 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.
42
+
43
+ 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).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/peatio.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "peatio"
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/peatio ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- RUBY -*-
3
+
4
+ PEATIO_CORE = ENV["PEATIO_CORE"] || File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+ $: << File.join(PEATIO_CORE, "lib")
6
+
7
+ require "clamp"
8
+
9
+ require "peatio"
10
+ require "peatio/command/root"
11
+
12
+ Peatio::Root.run
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ module Peatio
2
+ class AdapterRegistry
3
+ Error = Class.new(StandardError)
4
+ DuplicatedAdapterError = Class.new(Error)
5
+ NotRegisteredAdapterError = Class.new(Error)
6
+
7
+ def []=(name, instance)
8
+ name = name.to_sym
9
+ raise DuplicatedAdapterError, name if adapters.key?(name)
10
+ adapters[name] = instance
11
+ end
12
+
13
+ def [](name)
14
+ adapters.fetch(name.to_sym) { raise NotRegisteredAdapterError, name }
15
+ end
16
+
17
+ def adapters
18
+ @adapters ||= {}
19
+ end
20
+
21
+ def adapters=(h)
22
+ @adapters = h
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Peatio::Auth
2
+ # Error repesent all errors that can be returned from Auth module.
3
+ class Error < Peatio::Error
4
+ # @return [String, JWT::*] Reason store underlying reason for given error.
5
+ #
6
+ # @see https://github.com/jwt/ruby-jwt/blob/master/lib/jwt/error.rb List of JWT::* errors.
7
+ attr_reader :reason
8
+
9
+ def initialize(reason = nil)
10
+ @reason = reason
11
+
12
+ super(
13
+ code: 2001,
14
+ text: "Authorization failed".tap { |t| t << ": #{reason}" if reason },
15
+ )
16
+ end
17
+ end
18
+ end