Added migration code for updating vesting contract address

This commit is contained in:
Jędrzej Stuczyński
2022-11-15 16:06:03 +00:00
parent c74a880838
commit 8774b22d84
2 changed files with 15 additions and 3 deletions
@@ -413,4 +413,6 @@ pub enum QueryMsg {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct MigrateMsg {}
pub struct MigrateMsg {
pub vesting_contract_address: String,
}
+12 -2
View File
@@ -467,10 +467,20 @@ pub fn query(
#[entry_point]
pub fn migrate(
_deps: DepsMut<'_>,
deps: DepsMut<'_>,
_env: Env,
_msg: MigrateMsg,
msg: MigrateMsg,
) -> Result<Response, MixnetContractError> {
// 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
if !msg.vesting_contract_address.is_empty() {
let mut current_state = mixnet_params_storage::CONTRACT_STATE.load(deps.storage)?;
current_state.vesting_contract_address =
deps.api.addr_validate(&msg.vesting_contract_address)?;
mixnet_params_storage::CONTRACT_STATE.save(deps.storage, &current_state)?;
}
Ok(Default::default())
}