Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gers2017/zenode
Abstraction layer on top of p2panda to interact with p2panda nodes
https://github.com/gers2017/zenode
abstraction aquadoggo cryptography graphql p2p p2panda peer-to-peer rust schema utility-library
Last synced: about 5 hours ago
JSON representation
Abstraction layer on top of p2panda to interact with p2panda nodes
- Host: GitHub
- URL: https://github.com/gers2017/zenode
- Owner: Gers2017
- License: mit
- Created: 2022-09-21T20:11:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-06T22:42:58.000Z (over 1 year ago)
- Last Synced: 2024-11-16T04:45:39.563Z (1 day ago)
- Topics: abstraction, aquadoggo, cryptography, graphql, p2p, p2panda, peer-to-peer, rust, schema, utility-library
- Language: Rust
- Homepage: https://crates.io/crates/zenode
- Size: 105 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Zenode
## What is this project
This project is an abstraction layer between the client and the p2panda node by
providing tools to easily perform operations on a p2panda node.### Before you start
In order to run this you first need to install [aquadoggo](https://github.com/p2panda/aquadoggo)
```sh
git clone https://github.com/p2panda/aquadoggo.gitRUST_LOG=aquadoggo=info cargo run
```The `Operator` struct is the main wrapper around the p2panda library and the graphql layer.
To create a new `Operator` use `Operator::default()` or `Operator::new()`.
`Operator::default()` reads the `ENDPOINT` environment variable, if is not present it uses `http://localhost:2020/graphql` as default endpoint.
Run the following to test `Zenode` (aquadoggo must be running in the background):
```sh
cargo test
```## Quick start
```rs
use zenode::{field, Operator};
use zenode::FieldType::*;// create an Operator
let op = Operator::default();// create a schema
let id = op.create_schema(
"POKEMON",
"Pokemon schema",
&mut [
field_def("pokemon_id", Int), // same as field("pokemon_id", "int")
field_def("pokemon_name", Str),
]
).await?;// generate schema_id
let schema_id = format!("POKEMON_{}", id);// create an instance
let instance_id = op.create_instance(&schema_id, &mut [
field("pokemon_id", "1"), field("pokemon_name", "Bulbasaur")
]).await?;// update the instance
let update_id = op.update_instance(&schema_id, &instance_id, &mut [
field("pokemon_name", "Charmander")
]).await?;// finally delete the instance
let _delete_id = op.delete_instance(&schema_id, &update_id).await?;
```## Experimental Schema Builder
```rs
let op = Operator::default();let mut puppy_builder = SchemaBuilder::new("puppy", "Puppy schema", &op)
.field("name", Str)
.field("cuteness", Int);puppy_builder.build().await?;
let tiramisu_id = puppy_builder
.instantiate(&mut [field("name", "Tiramisu"), field("cuteness", "200")])
.await?;
```## Features
- [x] Create schemas
- [x] Crate fields
- [x] Crate instance
- [x] Update instance
- [x] Delete instance
- [x] Read endpoint from env
- [x] Better field to json
- [ ] Save schema_id
- [ ] Link schema name with schema_id
- [ ] Serializable query string