haveno/docs/developer-guide.md

53 lines
3.6 KiB
Markdown
Raw Normal View History

2021-10-30 15:34:32 +02:00
# Developer Guide
This document is a guide for Haveno development.
## Installing and testing Haveno
2021-10-30 15:34:32 +02:00
[Build Haveno and join the test network or test locally](installing.md).
2021-10-30 15:34:32 +02:00
## Running the UI proof of concept
2022-05-03 14:03:09 +02:00
Follow [instructions](https://github.com/haveno-dex/haveno-ts#run-in-a-browser) to run Haveno's UI proof of concept in a browser.
2021-10-30 15:34:32 +02:00
This proof of concept demonstrates using Haveno's gRPC server with a web frontend (react and typescript) instead of Bisq's JFX application.
## Importing Haveno into development environment
Follow [instructions](import-haveno.md) to import Haveno into a development environment.
## Running end-to-end API tests
2022-05-03 14:03:09 +02:00
Follow [instructions](https://github.com/haveno-dex/haveno-ts#run-tests) to run end-to-end API tests in the UI project.
2021-10-30 15:34:32 +02:00
## Adding new API functions and tests
2022-05-03 14:03:09 +02:00
1. Follow [instructions](https://github.com/haveno-dex/haveno-ts#run-tests) to run Haveno's existing API tests successfully.
2021-10-30 15:34:32 +02:00
2. Define the new service or message in Haveno's [protobuf definition](../proto/src/main/proto/grpc.proto).
3. Clean and build Haveno after modifying the protobuf definition: `make clean && make`
4. Implement the new service in Haveno's backend, following existing patterns.<br>
For example, the gRPC function to get offers is implemented by [`GrpcServer`](https://github.com/haveno-dex/haveno/blob/master/daemon/src/main/java/bisq/daemon/grpc/GrpcServer.java) > [`GrpcOffersService.getOffers(...)`](https://github.com/haveno-dex/haveno/blob/b761dbfd378faf49d95090c126318b419af7926b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java#L104) > [`CoreApi.getOffers(...)`](https://github.com/haveno-dex/haveno/blob/b761dbfd378faf49d95090c126318b419af7926b/core/src/main/java/bisq/core/api/CoreApi.java#L128) > [`CoreOffersService.getOffers(...)`](https://github.com/haveno-dex/haveno/blob/b761dbfd378faf49d95090c126318b419af7926b/core/src/main/java/bisq/core/api/CoreOffersService.java#L126) > [`OfferBookService.getOffers()`](https://github.com/haveno-dex/haveno/blob/b761dbfd378faf49d95090c126318b419af7926b/core/src/main/java/bisq/core/offer/OfferBookService.java#L193).
5. Build Haveno: `make`
2022-05-03 14:03:09 +02:00
6. Update the gRPC client in haveno-ts: `npm install`
7. Add the corresponding typescript method(s) to [haveno.ts](https://github.com/haveno-dex/haveno-ts/blob/master/src/haveno.ts) with clear and concise documentation.
8. Add clean and comprehensive tests to [haveno.test.ts](https://github.com/haveno-dex/haveno-ts/blob/master/src/haveno.test.ts), following existing patterns.
9. Run the tests with `npm run test -- -t 'my test'` to run tests by name and `npm test` to run all tests together. Ensure all tests pass and there are no exception stacktraces in the terminals of Alice, Bob, or the arbitrator.
2022-05-03 14:03:09 +02:00
10. Open pull requests to the haveno and haveno-ts projects for the backend and frontend implementations.
2021-10-30 15:34:32 +02:00
## How to rebase and squash your commits
When submitting a pull request for review, please first rebase and squash your commits.
1. Checkout the latest version from master, e.g.: `git checkout master && git pull upstream master`
2. Checkout your feature branch, e.g.: `git checkout your_branch`
3. Optionally make a backup branch just in case something goes wrong, e.g.: `git checkout -b your_branch_bkp && git checkout your_branch`
4. Rebase on master: `git rebase master`
5. Squash your commits: `git reset --soft <last hash before your first commit>`
6. Commit your changes to a single commit: `git commit`
7. Push your local branch to your remote repository: `git push --force`
If you have a PR open on that branch, it'll be updated automatically.
2021-10-30 15:34:32 +02:00
## Trade Protocol
For documentation of the trade protocol, see [trade protocol](trade_protocol/trade-protocol.pdf).