diff --git a/contracts/tgrade-validator-voting/src/contract.rs b/contracts/tgrade-validator-voting/src/contract.rs index 511e7d0..e2cc6fe 100644 --- a/contracts/tgrade-validator-voting/src/contract.rs +++ b/contracts/tgrade-validator-voting/src/contract.rs @@ -164,6 +164,26 @@ pub fn execute_execute( 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 b3b5189..9a7f913 100644 --- a/contracts/tgrade-validator-voting/src/msg.rs +++ b/contracts/tgrade-validator-voting/src/msg.rs @@ -91,6 +91,16 @@ pub enum ValidatorProposal { /// 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 e57e62d..c18bee1 100644 --- a/contracts/tgrade-validator-voting/src/validate.rs +++ b/contracts/tgrade-validator-voting/src/validate.rs @@ -83,7 +83,16 @@ impl ValidatorProposal { return Err(ContractError::InvalidConsensusParams {}); } } - ValidatorProposal::PromoteToPrivilegedContract { .. } + 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 {} => {}