diff --git a/smart-contracts/osmosis/contracts/cl-vault/Cargo.toml b/smart-contracts/osmosis/contracts/cl-vault/Cargo.toml index 01f3569f2..fc51e0588 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/Cargo.toml +++ b/smart-contracts/osmosis/contracts/cl-vault/Cargo.toml @@ -2,7 +2,7 @@ authors = ["LaurensKubat <32776056+LaurensKubat@users.noreply.github.com>"] edition = "2021" name = "cl-vault" -version = "0.3.0" +version = "0.3.1" exclude = [ "cl_vault.wasm", diff --git a/smart-contracts/osmosis/contracts/cl-vault/schema/cl-vault.json b/smart-contracts/osmosis/contracts/cl-vault/schema/cl-vault.json index d5c0df4aa..3c567fae5 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/schema/cl-vault.json +++ b/smart-contracts/osmosis/contracts/cl-vault/schema/cl-vault.json @@ -1,6 +1,6 @@ { "contract_name": "cl-vault", - "contract_version": "0.3.0", + "contract_version": "0.3.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs b/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs index 0fea53c02..90080a744 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs @@ -201,6 +201,9 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result { + cw2::assert_contract_version(deps.storage, CONTRACT_NAME, "0.3.0")?; + let previous_version = + cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let dex_router_item: Item = Item::new("dex_router"); dex_router_item.remove(deps.storage); // VaultConfig @@ -246,7 +249,10 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result = Map::new("user_rewards"); USER_REWARDS.clear(deps.storage); - let response = Response::new().add_attribute("migrate", "successful"); + let response = Response::new() + .add_attribute("migrate", "successful") + .add_attribute("previous version", previous_version.to_string()) + .add_attribute("new version", CONTRACT_VERSION); Ok(response) } @@ -260,6 +266,7 @@ mod tests { fn test_migrate() { let env = mock_env(); let mut deps = mock_dependencies(); + assert!(set_contract_version(deps.as_mut().storage, CONTRACT_NAME, "0.3.0").is_ok()); // VaultConfig mocking #[cw_serde] @@ -272,7 +279,7 @@ mod tests { const OLD_VAULT_CONFIG: Item = Item::new("vault_config_v2"); OLD_VAULT_CONFIG .save( - &mut deps.storage, + deps.as_mut().storage, &OldVaultConfig { performance_fee: Decimal::percent(1), treasury: Addr::unchecked("treasury"), @@ -290,13 +297,17 @@ mod tests { } pub const MIGRATION_STATUS: Item = Item::new("migration_status"); MIGRATION_STATUS - .save(&mut deps.storage, &MigrationStatus::Closed) + .save(deps.as_mut().storage, &MigrationStatus::Closed) .unwrap(); // UserRewards mocking pub const USER_REWARDS: Map = Map::new("user_rewards"); USER_REWARDS - .save(&mut deps.storage, Addr::unchecked("user"), &CoinList::new()) + .save( + deps.as_mut().storage, + Addr::unchecked("user"), + &CoinList::new(), + ) .unwrap(); // Migrate and assert new states diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/error.rs b/smart-contracts/osmosis/contracts/cl-vault/src/error.rs index 06d1f4395..da82edd37 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/error.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/error.rs @@ -4,6 +4,7 @@ use cosmwasm_std::{ CoinFromStrError, ConversionOverflowError, Decimal, Decimal256, Decimal256RangeExceeded, DecimalRangeExceeded, DivideByZeroError, OverflowError, StdError, Storage, Uint128, }; +use cw2::VersionError; use cw_utils::PaymentError; use prost::DecodeError; use quasar_types::pool_pair::PoolPairError; @@ -162,6 +163,9 @@ pub enum ContractError { #[error("{0}")] PoolPair(#[from] PoolPairError), + + #[error("{0}")] + Version(#[from] VersionError), } pub fn assert_deposits(funds: &[Coin], config: &PoolConfig) -> Result<(), ContractError> {