Skip to content

Commit

Permalink
Make clippy happy, use only migrate newer across all voting contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 3, 2023
1 parent 89385f5 commit 6da6ec6
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion contracts/external/cw-tokenfactory-issuer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, C
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version < CONTRACT_VERSION.to_string() {
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@
]
},
"StakeChangedHookMsg": {
"description": "An enum representing staking hooks.",
"oneOf": [
{
"type": "object",
Expand Down
14 changes: 10 additions & 4 deletions contracts/voting/dao-voting-cw20-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmwasm_std::{
to_binary, Addr, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult,
SubMsg, Uint128, Uint256, WasmMsg,
};
use cw2::set_contract_version;
use cw2::{get_contract_version, set_contract_version, ContractVersion};
use cw20::{Cw20Coin, TokenInfoResponse};
use cw_utils::parse_reply_instantiate_data;
use dao_interface::voting::IsActiveResponse;
Expand Down Expand Up @@ -372,9 +372,15 @@ pub fn query_active_threshold(deps: Deps) -> StdResult<Binary> {

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
Ok(Response::default())
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}

Ok(Response::new().add_attribute("action", "migrate"))
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-cw20-staked/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ fn test_migrate() {
#[test]
pub fn test_migrate_update_version() {
let mut deps = mock_dependencies();
cw2::set_contract_version(&mut deps.storage, "my-contract", "old-version").unwrap();
cw2::set_contract_version(&mut deps.storage, "my-contract", "1.0.0").unwrap();
migrate(deps.as_mut(), mock_env(), MigrateMsg {}).unwrap();
let version = cw2::get_contract_version(&deps.storage).unwrap();
assert_eq!(version.version, CONTRACT_VERSION);
Expand Down
2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-cw4/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, C
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version < CONTRACT_VERSION.to_string() {
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-cw721-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, C
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version < CONTRACT_VERSION.to_string() {
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-native-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, C
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version < CONTRACT_VERSION.to_string() {
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, C
let storage_version: ContractVersion = get_contract_version(deps.storage)?;

// Only migrate if newer
if storage_version.version < CONTRACT_VERSION.to_string() {
if storage_version.version.as_str() < CONTRACT_VERSION {
// Set contract to version to latest
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ impl Module for TokenFactoryModule {
_router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
_block: &BlockInfo,
_sender: Addr,
msg: Self::ExecT,
_msg: Self::ExecT,
) -> AnyResult<AppResponse>
where
ExecC: Debug + Clone + PartialEq + JsonSchema + DeserializeOwned + 'static,
QueryC: CustomQuery + DeserializeOwned + 'static,
{
match msg {
_ => bail!("execute not implemented for TokenFactoryModule"),
}
bail!("execute not implemented for TokenFactoryModule")
}

fn sudo<ExecC, QueryC>(
Expand Down

0 comments on commit 6da6ec6

Please sign in to comment.