Crates.io | cyber-std |
lib.rs | cyber-std |
version | 0.3.0 |
source | src |
created_at | 2022-03-01 14:11:19.408427 |
updated_at | 2024-10-15 07:25:29.892633 |
description | Bindings for CustomMsg and CustomQuery for the Cyber |
homepage | https://github.com/cybercongress/go-cyber |
repository | https://github.com/cybercongress/cw-cyber |
max_upload_size | |
id | 541558 |
size | 69,439 |
This crate provides Cyber-specific bindings to enable your CosmWasm smart contracts to interact with the Cyber blockchain by exposing messages and queriers that can be emitted and used from within your contract.
Currently, the Cyber bindings include:
In order to use the query functions enabled by the bindings, create a CyberQuerier
instance within your contract logic. You can access all the enabled queries through this object.
// src/contract.rs
use cosmwasm_std::Coin;
use cyber_std::{ CyberQuerier, RankValueResponse };
...
// handler
pub fn try_something(
deps: Deps,
_env: Env,
particle: String,
...
) -> StdResult<ParticleRankResponse> {
let querier = CyberQuerier::new(&deps.querier);
let res: ParticleRankResponse = querier.query_particle_rank(particle)?;
...
Ok(res)
}
You may want your contract to perform messages such as MsgCyberlink
operations at the end of its execution. To do this, create a message using the predefined functions:
create_cyberlink_msg
use cosmwasm_std::CosmosMsg;
use cyber_std::{ create_cyberlink_msg, CyberMsgWrapper };
...
pub fn try_something(
deps: DepsMut,
env: Env,
links: Vec<Link>,
...
) -> Result<Response, ContractError> {
...
let contract_addr = env.contract.address;
let msg: CosmosMsg<CyberMsgWrapper> = create_cyberlink_msg(contract_addr.into(), links);
let res = Response::new()
.add_message(msg);
Ok(res)
}