Skip to content
Open
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
13 changes: 10 additions & 3 deletions contracts/external/cw-vesting/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use cw_ownable::OwnershipError;
use cw_utils::{must_pay, nonpayable};

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, ReceiveMsg};
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, ReceiveMsg};
use crate::state::{PAYMENT, UNBONDING_DURATION_SECONDS};
use crate::vesting::{Status, VestInit};

const CONTRACT_NAME: &str = "crates.io:cw-vesting";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const CONTRACT_NAME: &str = "crates.io:cw-vesting";
pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -482,3 +482,10 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::VestDuration {} => to_json_binary(&PAYMENT.duration(deps.storage)?),
}
}

#[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())
}
2 changes: 2 additions & 0 deletions contracts/external/cw-vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub use cw_ownable::Ownership;
// so consumers don't need a cw_stake_tracker dependency to use this contract's queries.
pub use cw_stake_tracker::StakeTrackerQuery;

#[cfg(test)]
mod migrate_tests;
#[cfg(test)]
mod suite_tests;
#[cfg(test)]
Expand Down
14 changes: 14 additions & 0 deletions contracts/external/cw-vesting/src/migrate_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use cosmwasm_std::testing::{mock_dependencies, mock_env};

use crate::contract::{migrate, CONTRACT_NAME, CONTRACT_VERSION};
use crate::msg::MigrateMsg;

#[test]
pub fn test_migrate_update_version() {
let mut deps = mock_dependencies();
cw2::set_contract_version(&mut deps.storage, "my-contract", "old-version").unwrap();
migrate(deps.as_mut(), mock_env(), MigrateMsg {}).unwrap();
let version = cw2::get_contract_version(&deps.storage).unwrap();
assert_eq!(version.version, CONTRACT_VERSION);
assert_eq!(version.contract, CONTRACT_NAME);
}
3 changes: 3 additions & 0 deletions contracts/external/cw-vesting/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,6 @@ pub enum QueryMsg {
#[returns(::cosmwasm_std::Uint128)]
Stake(StakeTrackerQuery),
}

#[cw_serde]
pub struct MigrateMsg {}
Loading