diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..e52cbf5d --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,31 @@ +name: Build and Push Docker Image + +on: + workflow_dispatch: +# on: +# push: +# tags: +# - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker Image + run: | + docker build -t ghcr.io/${{ github.repository }}:${{ github.ref_name }} . + + - name: Push Docker Image to GitHub Container Registry + run: | + docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dafbe86a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Node.js +FROM node:20 + +# Work directory +WORKDIR /app + +# Install pnpm +RUN npm install -g pnpm + +# Copy package.json, pnpm-lock.yaml to workdir +COPY package.json pnpm-lock.yaml ./ + +# Install dependencies +RUN pnpm install + +# Copy the project +COPY . . + +# Build app +RUN pnpm run build + +# Run app +CMD ["pnpm", "run", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 98c5aa5b..ca9a464f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Clone the repository and run on the root folder: pnpm i pnpm dev ``` - ### Node.js Server When running `nuxt build` with the Node server preset, the result will be an entry point that launches a ready-to-run Node server. @@ -41,3 +40,57 @@ module.exports = { Also, you can use different [presets](https://nuxt.com/docs/getting-started/deployment#hosting-providers). E.g. **Cloudflare Pages**: `cloudflare_pages`. Note, some providers do not support server-side rendering. + +--- + +### Docker Setup + +You can also run the application in Docker. +Build the image and run the container: +``` +docker build -t celenium-app +docker run -p 3000:3000 --env-file .env celenium-app +``` +Make sure to create a ```.env``` file in the root directory or pass the required environment variables directly with ```-e```. + +### Run with Docker Compose +Start with: +``` +docker-compose up -d +``` + +By default: +- Builds the image from the local `Dockerfile` +- Runs the app on `127.0.0.1:3000` +- Automatically restarts the container on failure +- Uses `npm run start` as the startup command +- Limits logs (10 MB per file, max 5 files) + +If you want to use a prebuilt image from **GitHub Container Registry**, specify a tag: +- `TAG=latest docker-compose up -d` + +--- + +### Environment Variables + +#### Required for App Startup +- **NUXT_PUBLIC_API_DEV** — indexer API (e.g. `https://api.localhost:9876/v1`). +- **NUXT_PUBLIC_WSS_DEV** — webSocket endpoint (e.g. `wss://api.localhost:9876/v1/ws`). +- **NUXT_PUBLIC_SELFHOSTED** — set to `true` when running in self-hosted mode. + +#### Blobstream Configuration +- **NUXT_PUBLIC_BLOBSTREAM_MAINNET** — API for blobstream data. + +#### Faucet Configuration +- **NUXT_PUBLIC_FAUCET_ADDRESS** — faucet address. +- **NUXT_PUBLIC_FAUCET_MOCHA** — faucet API for the Mocha network. +- **NUXT_PUBLIC_FAUCET_ARABICA** — faucet API for the Arabica network. +- **NUXT_PUBLIC_FAUCET_MAMMOTH** — faucet API for the Mammoth network. + +#### External Services Configuration +- **NUXT_PUBLIC_BLOCKSCOUT** — used to check whether a batch exists in Blockscout. If found, a dedicated button will appear on the blob form/page. +- **NUXT_PUBLIC_NODE_STATS** — provides statistics about node types, versions, and geographic distribution across the Celestia ecosystem. +- **NUXT_PUBLIC_QUOTE** — provides price data. It is used to display the current TIA price in the header and to convert all values from TIA to USD. +- **NUXT_PUBLIC_ROLLUP_RANKING** — fetches rollup ranking data displayed on the rollup leaderboard, individual rollup pages, and a dedicated rollup ranking page. The ranking page also includes detailed calculations, as well as repository and commit statistics. +- **NUXT_PUBLIC_GITHUB** — required for retrieving repository statistics on a rollup ranking page. +- **NUXT_PUBLIC_TVL** — provides TVL (Total Value Locked) statistics for rollups and TVS (Total Value Secured) for the Celestia network. These values are displayed in the header, on the statistics page, and on individual rollup pages. diff --git a/app.vue b/app.vue index e06286b4..695dc095 100644 --- a/app.vue +++ b/app.vue @@ -24,7 +24,6 @@ import { useSettingsStore } from "@/store/settings.store" import { useEnumStore } from "@/store/enums.store" import { useLegalStore } from "@/store/legal.store" import { useNotificationsStore } from "@/store/notifications.store" -import { useActivityStore } from "@/store/activity.store" const nodeStore = useNodeStore() const appStore = useAppStore() const bookmarksStore = useBookmarksStore() @@ -32,7 +31,6 @@ const settingsStore = useSettingsStore() const enumStore = useEnumStore() const legalStore = useLegalStore() const notificationsStore = useNotificationsStore() -const activityStore = useActivityStore() bookmarksStore.$subscribe((mutation, state) => { localStorage.setItem("bookmarks", JSON.stringify(state.bookmarks)) @@ -43,9 +41,6 @@ settingsStore.$subscribe((mutation, state) => { legalStore.$subscribe((mutation, state) => { localStorage.setItem("legal", JSON.stringify(state.legal)) }) -activityStore.$subscribe((mutation, state) => { - localStorage.setItem("rollups_ranking", JSON.stringify(state.rollups_ranking)) -}) appStore.initConstants() @@ -98,8 +93,9 @@ onMounted(async () => { } settingsStore.init() - activityStore.init() + appStore.initGlobalUpdates() + const runtimeConfig = useRuntimeConfig() amp.init(runtimeConfig.public.AMP) diff --git a/assets/icons.json b/assets/icons.json index 421bc45f..5eb53d6b 100644 --- a/assets/icons.json +++ b/assets/icons.json @@ -154,6 +154,7 @@ "clock-forward-2": "M21,10.12H14.22L16.96,7.3C14.23,4.6 9.81,4.5 7.08,7.2C4.35,9.91 4.35,14.28 7.08,17C9.81,19.7 14.23,19.7 16.96,17C18.32,15.65 19,14.08 19,12.1H21C21,14.08 20.12,16.65 18.36,18.39C14.85,21.87 9.15,21.87 5.64,18.39C2.14,14.92 2.11,9.28 5.62,5.81C9.13,2.34 14.76,2.34 18.27,5.81L21,3V10.12M12.5,8V12.25L16,14.33L15.28,15.54L11,13V8H12.5Z", "calendar-date": "M 15 2.001 C 15.476 2.003 15.891 2.013 16.252 2.043 C 16.814 2.089 17.331 2.188 17.816 2.435 C 18.569 2.818 19.181 3.43 19.564 4.183 C 19.811 4.668 19.91 5.185 19.956 5.748 C 20 6.288 20 6.953 20 7.758 L 20 16.242 C 20 17.046 20 17.711 19.956 18.252 C 19.91 18.814 19.811 19.331 19.564 19.816 C 19.181 20.569 18.569 21.181 17.816 21.564 C 17.331 21.811 16.814 21.91 16.251 21.956 C 15.711 22 15.046 22 14.241 22 L 5.758 22 C 4.954 22 4.29 22 3.748 21.956 C 3.186 21.91 2.669 21.811 2.184 21.564 C 1.431 21.181 0.819 20.569 0.436 19.816 C 0.189 19.331 0.09 18.814 0.044 18.251 C 0 17.711 0 17.046 0 16.241 L 0 7.758 C 0 6.954 0 6.29 0.044 5.748 C 0.09 5.186 0.189 4.669 0.436 4.184 C 0.819 3.431 1.431 2.819 2.184 2.436 C 2.669 2.189 3.186 2.09 3.748 2.044 C 4.109 2.015 4.525 2.005 5 2.002 L 5 1 C 5 0.448 5.448 0 6 0 C 6.552 0 7 0.448 7 1 L 7 2 L 13 2 L 13 1 C 13 0.448 13.448 0 14 0 C 14.552 0 15 0.448 15 1 Z M 5 5 L 5 4.002 C 4.554 4.005 4.205 4.014 3.911 4.038 C 3.473 4.073 3.248 4.138 3.092 4.218 C 2.716 4.41 2.41 4.716 2.218 5.092 C 2.138 5.248 2.073 5.472 2.038 5.911 C 2 6.361 2 6.943 2 7.8 L 2 8 L 18 8 L 18 7.8 C 18 6.943 18 6.361 17.962 5.911 C 17.927 5.473 17.862 5.248 17.782 5.092 C 17.59 4.716 17.284 4.41 16.908 4.218 C 16.752 4.138 16.528 4.073 16.089 4.038 C 15.727 4.013 15.363 4.001 15 4.002 L 15 5 C 15 5.552 14.552 6 14 6 C 13.448 6 13 5.552 13 5 L 13 4 L 7 4 L 7 5 C 7 5.552 6.552 6 6 6 C 5.448 6 5 5.552 5 5 Z M 9.445 11.168 L 7.945 12.168 C 7.495 12.467 7.364 13.07 7.649 13.529 C 7.934 13.988 8.533 14.137 9 13.866 L 9 16 L 8.75 16 C 8.198 16 7.75 16.448 7.75 17 C 7.75 17.552 8.198 18 8.75 18 L 11.25 18 C 11.802 18 12.25 17.552 12.25 17 C 12.25 16.448 11.802 16 11.25 16 L 11 16 L 11 12 C 11 11.631 10.797 11.292 10.472 11.118 C 10.147 10.944 9.752 10.963 9.445 11.168 Z", "merge": "M7.04652 9.86171C8.74809 9.4017 10 7.84705 10 6C10 3.79086 8.20914 2 6 2C3.79086 2 2 3.79086 2 6C2 7.86384 3.27477 9.42994 5 9.87398V21C5 21.5523 5.44772 22 6 22C6.55228 22 7 21.5523 7 21V15.0001C7.28228 15.3764 7.59237 15.7345 7.92893 16.0711C9.59483 17.737 11.788 18.7544 14.1162 18.9609C14.5465 20.7059 16.1221 22 18 22C20.2091 22 22 20.2091 22 18C22 15.7909 20.2091 14 18 14C16.153 14 14.5983 15.2519 14.1383 16.9535C12.3334 16.758 10.6389 15.9526 9.34315 14.6569C8.04737 13.3611 7.24201 11.6666 7.04652 9.86171Z", + "node": "M 18 8 C 18 12.032 15 15.434 11 15.938 L 11 16.171 C 11.854 16.474 12.527 17.146 12.83 18 L 19 18 C 19.552 18 20 18.448 20 19 C 20 19.552 19.552 20 19 20 L 12.83 20 C 12.407 21.2 11.272 22.002 10 22.002 C 8.728 22.002 7.593 21.2 7.17 20 L 1 20 C 0.448 20 0 19.552 0 19 C 0 18.448 0.448 18 1 18 L 7.17 18 C 7.473 17.145 8.145 16.473 9 16.17 L 9 15.938 C 4.813 15.405 1.76 11.712 2.025 7.5 C 2.289 3.288 5.78 0.005 10 0 C 14.418 0 18 3.582 18 8 Z M 7.722 13.552 C 6.928 12.151 6.431 10.602 6.263 9 L 4.083 9 C 4.43 11.043 5.805 12.764 7.722 13.552 Z M 15.917 9 L 13.74 9 C 13.571 10.601 13.074 12.15 12.28 13.551 C 14.196 12.763 15.57 11.043 15.917 9 Z M 15.918 7 C 15.571 4.957 14.197 3.238 12.281 2.449 C 13.075 3.85 13.572 5.399 13.74 7 Z M 7.722 2.448 C 5.805 3.236 4.43 4.957 4.083 7 L 6.263 7 C 6.431 5.398 6.928 3.849 7.722 2.448 Z M 10 2.588 C 9.07 3.894 8.478 5.41 8.276 7 L 11.726 7 C 11.524 5.409 10.931 3.894 10.001 2.588 Z M 10.001 13.412 C 10.001 13.412 10.001 13.412 10.001 13.411 C 10 13.412 10 13.412 10 13.412 Z M 10.001 13.411 C 10.931 12.106 11.524 10.59 11.726 9 L 8.276 9 C 8.478 10.59 9.07 12.106 10.001 13.411 Z", "eye": "M 5.077 6.707 C 6.805 5.265 9.138 4 12 4 C 14.862 4 17.195 5.265 18.923 6.707 C 20.649 8.148 21.833 9.814 22.426 10.753 L 22.45 10.791 C 22.568 10.976 22.72 11.217 22.797 11.553 C 22.859 11.848 22.859 12.152 22.797 12.447 C 22.72 12.783 22.567 13.024 22.45 13.209 L 22.426 13.247 C 21.833 14.186 20.649 15.852 18.923 17.293 C 17.195 18.735 14.862 20 12 20 C 9.138 20 6.805 18.735 5.077 17.293 C 3.35 15.852 2.167 14.186 1.574 13.247 L 1.55 13.209 C 1.389 12.978 1.272 12.72 1.203 12.447 C 1.141 12.152 1.141 11.848 1.203 11.553 C 1.28 11.216 1.433 10.976 1.55 10.791 L 1.574 10.753 C 2.167 9.814 3.35 8.148 5.077 6.707 Z M 12 16 C 14.209 16 16 14.209 16 12 C 16 9.791 14.209 8 12 8 C 9.791 8 8 9.791 8 12 C 8 14.209 9.791 16 12 16 Z M 14 12 C 14 13.105 13.105 14 12 14 C 10.895 14 10 13.105 10 12 C 10 10.895 10.895 10 12 10 C 13.105 10 14 10.895 14 12 Z", "eye-off": "M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z", "edit": "M16.2927 2.29295C17.7878 0.797857 20.2118 0.797859 21.7069 2.29295C23.202 3.78805 23.202 6.21207 21.7069 7.70717L20.5454 8.86869L20.5454 8.86873C20.1494 9.26471 19.9514 9.46271 19.723 9.5369C19.5222 9.60216 19.3058 9.60216 19.105 9.5369C18.8768 9.46274 18.6789 9.26484 18.2831 8.86911L18.2826 8.86869L15.1312 5.71722L15.1305 5.71645C14.735 5.32094 14.5371 5.12304 14.463 4.89486C14.3977 4.69402 14.3977 4.47767 14.463 4.27683C14.5371 4.04865 14.735 3.85075 15.1305 3.45524L15.1312 3.45447L16.2927 2.29295ZM16.8694 12.5448L16.8686 12.5456L8.451 20.9633C8.2061 21.2086 7.99008 21.4249 7.7334 21.5942C7.50774 21.743 7.26301 21.8606 7.00584 21.9439C6.71345 22.0385 6.40966 22.0721 6.0653 22.11L6.06494 22.1101L2.61044 22.4939C2.30851 22.5274 2.00771 22.4219 1.7929 22.2071C1.57809 21.9923 1.47258 21.6915 1.50612 21.3896L1.88992 17.9351L1.88992 17.9351C1.92792 17.5906 1.96144 17.2867 2.05613 16.9942C2.13938 16.737 2.25701 16.4923 2.40582 16.2666C2.57502 16.01 2.79132 15.794 3.03652 15.5492L3.03673 15.549L11.4544 7.13134C11.8504 6.73532 12.0484 6.53732 12.2768 6.46313C12.4776 6.39787 12.694 6.39787 12.8948 6.46313C13.123 6.53729 13.321 6.73519 13.7168 7.13091L13.7172 7.13134L16.8686 10.2828L16.8698 10.2839C17.265 10.6793 17.4628 10.8771 17.5368 11.1052C17.6021 11.306 17.6021 11.5224 17.5368 11.7232C17.4628 11.9514 17.2649 12.1493 16.8694 12.5448Z", @@ -172,6 +173,7 @@ "square": "M14 2.75C15.907 2.75 17.262 2.752 18.29 2.89C19.295 3.025 19.875 3.279 20.298 3.702C20.721 4.125 20.975 4.705 21.11 5.711C21.248 6.739 21.25 8.093 21.25 10C21.25 10.1989 21.329 10.3897 21.4697 10.5303C21.6103 10.671 21.8011 10.75 22 10.75C22.1989 10.75 22.3897 10.671 22.5303 10.5303C22.671 10.3897 22.75 10.1989 22.75 10V9.944C22.75 8.106 22.75 6.65 22.597 5.511C22.439 4.339 22.107 3.39 21.359 2.641C20.61 1.893 19.661 1.561 18.489 1.403C17.349 1.25 15.894 1.25 14.056 1.25H14C13.8011 1.25 13.6103 1.32902 13.4697 1.46967C13.329 1.61032 13.25 1.80109 13.25 2C13.25 2.19891 13.329 2.38968 13.4697 2.53033C13.6103 2.67098 13.8011 2.75 14 2.75ZM9.944 1.25H10C10.1989 1.25 10.3897 1.32902 10.5303 1.46967C10.671 1.61032 10.75 1.80109 10.75 2C10.75 2.19891 10.671 2.38968 10.5303 2.53033C10.3897 2.67098 10.1989 2.75 10 2.75C8.093 2.75 6.739 2.752 5.71 2.89C4.705 3.025 4.125 3.279 3.702 3.702C3.279 4.125 3.025 4.705 2.89 5.711C2.752 6.739 2.75 8.093 2.75 10C2.75 10.1989 2.67098 10.3897 2.53033 10.5303C2.38968 10.671 2.19891 10.75 2 10.75C1.80109 10.75 1.61032 10.671 1.46967 10.5303C1.32902 10.3897 1.25 10.1989 1.25 10V9.944C1.25 8.106 1.25 6.65 1.403 5.511C1.561 4.339 1.893 3.39 2.641 2.641C3.39 1.893 4.339 1.561 5.511 1.403C6.651 1.25 8.106 1.25 9.944 1.25ZM5.527 5.527C5 6.054 5 6.903 5 8.6C5 9.731 5 10.297 5.351 10.649C5.703 11 6.27 11 7.4 11H8.6C9.731 11 10.297 11 10.649 10.649C11 10.296 11 9.73 11 8.6V7.4C11 6.269 11 5.703 10.649 5.351C10.296 5 9.73 5 8.6 5C6.903 5 6.054 5 5.527 5.527ZM5.527 18.473C5 17.946 5 17.097 5 15.4C5 14.269 5 13.703 5.351 13.351C5.703 13 6.27 13 7.4 13H8.6C9.731 13 10.297 13 10.649 13.351C11 13.703 11 14.269 11 15.4V16.6C11 17.731 11 18.297 10.649 18.648C10.296 19 9.73 19 8.6 19C6.903 19 6.054 19 5.527 18.473ZM13 7.4C13 6.269 13 5.703 13.351 5.351C13.704 5 14.27 5 15.4 5C17.097 5 17.946 5 18.473 5.527C19 6.054 19 6.903 19 8.6C19 9.731 19 10.297 18.648 10.649C18.298 11 17.731 11 16.6 11H15.4C14.269 11 13.703 11 13.351 10.649C13 10.296 13 9.73 13 8.6V7.4ZM13.351 18.648C13 18.298 13 17.731 13 16.6V15.4C13 14.269 13 13.703 13.351 13.351C13.704 13 14.27 13 15.4 13H16.6C17.731 13 18.297 13 18.648 13.351C19 13.703 19 14.269 19 15.4C19 17.097 19 17.946 18.473 18.473C17.946 19 17.097 19 15.4 19C14.269 19 13.703 19 13.351 18.648ZM22.5303 13.4697C22.3897 13.329 22.1989 13.25 22 13.25C21.8011 13.25 21.6103 13.329 21.4697 13.4697C21.329 13.6103 21.25 13.8011 21.25 14C21.25 15.907 21.248 17.262 21.11 18.289C20.975 19.295 20.721 19.875 20.298 20.298C19.875 20.721 19.295 20.975 18.29 21.11C17.262 21.248 15.907 21.25 14 21.25C13.8011 21.25 13.6103 21.329 13.4697 21.4697C13.329 21.6103 13.25 21.8011 13.25 22C13.25 22.1989 13.329 22.3897 13.4697 22.5303C13.6103 22.671 13.8011 22.75 14 22.75H14.056H14.0561C15.894 22.75 17.349 22.75 18.489 22.597C19.661 22.439 20.61 22.107 21.359 21.359C22.107 20.61 22.439 19.661 22.597 18.489C22.75 17.35 22.75 15.894 22.75 14.056V14C22.75 13.8011 22.671 13.6103 22.5303 13.4697ZM2.53033 13.4697C2.67098 13.6103 2.75 13.8011 2.75 14C2.75 15.907 2.752 17.262 2.89 18.289C3.025 19.295 3.279 19.875 3.702 20.298C4.125 20.721 4.705 20.975 5.71 21.11C6.739 21.248 8.093 21.25 10 21.25C10.1989 21.25 10.3897 21.329 10.5303 21.4697C10.671 21.6103 10.75 21.8011 10.75 22C10.75 22.1989 10.671 22.3897 10.5303 22.5303C10.3897 22.671 10.1989 22.75 10 22.75H9.944H9.94393C8.10596 22.75 6.65099 22.75 5.511 22.597C4.339 22.439 3.39 22.107 2.641 21.359C1.893 20.61 1.561 19.661 1.403 18.489C1.25 17.35 1.25 15.894 1.25 14.056V14C1.25 13.8011 1.32902 13.6103 1.46967 13.4697C1.61032 13.329 1.80109 13.25 2 13.25C2.19891 13.25 2.38968 13.329 2.53033 13.4697Z", "arrow-narrow-right": "M14.7071 5.29289C14.3166 4.90237 13.6834 4.90237 13.2929 5.29289C12.9024 5.68342 12.9024 6.31658 13.2929 6.70711L17.5858 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H17.5858L13.2929 17.2929C12.9024 17.6834 12.9024 18.3166 13.2929 18.7071C13.6834 19.0976 14.3166 19.0976 14.7071 18.7071L20.7071 12.7071C21.0976 12.3166 21.0976 11.6834 20.7071 11.2929L14.7071 5.29289Z", "arrow-narrow-left": "M10.7071 6.70711C11.0976 6.31658 11.0976 5.68342 10.7071 5.29289C10.3166 4.90237 9.68342 4.90237 9.29289 5.29289L3.29289 11.2929C2.90237 11.6834 2.90237 12.3166 3.29289 12.7071L9.29289 18.7071C9.68342 19.0976 10.3166 19.0976 10.7071 18.7071C11.0976 18.3166 11.0976 17.6834 10.7071 17.2929L6.41421 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H6.41421L10.7071 6.70711Z", + "repeat": "M15.7071 3.29289C15.3166 2.90237 14.6834 2.90237 14.2929 3.29289C13.9024 3.68342 13.9024 4.31658 14.2929 4.70711L17.5858 8H13.5556C11.913 7.99999 10.6191 7.99999 9.57778 8.08507C8.51543 8.17186 7.62827 8.35217 6.82207 8.76295C5.50493 9.43407 4.43407 10.5049 3.76295 11.8221C3.35217 12.6283 3.17186 13.5154 3.08507 14.5778C2.99999 15.6191 2.99999 16.913 3 18.5556V20C3 20.5523 3.44772 21 4 21C4.55229 21 5 20.5523 5 20V18.6C5 16.9033 5.00078 15.691 5.07842 14.7406C5.15512 13.802 5.30179 13.2073 5.54497 12.73C6.02433 11.7892 6.78924 11.0243 7.73005 10.545C8.20732 10.3018 8.80197 10.1551 9.74064 10.0784C10.691 10.0008 11.9033 10 13.6 10H17.5858L14.2929 13.2929C13.9024 13.6834 13.9024 14.3166 14.2929 14.7071C14.6834 15.0976 15.3166 15.0976 15.7071 14.7071L20.7071 9.70711C21.0976 9.31658 21.0976 8.68342 20.7071 8.29289L15.7071 3.29289Z", "level": "M 23 12 C 23 18.075 18.075 23 12 23 C 5.925 23 1 18.075 1 12 C 1 5.925 5.925 1 12 1 C 18.075 1 23 5.925 23 12 Z M 6 12 C 5.999 10.223 6.787 8.536 8.15 7.396 C 9.514 6.256 11.313 5.778 13.062 6.093 C 13.419 6.169 13.79 6.044 14.028 5.767 C 14.266 5.49 14.335 5.106 14.206 4.764 C 14.078 4.422 13.774 4.177 13.412 4.125 C 10.226 3.553 7.009 4.957 5.262 7.682 C 3.515 10.408 3.583 13.917 5.434 16.573 C 5.75 17.026 6.374 17.137 6.826 16.82 C 7.279 16.504 7.39 15.881 7.074 15.428 C 6.372 14.423 5.997 13.226 6 12 Z M 19.816 10.287 C 19.743 9.935 19.486 9.649 19.144 9.539 C 18.802 9.428 18.427 9.51 18.161 9.753 C 17.896 9.996 17.782 10.362 17.862 10.713 C 18.217 12.347 17.878 14.054 16.925 15.428 C 16.623 15.881 16.738 16.492 17.185 16.803 C 17.631 17.115 18.245 17.012 18.565 16.572 C 19.836 14.741 20.289 12.465 19.815 10.287 Z M 17.207 8.207 C 17.586 7.815 17.581 7.191 17.195 6.805 C 16.809 6.419 16.185 6.414 15.793 6.793 L 12.518 10.068 C 11.766 9.864 10.964 10.115 10.462 10.711 C 9.96 11.307 9.851 12.141 10.181 12.847 C 10.511 13.552 11.221 14.003 12 14 C 12.622 14 13.208 13.711 13.587 13.217 C 13.966 12.724 14.093 12.083 13.932 11.482 Z", "layers": "M11.7234 1.0848C11.9062 1.05051 12.0938 1.05051 12.2766 1.0848C12.493 1.12541 12.6861 1.22394 12.7794 1.27155L12.805 1.28452L22.4472 6.10564C22.786 6.27503 23 6.62129 23 7.00006C23 7.37884 22.786 7.7251 22.4472 7.89449L12.805 12.7156L12.7794 12.7286C12.6861 12.7762 12.493 12.8747 12.2766 12.9153C12.0938 12.9496 11.9062 12.9496 11.7234 12.9153C11.507 12.8747 11.3139 12.7762 11.2206 12.7286L11.195 12.7156L1.55279 7.89449C1.214 7.7251 1 7.37884 1 7.00006C1 6.62129 1.214 6.27503 1.55279 6.10564L11.195 1.28452L11.2206 1.27155C11.3139 1.22394 11.507 1.12541 11.7234 1.0848ZM2.52769 10.618L1.55279 11.1054C1.214 11.2748 1 11.6211 1 11.9999C1 12.3786 1.214 12.7249 1.55279 12.8943L11.195 17.7154L11.2206 17.7284C11.3139 17.776 11.507 17.8745 11.7234 17.9151C11.9062 17.9494 12.0938 17.9494 12.2766 17.9151C12.493 17.8745 12.6861 17.776 12.7794 17.7284L12.805 17.7154L22.4472 12.8943C22.786 12.7249 23 12.3786 23 11.9999C23 11.6211 22.786 11.2748 22.4472 11.1054L21.4723 10.618L13.6994 14.5044L13.6876 14.5103C13.6388 14.5349 13.5187 14.5951 13.3985 14.6474C13.2382 14.7172 12.9785 14.8185 12.6454 14.881C12.2189 14.961 11.7811 14.961 11.3546 14.881C11.0215 14.8185 10.7618 14.7172 10.6015 14.6474C10.4813 14.5951 10.3612 14.5349 10.3124 14.5103L10.3006 14.5044L2.52769 10.618ZM1.55279 16.1055L2.52784 15.618L10.3006 19.5044L10.3124 19.5103L10.3125 19.5104C10.3614 19.5349 10.4814 19.5952 10.6015 19.6474C10.7618 19.7172 11.0215 19.8185 11.3546 19.881C11.7811 19.961 12.2189 19.961 12.6454 19.881C12.9785 19.8185 13.2382 19.7172 13.3985 19.6474C13.5186 19.5952 13.6386 19.5349 13.6875 19.5104L13.6876 19.5103L13.6994 19.5044L21.4722 15.618L22.4472 16.1055C22.786 16.2749 23 16.6212 23 17C23 17.3787 22.786 17.725 22.4472 17.8944L12.805 22.7155L12.7794 22.7285C12.6861 22.7761 12.493 22.8746 12.2766 22.9152C12.0938 22.9495 11.9062 22.9495 11.7234 22.9152C11.507 22.8746 11.3139 22.7761 11.2206 22.7285L11.195 22.7155L1.55279 17.8944C1.214 17.725 1 17.3787 1 17C1 16.6212 1.214 16.2749 1.55279 16.1055Z", "return": "M6.2929 18.7071C6.6834 19.0976 7.3166 19.0976 7.7071 18.7071C8.0976 18.3166 8.0976 17.6834 7.7071 17.2929L5.4142 15H16.5C19.5376 15 22 12.5376 22 9.5C22 6.4624 19.5376 4 16.5 4H12C11.4477 4 11 4.4477 11 5C11 5.5523 11.4477 6 12 6H16.5C18.433 6 20 7.567 20 9.5C20 11.433 18.433 13 16.5 13H5.4142L7.7071 10.7071C8.0976 10.3166 8.0976 9.6834 7.7071 9.2929C7.3166 8.9024 6.6834 8.9024 6.2929 9.2929L2.2929 13.2929C1.9024 13.6834 1.9024 14.3166 2.2929 14.7071L6.2929 18.7071Z", diff --git a/assets/styles/base.scss b/assets/styles/base.scss index b2d9a8b4..ae1018c4 100644 --- a/assets/styles/base.scss +++ b/assets/styles/base.scss @@ -378,6 +378,21 @@ body { transform: translateY(-25px); } +.slide-fade-enter-active, +.slide-fade-leave-active { + transition: all 0.2s ease; + position: absolute; + width: 100%; +} +.slide-fade-enter-from { + opacity: 0; + transform: translateX(-30%); +} +.slide-fade-leave-to { + opacity: 0; + transform: translateX(30%); +} + .table_column_alias { max-width: 125px; diff --git a/components/Feed.vue b/components/Feed.vue index bd840e6c..4d5e0583 100644 --- a/components/Feed.vue +++ b/components/Feed.vue @@ -3,38 +3,26 @@ import { DateTime } from "luxon" /** Services */ -import { abbreviate, comma, formatBytes, isMainnet, roundTo } from "@/services/utils" +import { abbreviate, capitilize, comma, formatBytes, isMainnet, roundTo } from "@/services/utils" import { getRankCategory } from "@/services/constants/rollups" +import { quoteServiceURL, rollupRankingServiceURL } from "@/services/config" /** UI */ import Tooltip from "@/components/ui/Tooltip.vue" /** API */ +import { fetchRollupsRanking } from "@/services/api/rollup" import { fetchPriceSeries, fetchSummary, fetchTVS } from "@/services/api/stats" /** Store */ import { useAppStore } from "@/store/app.store" -import { useActivityStore } from "@/store/activity.store" const appStore = useAppStore() -const activityStore = useActivityStore() const head = computed(() => appStore.lastHead) const currentPrice = computed(() => appStore.currentPrice) const totalFees = computed(() => head.value.total_fee / 1_000_000) const totalFeesUSD = computed(() => totalFees.value * currentPrice.value?.close) -const topRollup = computed(() => { - let rankCategory = getRankCategory(roundTo(activityStore?.rollups_ranking?.top_rollup?.rank / 10, 0)) - return { - slug: activityStore?.rollups_ranking?.top_rollup?.slug, - name: activityStore?.rollups_ranking?.top_rollup?.name, - rank: { - name: rankCategory?.name, - score: activityStore?.rollups_ranking?.top_rollup?.rank, - color: rankCategory?.color, - }, - } -}) const isLoading = ref(true) const series = ref([]) @@ -43,24 +31,43 @@ const price = reactive({ diff: 0, side: null, }) +const showPrice = ref(!!quoteServiceURL()) +const topRollup = ref(null) +const showTopRollup = ref(isMainnet() && !!rollupRankingServiceURL()) const tvs = computed(() => appStore.tvs) const txCount24h = ref(0) const bytesInBlocks24h = ref(0) onMounted(async () => { - const dataSeries = await fetchPriceSeries({ from: parseInt(DateTime.now().minus({ days: 3 }).ts / 1_000) }) - series.value = dataSeries - appStore.currentPrice = series.value[0] - price.value = parseFloat(series.value[0].close) - - const prevDayClosePrice = parseFloat(series.value[1].close) - price.diff = (Math.abs(prevDayClosePrice - price.value) / ((prevDayClosePrice + price.value) / 2)) * 100 - let side = "stay" - if (price.value - prevDayClosePrice !== 0) { - side = price.value - prevDayClosePrice > 0 ? "rise" : "fall" + if (showPrice.value) { + const dataSeries = await fetchPriceSeries({ from: parseInt(DateTime.now().minus({ days: 3 }).ts / 1_000) }) + if (dataSeries.length) { + series.value = dataSeries + appStore.currentPrice = series.value[0] + price.value = parseFloat(series.value[0].close) + + const prevDayClosePrice = parseFloat(series.value[1].close) + price.diff = (Math.abs(prevDayClosePrice - price.value) / ((prevDayClosePrice + price.value) / 2)) * 100 + let side = "stay" + if (price.value - prevDayClosePrice !== 0) { + side = price.value - prevDayClosePrice > 0 ? "rise" : "fall" + } + price.side = side + } } - price.side = side + if (showTopRollup.value) { + const _topRollups = await fetchRollupsRanking({ limit: 1 }) + if (_topRollups.length) { + const _r = _topRollups[0] + topRollup.value = { + ..._r, + category: getRankCategory(roundTo(_r.rank / 10, 0)), + name: _r.slug.split("-").map(el => capitilize(el)).join(" "), + } + } + } + const _tvs = await fetchTVS({ period: null }) if (_tvs.value) { appStore.tvs = _tvs.value @@ -83,7 +90,7 @@ onMounted(async () => { -