This crate provides re-implementations of types from the neptune-cash
crate that are exposed via its RPC API.
This crate is in an early, very rough prototype state. Everything is subject to change, or it could be abandoned altogether.
The primary motivation for this crate is to make the core data types used in neptune-cash
available in a WebAssembly (WASM) environment. This is useful for developing browser-based GUI wallet software and other web-based tools that need to interact with the Neptune network.
The types in this crate are designed to be direct, binary-compatible replacements for their counterparts in neptune-cash
.
-
WASM Compatibility: The immediate goal is to provide a set of types that can be compiled to WASM, allowing developers to build rich client-side applications (e.g., GUI wallets) that can interact with the
neptune-cash
RPC API. -
Serialization Compatibility: It is a requirement/guarantee that the types defined in
neptune-types
are serializable to/from the original types inneptune-cash
. This is achieved by ensuring field order of types are identical, and via a set of unit tests that actually de/serialize in both directions and compare the serialized data for equality. Thus changes/breakages can be detected when the tests are run. -
RPC API Compatibility: The neptune-cash RPC API is implemented via
tarpc
which automatically generates a Client type from a trait defined in neptune-cash. The Client type calls the server and performs necessary serialization steps. Theneptune-types
crate mirrors this trait from neptune-cash, but the types used in the method signatures are fromneptune-types
. In this way, an app can use theneptune-types
tarpc client to call a neptune-core (neptune-cash executable) server. -
Future Integration: A longer-term objective is to have
neptune-cash
itself depend onneptune-types
. This would establish a single source of truth for these core data structures, simplifying maintenance and reducing code duplication. Once that is complete, the RPC trait itself could be made a separate crate.
- Not attempting to include all types from neptune-cash, only those needed for wallet & rpc purposes.
- Not attempting to have every single method or derive as each equivalent neptune-cash type. Sometimes that is not feasible.
There are two types of unit test modules in the source files of this crate.
-
The original unit tests from neptune-cash. These presently do not compile and are gated behind feature
original-tests
. -
de/serialization tests that verify compatibility with neptune-cash types across bincode, serde-json, and serde-json-wasm serialization methods. These do compile and can be run with
cargo test
, however some still fail because the code to create the relevant type is stubbed with todo!().
Add this crate to your Cargo.toml
:
[dependencies]
# note: neptune-types is not on crates.io yet. It is generally best to pick a specific github revision to use.
neptune-types = {git = "https://github.com/Neptune-Crypto/neptune-types/", rev = "<revision>"}
cargo test