This repo consists of 3 main parts:
src
- Foundry contracts (read more https://book.getfoundry.sh/). Generally, repo follow structure of Foundry repo.subgraph
- javascript client to interact with the graph node, called subgraph (read more https://thegraph.com/docs/quick-start), READMEts-client
- npm package from contract developers to interact with contracts, more in READMEintegration-tests
- npm module to prepare integration tests for Deal contracts flow, more in README
To access to the general points of the each part in the repo root makefile is presented. Below are main commands of the makefile.
| The root package.json consists of dev packages for prettier and code linting via Husky. More about in
Full requirements to develop in this repo.
- foundry (https://book.getfoundry.sh/)
- makefile (TODO)
- node version 18.16
To work with contracts we use forge (foundry): to deploy, to test unittests. Thus, to work in the repo you first of all should install Foundry: https://book.getfoundry.sh/
To run foundry commands and commands that create artifacts and insert contract artifacts into packages/modules: ts-client, subgraph we use makefile
(and we use makefile for even further steps after: to build & deploy those modules after injecting artefacts of contracts into them).
Because scripts and makefile supports env (actually makefile reads env from .env) we note that in the repo we leave .example.env.
Below is the list of env. For description we aim you to .example.env directly.
- PRIVATE_KEY
- LOCAL_CHAIN_BLOCK_MINING_INTERVAL
- MAX_FAILED_RATIO
- IS_MOCKED_RANDOMX
Below is some of useful makefile commands with their descriptions.
To check out all commands and their descriptions run make help
.
$ make install-npms
$ make build-all
$ make build-contracts
$ make build-npms
$ make deploy-subgraph-local
$ docker compose -f docker/docker-compose.yml up
RPC: http://0.0.0.0:8545
Explorer: http://localhost:4000
$ make start-local-chain
$ make deploy-contracts-local
$ PRIVATE_KEY=${} make deploy-{network_name}
- Contracts
$ forge test
- TS Clients
cd ts-client && npm test unittests
cd ts-client && npm test integrational-tests
$ forge fmt
Error on make <soemthing>
:
No such file or directory (os error 2); check configured remappings.
git submodule update --init --recursive
$ forge snapshot
It is a backend for the contracts that collects info from contract events into graphQL schemes.
For more info check out README.md.
After starting local network you could create market on our contracts:
$ make create-pure-market-local
In the monorepo we use general code style defined in .editorconfig and mirrored in .prettierrc (it is mirrored coz of this issue).
Note, that in repo CI process maintain the prettier check.
To install pre-commit follow instruction here: https://pre-commit.com/
TODO: add flow on how to work with already built images from registry.
Let`s suppose you want to boot up local network and subgraph (thus, all deal infrastructure) to develop on the repo locally.
- Clone this repo. Clone with submodules, e.g.:
git submodule update --init --recursive
2. Start local chain node containers (chain, explorer, deploy script):
```bash
docker compose -f docker/docker-compose.yml up -d --build
| Note, you can omit --build
flag if you have already built images locally, nothing to rebuild.
| Note, that chain-deploy-script
will produce deployment/local.json
file that is used in
the next steps.
- Prepare npm packages:
make install-npms
make build-npms
- Deploy subgraph:
make deploy-subgraph-local
- [Optional] Since contracts are fresh and empty you can fill them with test data:
make create-pure-market-local
- To stop and cleanup dev environment run:
docker-compose -f docker/docker-compose.yml down --volumes
- To redeploy contracts:
make deploy-contracts-local
and do not forget to repeat from 3d step (depends on your needs).