Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'front-end-corrections' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusGautamah committed Jan 28, 2023
2 parents e48f9b5 + 3f7c034 commit 737e9fa
Show file tree
Hide file tree
Showing 49 changed files with 450 additions and 809 deletions.
3 changes: 2 additions & 1 deletion .env_sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX
FIRESTORE_PROJECT_ID=YOUR_FIRESTORE_PROJECT_ID
FIRESTORE_KEY_FILE=YOUR_FIRESTORE_KEY_FILE
FIRESTORE_KEY_FILE_PATH=YOUR_FIRESTORE_KEY_FILE_PATH

POSTGRES_USER=YOUR_POSTGRES_USER
POSTGRES_PASSWORD=YOUR_POSTGRES_PASSWORD
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@
osbc-*.gem
.env
/.env
/.env.*
/.env.*
/mining_concept.ipynb
/mining_concept.ipynb_checkpoints
/hyperminer.py
68 changes: 50 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# <img src="https://osbc-blockchain.herokuapp.com/assets/logo-70825bc795d25668cf4f11b06b990ed0d1c2cae887acce0625e5059226a7946a.png" width="25" height="25"> Outerspace Blockchain
<!-- Outerspace Logo -->
## What is Outerspace Blockchain?
### A Ruby implementation of web blockchain framework.
Outerspace Blockchain is a blockchain framework that allows you to create your own blockchain in a few minutes with this backend server.
This application has the intention to be a blockchain framework that can be used to create a blockchain with a web interface and a mobile wallet.
Utility Tokens and NFT's will be supported native in this blockchain framework.
This blockchain framework will be used to create a blockchain for the Outerspace Coding projects in the future.

This blockchain works with a different approach than the other blockchains.
Use it to work with less complexity and more flexibility.
Perfect for small/medium projects that need a blockchain and can't use Ethereum Network or other blockchains.

Remember always to verify your enviroment variables and do security modifications like changing the default passwords, increasing the security of the database, etc.

### This application is instable and under development.
### This application is unstable and under development.
### Please, use it with caution and at your own risk.
### A Ruby implementation of web blockchain framework.
### Demo version:
https://osbc.outerspacecoding.com

### Demo staging version:
https://blockchain-staging.outerspacecoding.com

#### Developed using TDD (Test Driven Development).
#### Github Actions CI/CD pipeline.
#### Firestore is used to store the blockchain.
#### Firestore will be used to store the blockchain data.

#### Simplecov is used to test code coverage.

Expand All @@ -15,14 +32,20 @@

#### Rspec is used to test the blockchain.

## Build Version: 0.2.0
## Build Version: 0.2.1

## Todo
* [ ] Firebase integration (this will be use instead of Redis management)
## In Progress
* [ ] Add and correct tests
* [ ] Add and correct documentation
* [ ] Better layout for the blockchain web interface
* [ ] Add and correct documentation, create api documentation page
## Todo
* [ ] Simplify SMTP configuration
* [ ] Create a template for the user registration email
* [ ] Create blockchain report mailer to admin
* [ ] Create blockchain monitor board to admin
* [ ] Firestore integration (this will be used instead of Redis management)
* [ ] Add user verification methods
* [ ] Better mobile layout
* [ ] Increase environment variables for easily setup custom information for the blockchain
* [ ] Create the price visualization and the price history api
* [ ] Add more blockchain features
* [ ] Add more blockchain tests
Expand All @@ -31,23 +54,23 @@
* [ ] Add nft's modularization class
* [ ] Add nft's generator class
* [ ] Benchmark blockchain and mining
* [ ] Create a blockchain explorer
* [ ] Create a blockchain dinamic explorer
* [ ] Create a default blockchain wallet android app generator with flutter
* [ ] Create generators that will work with rails and flutter at the same time
* [ ] Create the user marketplace
* [ ] Integrate Blockchain Api in other projects

Kubernets integration will be worked on in the future.

Kubernetes integration will be worked on in the future.
Appwrite integration will be worked on in the future.
## System dependencies
1. Docker
2. Postgresql
3. Ruby
4. Redis

* Ruby 3.0.3
* Ruby 3.2
* Compose Version 3.3
* Docker Image: ruby:3.0.3
* Docker Image: ruby:3.2

