-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove performed mixnet contract migration
- Loading branch information
Showing
4 changed files
with
155 additions
and
220 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,2 @@ | ||
// Copyright 2022-2024 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod config_score_params { | ||
use crate::constants::CONTRACT_STATE_KEY; | ||
use crate::mixnet_contract_settings::storage as mixnet_params_storage; | ||
use crate::mixnet_contract_settings::storage::NymNodeVersionHistory; | ||
use cosmwasm_std::{Addr, Coin, DepsMut, Env}; | ||
use cw_storage_plus::Item; | ||
use mixnet_contract_common::error::MixnetContractError; | ||
use mixnet_contract_common::{ | ||
ConfigScoreParams, ContractState, ContractStateParams, DelegationsParams, MigrateMsg, | ||
OperatingCostRange, OperatorsParams, ProfitMarginRange, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::str::FromStr; | ||
|
||
pub(crate) fn add_config_score_params( | ||
deps: DepsMut<'_>, | ||
env: Env, | ||
msg: &MigrateMsg, | ||
) -> Result<(), MixnetContractError> { | ||
if semver::Version::from_str(&msg.current_nym_node_semver).is_err() { | ||
return Err(MixnetContractError::InvalidNymNodeSemver { | ||
provided: msg.current_nym_node_semver.to_string(), | ||
}); | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct OldContractState { | ||
pub owner: Option<Addr>, | ||
pub rewarding_validator_address: Addr, | ||
pub vesting_contract_address: Addr, | ||
pub rewarding_denom: String, | ||
pub params: OldContractStateParams, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct OldContractStateParams { | ||
pub minimum_delegation: Option<Coin>, | ||
pub minimum_pledge: Coin, | ||
#[serde(default)] | ||
pub profit_margin: ProfitMarginRange, | ||
#[serde(default)] | ||
pub interval_operating_cost: OperatingCostRange, | ||
} | ||
|
||
const OLD_CONTRACT_STATE: Item<'_, OldContractState> = Item::new(CONTRACT_STATE_KEY); | ||
let old_state = OLD_CONTRACT_STATE.load(deps.storage)?; | ||
|
||
#[allow(deprecated)] | ||
let new_state = ContractState { | ||
owner: old_state.owner, | ||
rewarding_validator_address: old_state.rewarding_validator_address, | ||
vesting_contract_address: old_state.vesting_contract_address, | ||
rewarding_denom: old_state.rewarding_denom, | ||
params: ContractStateParams { | ||
delegations_params: DelegationsParams { | ||
minimum_delegation: old_state.params.minimum_delegation, | ||
}, | ||
operators_params: OperatorsParams { | ||
minimum_pledge: old_state.params.minimum_pledge, | ||
profit_margin: old_state.params.profit_margin, | ||
interval_operating_cost: old_state.params.interval_operating_cost, | ||
}, | ||
config_score_params: ConfigScoreParams { | ||
version_weights: msg.version_score_weights, | ||
version_score_formula_params: msg.version_score_params, | ||
}, | ||
}, | ||
}; | ||
|
||
mixnet_params_storage::CONTRACT_STATE.save(deps.storage, &new_state)?; | ||
|
||
// initialise the version chain | ||
NymNodeVersionHistory::new().try_insert_new( | ||
deps.storage, | ||
&env, | ||
&msg.current_nym_node_semver, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
pub(crate) use config_score_params::add_config_score_params; |
Oops, something went wrong.