Skip to content

Commit

Permalink
feat: add new indexer graphql package (L2) (#172)
Browse files Browse the repository at this point in the history
Co-authored-by: LuizAsFight <[email protected]>
Co-authored-by: Luiz Gomes - LuizAsFight.eth <[email protected]>
Co-authored-by: luizstacio <[email protected]>
Co-authored-by: Hélcio Franco <[email protected]>
  • Loading branch information
5 people authored Apr 10, 2024
1 parent 6cbc22c commit 4daabc0
Show file tree
Hide file tree
Showing 139 changed files with 13,349 additions and 1,496 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Build and push Ethereum hardhat image
- name: Build and push Fuel Explorer Graphql image
uses: ./.github/actions/docker-publish
id: publish
with:
Expand All @@ -31,3 +31,23 @@ jobs:
image: ghcr.io/fuellabs/fuel-explorer
dockerfile: deployment/Dockerfile
context: ./packages/graphql

# Temporary publish a new version of the graphql-new
# until the graphql removed to use only the new version
build-and-publish-image-v2:
runs-on: buildjet-4vcpu-ubuntu-2204
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3

- name: Build and push Fuel Explorer Graphql image V2
uses: ./.github/actions/docker-publish
id: publish
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/fuellabs/fuel-explorer
dockerfile: deployment/Dockerfile.v2
context: ./packages/graphql-new
3 changes: 3 additions & 0 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:

- name: Create .env file graphql
run: cp packages/graphql/.env.example packages/graphql/.env

- name: Create .env file graphql-new
run: cp packages/graphql-new/.env.example packages/graphql-new/.env

- name: Create .env file explorer
run: cp packages/app-explorer/.env.example packages/app-explorer/.env
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ concurrency:

env:
COVERAGE_FILE: report.json
NEXT_PUBLIC_FUEL_CHAIN_NAME: fuelBeta5
NEXT_PUBLIC_FUEL_CHAIN_NAME: fuelBeta5 # For Next.JS apps
FUEL_PROVIDER: https://beta-5.fuel.network/graphql # For GraphQL apps

jobs:
validate-title:
Expand Down
4 changes: 2 additions & 2 deletions contracts/predicate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"dotenv": "16.4.1",
"fuels": "0.74.0",
"tsx": "4.7.0",
"vitest": "1.2.2"
"vitest": "1.2.2",
"tsx": "4.7.1"
}
}
38 changes: 38 additions & 0 deletions deployment/Dockerfile.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This image contains the graphql server
# built for the fuel-explorer
FROM node:20-slim AS base

# Expose the ENVs to the env of the container
ENV PORT="${PORT}"
ENV FUEL_PROVIDER="${FUEL_PROVIDER:-https://beta-5.fuel.network/graphql}"
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV SERVER_BUILD=true
ENV SYNC_MISSING=false
ENV DB_MIGRATE=false

# Database config
ENV DB_HOST="${DB_HOST}"
ENV DB_PORT="${DB_PORT}"
ENV DB_USER="${DB_USER}"
ENV DB_PASS="${DB_PASS}"
ENV DB_NAME="${DB_NAME}"

# Enable pnpm using corepack form node.js
RUN corepack enable

# Install dependencies for the entire monorepo
COPY . /app-explorer
WORKDIR /app-explorer

# Install dependencies for the entire monorepo
RUN pnpm install
RUN pnpm db:setup

# Expose the specified port
EXPOSE ${PORT}

# Start GraphQL server
WORKDIR /app-explorer

CMD ["pnpm", "server:start"]
23 changes: 22 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.4'
version: "3.4"

services:
l1_chain:
Expand All @@ -14,6 +14,7 @@ services:
fuel_core:
depends_on:
- l1_chain
- fuel-explorer-pgsql
image: fueldev/fuelcore:${DOCKER_TAG_FUEL_CORE:-latest}
platform: linux/amd64
build:
Expand Down Expand Up @@ -69,3 +70,23 @@ services:
ports:
# expose the service to the host for integration testing
- ${ERC20_HTTP_PORT:-8082}:9090

