Skip to content

Commit 0d5f2bf

Browse files
committed
tweaks to docs and ignore readme doctests
1 parent 18af00d commit 0d5f2bf

File tree

16 files changed

+95
-79
lines changed

16 files changed

+95
-79
lines changed

packages/crypto/Readme.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,46 @@
22

33
⚠️ This package is a sub-package of the `secret-toolkit` package. Please see its crate page for more context.
44

5-
This package contains all the tools related to crypto
5+
This crate contains common cryptography tools used in the development of Secret Contracts
6+
running on the Secret Network.
7+
8+
Note: It has a deep dependency tree and increases compilation times significantly.
9+
10+
Add the following to your `cargo.toml` file:
11+
12+
```toml
13+
[dependencies]
14+
secret-toolkit = { version = "0.3.0", features = ["crypto"] }
15+
secret-toolkit-crypto = { version = "0.3.0", features = ["hash", "rand", "ecc-secp256k1"] }
16+
```
17+
18+
## Example usage:
19+
20+
```ignore
21+
# extern crate secret_toolkit_crypto;
22+
23+
# use secret_toolkit_crypto::{sha_256, Prng, secp256k1::{PrivateKey, PublicKey, Signature}};
24+
# use base64;
25+
# use cosmwasm_std::{StdError, testing::mock_dependencies};
26+
27+
# fn main() -> Result<(), StdError> {
28+
# let deps = mock_dependencies(20, &[]);
29+
let entropy: String = "secret".to_owned();
30+
let prng_seed: Vec<u8> = sha_256(base64::encode(&entropy.clone()).as_bytes()).to_vec();
31+
32+
let mut rng = Prng::new(&prng_seed, entropy.as_bytes());
33+
34+
let private_key: PrivateKey = PrivateKey::parse(&rng.rand_bytes())?;
35+
let public_key: PublicKey = private_key.pubkey();
36+
37+
let message: &[u8] = b"message";
38+
let signature: Signature = private_key.sign(message, deps.api);
39+
# Ok(())
40+
# }
41+
```
42+
43+
### Cargo Features
44+
- `["hash"]` - Provides an easy-to-use `sha256` function. Uses [sha2](https://crates.io/crates/sha2).
45+
- `["rand"]` - Used to generate pseudo-random numbers. Uses [rand_chacha] and [rand_core].
46+
- `["ecc-secp256k1"]` - Contains types and methods for working with secp256k1 keys and signatures,
47+
as well as standard constants for key sizes. Uses [secp256k1](https://crates.io/crates/secp256k1).

packages/crypto/src/lib.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,4 @@
1-
//! # Crypto
2-
//! This crate contains common cryptography tools used in the development of Secret Contracts
3-
//! running on the Secret Network.
4-
//!
5-
//! Note: It has a deep dependency tree and increases compilation times significantly.
6-
//!
7-
//! Add the following to your `cargo.toml` file:
8-
//!
9-
//! ```toml
10-
//! [dependencies]
11-
//! secret-toolkit = { version = "0.3.0", features = ["crypto"] }
12-
//! secret-toolkit-crypto = { version = "0.3.0", features = ["hash", "rand", "ecc-secp256k1"] }
13-
//! ```
14-
//!
15-
//! ## Example usage:
16-
//!
17-
//! ```ignore
18-
//! # extern crate secret_toolkit_crypto;
19-
//!
20-
//! # use secret_toolkit_crypto::{sha_256, Prng, secp256k1::{PrivateKey, PublicKey, Signature}};
21-
//! # use base64;
22-
//! # use cosmwasm_std::{StdError, testing::mock_dependencies};
23-
//!
24-
//! # fn main() -> Result<(), StdError> {
25-
//! # let deps = mock_dependencies(20, &[]);
26-
//! let entropy: String = "secret".to_owned();
27-
//! let prng_seed: Vec<u8> = sha_256(base64::encode(&entropy.clone()).as_bytes()).to_vec();
28-
//!
29-
//! let mut rng = Prng::new(&prng_seed, entropy.as_bytes());
30-
//!
31-
//! let private_key: PrivateKey = PrivateKey::parse(&rng.rand_bytes())?;
32-
//! let public_key: PublicKey = private_key.pubkey();
33-
//!
34-
//! let message: &[u8] = b"message";
35-
//! let signature: Signature = private_key.sign(message, deps.api);
36-
//! # Ok(())
37-
//! # }
38-
//! ```
39-
//!
40-
//! ### Cargo Features
41-
//! - `["hash"]` - Provides an easy-to-use `sha256` function. Uses [sha2](https://crates.io/crates/sha2).
42-
//! - `["rand"]` - Used to generate pseudo-random numbers. Uses [rand_chacha] and [rand_core].
43-
//! - `["ecc-secp256k1"]` - Contains types and methods for working with secp256k1 keys and signatures,
44-
//! as well as standard constants for key sizes. Uses [secp256k1](https://crates.io/crates/secp256k1).
1+
#![doc = include_str!("../Readme.md")]
452

463
#[cfg(feature = "hash")]
474
mod hash;

packages/incubator/Readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This package contains tools that are not yet final and may change or contain unk
77
## Max heap storage
88

99
A "max heap store" is a storage wrapper that implements a binary tree maxheap data structure.
10-
https://en.wikipedia.org/wiki/Min-max_heap
11-
Implementation based on https://algorithmtutor.com/Data-Structures/Tree/Binary-Heaps/
10+
<https://en.wikipedia.org/wiki/Min-max_heap>
11+
Implementation based on <https://algorithmtutor.com/Data-Structures/Tree/Binary-Heaps/>
1212

1313
* Insertion O(log n)
1414
* Remove max O(log n)
@@ -17,7 +17,7 @@ Implementation based on https://algorithmtutor.com/Data-Structures/Tree/Binary-H
1717

1818
The usage of `MaxHeapStoreMut` and `MaxHeapStore` are modeled on `AppendStoreMut` and `AppendStore`, respectively. To add an item to the heap use `insert` and to take the top value off use `remove`, which also returns the item that was removed. To peek at the max value without removing, use the `get_max` function. Duplicate items can be added to the heap.
1919

20-
```rust
20+
```ignore
2121
let mut storage = MockStorage::new();
2222
let mut heap_store = MaxHeapStoreMut::attach_or_create(&mut storage)?;
2323
heap_store.insert(&1234)?;
@@ -35,7 +35,7 @@ assert_eq!(heap_store.remove(), Ok(1234));
3535

3636
In order to use a custom struct with `MaxHeapStore` you will need to implement the appropriate Ordering traits. The following is an example with a custom struct `Tx` that uses the `amount` field to determine order in the heap:
3737

38-
```rust
38+
```ignore
3939
#[derive(Serialize, Deserialize, Clone, Debug, Eq)]
4040
pub struct Tx {
4141
address: HumanAddr,
@@ -110,7 +110,7 @@ In effect, this example is a graph structure where the nodes are elements and th
110110

111111
See tests in `generational_store.rs` for more examples, including iteration.
112112

113-
```rust
113+
```ignore
114114
let mut storage = MockStorage::new();
115115
let mut gen_store = GenerationalStoreMut::attach_or_create(&mut storage)?;
116116
let alpha = gen_store.insert(String::from("Alpha"));

packages/incubator/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../Readme.md")]
2+
13
#[cfg(feature = "generational-store")]
24
pub mod generational_store;
35
#[cfg(feature = "generational-store")]

packages/permit/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../Readme.md")]
2+
13
pub mod funcs;
24
pub mod state;
35
pub mod structs;

packages/serialization/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../Readme.md")]
2+
13
use serde::{de::DeserializeOwned, Serialize};
24

35
use cosmwasm_std::StdResult;

packages/snip20/Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can create a HandleMsg variant and call the `to_cosmos_msg` function to gene
1111
Or you can call the individual function for each Handle message to generate the appropriate callback CosmosMsg.
1212

1313
Example:
14-
```rust
14+
```ignore
1515
let recipient = HumanAddr("ADDRESS_TO_TRANSFER_TO".to_string());
1616
let amount = Uint128(10000);
1717
let padding = None;
@@ -41,7 +41,7 @@ You probably have also noticed that CreateViewingKey is not supported. This is
4141
## Queries
4242

4343
These are the types that SNIP20 tokens can return from queries
44-
```rust
44+
```ignore
4545
pub struct TokenInfo {
4646
pub name: String,
4747
pub symbol: String,
@@ -127,7 +127,7 @@ You can create a QueryMsg variant and call the `query` function to query a SNIP2
127127
Or you can call the individual function for each query.
128128

129129
Example:
130-
```rust
130+
```ignore
131131
let address = HumanAddr("ADDRESS_WHOSE_BALANCE_IS_BEING_REQUESTED".to_string());
132132
let key = "THE_VIEWING_KEY_PREVIOUSLY_SET_BY_THE_ADDRESS".to_string();
133133
let block_size = 256;
@@ -137,4 +137,4 @@ Example:
137137
let balance =
138138
balance_query(&deps.querier, address, key, block_size, callback_code_hash, contract_addr)?;
139139
```
140-
In this example, we are doing a Balance query for the specified address/key pair and storing the response in the balance variable, which is of the Balance type defined above. The query message is padded to blocks of 256 bytes.
140+
In this example, we are doing a Balance query for the specified address/key pair and storing the response in the balance variable, which is of the Balance type defined above. The query message is padded to blocks of 256 bytes.

packages/snip20/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../Readme.md")]
2+
13
pub mod batch;
24
pub mod handle;
35
pub mod query;

packages/snip721/Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can create a HandleMsg variant and call the `to_cosmos_msg` function to gene
1111
Or you can call the individual function for each Handle message to generate the appropriate callback CosmosMsg.
1212

1313
Example:
14-
```rust
14+
```ignore
1515
let recipient = HumanAddr("ADDRESS_TO_TRANSFER_TO".to_string());
1616
let token_id = "TOKEN_ID".to_string();
1717
let memo = Some("TRANSFER_MEMO".to_string());
@@ -43,7 +43,7 @@ You probably have also noticed that CreateViewingKey is not supported. This is
4343
## Queries
4444

4545
These are the types that the SNIP-721 toolkit queries can return
46-
```rust
46+
```ignore
4747
pub struct ContractInfo {
4848
pub name: String,
4949
pub symbol: String,
@@ -166,7 +166,7 @@ You can create a QueryMsg variant and call the `query` function to query a SNIP-
166166
Or you can call the individual function for each query.
167167

168168
Example:
169-
```rust
169+
```ignore
170170
let token_id = "TOKEN_ID".to_string();
171171
let viewer = Some(ViewerInfo {
172172
address: HumanAddr("VIEWER'S_ADDRESS".to_string()),
@@ -180,4 +180,4 @@ Example:
180180
let nft_dossier =
181181
nft_dossier_query(&deps.querier, token_id, viewer, include_expired, block_size, callback_code_hash, contract_addr)?;
182182
```
183-
In this example, we are doing an NftDossier query on the token named "TOKEN_ID", supplying the address and viewing key of the querier, and storing the response in the nft_dossier variable, which is of the NftDossier type defined above. Because no `include_expired` was specified, the response defaults to only displaying approvals that have not expired, but approvals will only be displayed if the viewer is the owner of the token. The query message is padded to blocks of 256 bytes.
183+
In this example, we are doing an NftDossier query on the token named "TOKEN_ID", supplying the address and viewing key of the querier, and storing the response in the nft_dossier variable, which is of the NftDossier type defined above. Because no `include_expired` was specified, the response defaults to only displaying approvals that have not expired, but approvals will only be displayed if the viewer is the owner of the token. The query message is padded to blocks of 256 bytes.

packages/snip721/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../Readme.md")]
2+
13
//#![allow(clippy::field_reassign_with_default)]
24
pub mod expiration;
35
pub mod handle;

0 commit comments

Comments
 (0)