Skip to content

Commit

Permalink
Merge pull request #4871 from nymtech/chore/remove-another-mixnet-mig…
Browse files Browse the repository at this point in the history
…ration

chore: remove queued migration for adding explicit admin
  • Loading branch information
jstuczyn authored Sep 25, 2024
2 parents 1627146 + f938357 commit 5d4a0fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
4 changes: 1 addition & 3 deletions contracts/mixnet/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,13 @@ pub fn query(

#[entry_point]
pub fn migrate(
mut deps: DepsMut<'_>,
deps: DepsMut<'_>,
_env: Env,
msg: MigrateMsg,
) -> Result<Response, MixnetContractError> {
set_build_information!(deps.storage)?;
cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

crate::queued_migrations::explicit_contract_admin(deps.branch())?;

// due to circular dependency on contract addresses (i.e. mixnet contract requiring vesting contract address
// and vesting contract requiring the mixnet contract address), if we ever want to deploy any new fresh
// environment, one of the contracts will HAVE TO go through a migration
Expand Down
20 changes: 1 addition & 19 deletions contracts/mixnet/src/queued_migrations.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
// Copyright 2022-2023 - Nym Technologies SA <[email protected]>
// Copyright 2022-2024 - Nym Technologies SA <[email protected]>
// SPDX-License-Identifier: Apache-2.0

use crate::mixnet_contract_settings::storage as mixnet_params_storage;
use cosmwasm_std::DepsMut;
use mixnet_contract_common::error::MixnetContractError;

pub(crate) fn explicit_contract_admin(deps: DepsMut) -> Result<(), MixnetContractError> {
// we need to read the deprecated field to migrate it over
#[allow(deprecated)]
// SAFETY: this value should ALWAYS exist on the first execution of this migration;
// as a matter of fact, it should ALWAYS continue existing until another migration
#[allow(clippy::expect_used)]
let existing_admin = mixnet_params_storage::CONTRACT_STATE
.load(deps.storage)?
.owner
.expect("the contract state is corrupt - there's no admin set");
mixnet_params_storage::ADMIN.set(deps, Some(existing_admin))?;
Ok(())
}

0 comments on commit 5d4a0fe

Please sign in to comment.