-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add `TxClient` interface * chore: add option support to `ReplayObservable` * feat: add `txClient` implementation * test: `txClient` * test: tx client integration * chore: s/tx/transaction/g * chore: update pkg README.md template * wip: client pkg README * docs: fix client pkg godoc comment * fix: flakey test * chore: dial back godoc comments 😅 * chore: revise (and move to godoc.go) `testblock` & `testeventsquery` pkg godoc comment * chore: update go.mod * chore: refactor & condense godoc comments * chore: fix import paths post-update * chore: review feedback improvements * docs: update client README.md * docs: add `tx query` usage association between `txContext` & `Blockchain` * docs: add TOC * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * docs: improve godoc comments & client README.md --------- Co-authored-by: Daniel Olshansky <[email protected]>
- Loading branch information
1 parent
21edfe7
commit 51ae802
Showing
20 changed files
with
1,517 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# Package `client` | ||
|
||
## Table of Contents | ||
|
||
- [Overview](#overview) | ||
- [Features](#features) | ||
- [Architecture Overview](#architecture-overview) | ||
- [Component Diagram Legend](#component-diagram-legend) | ||
- [Clients Dependency Tree](#clients-dependency-tree) | ||
- [Network Interaction](#network-interaction) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Basic Example](#basic-example) | ||
- [Advanced Usage](#advanced-usage) | ||
- [Configuration](#configuration) | ||
- [API Reference](#api-reference) | ||
- [Best Practices](#best-practices) | ||
- [FAQ](#faq) | ||
|
||
|
||
## Overview | ||
|
||
The `client` package exposes go APIs to facilitate interactions with the Pocket network. | ||
It includes lower-level interfaces for working with transactions and subscribing to events generally, as well as higher-level interfaces for tracking blocks and broadcasting protocol-specific transactions. | ||
|
||
## Features | ||
|
||
| Interface | Description | | ||
|-------------------------|----------------------------------------------------------------------------------------------------| | ||
| **`SupplierClient`** | A high-level client for use by the "supplier" actor. | | ||
| **`TxClient`** | A high-level client used to build, sign, and broadcast transaction from cosmos-sdk messages. | | ||
| **`TxContext`** | Abstracts and encapsulates the transaction building, signing, encoding, and broadcasting concerns. | | ||
| **`BlockClient`** | Exposes methods for receiving notifications about newly committed blocks. | | ||
| **`EventsQueryClient`** | Encapsulates blockchain event subscriptions. | | ||
| **`Connection`** | A transport agnostic communication channel for sending and receiving messages. | | ||
| **`Dialer`** | Abstracts the establishment of connections. | | ||
|
||
## Architecture Overview | ||
|
||
```mermaid | ||
--- | ||
title: Component Diagram Legend | ||
--- | ||
flowchart | ||
c[Component] | ||
d[Dependency Component] | ||
s[[Subcomponent]] | ||
r[Remote Component] | ||
c --"direct usage via #DependencyMethod()"--> d | ||
c -."usage via network I/O".-> r | ||
c --> s | ||
``` | ||
|
||
> **Figure 1**: A legend for the component diagrams in this document. | ||
```mermaid | ||
--- | ||
title: Clients Dependency Tree | ||
--- | ||
flowchart | ||
sup[SupplierClient] | ||
tx[TxClient] | ||
txctx[[TxContext]] | ||
bl[BlockClient] | ||
evt[EventsQueryClient] | ||
conn[[Connection]] | ||
dial[[Dialer]] | ||
sup --"#SignAndBroadcast()"--> tx | ||
tx --"#CommittedBlocksSequence()"--> bl | ||
tx --"#BroadcastTx"--> txctx | ||
tx --"#EventsBytes()"--> evt | ||
bl --"#EventsBytes()"--> evt | ||
evt --> conn | ||
evt --"#DialContext()"--> dial | ||
dial --"(returns)"--> conn | ||
``` | ||
|
||
> **Figure 2**: An overview which articulates the dependency relationships between the various client interfaces and their subcompnents. | ||
```mermaid | ||
--- | ||
title: Network Interaction | ||
--- | ||
flowchart | ||
txctx[[TxContext]] | ||
conn[[Connection]] | ||
dial[[Dialer]] | ||
chain[Blockchain] | ||
conn <-."subscribed events".-> chain | ||
dial -."RPC subscribe".-> chain | ||
txctx -."tx broadcast".-> chain | ||
txctx -."tx query".-> chain | ||
``` | ||
|
||
> **Figure 3**: An overview of how client subcomponents interact with the network. | ||
## Installation | ||
|
||
```bash | ||
go get github.com/pokt-network/poktroll/pkg/client | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic Example | ||
|
||
```go | ||
// TODO: Code example showcasing the use of TxClient or any other primary interface. | ||
``` | ||
|
||
### Advanced Usage | ||
|
||
```go | ||
// TODO: Example illustrating advanced features or edge cases of the package. | ||
``` | ||
|
||
### Configuration | ||
|
||
- **TxClientOption**: Function type that modifies the `TxClient` allowing for flexible and optional configurations. | ||
- **EventsQueryClientOption**: Modifies the `EventsQueryClient` to apply custom behaviors or configurations. | ||
|
||
## API Reference | ||
|
||
For the complete API details, see the [godoc](https://pkg.go.dev/github.com/pokt-network/poktroll/pkg/client). | ||
|
||
## Best Practices | ||
|
||
- **Use Abstractions**: Instead of directly communicating with blockchain platforms, leverage the provided interfaces for consistent and error-free interactions. | ||
- **Stay Updated**: With evolving blockchain technologies, ensure to keep the package updated for any new features or security patches. | ||
|
||
## FAQ | ||
|
||
#### How does the `TxClient` interface differ from `TxContext`? | ||
|
||
While `TxClient` is centered around signing and broadcasting transactions, `TxContext` consolidates operational dependencies for the transaction lifecycle, like building, encoding, and querying. | ||
|
||
#### Can I extend or customize the provided interfaces? | ||
|
||
Yes, the package is designed with modularity in mind. You can either implement the interfaces based on your requirements or extend them for additional functionalities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package testblock provides helper functions for constructing real (e.g. localnet) | ||
// and mock BlockClient objects with pre-configured and/or parameterized call | ||
// arguments, return value(s), and/or expectations thereof. Intended for use in tests. | ||
package testblock |
Oops, something went wrong.