* [Installation](#installation)
- [Docker](#docker) https://docs.docker.com/engine/install/
Expand All @@ -56,7 +79,7 @@ Kubernets integration will be worked on in the future.
- [Postgres](#postgres) https://www.postgresql.org/download/
- [Rails](#rails) https://guides.rubyonrails.org/getting_started.html

### Install it from RubyGems (Ruby 3.0.3)
### Install it from RubyGems (Ruby 3.2)
```bash
gem install osbc
```
Expand Down Expand Up @@ -95,9 +118,9 @@ Use the gem with the following command:
```bash
osbc PATH_TO_GENERATE_BLOCKCHAIN
```
## RVM Commands to install Ruby 3.0.3 and Compile the Gem
* `rvm install 3.0.3`
* `rvm use 3.0.3`
## RVM Commands to install Ruby 3.2
* `rvm install 3.2`
* `rvm use 3.2`
* `rvm gemset create outerspace`
* `rvm gemset use outerspace`
* `gem install bundler`
Expand Down Expand Up @@ -213,6 +236,15 @@ The timestamps of the signatures will be usefull to version the block, checking
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/JesusGautamah/outerspace-blockchain

## [![Repography logo](https://images.repography.com/logo.svg)](https://repography.com) Recent activity
[![Time period](https://images.repography.com/33522702/JesusGautamah/outerspace-blockchain/recent-activity/0yzGOYYHXYK_C0-EPT33h2yxMGPjAfT8cxuHq8Ukjrg/Zuq9y_QVJvoZeqCjzE6_J-roxfVO_FF0P0SDhZ9Yo6Y_badge.svg)](https://repography.com)

[![Timeline graph](https://images.repography.com/33522702/JesusGautamah/outerspace-blockchain/recent-activity/0yzGOYYHXYK_C0-EPT33h2yxMGPjAfT8cxuHq8Ukjrg/Zuq9y_QVJvoZeqCjzE6_J-roxfVO_FF0P0SDhZ9Yo6Y_timeline.svg)](https://github.com/JesusGautamah/outerspace-blockchain/commits)
[![Issue status graph](https://images.repography.com/33522702/JesusGautamah/outerspace-blockchain/recent-activity/0yzGOYYHXYK_C0-EPT33h2yxMGPjAfT8cxuHq8Ukjrg/Zuq9y_QVJvoZeqCjzE6_J-roxfVO_FF0P0SDhZ9Yo6Y_issues.svg)](https://github.com/JesusGautamah/outerspace-blockchain/issues)

[![Pull request status graph](https://images.repography.com/33522702/JesusGautamah/outerspace-blockchain/recent-activity/0yzGOYYHXYK_C0-EPT33h2yxMGPjAfT8cxuHq8Ukjrg/Zuq9y_QVJvoZeqCjzE6_J-roxfVO_FF0P0SDhZ9Yo6Y_prs.svg)](https://github.com/JesusGautamah/outerspace-blockchain/pulls)
[![Top contributors](https://images.repography.com/33522702/JesusGautamah/outerspace-blockchain/recent-activity/0yzGOYYHXYK_C0-EPT33h2yxMGPjAfT8cxuHq8Ukjrg/Zuq9y_QVJvoZeqCjzE6_J-roxfVO_FF0P0SDhZ9Yo6Y_users.svg)](https://github.com/JesusGautamah/outerspace-blockchain/graphs/contributors)

## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
* [LICENSE](LICENSE) - MIT License
* [LICENSE](LICENSE) - MIT License
1 change: 1 addition & 0 deletions app/controllers/api/v1/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def current_pool
end

def ticket
return nil unless user.present?
@ticket = Ticket.find_by(user_id: user.id, status: :active)
end

Expand Down
71 changes: 1 addition & 70 deletions app/controllers/chains_controller.rb
Original file line number Diff line number Diff line change
@@ -1,72 +1,3 @@
# frozen_string_literal: true

class ChainsController < ApplicationController
before_action :set_chain, only: %i[ show edit update destroy ]

# GET /chains or /chains.json
def index
@chains = Chain.all
end

# GET /chains/1 or /chains/1.json
def show
end

# GET /chains/new
def new
@chain = Chain.new
end

# GET /chains/1/edit
def edit
end

# POST /chains or /chains.json
def create
@chain = Chain.new(chain_params)

respond_to do |format|
if @chain.save
format.html { redirect_to chain_url(@chain), notice: "Chain was successfully created." }
format.json { render :show, status: :created, location: @chain }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @chain.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /chains/1 or /chains/1.json
def update
respond_to do |format|
if @chain.update(chain_params)
format.html { redirect_to chain_url(@chain), notice: "Chain was successfully updated." }
format.json { render :show, status: :ok, location: @chain }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @chain.errors, status: :unprocessable_entity }
end
end
end

# DELETE /chains/1 or /chains/1.json
def destroy
@chain.destroy

respond_to do |format|
format.html { redirect_to chains_url, notice: "Chain was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_chain
@chain = Chain.find(params[:id])
end

# Only allow a list of trusted parameters through.
def chain_params
params.require(:chain).permit(:name, :blocks_count, :maintainer, :chain_version, :description)
end
end
class ChainsController < ApplicationController; end
19 changes: 1 addition & 18 deletions app/controllers/signatures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# frozen_string_literal: true

class SignaturesController < ApplicationController
before_action :set_signature, only: %i[ show edit update destroy ]

# GET /signatures or /signatures.json
def index
@signatures = Signature.all
end

# GET /signatures/1 or /signatures/1.json
def show
end

private
# Use callbacks to share common setup or constraints between actions.
def set_signature
@signature = Signature.find(params[:id])
end
end
class SignaturesController < ApplicationController; end
10 changes: 10 additions & 0 deletions app/controllers/tickets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ def new
# POST /tickets or /tickets.json
def create
return no_transactions_response if block_transactions.empty?
return you_already_have_a_ticket_in_this_pool if user_ticket_on_this_pool?
create_ticket
redirect_to tickets_path, notice: "Processing ticket, please wait, wait a minute and refresh the page"
end

private

def user_ticket_on_this_pool?
current_user.tickets.where(status: 'active').any?
end

def you_already_have_a_ticket_in_this_pool
redirect_to root_path, notice: "You already have a ticket in this pool"
end

def create_ticket
CreateTicketWorker.perform_async(current_user.id, current_pool.id, time_ref)
end
Expand Down
1 change: 1 addition & 0 deletions app/javascript/controllers/hello_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
console.log("Hello World!")
}
}
30 changes: 0 additions & 30 deletions app/models/concerns/sequences_validator.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class Contract < ApplicationRecord
validates :blk_transaction, presence: true
belongs_to :blk_transaction, class_name: "Transaction", foreign_key: "transaction_id", inverse_of: :contract
has_many :signatures, inverse_of: :contract, dependent: :destroy

def confirmed
signatures_count == ENV["SIGNATURES_LIMIT"].to_i
end
end
3 changes: 3 additions & 0 deletions app/services/application_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class ApplicationService
private
attr_reader :user_id, :wallet_id, :wallet_key, :wallet_method

def dev_error(e)
if env_acceptable?
puts "#{e.class}: #{e.message}"
Expand All @@ -10,6 +12,7 @@ def dev_error(e)
end

def user_exists?
return false unless user_id
User.find_by(id: user_id).present?
end

Expand Down
7 changes: 0 additions & 7 deletions app/services/create_ticket_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,14 @@ def generate_transaction_id_list
end

def shuffled_string
puts "Word: #{word}"
puts "Number sequence: #{number_sequence}"
puts "Symbol sequence: #{symbol_sequence}"
string_sum = (word + number_sequence + symbol_sequence).split("").shuffle.join
puts "Shuffled string: #{string_sum}"
string_sum
end

def generate_user_acceptable_hash
hash = Digest::SHA256.hexdigest(shuffled_string)
puts "Hash: #{hash}"
block_hash = Digest::SHA256.hexdigest(@transactions.to_json)
puts "Block hash: #{block_hash}"
master_hash = Digest::SHA256.hexdigest(hash + block_hash)
puts "Master hash: #{master_hash}"
[hash, block_hash, master_hash]
end

Expand Down
Loading

0 comments on commit 737e9fa

Please sign in to comment.