Skip to content

Commit

Permalink
add and remove schedule msgs can be modified in chain manager
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Sep 3, 2024
1 parent cc590b9 commit a6a80d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
29 changes: 16 additions & 13 deletions contracts/dao/neutron-chain-manager/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cron_module_param_types::{
MsgUpdateParamsCron, ParamsRequestCron, ParamsResponseCron, MSG_TYPE_UPDATE_PARAMS_CRON,
PARAMS_QUERY_PATH_CRON,
use crate::cron_module_types::{
MsgUpdateParamsCron, ParamsRequestCron, ParamsResponseCron, MSG_TYPE_ADD_SCHEDULE,
MSG_TYPE_REMOVE_SCHEDULE, MSG_TYPE_UPDATE_PARAMS_CRON, PARAMS_QUERY_PATH_CRON,
};
use crate::dex_module_param_types::{
MsgUpdateParamsDex, ParamsRequestDex, ParamsResponseDex, MSG_TYPE_UPDATE_PARAMS_DEX,
Expand Down Expand Up @@ -180,16 +180,6 @@ fn check_neutron_msg(
neutron_msg: NeutronMsg,
) -> Result<(), ContractError> {
match neutron_msg {
NeutronMsg::AddSchedule { .. } => {
if !strategy.has_cron_add_schedule_permission() {
return Err(ContractError::Unauthorized {});
}
}
NeutronMsg::RemoveSchedule { name: _ } => {
if !strategy.has_cron_remove_schedule_permission() {
return Err(ContractError::Unauthorized {});
}
}
NeutronMsg::SubmitAdminProposal { admin_proposal } => {
check_submit_admin_proposal_message(deps, strategy, admin_proposal)?;
}
Expand Down Expand Up @@ -245,10 +235,23 @@ fn check_proposal_execute_message(
} else if typed_proposal.type_field.as_str() == MSG_TYPE_UPDATE_PARAMS_DEX {
check_dex_update_msg_params(deps, strategy, proposal)?;
Ok(())
} else if typed_proposal.type_field.as_str() == MSG_TYPE_ADD_SCHEDULE {
if strategy.has_cron_add_schedule_permission() {
Ok(())
} else {
Err(ContractError::Unauthorized {})
}
} else if typed_proposal.type_field.as_str() == MSG_TYPE_REMOVE_SCHEDULE {
if strategy.has_cron_remove_schedule_permission() {
Ok(())
} else {
Err(ContractError::Unauthorized {})
}
} else {
Err(ContractError::Unauthorized {})
}
}

/// Checks that the strategy owner is authorised to change the parameters of the
/// cron module. We query the current values for each parameter & compare them to
/// the values in the proposal; all modifications must be allowed by the strategy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use serde::{Deserialize, Serialize};

pub const PARAMS_QUERY_PATH_CRON: &str = "/neutron.cron.Query/Params";
pub const MSG_TYPE_UPDATE_PARAMS_CRON: &str = "/neutron.cron.MsgUpdateParams";
pub const MSG_TYPE_ADD_SCHEDULE: &str = "/neutron.cron.MsgAddSchedule";
pub const MSG_TYPE_REMOVE_SCHEDULE: &str = "/neutron.cron.MsgRemoveSchedule";

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
Expand Down
2 changes: 1 addition & 1 deletion contracts/dao/neutron-chain-manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod contract;
mod cron_module_param_types;
mod cron_module_types;
mod dex_module_param_types;
mod error;
pub mod msg;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cron_module_param_types::{ParamsCron, ParamsResponseCron};
use crate::cron_module_types::{ParamsCron, ParamsResponseCron};
use crate::dex_module_param_types::{ParamsDex, ParamsResponseDex};
use crate::tokenfactory_module_param_types::{ParamsResponseTokenfactory, ParamsTokenfactory};
use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage};
Expand Down

0 comments on commit a6a80d4

Please sign in to comment.