diff --git a/.github/workflows/statescan.yml b/.github/workflows/statescan.yml new file mode 100644 index 0000000..df88d3b --- /dev/null +++ b/.github/workflows/statescan.yml @@ -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.actor }} + 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 }} + 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.actor }} + 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 }} diff --git a/statescan/.dockerignore b/statescan/.dockerignore new file mode 100644 index 0000000..f937f12 --- /dev/null +++ b/statescan/.dockerignore @@ -0,0 +1,8 @@ +.github +.husky +.vscode +node_modules + +.env +.env.example +*.md \ No newline at end of file diff --git a/statescan/.gitignore b/statescan/.gitignore new file mode 100644 index 0000000..f19d72b --- /dev/null +++ b/statescan/.gitignore @@ -0,0 +1 @@ +mongo-data \ No newline at end of file diff --git a/statescan/backend/Dockerfile b/statescan/backend/Dockerfile new file mode 100644 index 0000000..03d1253 --- /dev/null +++ b/statescan/backend/Dockerfile @@ -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"] diff --git a/statescan/backend/packages/server/src/utils/consts/chains.js b/statescan/backend/packages/server/src/utils/consts/chains.js new file mode 100644 index 0000000..0b833a3 --- /dev/null +++ b/statescan/backend/packages/server/src/utils/consts/chains.js @@ -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, +}; \ No newline at end of file diff --git a/statescan/docker-compose.yml b/statescan/docker-compose.yml new file mode 100644 index 0000000..5402f06 --- /dev/null +++ b/statescan/docker-compose.yml @@ -0,0 +1,120 @@ +version: '3.7' + +x-common-arguments: &common-arguments + REACT_APP_PUBLIC_API_END_POINT: https://api-explorer.subsocial.network/ + REACT_APP_PUBLIC_SIMPLE_MODE: "true" + +x-common-variables: &common-variables + MONGO_DB_META_NAME: meta-subsocial + MONGO_META_URL: mongodb://mongodb:27017 + MONGO_BLOCK_SCAN_URL: mongodb://mongodb:27017 + MONGO_ACCOUNT_SCAN_URL: mongodb://mongodb:27017 + MONGO_RUNTIME_SCAN_URL: mongodb://mongodb:27017 + MONGO_ASSET_SCAN_URL: mongodb://mongodb:27017 + MONGO_UNIQUES_SCAN_URL: mongodb://mongodb:27017 + MONGO_DB_KNOWN_HEIGHTS_URL: mongodb://mongodb:27017 + MONGO_BLOCK_SCAN_NAME: statescan-subsocial-block + MONGO_ACCOUNT_SCAN_NAME: statescan-subsocial-account + MONGO_RUNTIME_SCAN_NAME: statescan-subsocial-runtime + MONGO_ASSET_SCAN_NAME: statescan-subsocial-asset + MONGO_UNIQUES_SCAN_NAME: prod-statescan-subsocial-uniques + CHAIN: subsocial + WS_ENDPOINT: wss://para.f3joule.space + 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: dappforce/statescan-subsocial:backend + command: ["node", "account-scan/src/index.js"] + build: + context: backend + dockerfile: Dockerfile + container_name: account-scan + restart: always + environment: + <<: *common-variables + SCAN_STEP: 500 + + asset-scan: + image: dappforce/statescan-subsocial:backend + command: [ "node", "asset-scan/src/index.js" ] + build: + context: backend + dockerfile: Dockerfile + container_name: asset-scan + restart: always + environment: + <<: *common-variables + USE_KNOWN_HEIGHTS: 0 + MONGO_DB_KNOWN_HEIGHTS_NAME: known-heights-statescan-subsocial-asset + FOLLOW_BLOCK_SCAN: "true" + SCAN_STEP: 500 + + block-scan: + image: dappforce/statescan-subsocial:backend + command: ["node", "block-scan/src/index.js"] + container_name: block-scan + restart: always + environment: + <<: *common-variables + SCAN_STEP: 500 + + runtime-scan: + image: dappforce/statescan-subsocial:backend + command: ["node", "runtime-scan/src/index.js"] + container_name: runtime-scan + restart: always + environment: + <<: *common-variables + SCAN_STEP: 500 + + rest-api: + image: dappforce/statescan-subsocial: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.subsocial.network + VIRTUAL_PORT: 5010 + VIRTUAL_PATH: / + LETSENCRYPT_HOST: api-explorer.subsocial.network + LETSENCRYPT_EMAIL: dummyemails@sub.id + + web-app: + image: dappforce/statescan-subsocial:web-app + build: + context: site + dockerfile: Dockerfile + args: + <<: *common-arguments + environment: + VIRTUAL_HOST: explorer.subsocial.network + VIRTUAL_PORT: 3000 + VIRTUAL_PATH: / + LETSENCRYPT_HOST: explorer.subsocial.network + LETSENCRYPT_EMAIL: dummyemails@sub.id + container_name: web-app + restart: always + ports: + - "127.0.0.1:3000:3000" + +networks: + default: + name: net-explorer + external: true diff --git a/statescan/site/Dockerfile b/statescan/site/Dockerfile new file mode 100644 index 0000000..ce7d55e --- /dev/null +++ b/statescan/site/Dockerfile @@ -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"] diff --git a/statescan/site/public/index.html b/statescan/site/public/index.html new file mode 100644 index 0000000..07abf9b --- /dev/null +++ b/statescan/site/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + Kreivo Explorer + + + + +
+ + + + \ No newline at end of file diff --git a/statescan/site/src/components/icons/kreivo.svg b/statescan/site/src/components/icons/kreivo.svg new file mode 100644 index 0000000..f229be1 --- /dev/null +++ b/statescan/site/src/components/icons/kreivo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/statescan/site/src/utils/consts/chains/index.js b/statescan/site/src/utils/consts/chains/index.js new file mode 100644 index 0000000..6f6b3c0 --- /dev/null +++ b/statescan/site/src/utils/consts/chains/index.js @@ -0,0 +1,47 @@ +import litentry from "./litentry"; +import statemine from "./statemine"; +import statemint from "./statemint"; +import westmint from "./westmint"; +import litmus from "./litmus"; +import westendCollectives from "./westendCollectives"; +import collectives from "./collectives"; +import kusama from "./kusama"; +import polkadot from "./polkadot"; +import shadow from "./shadow"; +import gargantua from "./gargantua"; +import polkadotCrustParachain from "./polkadotCrust"; +import tangleTestnet from "./tangleTestnet"; +import tangle from "./tangle"; +import parallel from "./parallel"; +import heiko from "./heiko"; +import crust from "./crust"; +import invarch from "./invarch"; +import tinkernet from "./tinkernet"; +import kreivo from "./kreivo"; + +const chains = { + kusama, + polkadot, + litentry, + litmus, + statemine, + statemint, + westmint, + "westend-collectives": westendCollectives, + collectives, + // "hydradx-testnet": hydradxTestnet, + // polimec, + shadow, + gargantua, + "polkadot-crust-parachain": polkadotCrustParachain, + crust, + "tangle-testnet": tangleTestnet, + invarch, + parallel, + heiko, + tangle, + tinkernet, + kreivo, +}; + +export default chains; \ No newline at end of file diff --git a/statescan/site/src/utils/consts/chains/kreivo.js b/statescan/site/src/utils/consts/chains/kreivo.js new file mode 100644 index 0000000..2a96087 --- /dev/null +++ b/statescan/site/src/utils/consts/chains/kreivo.js @@ -0,0 +1,40 @@ +import { ReactComponent as Kreivo } from "../../../components/icons/kreivo.svg"; + +const nodes = [ + { + name: "Kreivo", + url: "wss://kreivo.io/", + }, + { + name: "Kippu", + url: "wss://kreivo.kippu.rocks/", + }, +]; + +const modules = { + identity: false, + assets: true, + uniques: true, +}; + +const kreivo = { + name: "Kreivo", + icon: , + identity: "kusama", + sub: "kusama", + value: "kreivo", + chain: "kusama", + symbol: "KSM", + decimals: 12, + color: "#294940", + colorSecondary: "#9063cd", + para: { + relay: "Kusama", + id: "2081", + }, + nodes, + modules, + useOnChainBlockData: true, +}; + +export default kreivo; \ No newline at end of file