You'll notice a set files with the .env
prefix. The .env
file contains environment variables that apply to all users across all environments. To add an environment variable specific to your local setup, add the variable to .env.NODE_ENV.local
where NODE_ENV can be test, development, etc.
Make sure a local ganache instance is running by following the instructions at the root of the repo
$ npm i -g yarn
$ yarn install
$ yarn watch (will rebuild app on file change)
- To enable logging to the console, set
LOG_DESTINATION=console
- To enable logging to a file, set
LOG_DESTINATION=someFilenameOtherThanConsole
NOTE: Running this package makes a connection to a shared external Firebase database. So, to avoid colliding with other developers also running this package, set the environment variable HUB_PARTICIPANT_ID
to one that is likely not being used by any other developer for local development purposes.
To connect to the hub
from the browser wallet
, the hub
and the browser wallet
need to:
- Share the state-channel address of the hub. A good way to do so is to create a
.env.development.local
in the monorepo root withHUB_CHANNEL_PK
defined. - Point to the same local Ganache server. Configure your
.env
files accordingly. This should work without any modifications. - Point to the same shared local Ganache server. This should work without any modifications. To see which ports are being used by the
hub
andwallet
, and to verify they are the same, you can reference theGANACHE_PORT
environment variable which by default is set in.env
of each package. - Point to the same contract addresses on Ganache. This will be the case if the hub and the client wallet point to the same Ganache server.
You will also need to make sure that the hub's blockchain address has funds. The default hub blockchain address is calculated from the HUB_CHAIN_PK in constants.ts. This address will have funds by default. Ganache is started with these funded private keys. Consequently, feel free to substitute any of these private keys for HUB_CHAIN_PK
.
For any environment variables specific to local setup, do not modify .env
files checked into the repository. Instead, add the variables to .env.test.local
(or to other local .env
files).
yarn install
yarn test:ci
Heroku runs a production version of the build docker/simple-hub.dockerfile
. To deploy:
- The preferred method is to use the deploy branch. Push the desired commit to the branch, and the
release-hub
CicrcleCI job will build and release the hub. - The manual way is to run
docker/build-push-release.sh
. The key point to take in is that this relies on pre-transpiled monorepo packages (nitro-protocol, wire-format, and simple-hub). If the transpiled directories are out of date or contain development changes, the deploy script will push those to the production heroku. The safest way to use the build script is to:- Remove the build directories for all monorepo packages that the hub uses. These are typically named
build
orlib
. - Run
yarn
in monorepo root. This will rebuild all monorepo packages viayarn prepare
automatically triggered byyarn
. - Run
docker/build-push-release.sh
.
- Remove the build directories for all monorepo packages that the hub uses. These are typically named
To start a hub in a docker container locally with development environment variables:
docker run -it --env-file .env.development registry.heroku.com/simple-hub-production/simple-hub:latest
To start a docker container locally without starting the hub, append bash
to the command above. This is handy when you would like to poke around the container or try running commands in the container:
docker run -it --env-file .env.development registry.heroku.com/simple-hub-production/simple-hub:latest bash