Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add and remove schedule msgs can be modified in chain manager #ntrn-387 #113

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 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 @@ -245,10 +245,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 {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But i think it's possible to save a couple of lines of code. If you remove all 3

} else {
            Err(ContractError::Unauthorized {})
        }

and just return the error Err(ContractError::Unauthorized {}) at the very end if non of if matches

}
} 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
Loading