This web application and back-end builds a Stacking tracker for all PoX/Signer/Miner infrastructure needs on Stacks.
The development of this application is supported by a critical bounty from the Stacks foundation, see stacksgov/critical-bounties#28
Next.JS
See package.json for available commands.
AWS CLI
AWS CDK
npm install -g aws-cdk
Domain The domain should be set up in AWS manually.
Credentials
Create a .env file similar to .env.example in /cdk
Run aws configure. The access_key_id and secret_access_key can be found via AWS IAM console. Output format should be set to json.
This should create 2 files:
-
~/.aws/credentials
-
~/.aws/config
Deploy
Test docker build:
docker build -t stacking-tracker .
Bootstrap CDK:
- Run:
cdk bootstrap
Setup CloudFront and Certificate:
cdk deploy CloudFront- Update vars
CDK_AWS_CERTIFICATE_ARNandCDK_AWS_HOSTEDZONE_IDin/cdk/.env
Deploy Architecture:
cdk deploy Queuescdk deploy Vpccdk deploy Databasecdk deploy Cluster
Setup Database:
- Get the database url from AWS Secrets Manager, update var
DATABASE_URLin/cdk/.envand/packages/database - In
/packages/databaserunnpm run db:generate - In
/packages/databaserunnpm run db:push
Deploy Services:
cdk deploy StacksListenercdk deploy PublicApicdk deploy Webcdk deploy Lambdas
Local Postgresql on Mac OS
Needed to run tests.
-
brew install postgresql -
brew services start postgresql -
psql postgres -
CREATE ROLE test WITH LOGIN PASSWORD 'test'; -
CREATE DATABASE tracker_test; -
GRANT ALL PRIVILEGES ON DATABASE tracker_test TO test;
Environment Variables
Create a .env file similar to .env.example in:
-
/cdk
-
/apps/functions
-
/apps/stacks-listener
-
/packages/database
-
/packages/stacks
Lambda Scripts
ts-node signer-processor.ts run
CDK
-
cdk bootstrap -
cdk deploy -
cdk destroy
Drizzle
npx drizzle-kit studionpx drizzle-kit generatenpx drizzle-kit push
Create bot via BotFather chat.
Use ngrok to set up tunnel to local machine: ngrok http 3030
curl -X POST "https://api.telegram.org/bot{{botid}}/setWebhook" -d "url=https://5.ngrok-free.app/telegram"
curl -X POST "https://api.telegram.org/bot{{botid}}/getWebhookInfo"
curl -X POST "https://api.telegram.org/bot{{botid}}/deleteWebhook"