osbc 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env +5 -0
- data/.rspec +1 -0
- data/.rubocop.yml +273 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Dockerfile +17 -0
- data/Gemfile +109 -0
- data/Gemfile.lock +343 -0
- data/LICENSE.md +21 -0
- data/LICENSE.txt +21 -0
- data/Procfile +3 -0
- data/Procfile.dev +2 -0
- data/README.md +185 -0
- data/Rakefile +6 -0
- data/app/assets/builds/.keep +0 -0
- data/app/assets/config/manifest.js +5 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/bg.png +0 -0
- data/app/assets/images/gimage.png +0 -0
- data/app/assets/images/image.png +0 -0
- data/app/assets/images/logo.png +0 -0
- data/app/assets/images/outerspc.jpg +0 -0
- data/app/assets/images/proxy.jpg +0 -0
- data/app/assets/images/space.jpg +0 -0
- data/app/assets/images/space_four.jpg +0 -0
- data/app/assets/images/space_t.jpg +0 -0
- data/app/assets/images/space_th.jpg +0 -0
- data/app/assets/images/space_two.jpg +0 -0
- data/app/assets/images/th.jpg +0 -0
- data/app/assets/stylesheets/application.css +344 -0
- data/app/assets/stylesheets/application.tailwind.css +13 -0
- data/app/assets/stylesheets/home.css +0 -0
- data/app/channels/application_cable/channel.rb +6 -0
- data/app/channels/application_cable/connection.rb +6 -0
- data/app/controllers/api/v1/block_confirmations_controller.rb +65 -0
- data/app/controllers/application_controller.rb +72 -0
- data/app/controllers/blocks_controller.rb +20 -0
- data/app/controllers/chains_controller.rb +72 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/contracts_controller.rb +25 -0
- data/app/controllers/pools_controller.rb +73 -0
- data/app/controllers/signatures_controller.rb +25 -0
- data/app/controllers/tickets_controller.rb +76 -0
- data/app/controllers/transactions_controller.rb +48 -0
- data/app/controllers/users/confirmations_controller.rb +30 -0
- data/app/controllers/users/omniauth_callbacks_controller.rb +30 -0
- data/app/controllers/users/passwords_controller.rb +34 -0
- data/app/controllers/users/registrations_controller.rb +61 -0
- data/app/controllers/users/sessions_controller.rb +27 -0
- data/app/controllers/users/unlocks_controller.rb +30 -0
- data/app/controllers/wallets_controller.rb +18 -0
- data/app/helpers/application_helper.rb +4 -0
- data/app/helpers/blocks_helper.rb +4 -0
- data/app/helpers/chains_helper.rb +4 -0
- data/app/helpers/contracts_helper.rb +4 -0
- data/app/helpers/pools_helper.rb +4 -0
- data/app/helpers/signatures_helper.rb +4 -0
- data/app/helpers/tickets_helper.rb +4 -0
- data/app/helpers/transactions_helper.rb +4 -0
- data/app/helpers/wallets_helper.rb +4 -0
- data/app/javascript/application.js +3 -0
- data/app/javascript/controllers/application.js +9 -0
- data/app/javascript/controllers/hello_controller.js +7 -0
- data/app/javascript/controllers/index.js +11 -0
- data/app/jobs/application_job.rb +9 -0
- data/app/mailers/application_mailer.rb +6 -0
- data/app/models/acceptable_number_sequence.rb +4 -0
- data/app/models/acceptable_symbol_sequence.rb +4 -0
- data/app/models/acceptable_word.rb +4 -0
- data/app/models/application_record.rb +5 -0
- data/app/models/block.rb +17 -0
- data/app/models/chain.rb +10 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/concerns/sequences_validator.rb +30 -0
- data/app/models/concerns/wallet_exists_validator.rb +13 -0
- data/app/models/contract.rb +7 -0
- data/app/models/pool.rb +5 -0
- data/app/models/signature.rb +12 -0
- data/app/models/ticket.rb +11 -0
- data/app/models/transaction.rb +25 -0
- data/app/models/user.rb +44 -0
- data/app/models/wallet.rb +33 -0
- data/app/services/application_service.rb +23 -0
- data/app/services/assign_contracts_service.rb +162 -0
- data/app/services/create_ticket_service.rb +87 -0
- data/app/services/create_wallet_service.rb +20 -0
- data/app/services/transaction_to_block_service.rb +62 -0
- data/app/views/application/_featured_board.html.erb +77 -0
- data/app/views/application/home.html.slim +1 -0
- data/app/views/application/mining_profile.html.slim +59 -0
- data/app/views/application/privacy_policy.html.erb +0 -0
- data/app/views/application/terms.html.erb +0 -0
- data/app/views/blocks/_block.html.slim +13 -0
- data/app/views/blocks/_block.json.jbuilder +4 -0
- data/app/views/blocks/_form.html.slim +26 -0
- data/app/views/blocks/edit.html.slim +10 -0
- data/app/views/blocks/index.html.slim +12 -0
- data/app/views/blocks/index.json.jbuilder +3 -0
- data/app/views/blocks/new.html.slim +8 -0
- data/app/views/blocks/show.html.slim +8 -0
- data/app/views/blocks/show.json.jbuilder +3 -0
- data/app/views/chains/_chain.html.slim +16 -0
- data/app/views/chains/_chain.json.jbuilder +4 -0
- data/app/views/chains/_form.html.slim +30 -0
- data/app/views/chains/edit.html.slim +10 -0
- data/app/views/chains/index.html.slim +11 -0
- data/app/views/chains/index.json.jbuilder +3 -0
- data/app/views/chains/new.html.slim +8 -0
- data/app/views/chains/show.html.slim +10 -0
- data/app/views/chains/show.json.jbuilder +3 -0
- data/app/views/contracts/_contract.html.slim +8 -0
- data/app/views/contracts/_contract.json.jbuilder +4 -0
- data/app/views/contracts/_form.html.slim +34 -0
- data/app/views/contracts/edit.html.slim +10 -0
- data/app/views/contracts/index.html.slim +12 -0
- data/app/views/contracts/index.json.jbuilder +3 -0
- data/app/views/contracts/new.html.slim +8 -0
- data/app/views/contracts/show.html.slim +8 -0
- data/app/views/contracts/show.json.jbuilder +3 -0
- data/app/views/layouts/_alert.html.slim +6 -0
- data/app/views/layouts/_navbar.html.slim +27 -0
- data/app/views/layouts/_notice.html.slim +6 -0
- data/app/views/layouts/application.html.erb +32 -0
- data/app/views/layouts/mailer.html.erb +13 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/pools/_form.html.slim +30 -0
- data/app/views/pools/_pool.html.slim +16 -0
- data/app/views/pools/_pool.json.jbuilder +4 -0
- data/app/views/pools/edit.html.slim +10 -0
- data/app/views/pools/index.html.slim +12 -0
- data/app/views/pools/index.json.jbuilder +3 -0
- data/app/views/pools/new.html.slim +8 -0
- data/app/views/pools/show.html.slim +8 -0
- data/app/views/pools/show.json.jbuilder +3 -0
- data/app/views/signatures/_form.html.slim +46 -0
- data/app/views/signatures/_signature.html.slim +28 -0
- data/app/views/signatures/_signature.json.jbuilder +4 -0
- data/app/views/signatures/edit.html.slim +10 -0
- data/app/views/signatures/index.html.slim +10 -0
- data/app/views/signatures/index.json.jbuilder +3 -0
- data/app/views/signatures/new.html.slim +8 -0
- data/app/views/signatures/show.html.slim +10 -0
- data/app/views/signatures/show.json.jbuilder +3 -0
- data/app/views/tickets/_form.html.slim +26 -0
- data/app/views/tickets/_ticket.html.slim +10 -0
- data/app/views/tickets/_ticket.json.jbuilder +4 -0
- data/app/views/tickets/edit.html.slim +10 -0
- data/app/views/tickets/index.html.slim +16 -0
- data/app/views/tickets/index.json.jbuilder +3 -0
- data/app/views/tickets/new.html.slim +10 -0
- data/app/views/tickets/show.html.slim +8 -0
- data/app/views/tickets/show.json.jbuilder +3 -0
- data/app/views/transactions/_form.html.slim +16 -0
- data/app/views/transactions/_transaction.html.slim +24 -0
- data/app/views/transactions/_transaction.json.jbuilder +4 -0
- data/app/views/transactions/edit.html.slim +10 -0
- data/app/views/transactions/index.html.slim +19 -0
- data/app/views/transactions/index.json.jbuilder +3 -0
- data/app/views/transactions/new.html.slim +9 -0
- data/app/views/transactions/show.html.slim +8 -0
- data/app/views/transactions/show.json.jbuilder +3 -0
- data/app/views/users/confirmations/new.html.erb +16 -0
- data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/users/mailer/email_changed.html.erb +7 -0
- data/app/views/users/mailer/password_change.html.erb +3 -0
- data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/users/passwords/edit.html.erb +25 -0
- data/app/views/users/passwords/new.html.erb +16 -0
- data/app/views/users/registrations/edit.html.erb +43 -0
- data/app/views/users/registrations/new.html.erb +37 -0
- data/app/views/users/sessions/new.html.erb +30 -0
- data/app/views/users/shared/_error_messages.html.erb +15 -0
- data/app/views/users/shared/_links.html.erb +25 -0
- data/app/views/users/unlocks/new.html.erb +16 -0
- data/app/views/wallets/_form.html.slim +30 -0
- data/app/views/wallets/_wallet.html.slim +13 -0
- data/app/views/wallets/_wallet.json.jbuilder +4 -0
- data/app/views/wallets/edit.html.slim +10 -0
- data/app/views/wallets/index.html.slim +18 -0
- data/app/views/wallets/index.json.jbuilder +3 -0
- data/app/views/wallets/new.html.slim +8 -0
- data/app/views/wallets/show.html.slim +11 -0
- data/app/views/wallets/show.json.jbuilder +3 -0
- data/app/workers/application_worker.rb +82 -0
- data/app/workers/assign_contract_worker.rb +27 -0
- data/app/workers/create_ticket_worker.rb +23 -0
- data/app/workers/create_wallet_worker.rb +21 -0
- data/app/workers/transaction_to_block_worker.rb +48 -0
- data/bin/bundle +114 -0
- data/bin/console +15 -0
- data/bin/dev +9 -0
- data/bin/importmap +5 -0
- data/bin/osbc +77 -0
- data/bin/rails +6 -0
- data/bin/rake +6 -0
- data/bin/setup +35 -0
- data/config/application.rb +25 -0
- data/config/boot.rb +6 -0
- data/config/cable.yml +10 -0
- data/config/credentials.yml.enc +1 -0
- data/config/database.yml +21 -0
- data/config/environment.rb +7 -0
- data/config/environments/development.rb +73 -0
- data/config/environments/production.rb +95 -0
- data/config/environments/test.rb +62 -0
- data/config/importmap.rb +9 -0
- data/config/initializers/assets.rb +14 -0
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/devise.rb +311 -0
- data/config/initializers/filter_parameter_logging.rb +10 -0
- data/config/initializers/inflections.rb +17 -0
- data/config/initializers/permissions_policy.rb +12 -0
- data/config/locales/devise.en.yml +65 -0
- data/config/locales/en.yml +33 -0
- data/config/puma.rb +45 -0
- data/config/routes/api.rb +9 -0
- data/config/routes.rb +30 -0
- data/config/sidekiq.yml +10 -0
- data/config/storage.yml +34 -0
- data/config/tailwind.config.js +23 -0
- data/config.ru +8 -0
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +1853 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.12.3/application.css +1 -0
- data/coverage/assets/0.12.3/application.js +7 -0
- data/coverage/assets/0.12.3/colorbox/border.png +0 -0
- data/coverage/assets/0.12.3/colorbox/controls.png +0 -0
- data/coverage/assets/0.12.3/colorbox/loading.gif +0 -0
- data/coverage/assets/0.12.3/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.12.3/favicon_green.png +0 -0
- data/coverage/assets/0.12.3/favicon_red.png +0 -0
- data/coverage/assets/0.12.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.12.3/loading.gif +0 -0
- data/coverage/assets/0.12.3/magnify.png +0 -0
- data/coverage/index.html +20731 -0
- data/db/migrate/20221018053949_devise_create_users.rb +45 -0
- data/db/migrate/20221019002956_create_chains.rb +13 -0
- data/db/migrate/20221020112137_create_blocks.rb +12 -0
- data/db/migrate/20221020123102_add_chain_to_blocks.rb +5 -0
- data/db/migrate/20221020150504_create_wallets.rb +13 -0
- data/db/migrate/20221022221059_create_transactions.rb +20 -0
- data/db/migrate/20221023011005_add_block_to_transactions.rb +5 -0
- data/db/migrate/20221023014707_create_contracts.rb +11 -0
- data/db/migrate/20221023040749_create_pools.rb +13 -0
- data/db/migrate/20221023041015_create_tickets.rb +11 -0
- data/db/migrate/20221023103509_add_contracts_count_to_block.rb +6 -0
- data/db/migrate/20221023110613_add_acceptable_word_list_to_users.rb +7 -0
- data/db/migrate/20221023113539_create_signatures.rb +19 -0
- data/db/migrate/20221023113750_create_acceptable_words.rb +9 -0
- data/db/migrate/20221023114152_create_acceptable_number_sequences.rb +9 -0
- data/db/migrate/20221023114203_create_acceptable_symbol_sequences.rb +9 -0
- data/db/migrate/20221023114324_add_user_acceptable_hash_to_tickets.rb +7 -0
- data/db/migrate/20221023114408_add_time_ref_to_tickets.rb +5 -0
- data/db/migrate/20221024125047_add_master_hash_to_blocks.rb +5 -0
- data/db/migrate/20221109161845_add_transactions_count_to_blocks.rb +5 -0
- data/db/migrate/20221117135003_add_balance_to_chains.rb +5 -0
- data/db/migrate/20221117203417_add_transaction_id_list_to_tickets.rb +5 -0
- data/db/migrate/20221118080357_add_api_keys_to_users.rb +6 -0
- data/db/schema.rb +179 -0
- data/db/seeds.rb +134 -0
- data/docker-compose.yml +53 -0
- data/entrypoint.sh +8 -0
- data/lib/assets/.keep +0 -0
- data/lib/osbc/osbc.rb +9 -0
- data/lib/outerspace/blockchain/version.rb +7 -0
- data/lib/outerspace/blockchain.rb +10 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/compose.rake +92 -0
- data/lib/tasks/compose_db.rake +71 -0
- data/lib/tasks/compose_logs.rake +95 -0
- data/lib/tasks/compose_test.rake +62 -0
- data/log/.keep +0 -0
- data/mining_concept.ipynb +284 -0
- data/outerspace-blockchain.gemspec +50 -0
- data/public/404.html +67 -0
- data/public/422.html +67 -0
- data/public/500.html +66 -0
- data/public/apple-touch-icon-precomposed.png +0 -0
- data/public/apple-touch-icon.png +0 -0
- data/public/favicon.ico +0 -0
- data/public/robots.txt +1 -0
- data/storage/.keep +0 -0
- data/tmp/.keep +0 -0
- data/tmp/pids/.keep +0 -0
- data/tmp/storage/.keep +0 -0
- data/vendor/.keep +0 -0
- data/vendor/javascript/.keep +0 -0
- metadata +643 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DeviseCreateUsers < ActiveRecord::Migration[7.0]
|
4
|
+
def change
|
5
|
+
create_table :users do |t|
|
6
|
+
## Database authenticatable
|
7
|
+
t.string :username, null: false, index: { unique: true }, limit: 10
|
8
|
+
t.string :email, null: false, default: ""
|
9
|
+
t.string :encrypted_password, null: false, default: ""
|
10
|
+
|
11
|
+
## Recoverable
|
12
|
+
t.string :reset_password_token
|
13
|
+
t.datetime :reset_password_sent_at
|
14
|
+
|
15
|
+
## Rememberable
|
16
|
+
t.datetime :remember_created_at
|
17
|
+
|
18
|
+
## Trackable
|
19
|
+
t.integer :sign_in_count, default: 0, null: false
|
20
|
+
t.datetime :current_sign_in_at
|
21
|
+
t.datetime :last_sign_in_at
|
22
|
+
t.string :current_sign_in_ip
|
23
|
+
t.string :last_sign_in_ip
|
24
|
+
|
25
|
+
## Confirmable
|
26
|
+
t.string :confirmation_token
|
27
|
+
t.datetime :confirmed_at
|
28
|
+
t.datetime :confirmation_sent_at
|
29
|
+
# t.string :unconfirmed_email
|
30
|
+
|
31
|
+
## Lockable
|
32
|
+
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
33
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
34
|
+
t.datetime :locked_at
|
35
|
+
|
36
|
+
|
37
|
+
t.timestamps null: false
|
38
|
+
end
|
39
|
+
|
40
|
+
add_index :users, :email, unique: true
|
41
|
+
add_index :users, :reset_password_token, unique: true
|
42
|
+
add_index :users, :confirmation_token, unique: true
|
43
|
+
add_index :users, :unlock_token, unique: true
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateChains < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :chains do |t|
|
4
|
+
t.string :name, null: false, index: { unique: true }
|
5
|
+
t.integer :blocks_count, null: false, default: 0
|
6
|
+
t.string :maintainer, null: false
|
7
|
+
t.string :chain_version, null: false
|
8
|
+
t.text :description, null: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateBlocks < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :blocks do |t|
|
4
|
+
t.integer :nonce, default: 0, null: false
|
5
|
+
t.string :previous_hash
|
6
|
+
t.text :block_data
|
7
|
+
t.integer :connections, null: false, default: 0
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateWallets < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :wallets do |t|
|
4
|
+
t.references :user, null: false, foreign_key: true
|
5
|
+
t.string :pr_key, null: false
|
6
|
+
t.string :pv_key, null: false
|
7
|
+
t.decimal :balance, null: false, default: 0.0, precision: 16, scale: 2
|
8
|
+
t.integer :status, null: false, default: 0
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateTransactions < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :transactions do |t|
|
4
|
+
t.string :sender_key, null: false
|
5
|
+
t.string :receiver_key, null: false
|
6
|
+
t.time :signature_time
|
7
|
+
t.integer :status, null: false, default: 0
|
8
|
+
t.text :data
|
9
|
+
t.string :upl_file
|
10
|
+
t.string :upl_file_name
|
11
|
+
t.string :upl_file_type
|
12
|
+
t.string :upl_file_size
|
13
|
+
t.string :upl_file_hash
|
14
|
+
t.decimal :amount, null: false, default: 0.0, precision: 16, scale: 2
|
15
|
+
t.float :fee, null: false, default: 0.0, precision: 16, scale: 2
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateContracts < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :contracts do |t|
|
4
|
+
t.integer :signatures_count, default: 0, null: false
|
5
|
+
t.integer :status, default: 0, null: false
|
6
|
+
t.integer :transaction_id, null: false
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreatePools < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :pools do |t|
|
4
|
+
t.references :block, null: false, foreign_key: true
|
5
|
+
t.integer :users_count, default: 0, null: false
|
6
|
+
t.integer :signatures_count, default: 0, null: false
|
7
|
+
t.decimal :amount, null: false, default: 0.0, precision: 16, scale: 2
|
8
|
+
t.integer :stage, default: 0, null: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class AddAcceptableWordListToUsers < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
add_column :users, :acceptable_words, :text, array: true, default: [], null: false
|
4
|
+
add_column :users, :acceptable_number_sequences, :text, array: true, default: [], null: false
|
5
|
+
add_column :users, :acceptable_symbol_sequences, :text, array: true, default: [], null: false
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateSignatures < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :signatures do |t|
|
4
|
+
t.string :signature, null: false
|
5
|
+
# t.datetime :time_ref, null: false
|
6
|
+
t.references :contract, null: false, foreign_key: true
|
7
|
+
t.references :ticket, null: false, foreign_key: true
|
8
|
+
t.references :user, null: false, foreign_key: true
|
9
|
+
# t.string :common_word, null: false
|
10
|
+
# t.string :symbol_sequence, null: false
|
11
|
+
# t.string :number_sequence, null: false
|
12
|
+
# t.string :verify_sig, null: false
|
13
|
+
# t.string :block_hash, null: false
|
14
|
+
# t.string :signature_hash, null: false
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema[7.0].define(version: 2022_11_18_080357) do
|
14
|
+
# These are extensions that must be enabled in order to support this database
|
15
|
+
enable_extension "plpgsql"
|
16
|
+
|
17
|
+
create_table "acceptable_number_sequences", force: :cascade do |t|
|
18
|
+
t.string "seq", null: false
|
19
|
+
t.datetime "created_at", null: false
|
20
|
+
t.datetime "updated_at", null: false
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table "acceptable_symbol_sequences", force: :cascade do |t|
|
24
|
+
t.string "seq", null: false
|
25
|
+
t.datetime "created_at", null: false
|
26
|
+
t.datetime "updated_at", null: false
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "acceptable_words", force: :cascade do |t|
|
30
|
+
t.string "word", null: false
|
31
|
+
t.datetime "created_at", null: false
|
32
|
+
t.datetime "updated_at", null: false
|
33
|
+
end
|
34
|
+
|
35
|
+
create_table "blocks", force: :cascade do |t|
|
36
|
+
t.integer "nonce", default: 0, null: false
|
37
|
+
t.string "previous_hash"
|
38
|
+
t.text "block_data"
|
39
|
+
t.integer "connections", default: 0, null: false
|
40
|
+
t.datetime "created_at", null: false
|
41
|
+
t.datetime "updated_at", null: false
|
42
|
+
t.bigint "chain_id", null: false
|
43
|
+
t.integer "contracts_count", default: 0, null: false
|
44
|
+
t.integer "contracts_limit", default: 0, null: false
|
45
|
+
t.string "master_hash"
|
46
|
+
t.integer "transactions_count", default: 0, null: false
|
47
|
+
t.index ["chain_id"], name: "index_blocks_on_chain_id"
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table "chains", force: :cascade do |t|
|
51
|
+
t.string "name", null: false
|
52
|
+
t.integer "blocks_count", default: 0, null: false
|
53
|
+
t.string "maintainer", null: false
|
54
|
+
t.string "chain_version", null: false
|
55
|
+
t.text "description", null: false
|
56
|
+
t.datetime "created_at", null: false
|
57
|
+
t.datetime "updated_at", null: false
|
58
|
+
t.decimal "balance", precision: 16, scale: 2, default: "0.0", null: false
|
59
|
+
t.index ["name"], name: "index_chains_on_name", unique: true
|
60
|
+
end
|
61
|
+
|
62
|
+
create_table "contracts", force: :cascade do |t|
|
63
|
+
t.integer "signatures_count", default: 0, null: false
|
64
|
+
t.integer "status", default: 0, null: false
|
65
|
+
t.integer "transaction_id", null: false
|
66
|
+
t.datetime "created_at", null: false
|
67
|
+
t.datetime "updated_at", null: false
|
68
|
+
end
|
69
|
+
|
70
|
+
create_table "pools", force: :cascade do |t|
|
71
|
+
t.bigint "block_id", null: false
|
72
|
+
t.integer "users_count", default: 0, null: false
|
73
|
+
t.integer "signatures_count", default: 0, null: false
|
74
|
+
t.decimal "amount", precision: 16, scale: 2, default: "0.0", null: false
|
75
|
+
t.integer "stage", default: 0, null: false
|
76
|
+
t.datetime "created_at", null: false
|
77
|
+
t.datetime "updated_at", null: false
|
78
|
+
t.index ["block_id"], name: "index_pools_on_block_id"
|
79
|
+
end
|
80
|
+
|
81
|
+
create_table "signatures", force: :cascade do |t|
|
82
|
+
t.string "signature", null: false
|
83
|
+
t.bigint "contract_id", null: false
|
84
|
+
t.bigint "ticket_id", null: false
|
85
|
+
t.bigint "user_id", null: false
|
86
|
+
t.datetime "created_at", null: false
|
87
|
+
t.datetime "updated_at", null: false
|
88
|
+
t.index ["contract_id"], name: "index_signatures_on_contract_id"
|
89
|
+
t.index ["ticket_id"], name: "index_signatures_on_ticket_id"
|
90
|
+
t.index ["user_id"], name: "index_signatures_on_user_id"
|
91
|
+
end
|
92
|
+
|
93
|
+
create_table "tickets", force: :cascade do |t|
|
94
|
+
t.bigint "user_id", null: false
|
95
|
+
t.bigint "pool_id", null: false
|
96
|
+
t.integer "status"
|
97
|
+
t.datetime "created_at", null: false
|
98
|
+
t.datetime "updated_at", null: false
|
99
|
+
t.string "user_acceptable_hash"
|
100
|
+
t.string "confirmation_hash"
|
101
|
+
t.string "block_hash"
|
102
|
+
t.datetime "time_ref"
|
103
|
+
t.text "transaction_id_list", default: [], array: true
|
104
|
+
t.index ["pool_id"], name: "index_tickets_on_pool_id"
|
105
|
+
t.index ["user_id"], name: "index_tickets_on_user_id"
|
106
|
+
end
|
107
|
+
|
108
|
+
create_table "transactions", force: :cascade do |t|
|
109
|
+
t.string "sender_key", null: false
|
110
|
+
t.string "receiver_key", null: false
|
111
|
+
t.time "signature_time"
|
112
|
+
t.integer "status", default: 0, null: false
|
113
|
+
t.text "data"
|
114
|
+
t.string "upl_file"
|
115
|
+
t.string "upl_file_name"
|
116
|
+
t.string "upl_file_type"
|
117
|
+
t.string "upl_file_size"
|
118
|
+
t.string "upl_file_hash"
|
119
|
+
t.decimal "amount", precision: 16, scale: 2, default: "0.0", null: false
|
120
|
+
t.float "fee", default: 0.0, null: false
|
121
|
+
t.datetime "created_at", null: false
|
122
|
+
t.datetime "updated_at", null: false
|
123
|
+
t.bigint "block_id", null: false
|
124
|
+
t.index ["block_id"], name: "index_transactions_on_block_id"
|
125
|
+
end
|
126
|
+
|
127
|
+
create_table "users", force: :cascade do |t|
|
128
|
+
t.string "username", limit: 10, null: false
|
129
|
+
t.string "email", default: "", null: false
|
130
|
+
t.string "encrypted_password", default: "", null: false
|
131
|
+
t.string "reset_password_token"
|
132
|
+
t.datetime "reset_password_sent_at"
|
133
|
+
t.datetime "remember_created_at"
|
134
|
+
t.integer "sign_in_count", default: 0, null: false
|
135
|
+
t.datetime "current_sign_in_at"
|
136
|
+
t.datetime "last_sign_in_at"
|
137
|
+
t.string "current_sign_in_ip"
|
138
|
+
t.string "last_sign_in_ip"
|
139
|
+
t.string "confirmation_token"
|
140
|
+
t.datetime "confirmed_at"
|
141
|
+
t.datetime "confirmation_sent_at"
|
142
|
+
t.integer "failed_attempts", default: 0, null: false
|
143
|
+
t.string "unlock_token"
|
144
|
+
t.datetime "locked_at"
|
145
|
+
t.datetime "created_at", null: false
|
146
|
+
t.datetime "updated_at", null: false
|
147
|
+
t.text "acceptable_words", default: [], null: false, array: true
|
148
|
+
t.text "acceptable_number_sequences", default: [], null: false, array: true
|
149
|
+
t.text "acceptable_symbol_sequences", default: [], null: false, array: true
|
150
|
+
t.string "api_key"
|
151
|
+
t.string "api_secret"
|
152
|
+
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
153
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
154
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
155
|
+
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
|
156
|
+
t.index ["username"], name: "index_users_on_username", unique: true
|
157
|
+
end
|
158
|
+
|
159
|
+
create_table "wallets", force: :cascade do |t|
|
160
|
+
t.bigint "user_id", null: false
|
161
|
+
t.string "pr_key", null: false
|
162
|
+
t.string "pv_key", null: false
|
163
|
+
t.decimal "balance", precision: 16, scale: 2, default: "0.0", null: false
|
164
|
+
t.integer "status", default: 0, null: false
|
165
|
+
t.datetime "created_at", null: false
|
166
|
+
t.datetime "updated_at", null: false
|
167
|
+
t.index ["user_id"], name: "index_wallets_on_user_id"
|
168
|
+
end
|
169
|
+
|
170
|
+
add_foreign_key "blocks", "chains"
|
171
|
+
add_foreign_key "pools", "blocks"
|
172
|
+
add_foreign_key "signatures", "contracts"
|
173
|
+
add_foreign_key "signatures", "tickets"
|
174
|
+
add_foreign_key "signatures", "users"
|
175
|
+
add_foreign_key "tickets", "pools"
|
176
|
+
add_foreign_key "tickets", "users"
|
177
|
+
add_foreign_key "transactions", "blocks"
|
178
|
+
add_foreign_key "wallets", "users"
|
179
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def seed_exec
|
4
|
+
create_first_chain
|
5
|
+
create_acceptable_word_lists
|
6
|
+
create_first_block
|
7
|
+
end
|
8
|
+
|
9
|
+
def dev_seed_exec
|
10
|
+
puts "Seeding development database"
|
11
|
+
puts "Creating first chain"
|
12
|
+
create_first_chain
|
13
|
+
puts "Creating acceptable word lists"
|
14
|
+
create_acceptable_word_lists
|
15
|
+
puts "Creating first block"
|
16
|
+
create_first_block
|
17
|
+
puts "Creating test users"
|
18
|
+
create_test_users
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_first_chain
|
22
|
+
Chain.create(
|
23
|
+
name: ENV["FIRST_CHAIN_NAME"],
|
24
|
+
maintainer: ENV["FIRST_CHAIN_MAINTAINER"],
|
25
|
+
chain_version: "0.0.1",
|
26
|
+
description: "This is a blockchain project generated with outerspace-blockchain."
|
27
|
+
)
|
28
|
+
|
29
|
+
puts "Chain created"
|
30
|
+
puts "Chain name: #{ENV["FIRST_CHAIN_NAME"]}"
|
31
|
+
puts "Chain maintainer: #{ENV["FIRST_CHAIN_MAINTAINER"]}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_acceptable_word_lists
|
35
|
+
create_acceptable_words
|
36
|
+
create_acceptable_symbol_sequences
|
37
|
+
create_acceptable_number_sequences
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_acceptable_words
|
41
|
+
word_list = %w[the of and to a in
|
42
|
+
is you that it he
|
43
|
+
was for on are as
|
44
|
+
with his they I at
|
45
|
+
be this have from or
|
46
|
+
one had by word but
|
47
|
+
not what all were we
|
48
|
+
when your can said there
|
49
|
+
use an each which she do
|
50
|
+
how their if will up other
|
51
|
+
about out many then them
|
52
|
+
these so some her would
|
53
|
+
make like him into time
|
54
|
+
as look two more write
|
55
|
+
go see number no way could
|
56
|
+
people my than first water
|
57
|
+
been call who oil its now
|
58
|
+
find long down day did get
|
59
|
+
come made may part]
|
60
|
+
words = []
|
61
|
+
word_list.each do |word|
|
62
|
+
words << AcceptableWord.new(word: word) # rubocop:disable Lint/UselessAssignment
|
63
|
+
end
|
64
|
+
|
65
|
+
AcceptableWord.import words
|
66
|
+
end
|
67
|
+
|
68
|
+
def create_acceptable_symbol_sequences
|
69
|
+
symbol_sequence_list = %w[!!! !@# !@#$ !@#$% !@#$%^ !@#$%^& !@#$%^&* !@#$%^&*(
|
70
|
+
!@#$%^&*( )@#$%^&*( )@#$%^&*() @#$%^&*() @#$%^&*()_
|
71
|
+
@#$%^&*()_ @#$%^&*()_+ #$%^&*()_+ #$%^&*()_+{
|
72
|
+
#$%^&*()_+{ #$%^&*()_+{ }%^&*()_+{ }%^&*()_+{
|
73
|
+
@#¨$@¨$$¨@(#$ @#¨$@¨$$¨@(#$ @#¨$@¨$$¨ @(#$¨@#¨$@¨$$¨@(#$)
|
74
|
+
$#$¨@*#$¨$(@#) $@$(*#&$) $@#$&)@#$() @&(*@#&$$]
|
75
|
+
symbols = []
|
76
|
+
symbol_sequence_list.each do |symbol_sequence|
|
77
|
+
symbols << AcceptableSymbolSequence.new(seq: symbol_sequence) # rubocop:disable Lint/UselessAssignment
|
78
|
+
end
|
79
|
+
|
80
|
+
AcceptableSymbolSequence.import symbols
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_acceptable_number_sequences
|
84
|
+
number_sequence_list = (0..9999).map { |n| format("%04d", n) }
|
85
|
+
|
86
|
+
numbers = []
|
87
|
+
number_sequence_list.each do |number_sequence|
|
88
|
+
numbers << AcceptableNumberSequence.new(seq: number_sequence) # rubocop:disable Lint/UselessAssignment
|
89
|
+
end
|
90
|
+
|
91
|
+
AcceptableNumberSequence.import numbers
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def create_first_block
|
96
|
+
Block.create(
|
97
|
+
chain: Chain.first,
|
98
|
+
previous_hash: "0000000000000000000000000000000000000000000000000000000000000000",
|
99
|
+
block_data: "This is the first block of the blockchain.",
|
100
|
+
nonce: 0,
|
101
|
+
connections: 0,
|
102
|
+
contracts_count: 0,
|
103
|
+
contracts_limit: ENV["CONTRACTS_LIMIT"].to_i,
|
104
|
+
# timestamp: Time.now
|
105
|
+
)
|
106
|
+
|
107
|
+
puts "First block created"
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_test_users
|
111
|
+
if User.find_by(email: "lorem@ipsum.com", username: "lorem")
|
112
|
+
puts "Test user already exists"
|
113
|
+
else
|
114
|
+
User.create(
|
115
|
+
email: "lorem@ipsum.com", username: "lorem", password: "password", password_confirmation: "password"
|
116
|
+
)
|
117
|
+
puts "Test user created"
|
118
|
+
end
|
119
|
+
|
120
|
+
if User.find_by(email: "lorem_sec@ipsum.com", username: "lorem_sec")
|
121
|
+
puts "Test user already exists"
|
122
|
+
else
|
123
|
+
User.create(
|
124
|
+
email: "lorem_sec@ipsum.com", username: "lorem_sec", password: "password", password_confirmation: "password"
|
125
|
+
)
|
126
|
+
puts "Test user created"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if Rails.env.development?
|
131
|
+
dev_seed_exec
|
132
|
+
else
|
133
|
+
seed_exec
|
134
|
+
end
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
version: "3.3"
|
2
|
+
services:
|
3
|
+
redis:
|
4
|
+
image: redis:6.0.9-alpine
|
5
|
+
restart: always
|
6
|
+
ports:
|
7
|
+
- 6379:6379
|
8
|
+
volumes:
|
9
|
+
- ./data:/data
|
10
|
+
command: redis-server
|
11
|
+
db:
|
12
|
+
image: postgres
|
13
|
+
ports:
|
14
|
+
- "5432:5432"
|
15
|
+
volumes:
|
16
|
+
- ./tmp/db:/var/lib/postgresql/data
|
17
|
+
environment:
|
18
|
+
POSTGRES_PASSWORD: secret
|
19
|
+
web:
|
20
|
+
build: .
|
21
|
+
command: bash -c "rm -f tmp/pids/server.pid && foreman start -f Procfile.dev"
|
22
|
+
volumes:
|
23
|
+
- .:/myapp
|
24
|
+
ports:
|
25
|
+
- "80:80"
|
26
|
+
depends_on:
|
27
|
+
- redis
|
28
|
+
- db
|
29
|
+
- sidekiq
|
30
|
+
- chrome
|
31
|
+
env_file:
|
32
|
+
- .env
|
33
|
+
sidekiq:
|
34
|
+
build: .
|
35
|
+
command: bundle exec sidekiq -C config/sidekiq.yml
|
36
|
+
volumes:
|
37
|
+
- .:/myapp
|
38
|
+
depends_on:
|
39
|
+
- redis
|
40
|
+
- db
|
41
|
+
env_file:
|
42
|
+
- .env
|
43
|
+
chrome:
|
44
|
+
image: selenium/standalone-chrome
|
45
|
+
ports:
|
46
|
+
- "4444:4444"
|
47
|
+
depends_on:
|
48
|
+
- sidekiq
|
49
|
+
volumes:
|
50
|
+
- /dev/shm:/dev/shm
|
51
|
+
volumes:
|
52
|
+
redis:
|
53
|
+
postgres:
|
data/entrypoint.sh
ADDED
data/lib/assets/.keep
ADDED
File without changes
|