From 6da6ec6cd3391fcbbdacaf0c5a2ba223f608e755 Mon Sep 17 00:00:00 2001 From: Jake Hartnell Date: Sat, 2 Sep 2023 23:16:18 -0700 Subject: [PATCH] Make clippy happy, use only migrate newer across all voting contracts --- .../cw-tokenfactory-issuer/src/contract.rs | 2 +- .../schema/cw20-stake-external-rewards.json | 1 + .../voting/dao-voting-cw20-staked/src/contract.rs | 14 ++++++++++---- .../voting/dao-voting-cw20-staked/src/tests.rs | 2 +- contracts/voting/dao-voting-cw4/src/contract.rs | 2 +- .../voting/dao-voting-cw721-staked/src/contract.rs | 2 +- .../dao-voting-native-staked/src/contract.rs | 2 +- .../src/contract.rs | 2 +- .../src/tests/multitest/tf_module_mock.rs | 6 ++---- 9 files changed, 19 insertions(+), 14 deletions(-) diff --git a/contracts/external/cw-tokenfactory-issuer/src/contract.rs b/contracts/external/cw-tokenfactory-issuer/src/contract.rs index d3264c8f3..7de8b8f7b 100644 --- a/contracts/external/cw-tokenfactory-issuer/src/contract.rs +++ b/contracts/external/cw-tokenfactory-issuer/src/contract.rs @@ -162,7 +162,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result StdResult { #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - // 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)] diff --git a/contracts/voting/dao-voting-cw20-staked/src/tests.rs b/contracts/voting/dao-voting-cw20-staked/src/tests.rs index b6d664604..bab1b65a4 100644 --- a/contracts/voting/dao-voting-cw20-staked/src/tests.rs +++ b/contracts/voting/dao-voting-cw20-staked/src/tests.rs @@ -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); diff --git a/contracts/voting/dao-voting-cw4/src/contract.rs b/contracts/voting/dao-voting-cw4/src/contract.rs index 246889713..cf6b1e249 100644 --- a/contracts/voting/dao-voting-cw4/src/contract.rs +++ b/contracts/voting/dao-voting-cw4/src/contract.rs @@ -173,7 +173,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result Result Result Result, _block: &BlockInfo, _sender: Addr, - msg: Self::ExecT, + _msg: Self::ExecT, ) -> AnyResult 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(