Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed May 13, 2024
0 parents commit 214e353
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/statescan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Statescan
on:
push:
branches: [main]

jobs:
build-backend-image:
name: Build Backend Image
runs-on: ubuntu-latest
steps:
- name: Checkout Statescan
uses: actions/checkout@v4
with:
repository: opensquare-network/statescan-v2
ref: release-1.4.0
fetch-depth: 1
path: statescan-v2
- name: Checkout
uses: actions/checkout@v4
with:
clean: false
fetch-depth: 1
sparse-checkout: |
statescan
path: kreivo-platform
- name: Merge directories
run: rsync --recursive kreivo-platform/statescan/ statescan-v2/
- name: Verify checkout
run: ls -la statescan-v2/backend
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: statescan-v2/backend
push: true
tags: ghcr.io/virto-network/kreivo-statescan-backend:${{ github.sha }},ghcr.io/virto-network/kreivo-statescan-backend:latest
build-site-image:
name: Build Site Image
runs-on: ubuntu-latest
steps:
- name: Checkout Statescan
uses: actions/checkout@v4
with:
repository: opensquare-network/statescan-v2
ref: release-1.4.0
fetch-depth: 1
path: statescan-v2
- name: Checkout
uses: actions/checkout@v4
with:
clean: false
fetch-depth: 1
sparse-checkout: |
statescan
path: kreivo-platform
- name: Merge directories
run: rsync --recursive kreivo-platform/statescan/ statescan-v2/
- name: Verify checkout
run: ls -la statescan-v2/site
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: statescan-v2/site
push: true
tags: ghcr.io/virto-network/kreivo-statescan-site:${{ github.sha }},ghcr.io/virto-network/kreivo-statescan-site:latest
8 changes: 8 additions & 0 deletions statescan/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.github
.husky
.vscode
node_modules

.env
.env.example
*.md
1 change: 1 addition & 0 deletions statescan/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mongo-data
13 changes: 13 additions & 0 deletions statescan/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:22-alpine3.18

RUN mkdir -p /usr/statescan
WORKDIR /usr/statescan

COPY package.json yarn.lock /usr/statescan/
COPY packages/ /usr/statescan/packages/

RUN yarn install

WORKDIR /usr/statescan/packages

CMD ["node", "src/index.js"]
73 changes: 73 additions & 0 deletions statescan/backend/packages/server/src/utils/consts/chains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const chains = Object.freeze({
polkadot: "polkadot",
kusama: "kusama",
statemine: "statemine",
statemint: "statemint",
westmint: "westmint",
litentry: "litentry",
litmus: "litmus",
"westend-collectives": "westend-collectives",
collectives: "collectives",
"hydradx-testnet": "hydradx-testnet",
polimec: "polimec",
shadow: "shadow",
gargantua: "gargantua",
"polkadot-crust-parachain": "polkadot-crust-parachain",
tangle: "tangle",
"tangle-testnet": "tangle-testnet",
heiko: "heiko",
parallel: "parallel",
crust: "crust",
invarch: "invarch",
tinkernet: "tinkernet",
subsocial: "kreivo",
});

const ss58Format = Object.freeze({
[chains.polkadot]: 0,
[chains.kusama]: 2,
[chains.statemine]: 2,
[chains.statemint]: 0,
[chains.westmint]: 42,
[chains.litentry]: 31,
[chains.litmus]: 131,
[chains.collectives]: 0,
[chains["westend-collectives"]]: 0,
[chains["hydradx-testnet"]]: 63,
[chains.polimec]: 41,
[chains.shadow]: 66,
[chains.gargantua]: 42,
[chains["polkadot-crust-parachain"]]: 88,
[chains.tangle]: 5845,
[chains["tangle-testnet"]]: 42,
[chains.heiko]: 110,
[chains.parallel]: 172,
[chains.crust]: 66,
[chains.invarch]: 117,
[chains.tinkernet]: 117,
[chains.kreivo]: 2,
});

function getSs58Format(chain) {
return ss58Format[chain];
}

const assetsModuleChains = [
chains.statemint,
chains.statemine,
chains.westmint,
chains.parallel,
];

const uniquesModuleChains = [
chains.statemint,
chains.statemine,
chains.westmint,
];

module.exports = {
chains,
assetsModuleChains,
uniquesModuleChains,
getSs58Format,
};
109 changes: 109 additions & 0 deletions statescan/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
version: '3.7'

x-common-arguments: &common-arguments
REACT_APP_PUBLIC_API_END_POINT: https://api-explorer.kreivo.io/
REACT_APP_PUBLIC_SIMPLE_MODE: "true"

