diff --git a/contracts/tgrade-validator-voting/src/contract.rs b/contracts/tgrade-validator-voting/src/contract.rs index b8eb107..e2cc6fe 100644 --- a/contracts/tgrade-validator-voting/src/contract.rs +++ b/contracts/tgrade-validator-voting/src/contract.rs @@ -150,6 +150,40 @@ pub fn execute_execute( proposal: GovProposal::ChangeParams(params), }) } + PromoteToPrivilegedContract { contract } => { + res = res.add_message(TgradeMsg::ExecuteGovProposal { + title: proposal.title, + description: proposal.description, + proposal: GovProposal::PromoteToPrivilegedContract { contract }, + }) + } + DemotePrivilegedContract { contract } => { + res = res.add_message(TgradeMsg::ExecuteGovProposal { + title: proposal.title, + description: proposal.description, + proposal: GovProposal::DemotePrivilegedContract { contract }, + }) + } + SetContractAdmin { + contract, + new_admin, + } => { + res = res.add_message(TgradeMsg::ExecuteGovProposal { + title: proposal.title, + description: proposal.description, + proposal: GovProposal::SetContractAdmin { + contract, + new_admin, + }, + }) + } + ClearContractAdmin { contract } => { + res = res.add_message(TgradeMsg::ExecuteGovProposal { + title: proposal.title, + description: proposal.description, + proposal: GovProposal::ClearContractAdmin { contract }, + }) + } }; Ok(res diff --git a/contracts/tgrade-validator-voting/src/error.rs b/contracts/tgrade-validator-voting/src/error.rs index 18e0cc5..cd18760 100644 --- a/contracts/tgrade-validator-voting/src/error.rs +++ b/contracts/tgrade-validator-voting/src/error.rs @@ -50,6 +50,9 @@ pub enum ContractError { #[error("Invalid consensus params: All cannot be none")] InvalidConsensusParams {}, + + #[error("Empty new admin")] + EmptyAdmin {}, } impl From for ContractError { diff --git a/contracts/tgrade-validator-voting/src/msg.rs b/contracts/tgrade-validator-voting/src/msg.rs index e291c7c..9a7f913 100644 --- a/contracts/tgrade-validator-voting/src/msg.rs +++ b/contracts/tgrade-validator-voting/src/msg.rs @@ -83,6 +83,24 @@ pub enum ValidatorProposal { Text {}, /// Defines a proposal to change one or more parameters. ChangeParams(Vec), + PromoteToPrivilegedContract { + /// The contract address to be promoted + contract: String, + }, + DemotePrivilegedContract { + /// The contract address to be demoted + contract: String, + }, + SetContractAdmin { + /// The contract address to be updated + contract: String, + /// The account address to become migrate admin of this contract + new_admin: String, + }, + ClearContractAdmin { + /// The contract address to be cleared + contract: String, + }, } // We can also add this as a tg3 extension diff --git a/contracts/tgrade-validator-voting/src/validate.rs b/contracts/tgrade-validator-voting/src/validate.rs index 13dcae5..c18bee1 100644 --- a/contracts/tgrade-validator-voting/src/validate.rs +++ b/contracts/tgrade-validator-voting/src/validate.rs @@ -83,7 +83,19 @@ impl ValidatorProposal { return Err(ContractError::InvalidConsensusParams {}); } } - ValidatorProposal::CancelUpgrade {} | ValidatorProposal::Text {} => {} + ValidatorProposal::SetContractAdmin { + contract: _contract, + new_admin, + } => { + if new_admin.is_empty() { + return Err(ContractError::EmptyAdmin {}); + } + } + ValidatorProposal::ClearContractAdmin { .. } + | ValidatorProposal::PromoteToPrivilegedContract { .. } + | ValidatorProposal::DemotePrivilegedContract { .. } + | ValidatorProposal::CancelUpgrade {} + | ValidatorProposal::Text {} => {} } Ok(()) }