Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to

## [Unreleased]

### Added

- cosmwasm-std: Add `GovMsg::VoteWeighted`. In order to use this in a contract,
the `cosmwasm_1_2` feature needs to be enabled for the `cosmwasm_std`
dependency. This makes the contract incompatible with chains running versions
of CosmWasm earlier than 1.2.0 ([#1481]).

[#1481]: https://github.com/CosmWasm/cosmwasm/pull/1481

### Changed

- cosmwasm-vm: Avoid exposing OS specific file system errors in order to test
Expand Down
3 changes: 3 additions & 0 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ibc3 = ["stargate"]
# This feature makes `BankQuery::Supply` available for the contract to call, but requires
# the host blockchain to run CosmWasm `1.1.0` or higher.
cosmwasm_1_1 = []
# This feature makes `GovMsg::VoteWeighted` available for the contract to call, but requires
# the host blockchain to run CosmWasm `1.2.0` or higher.
cosmwasm_1_2 = []

[dependencies]
base64 = "0.13.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/std/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ extern "C" fn requires_stargate() -> () {}
#[no_mangle]
extern "C" fn requires_cosmwasm_1_1() -> () {}

#[cfg(feature = "cosmwasm_1_2")]
#[no_mangle]
extern "C" fn requires_cosmwasm_1_2() -> () {}

/// interface_version_* exports mark which Wasm VM interface level this contract is compiled for.
/// They can be checked by cosmwasm_vm.
/// Update this whenever the Wasm VM interface breaks.
Expand Down
2 changes: 2 additions & 0 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ pub use crate::query::{
pub use crate::query::{ChannelResponse, IbcQuery, ListChannelsResponse, PortIdResponse};
#[allow(deprecated)]
pub use crate::results::SubMsgExecutionResponse;
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
pub use crate::results::WeightedVoteOption;
pub use crate::results::{
attr, wasm_execute, wasm_instantiate, Attribute, BankMsg, ContractResult, CosmosMsg, CustomMsg,
Empty, Event, QueryResponse, Reply, ReplyOn, Response, SubMsg, SubMsgResponse, SubMsgResult,
Expand Down
15 changes: 15 additions & 0 deletions packages/std/src/results/cosmos_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use crate::errors::StdResult;
#[cfg(feature = "stargate")]
use crate::ibc::IbcMsg;
use crate::serde::to_binary;
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
use crate::Decimal;

use super::Empty;

Expand Down Expand Up @@ -183,6 +185,12 @@ pub enum WasmMsg {
pub enum GovMsg {
/// This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.
Vote { proposal_id: u64, vote: VoteOption },
/// This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address.
#[cfg(feature = "cosmwasm_1_2")]
VoteWeighted {
proposal_id: u64,
vote: WeightedVoteOption,
},
}

#[cfg(feature = "stargate")]
Expand All @@ -195,6 +203,13 @@ pub enum VoteOption {
NoWithVeto,
}

#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct WeightedVoteOption {
option: VoteOption,
weight: Decimal,
}

/// Shortcut helper as the construction of WasmMsg::Instantiate can be quite verbose in contract code.
///
/// When using this, `admin` is always unset. If you need more flexibility, create the message directly.
Expand Down
2 changes: 2 additions & 0 deletions packages/std/src/results/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ mod submessages;
mod system_result;

pub use contract_result::ContractResult;
#[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))]
pub use cosmos_msg::WeightedVoteOption;
pub use cosmos_msg::{wasm_execute, wasm_instantiate, BankMsg, CosmosMsg, CustomMsg, WasmMsg};
#[cfg(feature = "staking")]
pub use cosmos_msg::{DistributionMsg, StakingMsg};
Expand Down