crw-types

Crates.iocrw-types
lib.rscrw-types
version0.1.0
sourcesrc
created_at2021-03-24 16:56:31.617137
updated_at2021-03-24 16:56:31.617137
descriptionCollection of types used by cosmos-rust-wallet packages and modules
homepage
repositoryhttps://github.com/forbole/cosmos-rust-wallet
max_upload_size
id372980
size4,169
Leonardo Bragagnolo (bragaz)

documentation

README

Types Package

The types package contains all the common types used by modules and packages.

Types

Msg

Message type is the representation of a transaction's message already encoded from protobuf. It's a wrapper of the Any types and can be converted from and to it.

pub struct Msg(pub Any);

/// From protobuf definition
pub struct Any {
    pub type_url: String,
    pub value: Vec<u8>,
}

fn example() {
    let proto_msg = Msg(Any {
        type_url: "/cosmos.bank.v1beta1.Msg/Send".to_string(),
        value: msg_bytes,
    });
}

Error

Error is the representation of any kind of error that could happen during the execution of wallet's operations.

Any function that return a Result<T,E> can return an error to the above function as follow:

fn example() {
    let mnemonic = Mnemonic::from_phrase(mnemonic_words, Language::English)
    .map_err(|err| Error::Mnemonic(err.to_string()))?;
}
Commit count: 58

cargo fmt