Skip to content

Latest commit

 

History

History
154 lines (131 loc) · 4.79 KB

LOCAL_SETUP.md

File metadata and controls

154 lines (131 loc) · 4.79 KB

Local Development Setup Guide (Testnet)

Initial Project Setup

  1. Install node and yarn.
  2. Clone the repo:
git clone [email protected]:near-daos/astro-api-gateway.git
  1. Checkout to dev branch:
git checkout development
  1. Install dependencies:
yarn

VPN Setup

VPN connection is required to access Astro Indexer Database.

  1. Go to self-service portal: https://vpn.dev.astrodao.com
  2. Download and install AWS Client VPN for your platform.
    VPN Setup
  3. Download the VPN client configuration file.
    VPN Setup
  4. Open AWS Client VPN, go to File > Manage Profiles > Add Profile. Enter display name, provide configuration file and click Add Profile.
    VPN Setup
  5. Open AWS Client VPN, select the profile and click connect.
    VPN Setup
  6. Wait until VPN connection is established.
    VPN Setup

Docker Setup

  1. Install Docker: https://docs.docker.com/get-docker/
  2. Install Docker Compose: https://docs.docker.com/compose/install/
  3. Open console in project root folder and run:
docker-compose -f docker-compose-dev.yml up

Database Migration

After first docker start postgres database is empty, to run database migration:

yarn migration:run

To run dynamodb migration:

DATABASE_MIGRATIONS_LIST=DynamoTableMigration yarn start-migrations

Environment variables

By default .env contains environment variables needed for local development besides some secrets that need to be added locally.
To override or add some local env variables create .env.local in the root folder.
List of variables that might change depending on your needs:

  • NEAR environment variables (testnet by default):
NEAR_ENV=development
NEAR_CONTRACT_NAME=sputnikv2.testnet
NEAR_TOKEN_FACTORY_CONTRACT_NAME=tokenfactory.testnet
  • Indexer database connection variables (public testnet indexer by default):
NEAR_INDEXER_DATABASE_HOST=35.184.214.98
NEAR_INDEXER_DATABASE_PORT=5432
NEAR_INDEXER_DATABASE_NAME=testnet_explorer
NEAR_INDEXER_DATABASE_USERNAME=public_readonly
NEAR_INDEXER_DATABASE_PASSWORD=nearprotocol
  • DAO database connection variables (docker's postgres by default):
DATABASE_USERNAME=sputnik
DATABASE_PASSWORD=sputnik
DATABASE_NAME=sputnik-v2
DATABASE_HOST=localhost
DATABASE_PORT=5437
  • DynamoDB connection variables (docker's amazon/dynamodb-local by default):
DYNAMODB_REGION=local
DYNAMODB_ENDPOINT=http://localhost:8000
DYNAMODB_TABLE_NAME=entities_dev
AWS_ACCESS_KEY_ID=223344
AWS_SECRET_ACCESS_KEY=wJalrXUtTHISI/DYNAMODB/bPxRfiCYEXAMPLEKEY
  • Drafts database connection variables (docker's mongodb by default):
DRAFT_DATABASE_HOST=localhost
DRAFT_DATABASE_PORT=27021
DRAFT_DATABASE_USERNAME=draft
DRAFT_DATABASE_PASSWORD=draft
DRAFT_DATABASE_CERT_PATH=
  • Notifi config:
NOTIFI_ENV=Development
NOTIFI_SID=
NOTIFI_SECRET=

Note: Do not edit .env file as you can accidentally commit some secrets.

Run services

After all previous steps are finished, services are ready to start. You can run all/some services in parallel or a single service separately dependent or your needs.

DAO API service

Provides a list of API endpoints (http and socket) used on Astro DAO application.

  • Run service in dev mode:
yarn start-api:dev

Aggregator service

Synchronization historical data from DAO Contracts with the Database, updating FT and NFT tokens data, storing DAO statistics

  • Run service in dev mode:
yarn start-aggregator:dev

Draft service

Exposing all API endpoints used for managing draft proposal and comments on Astro UI.

  • Add PORT=3001 to .env.local to avoid port conflict with DAO API service.
  • Run service in dev mode:
yarn start-draft:dev

Notifier service

Responsible for sending notifications using Notifi

  • Run service in dev mode:
yarn start-notifier:dev

Indexer Processor service

Responsible for synchronization real time data from DAO Contracts with the Database.
Service depends on Astro Lake Framework

yarn start-indexer-processor:dev