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
This maps directly to MsgVote in the Cosmos SDK with voter set to the contract address.
Fields
§
option: VoteOption
The vote option.
This used to be called “vote”, but was changed for consistency with Cosmos SDK.
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 moreimpl 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more