Enum cosmwasm_std::GovMsg
source · pub enum GovMsg {
Vote {
proposal_id: u64,
option: VoteOption,
},
VoteWeighted {
proposal_id: u64,
options: Vec<WeightedVoteOption>,
},
}
Expand description
This message type allows the contract interact with the x/gov module in order to cast votes.
§Examples
Cast a simple vote:
use cosmwasm_std::{GovMsg, VoteOption};
#[entry_point]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, StdError> {
// ...
Ok(Response::new().add_message(GovMsg::Vote {
proposal_id: 4,
option: VoteOption::Yes,
}))
}
Cast a weighted vote:
use cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};
#[entry_point]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, StdError> {
// ...
Ok(Response::new().add_message(GovMsg::VoteWeighted {
proposal_id: 4,
options: vec![
WeightedVoteOption {
option: VoteOption::Yes,
weight: Decimal::percent(65),
},
WeightedVoteOption {
option: VoteOption::Abstain,
weight: Decimal::percent(35),
},
],
}))
}
Variants§
Vote
Fields
§
option: VoteOption
The vote option.
This used to be called “vote”, but was changed for consistency with Cosmos SDK.
This maps directly to MsgVote in the Cosmos SDK with voter set to the contract address.
VoteWeighted
This maps directly to MsgVoteWeighted in the Cosmos SDK with voter set to the contract address.
Trait Implementations§
source§impl<'de> Deserialize<'de> for GovMsg
impl<'de> Deserialize<'de> for GovMsg
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl JsonSchema for GovMsg
impl JsonSchema for GovMsg
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl PartialEq for GovMsg
impl PartialEq for GovMsg
impl Eq for GovMsg
impl StructuralPartialEq for GovMsg
Auto Trait Implementations§
impl Freeze for GovMsg
impl RefUnwindSafe for GovMsg
impl Send for GovMsg
impl Sync for GovMsg
impl Unpin for GovMsg
impl UnwindSafe for GovMsg
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more