Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: release #62

Merged
merged 94 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
df0c98e
feat: basic architecture
0xtiti Jul 12, 2024
3e405d2
feat: data fetching
0xtiti Jul 12, 2024
1138baf
style: file name
0xtiti Jul 12, 2024
1a5f8e5
style: file name
0xtiti Jul 12, 2024
a0ca85a
style: json formatting
0xtiti Jul 12, 2024
7ab5a8d
fix: queryClient | remove refetch effect
0xtiti Jul 15, 2024
285c55b
feat: chain routes
0xtiti Jul 15, 2024
a457e01
style: type name
0xtiti Jul 15, 2024
35621eb
style: imports
0xtiti Jul 16, 2024
1c3d621
feat: basic architecture (#1)
0xtiti Jul 16, 2024
3b5229d
Merge branch 'dev' into feat/chain-routes
0xtiti Jul 16, 2024
0d1a4c1
feat: ecosystem layout
0xtiti Jul 16, 2024
33b5e22
tests: remove boilerplate datatest
0xtiti Jul 16, 2024
8b82fb8
fix: html tags
0xtiti Jul 17, 2024
39e15f1
Merge branch 'dev' into feat/ecosystem-layout
0xtiti Jul 17, 2024
d1cf18c
feat: chain routes (#2)
0xtiti Jul 17, 2024
6d98155
Merge branch 'dev' into feat/ecosystem-layout
0xtiti Jul 17, 2024
3e1f3a9
style: fix quotes
0xtiti Jul 17, 2024
27e7571
style: imports
0xtiti Jul 17, 2024
c665412
style: imports
0xtiti Jul 17, 2024
99ac76f
feat: search bar
0xtiti Jul 17, 2024
6e39b9c
style: fix imports
0xtiti Jul 17, 2024
450b7f7
Merge branch 'dev' into feat/search
0xtiti Jul 17, 2024
fb72425
feat: ecosystem layout (#3)
0xtiti Jul 17, 2024
7b06a1a
Merge branch 'dev' into feat/search
0xtiti Jul 17, 2024
c43abdb
feat: i18n set up
0xtiti Jul 17, 2024
e855fcb
fix: resolve dashboard export
0xtiti Jul 17, 2024
6bfe87d
Merge branch 'dev' into feat/i18n
0xtiti Jul 17, 2024
7af1783
chore: install
0xtiti Jul 17, 2024
38d3de1
fix: config
0xtiti Jul 17, 2024
c6e6722
feat: add translations
0xtiti Jul 17, 2024
5be359a
fix: vercel deployment
0xtiti Jul 17, 2024
3dd2dfa
fix: module import
0xtiti Jul 17, 2024
d745108
fix: locales path
0xtiti Jul 17, 2024
6330bf1
fix: localePath
0xtiti Jul 17, 2024
23a7491
fix: static path
0xtiti Jul 17, 2024
bae2b9c
chore: dependencies
0xtiti Jul 17, 2024
f6a50ee
feat: search logic (#4)
0xtiti Jul 18, 2024
f5224b3
Merge branch 'dev' into feat/i18n
0xtiti Jul 18, 2024
8c41462
style: eslint
0xtiti Jul 18, 2024
9932945
feat: i18n set up (#6)
0xtiti Jul 19, 2024
ae66122
feat: format number (#5)
0xtiti Jul 22, 2024
9669d7f
feat: search chain by id (#8)
0xtiti Jul 22, 2024
443e50d
feat: language select (#7)
0xtiti Jul 23, 2024
afe3915
feat: chain page details (#9)
0xtiti Jul 31, 2024
6172d5c
feat: header design (#10)
0xtiti Jul 31, 2024
52d87c7
feat: footer design styles (#11)
0xtiti Aug 2, 2024
8caa5ff
feat: chain table (#12)
0xtiti Aug 2, 2024
5b3343d
feat: token graph design (#13)
0xtiti Aug 5, 2024
39d1d94
feat: chain page design (#14)
0xtiti Aug 8, 2024
e8d57a7
feat: dark light mode icons and colors (#16)
0xtiti Aug 8, 2024
ae0b469
feat: breadcrumb (#15)
0xtiti Aug 8, 2024
3952f80
feat: responsiveness (#17)
0xtiti Aug 12, 2024
0948c78
feat: search display (#18)
0xtiti Aug 13, 2024
52117eb
feat: skeleton loaders (#19)
0xtiti Aug 14, 2024
7b77477
feat: mobile menu (#20)
0xtiti Aug 14, 2024
710dd65
feat: token page (#21)
0xtiti Aug 14, 2024
31b80fb
feat: mobile table (#22)
0xtiti Aug 15, 2024
27cdd66
feat: misc fixes (#23)
0xtiti Aug 15, 2024
0ba24fe
feat: error page (#24)
0xtiti Aug 15, 2024
c289218
feat: backend integration schema (#26)
0xtiti Aug 15, 2024
f5a4a52
docs: readme and licence (#28)
0xtiti Aug 16, 2024
7fac669
chore: bump dependencies (#29)
0xArdy Aug 16, 2024
20f0f1d
feat: add network | complete offchain integration (#25)
0xtiti Aug 16, 2024
0063e16
chore: update dev and start scripts to use port 5173 (#32)
0xArdy Aug 18, 2024
0f5a9fb
docs: update readme & env.example (#31)
0xnigir1 Aug 18, 2024
8707095
fix: misc fixes (#30)
0xtiti Aug 19, 2024
8fb775c
feat: gas calculations (#33)
0xtiti Aug 20, 2024
1f4d19a
refactor: rename components (#34)
0xtiti Aug 20, 2024
6bf8c9c
fix: token table first cell (#35)
0xtiti Aug 20, 2024
04e0e1a
feat: not available data (#36)
0xtiti Aug 20, 2024
786a831
fix: remove rpc tags (#37)
0xtiti Aug 20, 2024
9ebb38e
refactor: icons (#38)
0xtiti Aug 21, 2024
eb26811
feat: chain number format (#39)
0xtiti Aug 21, 2024
22cd2ac
feat: improve web accessibility (#40)
0xtiti Aug 22, 2024
2670620
feat: add contract | notAvailable info (#42)
0xtiti Aug 26, 2024
e56030d
feat: show more rpc urls (#41)
0xtiti Aug 26, 2024
d420d8e
test: unit tests (#43)
0xtiti Aug 29, 2024
2668c65
fix: handle undefined data from backend (#47)
0xtiti Aug 30, 2024
f4ab36f
feat: testnet mode (#45)
0xtiti Aug 30, 2024
cd57046
test: e2e navigation tests (#44)
0xtiti Aug 30, 2024
2d61ae7
fix: fee params data (#48)
0xtiti Sep 2, 2024
b875424
fix: testnet mode (#52)
0xtiti Sep 3, 2024
b14a519
fix: show significant digit (#50)
0xtiti Sep 3, 2024
ca2eb24
docs: vercel deployment guide (#53)
0xtiti Sep 3, 2024
4418f69
feat: remove mock data (#49)
0xtiti Sep 4, 2024
23139a1
feat: docker deployment (#51)
0xtiti Sep 6, 2024
02c23da
fix: remove testing mode (#54)
0xtiti Sep 10, 2024
650ec31
fix: footer styling height (#56)
0xtiti Sep 10, 2024
69e6438
fix: tvl table row cursor (#55)
0xtiti Sep 10, 2024
4221914
docs: remove testing mode var (#57)
0xtiti Sep 10, 2024
1d853a7
fix: misc fixes (#58)
0xtiti Sep 10, 2024
4031984
style: rename PROJECT_ID to WALLETCONNECT_PROJECT_ID (#59)
0xtiti Sep 10, 2024
0561e6b
feat: add metadata (#60)
0xArdy Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore all .env files in any directory or subdirectory
**/.env

# Ignore node_modules and dist directories in any directory or subdirectory
**/node_modules
**/dist

**/.git
**/*.md
**/cypress
**/.github
.next
!.next/static
!.next/standalone
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_RPC_URL= # Example: https://localhost:8545
NEXT_PUBLIC_PROJECT_ID= # ProjectID from WalletConnect
NEXT_PUBLIC_ALCHEMY_KEY= # API key from Alchemy
NEXT_PUBLIC_API_BASE_URL= # Example: https://api.example.com
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID= # ProjectID from WalletConnect (Optional)
NEXT_PUBLIC_TESTNET_MODE= # true or false
6 changes: 3 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
with:
version: 8
version: 9.5.0

- name: Install Node
uses: actions/setup-node@v4
Expand All @@ -37,7 +37,7 @@ jobs:
cache: 'pnpm'

- name: Install project dependencies
run: pnpm install --frozen-lockfile --prefer-frozen-lockfile
run: pnpm install

- name: Run Prettier
run: pnpm prettier
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
with:
version: 8
version: 9.5.0

- name: Create env file
run: |
touch .env
echo "NEXT_PUBLIC_RPC_URL=${{ secrets.NEXT_PUBLIC_RPC_URL }}" >> .env
echo "NEXT_PUBLIC_PROJECT_ID=${{ secrets.NEXT_PUBLIC_PROJECT_ID }}" >> .env
echo "NEXT_PUBLIC_ALCHEMY_KEY=${{ secrets.NEXT_PUBLIC_ALCHEMY_KEY }}" >> .env
echo "NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_BASE_URL }}" >> .env

- name: run Cypress and Jest
uses: cypress-io/github-action@v6
with:
build: pnpm build
start: pnpm start
wait-on: 'http://localhost:3000'
wait-on: 'http://localhost:5173'
command: pnpm test
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Use an official Node.js image as a parent image
FROM node:20 AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# # Install pnpm globally
# RUN npm install -g pnpm


# Set the working directory in the container
WORKDIR /app

# Copy pnpm-lock.yaml and package.json files
COPY package.json pnpm-lock.yaml ./

# Install dependencies using pnpm
RUN CI=1 pnpm install --frozen-lockfile

# Copy the rest of the application code
COPY . .

# Build the application
RUN pnpm build

# Use a lighter Node.js image for the final stage
FROM node:20-slim AS ui
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV NODE_ENV=production
RUN corepack enable

# Set the working directory in the container
WORKDIR /app

# Copy only necessary files from the build stage
COPY --from=build /app/package.json /app/pnpm-lock.yaml ./
COPY --from=build /app/public ./public
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static


# # Install only production dependencies with pnpm
# RUN CI=1 pnpm install --no-frozen-lockfile

# Expose the port on which the application will run
EXPOSE 5173
ENV PORT=5173

# Specify the command to run the application
CMD ["node", "server.js"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Wonderland

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
146 changes: 114 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,127 @@
# Web3 React Boilerplate
# ZKchainHub UI 🌐

## Features
## Description

- Modern React setup with the latest tools and libraries.
- Boilerplate for building web3-enabled applications.
- Example unit and integration tests included.
- Code linting and formatting for clean and maintainable code.
- GitHub workflows for continuous integration.
The **ZKchainHub** proposes a decentralized, permissionless platform that provides custom analytics dashboards for ZK ecosystems, empowering chain operators to track and visualize key metrics like TVL, transaction counts, and block details. This allows users to easily explore each chain.

## Setup
## 📋 Prerequisites

1. Clone this repository.
2. Copy the `.env.example` file to `.env` and fill in the variables.
3. Install the project dependencies by running:
- Ensure you have `pnpm >= 9.0.0` installed.

## 💻 WebFlow

The flow of the application is as follows:

Home Page: The ecosystem page, where data is fetched from `metrics/ecosystem`. From here, you can navigate to all token's TVL data or directly to the Chain Page.

Chain Page: Accessible via search in the header or by selecting a row in the table. Information is fetched from `metrics/zkchain/:id`.

## 🚀 Installation

```bash
$ pnpm install
```

## ⚙️ Setting up env variables

- Create `.env` file in the `root` folder and copy paste `.env.example` content in there.

```
$ cp .env.example .env
```

- Set up `NEXT_PUBLIC_API_BASE_URL` with ZKchainHub Backend API url. It will typically run on `http://localhost:3000`
- (Optionally)
- Set `NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID` with your [Wallet Connect](https://walletconnect.com/) ProjectID
- Set `NEXT_PUBLIC_TESTNET_MODE ` with `true` to use testnet mode with testnet backend API URL set up in `NEXT_PUBLIC_API_BASE_URL`

## 🏃 Running the app

```bash
$ pnpm run start
```

To verify ZKchainHub UI is running open http://localhost:5173 in your browser

## Deployment

## 🏗️ Vercel deployment

## Prerequisites

1. **Vercel Account**: [Sign up](https://vercel.com) if you don’t have an account.
2. **Vercel CLI**: Install the Vercel CLI by running:

```bash
npm install -g vercel
```

## Deployment Steps

1. **Authenticate with Vercel**: Run the following command and follow the prompts to log in

```bash
vercel login
```

2. **Deploy Your Project**: Navigate to your project directory and run:

```bash
pnpm install
vercel
```

## Available Scripts
Follow the prompts to configure your project.
Vercel will automatically deploy your project and provide a live URL.

3. **Set Environment Variables**: To add environment variables, use:

```bash
vercel env add <name> <value>
```

**Additional Resources**

- **[Vercel CLI Documentation](https://vercel.com/docs/cli)**: Find comprehensive information on using the Vercel CLI.
- **[Vercel Documentation](https://vercel.com/docs)**: Access general Vercel documentation and guides.

## 🐳 Docker deployment

## Prerequisites

- **Docker**: Ensure that Docker is installed.

## Deployment Steps

1. **Build the Docker Image**

From your project directory, build the Docker image by running the following command:

```bash
docker build -t <app-name> .
```

2. **Run the Docker Container**

After the image is built, run the Docker container with the environment variables.

```bash
docker run -p 5173:5173 --env-file .env <app-name>
```

3. **Access your app:**

http://localhost:5173

## Development

### 💻 Conventional Commits

Available scripts that can be run using `pnpm`:
We follow the Conventional Commits [specification](https://www.conventionalcommits.org/en/v1.0.0/#specification).

| Script | Description |
| -------------- | ------------------------------------------------------------ |
| `dev` | Start the development server using Next. |
| `build` | Build the project for production. |
| `preview` | Preview the production build using Next. |
| `lint` | Run ESLint on the source code to check for coding standards. |
| `lint:fix` | Run ESLint and automatically fix code formatting issues. |
| `prettier` | Check code formatting using Prettier. |
| `prettier:fix` | Format code using Prettier and automatically fix issues. |
| `format` | Run Prettier and ESLint to format and fix code issues. |
| `format:check` | Check code formatting and linting without making changes. |
| `test` | Run tests using Cypress and Jest |
## Contributing

## Technologies Used
ZKchainHub was built with ❤️ by [Wonderland](https://defi.sucks).

This boilerplate leverages the latest technologies, including:
Wonderland is a team of top Web3 researchers, developers, and operators who believe that the future needs to be open-source, permissionless, and decentralized.

- [NextJS](https://nextjs.org/)
- [Wagmi](https://wagmi.sh/)
- [Viem](https://viem.sh/)
- [Rainbowkit](https://www.rainbowkit.com/)
[DeFi sucks](https://defi.sucks), but Wonderland is here to make it better.
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
baseUrl: 'http://localhost:5173',
},
});
3 changes: 3 additions & 0 deletions cypress/cypress.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"NEXT_PUBLIC_API_BASE_URL": "http://mock-api:3000"
}
67 changes: 67 additions & 0 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
describe('Navigation tests', () => {
beforeEach(() => {
// Intercept the ecosystem data API call and mock the response using a JSON fixture
cy.fixture('ecosystemMockData.json').then((ecosystemData) => {
cy.intercept('GET', '**/metrics/ecosystem', {
statusCode: 200,
body: ecosystemData,
}).as('fetchEcosystemData');
});

// Intercept the chain data API call and mock the response using a JSON fixture for chainId 324
cy.fixture('chainMockData.json').then((chainData) => {
cy.intercept('GET', '**/metrics/zkchain/*', {
statusCode: 200,
body: chainData,
}).as('fetchChainData');
});

// Intercept the chain data API call and mock the response using a JSON fixture for chainId 324
cy.fixture('nextData.json').then((nextData) => {
cy.intercept('GET', '**/_next/data/**/324.json?chain=324', {
statusCode: 200,
body: nextData,
}).as('fetchNextData');
});

cy.visit('/');
});

it('should navigate to search page, type a query, navigate to chain details, and go back to home on breadcrumb', () => {
cy.getByTestId('search-bar').click();
cy.url().should('include', '/search');

cy.getByTestId('search-bar').find('input').click().type('Invalid chain name');
cy.get('input').should('have.value', 'Invalid chain name');
cy.getByTestId('data-not-found').should('be.visible');

cy.getByTestId('search-bar').find('input').clear();
cy.get('input').should('have.value', '');

cy.getByTestId('search-bar').find('input').type('324');
cy.getByTestId('chain-row').should('be.visible').click();

cy.getByTestId('chain-id').should('be.visible').and('contain', '324');
cy.url().should('include', '/324');

cy.getByTestId('home-breadcrumb').click();
cy.url().should('eq', 'http://localhost:5173/');
cy.getByTestId('search-bar').find('input').should('have.value', '');
});

it('should navigate to tokens page, on all tokens button click', () => {
cy.getByTestId('all-tokens-button').click();
cy.url().should('include', '/tokens');

cy.getByTestId('tokens-title').should('be.visible');
cy.getByTestId('tokens-row').should('be.visible');
});

it('should navigate to chain page by clicking on dashboard chain row', () => {
cy.getByTestId('chains-dashboard').should('be.visible');
cy.getByTestId('chain-row').first().click();
cy.url().should('include', '/324');

cy.getByTestId('chain-id').should('be.visible').and('contain', '324');
});
});
6 changes: 0 additions & 6 deletions cypress/e2e/spec.cy.ts

This file was deleted.

Loading
Loading