Skip to content

Cerebellum-Network/cerestats

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cerestats

Cerestats is a block explorer for Cere Network.

Check it out live versions at Cerestats

Dependencies

In Ubuntu 20.04 server you can do:

apt update
apt upgrade
apt install libpq5=12.9-0ubuntu0.20.04.1
apt install git build-essential apt-transport-https ca-certificates curl software-properties-common libpq-dev

In macOS, you can do:

brew install postgresql libpq
export PATH="/opt/homebrew/opt/libpq/bin:$PATH" 

docker

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt update
apt install docker-ce

docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

node v14

curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt install nodejs

yarn

npm install --global yarn

Install

Install mono-repo:

git clone https://github.com/Cerebellum-Network/cerestats.git
cd cerestats
yarn

Backend

Before build dockers be sure to edit HASURA_GRAPHQL_ADMIN_SECRET environmment variable in the proper docker-compose file backend/docker/docker-compose-cere-mainnet.yml.

Cere Network:

yarn workspace backend docker:cere:mainnet

If you are experiencing a database doesn't exist error then clean docker volumes:

docker volume prune

That will build and start all the required dockers:

  • PostgreSQL
  • Hasura GraphQL server
  • Nodejs crawler
  • Nodejs API

Crawlers healthchecks API is available via GET/health request.

Hasura configuration

After that you need to access to Hasura console at http://localhost:8082 and:

  • Login as admin using the password you previously set in HASURA_GRAPHQL_ADMIN_SECRET
  • Track all tables
  • For all tables go to Permissions and:
    • Add a new ROLE named 'public' with SELECT permissions.
    • Enable aggregate permissions.

Frontend

Start a dev frontend with hot reload at http://localhost:3000

yarn workspace frontend dev

Generate a static build under frontend/dist directory:

yarn workspace frontend generate

Database migrations

db-migrate tool used to apply data migrations. More details you can find here: https://db-migrate.readthedocs.io/en/latest/

Install

npm install -g db-migrate

Create migration

yarn workspace backend db:migrate:create MIGRATION_NAME

In *-up.sql should be database updates you want to apply (via db-migrate up command) and in *-down.sql should be updates rollback that can be executed in case migration is incorrect (via db-migrate down command)

Note: *-down.sql is required.

All migrations must be listed in changelog and include description about compatibility with previous version of the code. Example:

Added migration #1 (compatible with the previous code version)

or

Added migration #1 (incompatible with the previous code version)

Apply migrations

yarn workspace backend db:migrate:up -e ENV

Rollback migrations

yarn workspace backend db:migrate:down -e ENV

Packages

No packages published

Languages

  • Vue 61.8%
  • JavaScript 32.6%
  • PLpgSQL 2.9%
  • SCSS 2.2%
  • Other 0.5%