This application should run on any UN*X operating system, including most Linux distros and Mac OS X versions.
Make sure you have the following installed on your system:
Make sure you are a member on the GitHub team and
you have already configured git
on your machine. Also make sure
you've created an SSH key
and added it to your GitHub account
.
Clone the repository with git
:
$ git clone [email protected]:SwidgeTeam/swidge.git
A new swidge
directory should have been created wherever you typed the previous command. Change to this directory to
be able to run the commands which are described in successive sections:
$ cd swidge
In the swidge
directory, type:
$ make up
The app will be available in a moment on http://localhost:3000. Please note the first time you run this it will take a bit since it has to download and build a few Docker images.
The first time after you start the app, you need to perform an extra step to set up required data and configurations.
For that, once you have the app running, type the following:
$ make setup
This will dump the existing migrations into the database, and create a queue for the localstack SQS.
You can stop the application with:
$ make stop
Or use the restart
shortcut if you intend to start it next:
$ make restart
While the application is running, you can open a console to local MySQL server:
$ make db-client
Make sure the application is running and type:
$ make db-import < ./path/to/your/dump.sql
The Different parts of the application have tests on them, so to run them all you can just execute:
$ make test
You will normally never do that though, because it runs the tests on each project and normally you are working only on one of them, so you can run the tests of the project you are working on with:
$ make test-api
$ make test-api-e2e
$ make test-front
$ make test-relayer
$ make test-contract
For sure you can also run them by going into the project's folder and executing them with the specific
binary(normally yarn
), but those are just shortcuts so you can run them from the root.
You can fork any accepted chain with:
$ make fork-<chain>
That will run Hardhat inside a container and fork the selected chain. Once you have done that, you can run any of the following helpers.
You can find the accepted chains on this env file.
If you are working with the contracts and need to try things on local, you can deploy all the contracts' suite on your already forked chain by typing:
$ make deploy-all-fork-<chain>
The chain here must be the same that its already forked, because the contracts to be deployed have external contract addresses dependencies.
If you need some tokens instead, you can just get them from an already holding wallet by typing:
$ make get-tokens-<chain> token=<token_name>
You can find the accepted tokens on this YAML file. But if the one you're looking for it's not there, you can always add it.
$ make fuck-db
$ make setup
At any time, you can access to the full live feed of logs of the app by typing:
$ make logs
Or you can get the logs of one specific service with:
$ make <service-name>-logs
The service names are the names defined for the services on the docker-compose.yml.
If some changes have been made to the infrastructure, or if you are experiencing weird issues that you might identify as being related to misbehaving infrastructure, you can recreate it all and restart it showing the logs to be able to debug, with:
$ make fuck off
If you need to change any of the environment variables for you local setup, you can
do so by creating a .env
file on the root of the project, and adding there any of
the variables you wish to override.
For example you could have something like:
DOCKER_COMPOSE_COMMAND=docker compose
MYSQL_PORT=33060
That would tell Makefile to invoke Docker Compose with that custom command, and would use the port 33060 of your machine to expose the MySQL server.
You can do the same with any variable of the conditionally set variables on the Makefile, as
also any of the variables on the /env
folder.
If for some reason you cannot run Docker on your machine, or you have trouble with some OS-specific dependencies configurations, you can just run everything inside a Vagrant box. For that, follow these steps.
In order to execute the whole lifecycle of a transaction on your local machine, follow these steps.
Changes to the code should be related to a exiting card on Trello. If you are about to make changes which are not documented on an issue, create one first. Assign the issue to yourself.
-
Make sure your working directory is clean:
$ git status
-
Switch to the point you want to start your branch from. It will be
master
most of the times:$ git checkout master
-
Ensure your branch is up-to-date with remote repository:
$ git pull
-
Create your new branch. Its name should follow the pattern:
{trello-card-id}-{short-snake-cased-description-of-the-solution}
. For example, if you are going to resolve an issue with IDTvKVs0U3
, whose title isSmall amounts on the origin input should be well formatted
:$ git checkout --branch TvKVs0U3-small-amounts-on-origin-input # Or: git checkout -b TvKVs0U3-small-amounts-on-origin-input
-
Do some coding..
-
Push your new branch to the remote repository with
git push
. The first time you do this on a branch, you'll need to add the following arguments in order to link your local branch with the remote one for subsequent pushes:$ git push --set-upstream origin TvKVs0U3-small-amounts-on-origin-input # Or: git push -u origin TvKVs0U3-small-amounts-on-origin-input