taunchpad 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +28 -0
  3. data/Rakefile +32 -0
  4. data/app/controllers/concerns/exception_handlers.rb +19 -0
  5. data/app/controllers/concerns/jwt_payload.rb +19 -0
  6. data/app/controllers/concerns/response.rb +25 -0
  7. data/app/controllers/launchpad/api/v2/admin/base_controller.rb +22 -0
  8. data/app/controllers/launchpad/api/v2/admin/ieo/orders_controller.rb +29 -0
  9. data/app/controllers/launchpad/api/v2/admin/ieo/sales_controller.rb +112 -0
  10. data/app/controllers/launchpad/api/v2/private/base_controller.rb +14 -0
  11. data/app/controllers/launchpad/api/v2/private/ieo/orders_controller.rb +97 -0
  12. data/app/controllers/launchpad/api/v2/private/ieo/sales_controller.rb +22 -0
  13. data/app/controllers/launchpad/api/v2/public/base_controller.rb +13 -0
  14. data/app/controllers/launchpad/api/v2/public/ieo/sales_controller.rb +56 -0
  15. data/app/controllers/launchpad/application_controller.rb +10 -0
  16. data/app/helpers/launchpad/application_helper.rb +4 -0
  17. data/app/models/launchpad/application_record.rb +5 -0
  18. data/app/models/launchpad/ieo.rb +21 -0
  19. data/app/models/launchpad/ieo/order.rb +576 -0
  20. data/app/models/launchpad/ieo/sale.rb +371 -0
  21. data/app/models/launchpad/ieo/sale_pair.rb +83 -0
  22. data/app/services/barong/management_api_v2/client.rb +33 -0
  23. data/app/services/management_api_v2/client.rb +73 -0
  24. data/app/services/management_api_v2/exception.rb +25 -0
  25. data/app/services/peatio/management_api_v2/client.rb +49 -0
  26. data/app/workers/launchpad/ieo/order_execute_worker.rb +26 -0
  27. data/app/workers/launchpad/ieo/order_refund_worker.rb +19 -0
  28. data/app/workers/launchpad/ieo/order_release_worker.rb +22 -0
  29. data/app/workers/launchpad/ieo/sale_cancel_worker.rb +20 -0
  30. data/app/workers/launchpad/ieo/sale_currency_list_worker.rb +19 -0
  31. data/app/workers/launchpad/ieo/sale_distribute_worker.rb +20 -0
  32. data/app/workers/launchpad/ieo/sale_finish_worker.rb +21 -0
  33. data/app/workers/launchpad/ieo/sale_pair_list_worker.rb +21 -0
  34. data/app/workers/launchpad/ieo/sale_release_funds_worker.rb +23 -0
  35. data/app/workers/launchpad/ieo/sale_start_worker.rb +21 -0
  36. data/config/initializers/active_model.rb +13 -0
  37. data/config/initializers/api_pagination.rb +33 -0
  38. data/config/initializers/inflections.rb +19 -0
  39. data/config/routes.rb +35 -0
  40. data/db/migrate/20191120145404_create_launchpad_ieo.rb +52 -0
  41. data/db/migrate/20200814114105_add_fees_policy_in_sale.rb +5 -0
  42. data/lib/launchpad.rb +10 -0
  43. data/lib/launchpad/engine.rb +17 -0
  44. data/lib/launchpad/precision_validator.rb +25 -0
  45. data/lib/launchpad/version.rb +3 -0
  46. data/lib/tasks/launchpad_tasks.rake +4 -0
  47. metadata +229 -0
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new inflection rules using the following format. Inflections
5
+ # are locale specific, and you may define rules for as many different
6
+ # locales as you wish. All of these examples are active by default:
7
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
8
+ # inflect.plural /^(ox)$/i, '\1en'
9
+ # inflect.singular /^(ox)en/i, '\1'
10
+ # inflect.irregular 'person', 'people'
11
+ # inflect.uncountable %w( fish sheep )
12
+ # end
13
+
14
+ # These inflection rules are supported but not enabled by default:
15
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
16
+ inflect.acronym "API"
17
+ inflect.acronym "JWT"
18
+ inflect.acronym "IEO"
19
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,35 @@
1
+ Rails.application.routes.draw do
2
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3
+ scope module: 'launchpad' do
4
+ namespace :api do
5
+ namespace :v2 do
6
+ namespace :public do
7
+ namespace :ieo do
8
+ resources :sales, only: %i[index show] do
9
+ collection do
10
+ get 'search'
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ namespace :admin do
17
+ namespace :ieo do
18
+ resources :sales, only: %i[index show create update] do
19
+ put 'release_fund/:id', to: 'sales#release_fund', on: :collection
20
+ put ':event', to: 'sales#trigger_event', on: :member
21
+ end
22
+ resources :orders, only: %i[index]
23
+ end
24
+ end
25
+
26
+ namespace :private do
27
+ namespace :ieo do
28
+ resources :sales, only: %i[show]
29
+ resources :orders, only: %i[create index destroy]
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,52 @@
1
+ class CreateLaunchpadIEO < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table "ieo_orders", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
4
+ t.bigint "sale_pair_id", null: false
5
+ t.string "uid", null: false
6
+ t.decimal "contribution", precision: 32, scale: 16, null: false
7
+ t.decimal "executed", precision: 32, scale: 16, default: "0.0", null: false
8
+ t.decimal "refunded", precision: 32, scale: 16, default: "0.0", null: false
9
+ t.decimal "tokens_received", precision: 32, scale: 16, default: "0.0", null: false
10
+ t.decimal "tokens_locked", precision: 32, scale: 16, default: "0.0", null: false
11
+ t.decimal "commission_rate", precision: 16, scale: 16, default: "0.0", null: false
12
+ t.decimal "commission_amount", precision: 32, scale: 16, default: "0.0", null: false
13
+ t.string "transfer_keys", limit: 1000
14
+ t.string "state", limit: 32, null: false
15
+ t.datetime "created_at", null: false
16
+ t.datetime "updated_at", null: false
17
+ t.index ["sale_pair_id"], name: "index_ieo_orders_on_sale_pair_id"
18
+ end
19
+
20
+ create_table "ieo_sale_pairs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
21
+ t.bigint "sale_id", null: false
22
+ t.string "quote_currency_id", limit: 10, null: false
23
+ t.decimal "price", precision: 32, scale: 16, null: false
24
+ t.boolean "listed"
25
+ t.datetime "created_at", null: false
26
+ t.datetime "updated_at", null: false
27
+ t.index ["sale_id", "quote_currency_id"], name: "index_ieo_sale_pairs_on_sale_id_and_quote_currency_id", unique: true
28
+ t.index ["sale_id"], name: "index_ieo_sale_pairs_on_sale_id"
29
+ end
30
+
31
+ create_table "ieo_sales", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
32
+ t.string "name", limit: 32, null: false
33
+ t.text "description"
34
+ t.string "owner_uid", null: false
35
+ t.string "currency_id", limit: 10, null: false
36
+ t.decimal "supply", precision: 32, scale: 16, null: false
37
+ t.decimal "low_goal", precision: 32, scale: 16, default: "0.0", null: false
38
+ t.decimal "commission", precision: 16, scale: 16, default: "0.0", null: false
39
+ t.decimal "min_amount", precision: 32, scale: 16, default: "0.0", null: false
40
+ t.decimal "max_amount", precision: 32, scale: 16, null: false
41
+ t.decimal "min_unit", precision: 32, scale: 16, default: "0.0", null: false
42
+ t.string "state", limit: 32, null: false
43
+ t.string "type", limit: 32, null: false
44
+ t.string "result", limit: 32, null: false
45
+ t.decimal "lockup_percentage", precision: 17, scale: 16, default: "0.0", null: false
46
+ t.datetime "starts_at", null: false
47
+ t.datetime "finishes_at"
48
+ t.datetime "created_at", null: false
49
+ t.datetime "updated_at", null: false
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ class AddFeesPolicyInSale < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :ieo_sales, :fees_policy, :string, after: :lockup_percentage
4
+ end
5
+ end
data/lib/launchpad.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "launchpad/engine"
4
+
5
+ require "aasm"
6
+ require "peatio"
7
+ require "ransack"
8
+ require "rails/pagination"
9
+
10
+ module Launchpad end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Launchpad
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Launchpad
6
+
7
+ config.generators do |generators|
8
+ generators.test_framework :rspec
9
+ generators.fixture_replacement :factory_bot
10
+ generators.factory_bot dir: "spec/factories"
11
+ end
12
+
13
+ initializer "launchpad.factories", after: "factory_bot.set_factory_paths" do
14
+ FactoryBot.definition_file_paths << File.expand_path("../../spec/factories", __dir__) if defined?(FactoryBot)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module Launchpad
5
+ class PrecisionValidator < ActiveModel::EachValidator
6
+ def validate_each(record, attribute, value)
7
+ return unless options.key?(:less_than_or_eq_to) && value.present?
8
+
9
+ precision = if options[:less_than_or_eq_to].respond_to?(:call)
10
+ options[:less_than_or_eq_to].call(record)
11
+ else
12
+ options[:less_than_or_eq_to]
13
+ end
14
+
15
+ unless value.is_a?(Numeric)
16
+ record.errors.add(attribute, 'must be a number')
17
+ return
18
+ end
19
+
20
+ unless value.round(precision) == value
21
+ record.errors.add(attribute, "precision must be less than or equal to #{precision}")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Launchpad
2
+ VERSION = '3.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :launchpad do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,229 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taunchpad
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maksym Naichuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aasm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: api-pagination
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.8.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.8.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: enumerize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mysql2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: net-http-persistent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: pagy
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: peatio
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.6.3
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 6.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 6.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: ransack
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 2.3.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.3.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: sidekiq
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: A token launch platform for transformative projects.
154
+ email:
155
+ - mnaichuk@heliostech.fr
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - README.md
161
+ - Rakefile
162
+ - app/controllers/concerns/exception_handlers.rb
163
+ - app/controllers/concerns/jwt_payload.rb
164
+ - app/controllers/concerns/response.rb
165
+ - app/controllers/launchpad/api/v2/admin/base_controller.rb
166
+ - app/controllers/launchpad/api/v2/admin/ieo/orders_controller.rb
167
+ - app/controllers/launchpad/api/v2/admin/ieo/sales_controller.rb
168
+ - app/controllers/launchpad/api/v2/private/base_controller.rb
169
+ - app/controllers/launchpad/api/v2/private/ieo/orders_controller.rb
170
+ - app/controllers/launchpad/api/v2/private/ieo/sales_controller.rb
171
+ - app/controllers/launchpad/api/v2/public/base_controller.rb
172
+ - app/controllers/launchpad/api/v2/public/ieo/sales_controller.rb
173
+ - app/controllers/launchpad/application_controller.rb
174
+ - app/helpers/launchpad/application_helper.rb
175
+ - app/models/launchpad/application_record.rb
176
+ - app/models/launchpad/ieo.rb
177
+ - app/models/launchpad/ieo/order.rb
178
+ - app/models/launchpad/ieo/sale.rb
179
+ - app/models/launchpad/ieo/sale_pair.rb
180
+ - app/services/barong/management_api_v2/client.rb
181
+ - app/services/management_api_v2/client.rb
182
+ - app/services/management_api_v2/exception.rb
183
+ - app/services/peatio/management_api_v2/client.rb
184
+ - app/workers/launchpad/ieo/order_execute_worker.rb
185
+ - app/workers/launchpad/ieo/order_refund_worker.rb
186
+ - app/workers/launchpad/ieo/order_release_worker.rb
187
+ - app/workers/launchpad/ieo/sale_cancel_worker.rb
188
+ - app/workers/launchpad/ieo/sale_currency_list_worker.rb
189
+ - app/workers/launchpad/ieo/sale_distribute_worker.rb
190
+ - app/workers/launchpad/ieo/sale_finish_worker.rb
191
+ - app/workers/launchpad/ieo/sale_pair_list_worker.rb
192
+ - app/workers/launchpad/ieo/sale_release_funds_worker.rb
193
+ - app/workers/launchpad/ieo/sale_start_worker.rb
194
+ - config/initializers/active_model.rb
195
+ - config/initializers/api_pagination.rb
196
+ - config/initializers/inflections.rb
197
+ - config/routes.rb
198
+ - db/migrate/20191120145404_create_launchpad_ieo.rb
199
+ - db/migrate/20200814114105_add_fees_policy_in_sale.rb
200
+ - lib/launchpad.rb
201
+ - lib/launchpad/engine.rb
202
+ - lib/launchpad/precision_validator.rb
203
+ - lib/launchpad/version.rb
204
+ - lib/tasks/launchpad_tasks.rake
205
+ homepage: https://github.com/openware/enterprise-engines/launchpad
206
+ licenses: []
207
+ metadata:
208
+ homepage_uri: https://github.com/openware/enterprise-engines/launchpad
209
+ source_code_uri: https://github.com/openware/enterprise-engines/launchpad
210
+ post_install_message:
211
+ rdoc_options: []
212
+ require_paths:
213
+ - lib
214
+ required_ruby_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ requirements: []
225
+ rubygems_version: 3.0.9
226
+ signing_key:
227
+ specification_version: 4
228
+ summary: A token launch platform for transformative projects.
229
+ test_files: []