This monorepo contains all the main apps and libraries used in the Solomon payments ecosystem. It relies on Nx for generating, running, building, and testing.
We recommend PNPM over NPM for package management. In the following sections, we also make use of an pnpx
alias, which can be added to your shell profile.
npm install -g pnpm
alias pnx="pnpm run nx --"
pnpm install
Follow these instructions to set up your local development environment. Only MacOs instructions are provided, but a similar process can be followed on other systems (replace Brew with local package manager).
Global Dependencies
Docker - containerization Kubernetes cluster on your desktop.
Homebrew - package manager for macOS.
NodeJs (LTS) and NPM - Follow NVM Wiki to install and select the correct Node/NPM versions
Helm - The package manager for Kubernetes.
$ brew install helm
Skaffold - build/deploy tool for local Kubernetes development.
$ brew install skaffold
Generate util-contract
The libs/shared/util-contract
is generated from apps/contracts
with following command:
pnpm run contracts:generate-type
Start local dev environment
$ pnpm install
$ pnpm run skaffold
Run individual Dockerfiles
It's possible to run apps individually, which can be useful if you're verifying package changes or debugging docker syntax:
Build the base image:
docker build --no-cache --progress=plain -t solomon_base:test -f tools/docker/base/Dockerfile .
Build app images
# Contracts
docker build --progress=plain --no-cache -t contracts:dev --build-arg SOLOMON_BASE=solomon_base:test -f apps/contracts/Dockerfile --target=dev .
# Blockchain watcher
docker build --progress=plain --no-cache -t blockchain-watcher:dev --build-arg SOLOMON_BASE=solomon_base:test -f apps/blockchain-watcher/Dockerfile --target=dev .
# API Database
docker build --progress=plain --no-cache -t db-api -f apps/db-api/Dockerfile .
# API
docker build --progress=plain --no-cache -t api:dev --build-arg SOLOMON_BASE=solomon_base:test -f apps/api/Dockerfile --target=dev .
# Web evidence
docker build --progress=plain --no-cache -t web-evidence:dev --build-arg SOLOMON_BASE=solomon_base:test -f apps/web-evidence/Dockerfile --target=dev .
The following table outlines all the apps available. Each app is located in apps/<app-name>
, and <app-name>
can be substituted in the next section to serve, build, or test specific apps.
app-name | Description |
---|---|
blockchain-watcher | Watches Solomon contracts and informs other apps when events occur |
api | Handles evidence upload and emailing parties during disputes |
Serve (local development)
pnpx nx serve <app-name>
Build
pnpx nx build <app-name>
Unit test
pnpx nx test <app-name>
E2E test
pnpx nx e2e <app-name>
apps/web-evidence
apps/api-evidence
The purpose of the uploader is to provide a simple interface for uploading evidence links to the blockchain during escrow disputes. Links must exist for the duration of the dispute (generally a maximum of 2 months). There are several methods for uploading evidence, and it is straightforward to add more.
backend
uploads to an S3-compatible data storeCurrently, only Metamask is supported as a wallet provider for posting the link to the blockchain, but WalletConnect and other methods may be added in the future.
A hosted frontend and backend will be provided by Solomon, based on this repository.
Currently, e2e test is not integrated to CI/CD yet. Please run skaffold dev
first, and run nx run app-e2e:e2e
in another console.
blockchain-watcher:generate-mail-template
: Generate mail html templates for watcher.blockchain-watcher:generate-event-interface
: Generate api events TypeScript interface for watcher.contract:generate-type
: Generate contracts type definitions.commit-msg
: Check the commit msg, the naming rule as follows.pre-push
:
nx format:write --base=main --head=HEAD
(use prettier)The branch name format is: <issue-number>_<short-summary>
(^[0-9]+_[a-z0-9-]+$
). For example: 17_some-fix
, 132_improve-core-performance
.
issue-number
: Numeral only.short-summary
: Short summary about the branch. Numeral, lowercase character and _
are acceptable. Uppercase would cause CI error, so lowercase only.The commit message format is: <scope> [<project>]: <short-summary> #<issue-number>
scope
: Follow the gitmoji ruleproject
: One of web
, api
, blockchain
, docs
and root
short-summary
: Short summary about this commitissue-number
: The related issue numberAll commit message header sections are required, and enforced by husky. You can check the validator here.
The following are gitmoji
recommendations for the scope
. These are not currently enforced, but may be in the future.
:bookmark:
:sparkles:
:books:
:bug:
:white_check_mark:
:art:
:hammer:
:fire:
:green_heart:
:lock:
:boom:
:wrench:
**.sh: not found
when running skaffold in Windows.
*.sh
files is LF
, not CRLF
, you can change it in your IDE. SO ref here.