yarn build
- build the applicationyarn start
- start the built applicationyarn dev
- start the application using eslint-registeryarn format
- check if formatting is correct with prettieryarn format:fix
- run prettier automatic formatteryarn lint
- check if the code satisfies the eslint configurationyarn lint:fix
- run eslint automatic fixeryarn typecheck
- check if the code satisfies the typescript compileryarn test
- run tests
To run or develop the backend you need to install and build its dependencies. You can do it by running the following commands in the repository root:
yarn
yarn build
After the nodejs dependencies have been installed you should also install a Postgres database. The recommended way is through docker using the commands below.
docker run -d --name=state_explorer_postgres -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
docker exec -it state_explorer_postgres psql -U postgres -c 'CREATE DATABASE local'
docker exec -it state_explorer_postgres psql -U postgres -c 'CREATE DATABASE test'
If you restart your system, running docker start state_explorer_postgres
will bring the database back online.
Once you have everything, create a .env
file with the following contents:
LOCAL_DB_URL=postgresql://postgres:password@localhost:5432/local
TEST_DB_URL=postgresql://postgres:password@localhost:5432/test
JSON_RPC_URL=<PASTE_YOUR_ALCHEMY_URL_HERE>
STARKEX_INSTANCE=dydx-mainnet
You can configure the behavior of the app with the following environment variables:
STARKEX_INSTANCE
- Mode in which the explorer is started (dydx-mainnet | dydx-local | gammax-goerli | myria-goerli
) If you want to start it ingammax-goerli
mode you will also need to provideGAMMAX_AG_SERVER_CERTIFICATE
,GAMMAX_AG_USER_CERTIFICATE
,GAMMAX_AG_USER_KEY
andGAMMAX_AG_URL
environment variables. ReplaceGAMMAX
withMYRIA
formyria-goerli
environment variablesDATABASE_URL
- Database url used in production deploymentLOCAL_DB_URL
- Database url used inyarn start
TEST_DB_URL
- Database url used inyarn test
LOG_LEVEL
- Integer specifying the log level (0 | 1 | 2 | 3
). Seesrc/tools/Logger.ts
PORT
- The port on which the application exposes the apiMAX_BLOCK_NUMBER
- Integer specifying the maximum block number that is going to be stored - all blocks created later in time will be skipped (used in environments with limited database space e.g. heroku review apps)
add(T): number
- adds a new record and returns it's idaddMany(T[]): number[]
- adds many new records and returns their idsgetAll(): T[]
- returns an array of all recordsgetByKey(K): T[]
- returns an array of all matching recordsfindByKey(K): T?
- returns a single matching record or undefineddeleteAll(): number
- removes all records and returns the number of removed recordsdeleteByKey(K): number
- removes all matching records and returns the number of removed recordssave(T): boolean
- updates a record and returns boolean indicating if record was updated