Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 2 additions & 100 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ The best approach to reach project’s goals is to use annotations and code gene
- [x] `@RpcDecoder`;

- [ ] Pallet
- [ ] `@Pallet`;
- [x] `@Pallet`;
- [ ] `@Transaction`;
- [ ] `@Query`;
- [x] `@Storage`;
- [ ] `@EventHandler`.

These allow the generation of scale serializers, deserializers, RPC methods, code for interaction with pallet, etc.
Expand Down Expand Up @@ -67,101 +67,3 @@ We take care of either lost responses or canceled futures by not holding handler
- ### Tests run with substrate node.
All API methods related to the substrate node will be tested for operability and compatibility.
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).

## Our vision of the API
### How to generate scale codec for DTO (implemented)
```java
@RequiredArgsConstructor
@Getter
@ScaleWriter
public class SignedExtra<E extends Era> implements Extra, SignedExtension {
@Ignore
private final long specVersion;
@Ignore
private final long txVersion;
@Ignore
private final BlockHash genesis;
@Ignore
private final BlockHash eraBlock;
private final E era;
@Scale(ScaleType.CompactBigInteger.class)
private final BigInteger nonce;
@Scale(ScaleType.CompactBigInteger.class)
private final BigInteger tip;

@Override
public AdditionalExtra getAdditionalExtra() {
return new SignedAdditionalExtra(specVersion, txVersion, genesis, eraBlock);
}
}
```

### How to generate RPC interface (implemented)
```java
@RpcInterface(section = "author")
public interface Author {
@RpcCall(method = "hasKey")
CompletableFuture<Boolean> hasKey(@Scale PublicKey publicKey, String keyType);

@RpcCall(method = "insertKey")
CompletableFuture<Void> insertKey(String keyType, String secretUri, @Scale PublicKey publicKey);

@RpcCall(method = "submitExtrinsic")
@Scale
CompletableFuture<Hash> submitExtrinsic(@Scale Extrinsic<?, ?, ?, ?> extrinsic);

@RpcSubscription(type = "extrinsicUpdate", subscribeMethod = "submitAndWatchExtrinsic", unsubscribeMethod = "unwatchExtrinsic")
CompletableFuture<Supplier<CompletableFuture<Boolean>>> submitAndWatchExtrinsic(@Scale Extrinsic<?, ?, ?, ?> extrinsic,
BiConsumer<Exception, ExtrinsicStatus> callback);
}
```

### Create instance of API (TBD)
```java
Api api = Api.builder()
.useWs()
.withNodes("127.0.0.1:9944", "127.0.0.2:9944")
.scanAnnotatedFrom("com.my_company.first", "com.my_company.second")
.build();
```

### RPC: call method (implemented but not integrated into the API)
```java
CompletableFuture<RuntimeVersion> versionFuture = api.getRpc()
.getState()
.getRuntimeVersion();
```

### RPC: subscribe (implemented but not integrated into the API)
```java
CompletableFuture<?> unsubscribe = api.getRpc()
.getChain()
.subscribeNewHeads((ex, header) -> { print(header); });
```

### Pallet: transaction (TBD)
```java
api.pallete(MyPallet.class)
.myExtrinsic(someValue)
.signAndSend(KEY_PAIR);
```

## To be implemented
- [x] Transport - layer that interacts with a node. It provides async API for RPC requests.
- [x] Scale
- [x] Scale codec - implementation of the [SCALE](https://docs.substrate.io/v3/advanced/scale-codec/) for standard types.
- [x] Scale code generation - approach to generate scale encoders/decoders for annotated classes.
- [ ] Signing:
- [x] SR25519
- [ ] ED25519
- [x] RPC code generation
- [x] RPC interfaces with methods
- [x] RPC encoders/decoders
- [ ] Declare known RPC sections and methods.
- [ ] Handling metadata
- [ ] Pallet API
- [ ] Transactions
- [ ] Queries
- [ ] Constants
- [ ] Events
- [ ] Load balancing