diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2554716 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.env +.env.example +.ponder \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7be2a1e --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +DATABASE_URL= +MAX_BLOCK_RANGE= diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..f2cfac7 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,21 @@ +name: Setup + +description: Ponder monorepo action setup + +runs: + using: composite + steps: + - name: Set up pnpm + uses: pnpm/action-setup@v3 + with: + version: 8 + + - name: Set up node + uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b29057a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Continuous Integration + +on: [push] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [18] + steps: + - name: Clone repository + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Codegen + run: pnpm codegen + + - name: Typecheck + run: pnpm typecheck + + - name: Lint + run: pnpm lint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c67a0f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +ARG NODE_VERSION=18 + +# Alpine image +FROM node:${NODE_VERSION}-slim AS base +RUN npm install pnpm turbo --global +RUN pnpm config set store-dir ~/.pnpm-store + +FROM base as installer +WORKDIR /app + +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +FROM base as runner +WORKDIR /app + +COPY --from=installer /app/node_modules ./node_modules +COPY . . + +CMD ["pnpm", "ponder", "start"] + diff --git a/package.json b/package.json index ac3ee7b..b6bfdfb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "stratosphere-points", + "name": "stratosphere-points-indexer", "version": "0.0.1", "private": false, "type": "module", @@ -7,14 +7,16 @@ "dev": "ponder dev", "start": "ponder start", "codegen": "ponder codegen", - "lint": "eslint .", - "typecheck": "tsc" + "lint": "eslint . --ext .ts --max-warnings 0", + "typecheck": "tsc --noEmit", + "docker:build": "docker build -t stratosphere-points-indexer .", + "docker:run": "docker run --env-file .env -p 3000:3000 stratosphere-points-indexer" }, "dependencies": { - "@ponder/core": "^0.2.6", - "axios": "^1.6.7", - "ethers": "^6.11.1", - "viem": "^1.19.3" + "@ponder/core": "0.2.6", + "axios": "1.6.7", + "ethers": "6.11.1", + "viem": "1.19.3" }, "devDependencies": { "@types/node": "^20.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dc9b94..16d0a85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,16 +6,16 @@ settings: dependencies: '@ponder/core': - specifier: ^0.2.6 + specifier: 0.2.6 version: 0.2.6(@types/node@20.9.0)(typescript@5.2.2)(viem@1.19.3) axios: - specifier: ^1.6.7 + specifier: 1.6.7 version: 1.6.7 ethers: - specifier: ^6.11.1 + specifier: 6.11.1 version: 6.11.1 viem: - specifier: ^1.19.3 + specifier: 1.19.3 version: 1.19.3(typescript@5.2.2) devDependencies: diff --git a/ponder.config.ts b/ponder.config.ts index a158705..a8a18b3 100644 --- a/ponder.config.ts +++ b/ponder.config.ts @@ -8,6 +8,10 @@ import { addresses } from "./src/config/constants"; import { LiquidMiningAbi } from "./abis/LiquidMiningAbi"; import { VapeStakingAbi } from "./abis/VapeStakingAbi"; +const maxBlockRange = process.env.MAX_BLOCK_RANGE + ? parseInt(process.env.MAX_BLOCK_RANGE) + : 2_000; + export default createConfig({ networks: { avalanche: { @@ -26,6 +30,7 @@ export default createConfig({ avalanche: { address: addresses.DexAggregator?.avalanche, startBlock: 42346292, + maxBlockRange, }, }, }, @@ -35,6 +40,7 @@ export default createConfig({ avalanche: { address: addresses.Stratosphere?.avalanche, startBlock: 20310567, + maxBlockRange, }, }, }, @@ -45,6 +51,7 @@ export default createConfig({ avalanche: { address: addresses.LiquidMining?.avalanche, startBlock: 32271032, + maxBlockRange, }, }, }, @@ -55,6 +62,7 @@ export default createConfig({ avalanche: { address: addresses.VapeStaking?.avalanche, startBlock: 32271032, + maxBlockRange, }, }, },