Skip to content

Commit 179f389

Browse files
committed
added Readme for package and resolved errors
1 parent 3724ab9 commit 179f389

File tree

6 files changed

+437
-14
lines changed

6 files changed

+437
-14
lines changed

README.MD

Whitespace-only changes.

packages/persistence-std/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name = "persistence-std"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "MIT OR Apache-2.0"
6+
description = "Standard library for Persistence chain modules with CosmWasm support included"
57

68
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
79

packages/persistence-std/README.MD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# persistence-std
2+
3+
Persistence SDK and pStake native proto-generated types and helpers for interacting with the Persistence Chain. Compatible with CosmWasm contracts.
4+
5+
This package is inspired from [osmosis-std](https://crates.io/crates/osmosis-std) and re-uses a lot of their code
6+
7+
## CosmWasm stargate message and stargate query
8+
9+
You can find all types and querier generated from Persistence SDK and PStake Native in their respective module in `persistence_std`.
10+
11+
WIP More details and examples to be added.
12+
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
pub fn add(left: usize, right: usize) -> usize {
2-
left + right
3-
}
4-
5-
#[cfg(test)]
6-
mod tests {
7-
use super::*;
8-
9-
#[test]
10-
fn it_works() {
11-
let result = add(2, 2);
12-
assert_eq!(result, 4);
13-
}
14-
}
1+
#![doc = include_str!("../README.md")]
2+
#![cfg_attr(docsrs, feature(doc_cfg))]
3+
#![forbid(unsafe_code)]
4+
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]
5+
6+
/// The version (commit hash) of the Cosmos SDK used when generating this library.
7+
// pub const PERSISTENCE_VERSION: &str = include_str!("types/");
8+
9+
mod serde;
10+
pub mod shim;
11+
12+
#[allow(deprecated)]
13+
pub mod types;
14+
15+
pub use shim::{cosmwasm_to_proto_coins, try_proto_to_cosmwasm_coins};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pub mod as_str {
2+
use serde::{de, Deserialize, Deserializer, Serializer};
3+
use std::{fmt::Display, str::FromStr};
4+
5+
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
6+
where
7+
T: FromStr,
8+
T::Err: Display,
9+
D: Deserializer<'de>,
10+
{
11+
let s = String::deserialize(deserializer)?;
12+
T::from_str(&s).map_err(de::Error::custom)
13+
}
14+
15+
pub fn serialize<S, T>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
16+
where
17+
S: Serializer,
18+
T: Display,
19+
{
20+
serializer.serialize_str(&value.to_string())
21+
}
22+
}

0 commit comments

Comments
 (0)