fuel-explorer-pgsql:
image: postgres:latest
platform: linux/amd64
container_name: fuel-explorer-pgsql
ports:
- "5435:5432"
volumes:
- fuel-explorer-pgsql-db:/usr/local/postgres
environment:
- POSTGRES_PASSWORD=postgres
- PGUSER=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "postgres", "-d", "postgres"]
interval: 5s
timeout: 5s
retries: 5

volumes:
fuel-explorer-pgsql-db:
2 changes: 1 addition & 1 deletion docker/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/fuellabs/fuel-core:v0.22.0
FROM ghcr.io/fuellabs/fuel-core:v0.22.4

ARG FUEL_IP=0.0.0.0
ARG FUEL_PORT=4001
Expand Down
7 changes: 7 additions & 0 deletions docker/fuel-core/chainConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
"amount": "0x000000e8d4a51000",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"contracts": [
{
"contract_id": "0x1111111111111111111111111111111111111111111111111111111111111111",
"code": "0x2222222222222222222222222222222222222222222222222222222222222222",
"salt": "0x0000000000000000000000000000000000000000000000000000000000000001"
}
]
},
"consensus_parameters": {
Expand Down
1 change: 1 addition & 0 deletions docker/fuel-core/fuel_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exec /root/fuel-core run \
--enable-relayer \
--relayer $L1_CHAIN_HTTP \
--relayer-v2-listening-contracts $FUEL_MESSAGE_PORTAL_CONTRACT_ADDRESS \
--coinbase-recipient 0x1111111111111111111111111111111111111111111111111111111111111111 \
--poa-interval-period 1s \
--min-gas-price 1 \
--chain ./chainConfig.json \
Expand Down
12 changes: 12 additions & 0 deletions docker/l1-chain/hardhat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "hardhat-node",
"version": "0.0.0",
"scripts": {
"start": "hardhat node --network hardhat"
},
"license": "MIT",
"dependencies": {
"dotenv": "^16.4.4",
"hardhat": "^2.20.1"
}
}
34 changes: 13 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,18 @@
"@jest/types": "29.6.3",
"@next/eslint-plugin-next": "^14.1.0",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@openzeppelin/hardhat-upgrades": "^3.0.2",
"@openzeppelin/hardhat-upgrades": "^3.0.3",
"@playwright/test": "^1.41.2",
"@swc/core": "1.4.0",
"@swc/core": "1.4.1",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "20.11.16",
"@types/react": "^18.2.54",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@xstate/cli": "^0.5.17",
"dotenv": "^16.4.1",
"dotenv": "^16.4.4",
"get-tsconfig": "4.7.2",
"hardhat-typechain": "^0.3.5",
"husky": "^9.0.10",
"husky": "^9.0.11",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-transform-stub": "^2.0.0",
Expand All @@ -89,22 +86,17 @@
"npm-run-all": "^4.1.5",
"ts-jest": "^29.1.2",
"ts-node": "10.9.2",
"tsup": "8.0.1",
"tsx": "4.7.0",
"turbo": "^1.12.2",
"tsup": "8.0.2",
"tsx": "4.7.1",
"turbo": "^1.12.4",
"typescript": "5.3.3",
"updates": "^15.1.1"
"updates": "^15.1.2",
"vitest": "1.2.2"
},
"pnpm": {
"peerDependencyRules": {
"allowAny": [
"react",
"react-dom"
],
"ignoreMissing": [
"react",
"react-dom"
]
"allowAny": ["react", "react-dom"],
"ignoreMissing": ["react", "react-dom"]
},
"overrides": {
"glob-parent@<5.1.2": ">=5.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/app-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
},
"dependencies": {
"@fuels/ui": "workspace:*",
"react": "^18.2.0",
"react": "18.2.0",
"tailwind-variants": "0.1.20"
},
"devDependencies": {
"@types/react": "^18.2.54",
"@types/react-dom": "^18.2.18",
"@types/react": "18.2.54",
"@types/react-dom": "18.2.22",
"typescript": "5.3.3"
}
}
12 changes: 6 additions & 6 deletions packages/app-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@
"@storybook/types": "^8.0.0-beta.5",
"@svgr/webpack": "8.1.0",
"@testing-library/dom": "9.3.4",
"@testing-library/jest-dom": "6.3.0",
"@testing-library/jest-dom": "6.4.2",
"@types/node": "20.11.6",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@types/react": "18.2.54",
"@types/react-dom": "18.2.22",
"@types/react-window": "1.8.8",
"@xstate/cli": "^0.5.17",
"autoprefixer": "10.4.17",
"postcss": "8.4.33",
"postcss-import": "16.0.0",
"postcss": "8.4.35",
"postcss-import": "16.0.1",
"radix-ui-themes-with-tailwind": "1.2.6",
"storybook": "^8.0.0-beta.5",
"storybook-addon-theme": "workspace:*",
Expand All @@ -79,7 +79,7 @@
"tsconfig-paths-webpack-plugin": "^4.1.0",
"tsup": "8.0.1",
"typescript": "5.3.3",
"vite": "^5.0.12",
"vite": "^5.1.3",
"vite-tsconfig-paths": "^4.3.1"
},
"browser": {
Expand Down
6 changes: 3 additions & 3 deletions packages/app-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"@tanstack/react-query": "5.0.5",
"@tanstack/react-query-devtools": "5.0.5",
"@types/node": "^18.13.0",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react": "18.2.54",
"@types/react-dom": "18.2.22",
"@xstate/cli": "^0.5.17",
"npm-run-all": "^4.1.5",
"postcss": "8.4.33",
Expand All @@ -57,4 +57,4 @@
"tailwindcss-radix": "2.8.0",
"typescript": "5.3.3"
}
}
}
4 changes: 4 additions & 0 deletions packages/graphql-new/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_moduels
.turbo
dist
.env
7 changes: 7 additions & 0 deletions packages/graphql-new/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FUEL_PROVIDER=http://beta-5.fuel.network/graphql
SERVER_PORT=3002
DB_HOST="127.0.0.1"
DB_PORT="5435"
DB_USER="postgres"
DB_PASS="postgres"
DB_NAME="postgres"
7 changes: 7 additions & 0 deletions packages/graphql-new/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FUEL_PROVIDER=https://beta-5.fuel.network/graphql
SERVER_PORT=3002
DB_HOST="127.0.0.1"
DB_PORT="5435"
DB_USER="postgres"
DB_PASS="postgres"
DB_NAME="postgres"
26 changes: 26 additions & 0 deletions packages/graphql-new/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Mock API

This is a mock api for block-explorer

## Run development server

```sh
pnpm dev
```

## Docker

```
docker run \
-e FUEL_PROVIDER=http://beta-5.fuel.network/graphql \
-e SERVER_PORT=3000 \
-e SYNC_MISSING=true \
-e DB_MIGRATE=true \
-e DB_HOST=192.168.3.240 \
-e DB_PORT=5435 \
-e DB_USER=postgres \
-e DB_PASS=postgres \
-e DB_NAME=postgres \
-p 3333:3000 \
ghcr.io/fuellabs/fuel-explorer:main
```
19 changes: 19 additions & 0 deletions packages/graphql-new/codegen.fuel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { CodegenConfig } from '@graphql-codegen/cli';
import dotenv from 'dotenv';
dotenv.config();

const SERVER_URL = process.env.FUEL_PROVIDER || 'http://127.0.0.1:4000/graphql';

const config: CodegenConfig = {
overwrite: true,
generates: {
'./src/graphql/schemas/fuelcore.graphql': {
schema: SERVER_URL,
plugins: ['schema-ast'],
config: {
includeDirectives: true,
},
},
},
};
export default config;
Loading

0 comments on commit 4daabc0

Please sign in to comment.