-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tx-indexer and frontend integration (#10)
* chore: add docker-compose with tx-indexer * chore: correct frontend ports * feat: build from docker compose * feat: get new vaults handled by autoswap
- Loading branch information
1 parent
42baf1e
commit 975a313
Showing
15 changed files
with
135 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
indexer-db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "frontend/tx-indexer"] | ||
path = tx-indexer | ||
url = https://github.com/gnolang/tx-indexer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
services: | ||
frontend: | ||
build: frontend | ||
restart: always | ||
ports: | ||
- "80:3000" | ||
environment: | ||
- REACT_APP_TX_INDEXER_URL=tx-indexer:8546 | ||
tx-indexer: | ||
build: tx-indexer | ||
restart: always | ||
ports: | ||
- "8546:8546" | ||
entrypoint: ["/usr/local/bin/indexer", "start", "--remote", "https://rpc.test4.gno.land", "--db-path", "indexer-db"] | ||
volumes: | ||
- ./indexer-db:/indexer-db | ||
|
||
volumes: | ||
indexer-db: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.next | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
FROM node:20-alpine AS base | ||
|
||
|
||
|
||
### Dependencies ### | ||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat git | ||
|
||
|
||
|
||
# Setup pnpm environment | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@latest --activate | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --prefer-frozen-lockfile | ||
|
||
# Builder | ||
FROM base AS builder | ||
|
||
RUN corepack enable | ||
RUN corepack prepare pnpm@latest --activate | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
RUN pnpm build | ||
|
||
|
||
### Production image runner ### | ||
FROM base AS runner | ||
|
||
# Set NODE_ENV to production | ||
ENV NODE_ENV production | ||
|
||
# Disable Next.js telemetry | ||
# Learn more here: https://nextjs.org/telemetry | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# Set correct permissions for nextjs user and don't run as root | ||
RUN addgroup nodejs | ||
RUN adduser -SDH nextjs | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public | ||
|
||
USER nextjs | ||
|
||
# Exposed port (for orchestrators and dynamic reverse proxies) | ||
EXPOSE 3000 | ||
ENV PORT 3000 | ||
ENV HOSTNAME "0.0.0.0" | ||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "wget", "-q0", "http://localhost:3000/health" ] | ||
|
||
# Run the nextjs app | ||
CMD ["node", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const txIndexerUrl = process.env.REACT_APP_TX_INDEXER_URL || 'http://localhost:3100'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ type Pool = { | |
TVL: number; | ||
APY: number; | ||
balance: number; | ||
tokenId: string; | ||
} | ||
export type { Pool }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { txIndexerUrl } from "@/config/constants"; | ||
import { Pool } from "@/types/pool"; | ||
import axios from "axios"; | ||
|
||
export async function getPools(): Promise<Pool[]> { | ||
const data = await axios.post(txIndexerUrl + '/graphql/query', { | ||
data: { | ||
"query": "# Get all the transactions that contain the specified Events on them.\nquery getEvents {\n getTransactions(\n where: {\n \n # Filtering by block height will speed up your queries, because it is the main internal index.\n block_height :{\n gt:100000\n }\n \n # Only show transactions that succeeded.\n success: {eq: true}, \n response: {\n events: {\n \n # This filter is checking that all transactions will contains a GnoEvent that \n # is GNOSWAP type calling SetPoolCreationFee function.\n GnoEvent: {\n type: { eq:\"NewVault\" }\n }\n }\n }\n }\n ) {\n response {\n events {\n ... on GnoEvent {\n type\n func\n attrs {\n key\n value\n }\n }\n }\n }\n }\n}", | ||
"operationName": "getEvents" | ||
} | ||
}) | ||
|
||
const pools = data.data.response.events.map((event: any) => { | ||
const pool: Pool = { | ||
tokenId: event.attrs[0].value, | ||
token0: event.attrs[1].value, | ||
token1: event.attrs[2].value, | ||
fee: parseFloat(event.attrs[3].value), | ||
lowerTick: parseInt(event.attrs[4].value), | ||
upperTick: parseInt(event.attrs[5].value), | ||
currentTick: 0, // TODO get current tick | ||
TVL: 0, // TODO get TVL | ||
APY: 0, // TODO get APY | ||
balance: 0 // TODO get balance | ||
} | ||
return pool; | ||
}); | ||
return pools; | ||
} |
Submodule tx-indexer
added at
83ec06