Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed May 7, 2024
1 parent e3fc5d7 commit 23573fa
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 105 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion secret-sdk-proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use cosmos_sdk_proto::*;

/// The version (commit hash) of the Cosmos SDK used when generating this library.
/// The version of Secret Network used when generating this library.
pub const SECRET_VERSION: &str = include_str!("prost/secret/SECRET_COMMIT");

/// Secret protobuf definitions.
Expand Down
46 changes: 23 additions & 23 deletions secretrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "secretrs"
version = "0.1.0-beta.0"
version = "0.1.0-beta.1"
authors = ["Kent"]
license = "Unlicense"
repository = "https://github.com/kent-3/secret-rust/tree/main/secretrs"
Expand All @@ -27,6 +27,24 @@ grpc-core = ["cosmrs/grpc-core", "secret-sdk-proto/grpc"]
grpc = ["grpc-core", "cosmrs/grpc", "secret-sdk-proto/grpc-transport"]
# dev = ["tokio"]

[[example]]
name = "encrypt"
path = "examples/encrypt.rs"

[[example]]
name = "query"
path = "examples/query.rs"
required-features = ["grpc"]

[[example]]
name = "tx"
path = "examples/tx.rs"
required-features = ["grpc"]

[[example]]
name = "contract_query"
path = "examples/contract_query.rs"
required-features = ["grpc"]

[dependencies]
tonic-web-wasm-client = "0.5.1"
Expand Down Expand Up @@ -64,9 +82,10 @@ thiserror = "1.0.51"
tonic = { version = "0.11.0", features = ["tls", "tls-webpki-roots", "transport"] }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
color-eyre = "0.6"
regex = "1"
tokio = { version = "1.37", features = ["rt", "sync", "time", "macros"] }
anyhow = "1.0.83"
color-eyre = "0.6.3"
regex = "1.10.4"
tokio = { version = "1.37.0", features = ["rt", "sync", "time", "macros"] }
tonic = { version = "0.11.0", features = ["tls", "tls-webpki-roots", "transport"] }

# wasm
Expand All @@ -79,22 +98,3 @@ nanorand = { version = "0.7.0", features = ["getrandom", "zeroize"] }
tokio = { version = "1.37", features = ["rt", "sync", "time", "macros"] }
tonic-web-wasm-client = "0.5.1"
wasm-bindgen-test = "0.3.42"

[[example]]
name = "encrypt"
path = "examples/encrypt.rs"

[[example]]
name = "query"
path = "examples/query.rs"
required-features = ["grpc"]

[[example]]
name = "tx"
path = "examples/tx.rs"
required-features = ["grpc"]

[[example]]
name = "contract_query"
path = "examples/contract_query.rs"
required-features = ["grpc"]
32 changes: 14 additions & 18 deletions secretrs/src/grpc_clients.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
//! # gRPC clients generated by `tonic`.
//! gRPC clients generated by [`tonic`].
//!
//! * Query clients are provided for each module.
//! * All transactions are broadcast using a [`TxServiceClient`].
//!
//! Example:
//! ```
//! use secretrs::clients::AuthQueryClient;
//! # Examples
//!
//! ```no_run
//! # use anyhow::Result;
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> Result<()> {
//! use secretrs::grpc_clients::AuthQueryClient;
//! use secretrs::proto::cosmos::auth::v1beta1::QueryAccountRequest;
//!
//! let base_url = "http://grpc.testnet.secretsaturn.net:9090".to_string();
//! let base_url = "http://grpc.testnet.secretsaturn.net:9090";
//! let mut auth_client = AuthQueryClient::connect(base_url).await?;
//!
//! let address = "secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03".to_string(),
//! let address = "secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03".to_string();
//! let request = QueryAccountRequest { address };
//! let response = auth_client.account(request).await?.into_inner();
//! # Ok(())
//! # }
//! ```
#![allow(unused)]

use async_trait::async_trait;

use cosmrs::tendermint::Hash;
use cosmrs::tx::Tx;

use crate::{
proto::{self, traits::Message},
Error, ErrorReport, Gas, Result,
};
//!
//! [`tonic`]: https://docs.rs/tonic
// Service Clients
pub use ::cosmrs::proto::cosmos::base::tendermint::v1beta1::service_client::ServiceClient as TendermintServiceClient;
Expand Down
37 changes: 34 additions & 3 deletions secretrs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
//! # SecretRS -
//!
//! SecretRS re-exports `cosmrs` at the top-level of the crate.
//! SecretRS re-exports [`cosmrs`] at the top-level of the crate.
//! This allows `secretrs` to be used as a drop-in replacement for `cosmrs`.
//!
//! # Feature flags
//!
//! The default features are `bip32`, `getrandom`, and `grpc-core`.
//!
//! - `bip32`: Enables the `bip32` feature in `cosmrs`.
//! - `getrandom`: Enables the `getrandom` feature in `cosmrs`.
//! - `grpc-core`: Enables the use of [`tonic`] generated gRPC query and service clients.
//! - `grpc`: Enables [`tonic::transport`], which provides a fully featured HTTP/2 [`Channel`] built on top of [`tokio`], [`hyper`] and [`tower`].
//! - `rpc`: Enables the `rpc` feature in `cosmrs`.
//!
//! # WASM support
//! SecretRS has support for gRPC-web in browsers, thanks to [`tonic_web_wasm_client`]. When building for the `wasm32-unknown-unknown` target, create each [`tonic::client::Grpc<T>`] using a [`tonic_web_wasm_client::Client`] instead of [`tonic::transport::Channel`]. The `grpc` feature must be disabled (this will disable the default transport layer of tonic).
//!
//! [`cosmrs`]: https://docs.rs/cosmrs
//! [`tonic`]: https://docs.rs/tonic
//! [`tonic::transport`]: https://docs.rs/tonic/latest/tonic/transport/index.html
//! [`Channel`]: https://docs.rs/tonic/latest/tonic/transport/struct.Channel.html
//! [`tokio`]: https://docs.rs/tokio
//! [`hyper`]: https://docs.rs/hyper
//! [`tower`]: https://docs.rs/tower
//! [`tonic_web_wasm_client`]: https://docs.rs/tonic_web_wasm_client
//! [`tonic_web_wasm_client::Client`]: https://docs.rs/tonic-web-wasm-client/latest/tonic_web_wasm_client/struct.Client.html
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
#![deny(rustdoc::broken_intra_doc_links)]
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod compute;

Expand Down
Loading

0 comments on commit 23573fa

Please sign in to comment.