diff --git a/crates/iroha_executor/src/default/isi/multisig/account.rs b/crates/iroha_executor/src/default/isi/multisig/account.rs index 5608bc9944b..1b27223b93f 100644 --- a/crates/iroha_executor/src/default/isi/multisig/account.rs +++ b/crates/iroha_executor/src/default/isi/multisig/account.rs @@ -1,61 +1,25 @@ //! Validation and execution logic of instructions for multisig accounts -use iroha_executor_data_model::permission::account::CanRegisterAccount; - use super::*; -use crate::permission::domain::is_domain_owner; impl VisitExecute for MultisigRegister { - fn visit(&self, executor: &mut V) { - let registrant = executor.context().authority.clone(); - let target_domain = self.account.domain(); - let host = executor.host(); - - let Ok(is_domain_owner) = is_domain_owner(target_domain, ®istrant, host) else { - deny!( - executor, - "domain must exist before registering multisig account" - ); - }; - - let has_permission = { - CanRegisterAccount { - domain: target_domain.clone(), - } - .is_owned_by(®istrant, host) - }; + fn visit(&self, _executor: &mut V) {} - // Impose the same restriction as for personal account registrations - // TODO Allow the signatories to register the multisig account? With propose and approve procedures? - if !(is_domain_owner || has_permission) { - deny!( - executor, - "registrant must have sufficient permission to register an account" - ); - } + fn execute(self, executor: &mut V) -> Result<(), ValidationFail> { + let multisig_account = self.account; + let multisig_role = multisig_role_for(&multisig_account); - for signatory in self.signatories.keys().cloned() { - if host - .query(FindAccounts) - .filter_with(|account| account.id.eq(signatory)) - .execute_single() - .is_err() - { - deny!( - executor, - "signatories must exist before registering multisig account" - ); - } - } - } + // The multisig registrant needs to have sufficient permission to register personal accounts + // TODO Loosen to just being one of the signatories? But impose the procedure of propose and approve? + visit_seq!(executor + .visit_register_account(&Register::account(Account::new(multisig_account.clone())))); - fn execute(self, executor: &mut V) -> Result<(), ValidationFail> { let domain_owner = executor .host() .query(FindDomains) - .filter_with(|domain| domain.id.eq(self.account.domain().clone())) + .filter_with(|domain| domain.id.eq(multisig_account.domain().clone())) .execute_single() - .dbg_unwrap() + .dbg_expect("domain should be found as the preceding account registration succeeded") .owned_by() .clone(); @@ -63,12 +27,6 @@ impl VisitExecute for MultisigRegister { // Just having permission to register accounts is insufficient to register multisig roles executor.context_mut().authority = domain_owner.clone(); - let multisig_account = self.account; - let multisig_role = multisig_role_for(&multisig_account); - - visit_seq!(executor - .visit_register_account(&Register::account(Account::new(multisig_account.clone())))); - visit_seq!(executor.visit_set_account_key_value(&SetKeyValue::account( multisig_account.clone(), SIGNATORIES.parse().unwrap(),