This is monorepo of Risedle's Snapshot services.
- PostgreSQL: Database that store all snapshot data.
- Snapshot Workers: Service that collect data from Vault contract
- Snapshot API: REST API service that serve data collected by the workers.
We use TypeORM to manage the database.
Please read PostgreSQL for more details on how to connect the database to your local machine.
- Create new database (e.g
snapshot_arbitrum
) - Create new
.env
based on.env.example
- Run database migration
npm run typeorm migration:run
- Edit the
worker/cron.ts
with your config, try run locally first. - Create new app
flyctl launch
with specified name (e.g.snapshot-arbitrum-workers
) - Create the secret
flyctl secrets --app snapshot-arbitrum-workers set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
- Create new fly config (e.g.
snapshot-arbitrum-workers.toml
) - Deploy the app
flyctl deploy --app snapshot-arbitrum-workers --config snapshot-arbitrum-workers.toml
- Create new app for the snapshot-api
flyctl launch
with namesnapshot-arbitrum-api
- Create new secret
flyctl secrets --app snapshot-arbitrum-api set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
- Create new fly config (e.g
snapshot-arbitrum-api.toml
) - Deploy the app
flyctl deploy --app snapshot-arbitrum-api --config snapshot-arbitrum-api.toml
- Setup custom domain name for the API and done.
Copy .env.example
to .env
and edit the content.
Then follow step by step below:
- Update entity in
./entities
. Mark column as nullable if you add existing column, don't ever delete the existing column. - Generate the migration file:
npm run typeorm migration:generate -- -n MIGRATIONNAME
- Run the migrations:
npm run typeorm migration:run
Copy .env.example
to .env
and edit the content.
Make sure you setup the Fly.io wireguard.
Then run the following command:
node -r ts-node/register api/server.ts
Copy .env.example
to .env
and edit the content.
Make sure you setup the Fly.io wireguard.
Then run the following command:
node -r ts-node/register workers/cron.ts
This bot is deployed to fly.io.
Create new app:
flyctl launch
Set the secrets:
flyctl secrets --app snapshot-kovan-workers set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
flyctl secrets --app snapshot-kovan-api set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
flyctl secrets --app snapshot-arbitrum-workers set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
flyctl secrets --app snapshot-arbitrum-api set RPC_URL="here" SENTRY_DSN="here" POSTGRES_URL="here"
Run the following command to deploy:
flyctl deploy --app snapshot-kovan-workers --config snapshot-kovan-workers.toml .
flyctl deploy --app snapshot-kovan-api --config snapshot-kovan-api.toml .
flyctl deploy --app snapshot-arbitrum-workers --config snapshot-arbitrum-workers.toml .
flyctl deploy --app snapshot-arbitrum-api --config snapshot-arbitrum-api.toml .
Don't forget to sync schema for the first deployment.