https://github.com/abstractsdk/cosmos-anybuf
https://github.com/abstractsdk/cosmos-anybuf
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abstractsdk/cosmos-anybuf
- Owner: AbstractSDK
- Created: 2024-02-21T20:56:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T16:19:00.000Z (about 2 years ago)
- Last Synced: 2025-10-09T23:19:47.695Z (8 months ago)
- Language: Rust
- Size: 184 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cosmos Anybuf
A low-level Rust protobuf crate for use in Stargate CosmWasm messages.
## Supported Modules
### Neutron
- Token Factory
- Interchain Queries
- Interchain Transactions
## Features
- Protobuf encoded messages
- Parsing of protobuf encoded responses (Query or Reply)
## Getting started
Currently cosmos-anybuf does not have crate published to crates.io, meaning it could only be installed as git dependency
```toml
[dependencies]
cosmos-anybuf = { version = "0.1.0", git = "https://github.com/AbstractSDK/cosmos-anybuf" }
```
## Example
### Sending Stargate messages
```rust
use cosmos_anybuf::{chains::neutron::Neutron, interfaces::TokenFactory};
#[entry_point]
pub fn execute(
_deps: DepsMut,
env: Env,
_info: MessageInfo,
msg: ExecuteMsg,
) -> StdResult {
let sender = env.contract.address.to_string();
let message = match msg {
// Just call a method of the module you want to use
ExecuteMsg::CreateDenom { subdenom } => Neutron::create_denom(sender, subdenom),
// You can also specify module in case method names are repeated
ExecuteMsg::Mint {
amount,
mint_to_address,
} => ::mint(sender, amount, mint_to_address),
};
Ok(Response::new().add_message(message))
}
```
### Querying Stargate Message
```rust
use cosmos_anybuf::{chains::neutron::Neutron, interfaces::TokenFactory};
#[entry_point]
pub fn query_params(deps: Deps) -> StdResult<::QueryParamsResponse> {
let params = Neutron::query_params(&deps.querier)?;
Ok(params)
}
```