Skip to content

Commit

Permalink
fix(multisig-prover): handle migration from several versions (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcobb23 authored Nov 21, 2024
1 parent 5012437 commit 3f86c95
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contracts/multisig-prover/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub const START_MULTISIG_REPLY_ID: u64 = 1;

const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
const BASE_VERSION: &str = "1.1.0";

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn instantiate(
Expand Down Expand Up @@ -117,13 +116,20 @@ pub fn query(
.map_err(axelar_wasm_std::error::ContractError::from)
}

// It is valid to migrate from any of the below versions
const BASE_VERSION: &str = "1.1.0";
const OLD_BASE_VERSION: &str = "1.0.0";
const PATCH_VERSION: &str = "1.0.1";
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(
deps: DepsMut,
_env: Env,
_msg: Empty,
) -> Result<Response, axelar_wasm_std::error::ContractError> {
cw2::assert_contract_version(deps.storage, CONTRACT_NAME, BASE_VERSION)?;
cw2::assert_contract_version(deps.storage, CONTRACT_NAME, BASE_VERSION)
.or_else(|_| cw2::assert_contract_version(deps.storage, CONTRACT_NAME, PATCH_VERSION))
.or_else(|_| cw2::assert_contract_version(deps.storage, CONTRACT_NAME, OLD_BASE_VERSION))?;

cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Ok(Response::default())
Expand Down

0 comments on commit 3f86c95

Please sign in to comment.