diff --git a/apps/indexer/.env.example b/apps/indexer/.env.example new file mode 100644 index 00000000..ebacfa1b --- /dev/null +++ b/apps/indexer/.env.example @@ -0,0 +1,2 @@ +AUTH_TOKEN=dna_xxx +POSTGRES_CONNECTION_STRING=postgresql://admin:postgres@localhost:5432/indexer \ No newline at end of file diff --git a/apps/indexer/Dockerfile b/apps/indexer/Dockerfile index 9f5c6e32..79e6de98 100644 --- a/apps/indexer/Dockerfile +++ b/apps/indexer/Dockerfile @@ -11,8 +11,8 @@ FROM quay.io/apibara/sink-postgres:0.7.0-x86_64 WORKDIR /app COPY ./src/* /app -ARG DATABASE_CONN_STRING +ARG POSTGRES_CONNECTION_STRING -ENV DATABASE_CONN_STRING=${DATABASE_CONN_STRING} +ENV POSTGRES_CONNECTION_STRING=${POSTGRES_CONNECTION_STRING} ENTRYPOINT ["/nix/store/rh1g8pb7wfnyr527jfmkkc5lm3sa1f0l-apibara-sink-postgres-0.7.0/bin/apibara-sink-postgres"] diff --git a/apps/indexer/README.md b/apps/indexer/README.md index 6c3a5609..ba2dbc4e 100644 --- a/apps/indexer/README.md +++ b/apps/indexer/README.md @@ -5,16 +5,15 @@ ## Install Postgres and Init the tables ``` -docker run --name afk-indexer -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 -v /afk-indexer:/docker-entrypoint-initdb.d postgres:16 +docker run --name afk-indexer -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=admin -e POSTGRES_DB=indexer -d -p 5432:5432 -v ./:/docker-entrypoint-initdb.d postgres:latest ``` # Test -unrugmeme_deploy +buy-token deploy ``` -apibara run ./src/pump-buy-coin.js -A dna_XXX - +apibara run ./src/buy-token.ts --allow-env .env -A dna_xxx ``` @@ -27,4 +26,4 @@ apibara run ./src/pump-buy-coin.js -A dna_XXX ``` ### Run it - docker run -it --env-file ./.env afk-indexer run /app/buy-token --tls-accept-invalid-certificates=true --allow-env-from-env DATABASE_CONN_STRING \ No newline at end of file + docker run -it --env-file ./.env afk-indexer run /app/buy-token.ts --tls-accept-invalid-certificates=true --allow-env-from-env POSTGRES_CONNECTION_STRING \ No newline at end of file diff --git a/apps/indexer/init.sql b/apps/indexer/init.sql index 06937b4a..daf01e44 100644 --- a/apps/indexer/init.sql +++ b/apps/indexer/init.sql @@ -55,8 +55,8 @@ CREATE TABLE token_transactions ( current_supply TEXT, liquidity_raised TEXT, price TEXT, + protocol_fee TEXT, amount TEXT, - time_stamp timestamp, _cursor bigint, transaction_type TEXT NOT NULL CHECK (transaction_type IN ('buy', 'sell')) diff --git a/apps/indexer/src/buy-token.ts b/apps/indexer/src/buy-token.ts index 6ba289e3..b37572f7 100644 --- a/apps/indexer/src/buy-token.ts +++ b/apps/indexer/src/buy-token.ts @@ -22,7 +22,7 @@ export const config = { filter, sinkType: "postgres", sinkOptions: { - connectionString: Deno.env.get("DATABASE_CONN_STRING"), + connectionString: Deno.env.get("POSTGRES_CONNECTION_STRING"), tableName: "token_transactions" } };