x-common-variables: &common-variables
MONGO_ACCOUNT_SCAN_URL: mongodb://mongodb:27017
MONGO_ACCOUNT_SCAN_NAME: statescan-kreivo-account
MONGO_ASSET_SCAN_URL: mongodb://mongodb:27017
MONGO_ASSET_SCAN_NAME: statescan-kreivo-asset
MONGO_BLOCK_SCAN_URL: mongodb://mongodb:27017
MONGO_BLOCK_SCAN_NAME: statescan-kreivo-block
MONGO_META_URL: mongodb://mongodb:27017
MONGO_DB_META_NAME: meta-kreivo
MONGO_RUNTIME_SCAN_URL: mongodb://mongodb:27017
MONGO_RUNTIME_SCAN_NAME: statescan-kreivo-runtime
MONGO_UNIQUES_SCAN_URL: mongodb://mongodb:27017
MONGO_UNIQUES_SCAN_NAME: prod-statescan-kreivo-uniques
MONGO_DB_KNOWN_HEIGHTS_URL: mongodb://mongodb:27017
CHAIN: kreivo
WS_ENDPOINT: wss://kreivo.io/
USE_META: 1
SIMPLE_MODE: 1
LOG_LEVEL: info
NODE_ENV: production

services:
mongodb:
image: mongo:4.4.18 #image: mongodb/mongodb-community-server:6.0-ubi8
container_name: statescan-mongo
restart: always
ports:
- "127.0.0.1:27100:27017"
volumes:
- ./mongo-data:/data/db

account-scan:
image: ghrc.io/virto-network/kreivo-statescan-backend
command: ["node", "account-scan/src/index.js"]
container_name: account-scan
restart: always
environment:
<<: *common-variables
SCAN_STEP: 500

asset-scan:
image: ghrc.io/virto-network/kreivo-statescan-backend
command: [ "node", "asset-scan/src/index.js" ]
container_name: asset-scan
restart: always
environment:
<<: *common-variables
USE_KNOWN_HEIGHTS: 0
MONGO_DB_KNOWN_HEIGHTS_NAME: known-heights-statescan-kreivo-asset
FOLLOW_BLOCK_SCAN: "true"
SCAN_STEP: 500

block-scan:
image: ghrc.io/virto-network/kreivo-statescan-backend
command: ["node", "block-scan/src/index.js"]
container_name: block-scan
restart: always
environment:
<<: *common-variables
SCAN_STEP: 500

runtime-scan:
image: ghrc.io/virto-network/kreivo-statescan-backend
command: ["node", "runtime-scan/src/index.js"]
container_name: runtime-scan
restart: always
environment:
<<: *common-variables
SCAN_STEP: 500

rest-api:
image: ghrc.io/virto-network/kreivo-statescan-backend
command: ["node", "server/src/index.js"]
container_name: rest-api
restart: always
ports:
- "127.0.0.1:5010:5010"
environment:
<<: *common-variables
PORT: 5010
VIRTUAL_HOST: api-explorer.kreivo.io
VIRTUAL_PORT: 5010
VIRTUAL_PATH: /
LETSENCRYPT_HOST: api-explorer.kreivo.io
LETSENCRYPT_EMAIL: [email protected]

web-app:
image: ghrc.io/virto-network/kreivo-statescan-site
environment:
VIRTUAL_HOST: explorer.kreivo.io
VIRTUAL_PORT: 3000
VIRTUAL_PATH: /
LETSENCRYPT_HOST: explorer.kreivo.io
LETSENCRYPT_EMAIL: [email protected]
container_name: web-app
restart: always
ports:
- "127.0.0.1:3000:3000"

networks:
default:
name: net-explorer
external: true
31 changes: 31 additions & 0 deletions statescan/site/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM node:20-alpine3.18 as builder

WORKDIR /usr/app

COPY package.json yarn.lock .eslintrc.cjs .yarnrc.yml /usr/app/
COPY .yarn/ /usr/app/.yarn/

RUN yarn install

ARG REACT_APP_PUBLIC_API_END_POINT
ARG REACT_APP_PUBLIC_SIMPLE_MODE

ENV REACT_APP_PUBLIC_API_END_POINT $REACT_APP_PUBLIC_API_END_POINT
ENV REACT_APP_PUBLIC_SIMPLE_MODE $REACT_APP_PUBLIC_SIMPLE_MODE
ENV REACT_APP_PUBLIC_CHAIN kreivo
ENV REACT_APP_DEFAULT_IPFS_GATEWAY https://cloudflare-ipfs.com/ipfs/

COPY public/ /usr/app/public/
COPY src/ /usr/app/src/

RUN yarn build

FROM node:20-alpine3.18

WORKDIR /usr/statescan
RUN npm i -g serve

COPY --from=builder /usr/app/node_modules/ /usr/statescan/node_modules/
COPY --from=builder /usr/app/build/ /usr/statescan/app/

CMD ["serve", "-s", "app"]
43 changes: 43 additions & 0 deletions statescan/site/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Explorer for Kreivo" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Kreivo Explorer</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</html>
13 changes: 13 additions & 0 deletions statescan/site/src/components/icons/kreivo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 214e353

Please sign in to comment.