Skip to content

Commit b9a2fbd

Browse files
committed
update Building Locally section based on my experience
1 parent ccded73 commit b9a2fbd

File tree

1 file changed

+79
-33
lines changed

1 file changed

+79
-33
lines changed

readme.md

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,87 +3,133 @@
33
</a>
44

55
# About
6+
67
This project provides written in Java API for interaction with a Polkadot or Substrate based network.
78

89
## Key features
9-
- ### Java 8 or higher.
10+
11+
### Java 8 or higher.
12+
1013
The main idea is to make this library available and usable for as many projects as possible.
1114

12-
- ### Non-blocking API.
15+
### Non-blocking API.
1316

1417
The API is designed to be non-blocking in order to not engage resources for waiting responses from a node, especially when working with web sockets.
1518
Each method returns `CompletableFuture<>`.
1619

17-
- ### Declarative approach.
20+
### Declarative approach.
21+
1822
Some of our goals are:
23+
1924
- make API simpler for usage;
2025
- let users organize their code similar to the one in the pallet they are interacting with;
2126
- hide difficulties of low level and infrastructure code;
2227
- facilitate the future maintenance.
2328

2429
The best approach to reach project’s goals is to use annotations and code generation techniques. Below are listed some annotations that this API shall provide:
30+
2531
- [x] Scale
26-
- [x] `@ScaleWriter`;
27-
- [x] `@ScaleReader`;
28-
- [x] `@Scale`;
29-
- [x] `@ScaleGeneric`;
30-
- [x] `@Ignore`;
32+
33+
- [x] `@ScaleWriter`;
34+
- [x] `@ScaleReader`;
35+
- [x] `@Scale`;
36+
- [x] `@ScaleGeneric`;
37+
- [x] `@Ignore`;
3138

3239
- [x] Rpc
33-
- [x] `@RpcInterface`;
34-
- [x] `@RpcCall`;
35-
- [x] `@RpcSubscription`;
36-
- [x] `@RpcEncoder`;
37-
- [x] `@RpcDecoder`;
40+
41+
- [x] `@RpcInterface`;
42+
- [x] `@RpcCall`;
43+
- [x] `@RpcSubscription`;
44+
- [x] `@RpcEncoder`;
45+
- [x] `@RpcDecoder`;
3846

3947
- [ ] Pallet
40-
- [x] `@Pallet`;
41-
- [ ] `@Transaction`;
42-
- [x] `@Storage`;
43-
- [x] `@Event`.
48+
- [x] `@Pallet`;
49+
- [ ] `@Transaction`;
50+
- [x] `@Storage`;
51+
- [x] `@Event`.
4452

4553
These allow the generation of scale serializers, deserializers, RPC methods, code for interaction with pallet, etc.
4654
More examples you can find below.
4755

48-
- ### Deferred parametrization of codecs
56+
### Deferred parametrization of codecs
57+
4958
Annotations for codecs allow deferring parameters of a generic until it's used at an RPC method. E.g.:
50-
```java
59+
60+
```java
5161
@RequiredArgsConstructor
5262
@Getter
5363
@ScaleWriter
5464
public class Some<A> {
55-
private final int number;
56-
private final A some;
65+
private final int number;
66+
private final A some;
5767
}
5868

5969
@RpcInterface(section = "test")
6070
public interface TestSection {
61-
@RpcCall(method = "sendSome")
62-
CompletableFuture<Boolean> doNothing(@Scale Some<Parameter> value);
71+
@RpcCall(method = "sendSome")
72+
CompletableFuture<Boolean> doNothing(@Scale Some<Parameter> value);
6373
}
6474
```
75+
6576
Annotation processors will generate scale writer for the class `Some` which expects another writer as a dependency.
6677
When a processor faces a parameter like `Some<String> value`, it injects the `Strings`'s writer into the writer of `Some`.
6778

68-
- ### GC Manageable requests.
79+
### GC Manageable requests.
80+
6981
We take care of either lost responses or canceled futures by not holding handlers that are needed to match an RPC request with a response.
7082

71-
- ### Tests run with substrate node.
83+
### Tests run with substrate node.
84+
7285
All API methods related to the substrate node will be tested for operability and compatibility.
7386
Currently, we use [test containers](https://www.testcontainers.org/) and docker image [parity/substrate:v3.0.0](https://hub.docker.com/layers/parity/substrate/v3.0.0/images/sha256-1aef07509d757c584320773c476dcb6077578bbf2f5e468ceb413dcf908897f1?context=explore).
7487

7588
## Building Locally
7689

7790
You will need to install
7891

79-
- [asdf](https://asdf-vm.com/guide/getting-started.html)
80-
- Install the [Rust plugin](https://github.com/asdf-community/asdf-rust)
81-
- Install the [Java plugin](https://github.com/halcyon/asdf-java)
82-
- Make sure to follow instructions in the **MacOS** section.
83-
- Then, run `asdf install` at the root of the repo.
92+
### Install Prerequisites:
8493

85-
_If you prefer to not use `asdf`, you can install [Rust directly](https://www.rust-lang.org/tools/install) and install Java via [`sdkman`](https://sdkman.io/install). Reference `.tool-versions` to ensure you are installing the correct versions._
94+
1. Install [asdf](https://asdf-vm.com/guide/getting-started.html) tools version manager. Make sure to follow instructions for your shell (e.g. ZSH, Fish, etc.) and package manager (e.g. Homebrew)
8695

87-
- [Docker](https://www.docker.com/products/docker-desktop/)
96+
- Install the [Rust plugin](https://github.com/asdf-community/asdf-rust)
97+
- Install the [Java plugin](https://github.com/halcyon/asdf-java)
98+
- Then, run `asdf install` at the root of the repo to install tools listed in `/.tool-versions`.
8899

89-
build
100+
1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/), an application for managing Docker containers and images along with docker CLI tools.
101+
102+
_Note: If using fish shell you'd need to update the $PATH manually with this command, so `docker` executables can be found:_
103+
104+
```sh
105+
set -U fish_user_paths /Applications/Docker.app/Contents/Resources/bin $fish_user_paths
106+
```
107+
108+
### Build and Publish
109+
110+
1. Build project.
111+
112+
```sh
113+
./gradlew build
114+
```
115+
116+
1. Publish compile artifacts to the local Maven cache, so other apps (e.g. Custodial Wallet) can consume it.
117+
```sh
118+
./gradlew publishToMavenLocal
119+
```
120+
121+
### Clean up Built Artifacts
122+
123+
To delete compiled artifacts in local `build` directories:
124+
125+
```sh
126+
./gradlew clean
127+
```
128+
129+
To verify all compiled artifacts have been deleted run this command in the repo root:
130+
131+
```sh
132+
find . -type d -name "build"
133+
---
134+
(should be empty output)
135+
```

0 commit comments

Comments
 (0)