Skip to content

Commit

Permalink
chore: remove CanRegisterAnyTrigger CanUnregisterAnyTrigger permi…
Browse files Browse the repository at this point in the history
…ssions

Signed-off-by: Shunkichi Sato <[email protected]>
  • Loading branch information
s8sato committed Nov 2, 2024
1 parent c8598bc commit e8e1316
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 94 deletions.
20 changes: 5 additions & 15 deletions crates/iroha_executor/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ pub mod domain {
AnyPermission::CanRegisterTrigger(permission) => {
permission.authority.domain() == domain_id
}
AnyPermission::CanRegisterAnyTrigger(_)
| AnyPermission::CanUnregisterAnyTrigger(_)
| AnyPermission::CanUnregisterTrigger(_)
AnyPermission::CanUnregisterTrigger(_)
| AnyPermission::CanExecuteTrigger(_)
| AnyPermission::CanModifyTrigger(_)
| AnyPermission::CanModifyTriggerMetadata(_)
Expand Down Expand Up @@ -548,9 +546,7 @@ pub mod account {
AnyPermission::CanBurnAsset(permission) => permission.asset.account() == account_id,
AnyPermission::CanTransferAsset(permission) => permission.asset.account() == account_id,
AnyPermission::CanRegisterTrigger(permission) => permission.authority == *account_id,
AnyPermission::CanRegisterAnyTrigger(_)
| AnyPermission::CanUnregisterAnyTrigger(_)
| AnyPermission::CanUnregisterTrigger(_)
AnyPermission::CanUnregisterTrigger(_)
| AnyPermission::CanExecuteTrigger(_)
| AnyPermission::CanModifyTrigger(_)
| AnyPermission::CanModifyTriggerMetadata(_)
Expand Down Expand Up @@ -816,8 +812,6 @@ pub mod asset_definition {
AnyPermission::CanUnregisterAccount(_)
| AnyPermission::CanRegisterAsset(_)
| AnyPermission::CanModifyAccountMetadata(_)
| AnyPermission::CanRegisterAnyTrigger(_)
| AnyPermission::CanUnregisterAnyTrigger(_)
| AnyPermission::CanRegisterTrigger(_)
| AnyPermission::CanUnregisterTrigger(_)
| AnyPermission::CanExecuteTrigger(_)
Expand Down Expand Up @@ -1342,8 +1336,8 @@ pub mod role {

pub mod trigger {
use iroha_executor_data_model::permission::trigger::{
CanExecuteTrigger, CanModifyTrigger, CanModifyTriggerMetadata, CanRegisterAnyTrigger,
CanRegisterTrigger, CanUnregisterAnyTrigger, CanUnregisterTrigger,
CanExecuteTrigger, CanModifyTrigger, CanModifyTriggerMetadata, CanRegisterTrigger,
CanUnregisterTrigger,
};
use iroha_smart_contract::data_model::trigger::Trigger;

Expand Down Expand Up @@ -1377,7 +1371,6 @@ pub mod trigger {
can_register_user_trigger_token
.is_owned_by(&executor.context().authority, executor.host())
}
|| CanRegisterAnyTrigger.is_owned_by(&executor.context().authority, executor.host())
{
execute!(executor, isi)
}
Expand All @@ -1402,7 +1395,6 @@ pub mod trigger {
can_unregister_user_trigger_token
.is_owned_by(&executor.context().authority, executor.host())
}
|| CanUnregisterAnyTrigger.is_owned_by(&executor.context().authority, executor.host())
{
let mut err = None;
for (owner_id, permission) in accounts_permissions(executor.host()) {
Expand Down Expand Up @@ -1584,9 +1576,7 @@ pub mod trigger {
AnyPermission::CanModifyTriggerMetadata(permission) => {
&permission.trigger == trigger_id
}
AnyPermission::CanRegisterAnyTrigger(_)
| AnyPermission::CanUnregisterAnyTrigger(_)
| AnyPermission::CanRegisterTrigger(_)
AnyPermission::CanRegisterTrigger(_)
| AnyPermission::CanManagePeers(_)
| AnyPermission::CanRegisterDomain(_)
| AnyPermission::CanUnregisterDomain(_)
Expand Down
34 changes: 2 additions & 32 deletions crates/iroha_executor/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ declare_permissions! {
iroha_executor_data_model::permission::parameter::{CanSetParameters},
iroha_executor_data_model::permission::role::{CanManageRoles},

iroha_executor_data_model::permission::trigger::{CanRegisterAnyTrigger},
iroha_executor_data_model::permission::trigger::{CanUnregisterAnyTrigger},
iroha_executor_data_model::permission::trigger::{CanRegisterTrigger},
iroha_executor_data_model::permission::trigger::{CanUnregisterTrigger},
iroha_executor_data_model::permission::trigger::{CanModifyTrigger},
Expand Down Expand Up @@ -756,8 +754,8 @@ pub mod account {
pub mod trigger {
//! Module with pass conditions for trigger related tokens
use iroha_executor_data_model::permission::trigger::{
CanExecuteTrigger, CanModifyTrigger, CanModifyTriggerMetadata, CanRegisterAnyTrigger,
CanRegisterTrigger, CanUnregisterAnyTrigger, CanUnregisterTrigger,
CanExecuteTrigger, CanModifyTrigger, CanModifyTriggerMetadata, CanRegisterTrigger,
CanUnregisterTrigger,
};

use super::*;
Expand Down Expand Up @@ -821,34 +819,6 @@ pub mod trigger {
}
}

impl ValidateGrantRevoke for CanRegisterAnyTrigger {
fn validate_grant(&self, authority: &AccountId, context: &Context, host: &Iroha) -> Result {
OnlyGenesis::from(self).validate(authority, host, context)
}
fn validate_revoke(
&self,
authority: &AccountId,
context: &Context,
host: &Iroha,
) -> Result {
OnlyGenesis::from(self).validate(authority, host, context)
}
}

impl ValidateGrantRevoke for CanUnregisterAnyTrigger {
fn validate_grant(&self, authority: &AccountId, context: &Context, host: &Iroha) -> Result {
OnlyGenesis::from(self).validate(authority, host, context)
}
fn validate_revoke(
&self,
authority: &AccountId,
context: &Context,
host: &Iroha,
) -> Result {
OnlyGenesis::from(self).validate(authority, host, context)
}
}

impl ValidateGrantRevoke for CanRegisterTrigger {
fn validate_grant(&self, authority: &AccountId, context: &Context, host: &Iroha) -> Result {
super::account::Owner::from(self).validate(authority, host, context)
Expand Down
10 changes: 0 additions & 10 deletions crates/iroha_executor_data_model/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,6 @@ pub mod asset {
pub mod trigger {
use super::*;

permission! {
#[derive(Copy)]
pub struct CanRegisterAnyTrigger;
}

permission! {
#[derive(Copy)]
pub struct CanUnregisterAnyTrigger;
}

permission! {
pub struct CanRegisterTrigger {
pub authority: AccountId,
Expand Down
5 changes: 0 additions & 5 deletions crates/iroha_genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use derive_more::Constructor;
use eyre::{eyre, Result, WrapErr};
use iroha_crypto::KeyPair;
use iroha_data_model::{block::SignedBlock, parameter::Parameter, prelude::*};
use iroha_executor_data_model::permission::trigger::{
CanRegisterAnyTrigger, CanUnregisterAnyTrigger,
};
use iroha_schema::IntoSchema;
use parity_scale_codec::{Decode, Encode};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -254,8 +251,6 @@ impl GenesisBuilder {
let instructions = vec![
Register::domain(Domain::new(SYSTEM_DOMAIN_ID.clone())).into(),
Register::account(Account::new(SYSTEM_ACCOUNT_ID.clone())).into(),
Grant::account_permission(CanRegisterAnyTrigger, SYSTEM_ACCOUNT_ID.clone()).into(),
Grant::account_permission(CanUnregisterAnyTrigger, SYSTEM_ACCOUNT_ID.clone()).into(),
];

let wasm_triggers = vec![];
Expand Down
8 changes: 0 additions & 8 deletions crates/iroha_schema_gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ pub fn build_schemas() -> MetaMap {
permission::asset::CanModifyAssetMetadata,
permission::parameter::CanSetParameters,
permission::role::CanManageRoles,
permission::trigger::CanRegisterAnyTrigger,
permission::trigger::CanUnregisterAnyTrigger,
permission::trigger::CanRegisterTrigger,
permission::trigger::CanExecuteTrigger,
permission::trigger::CanUnregisterTrigger,
Expand Down Expand Up @@ -627,12 +625,6 @@ mod tests {
insert_into_test_map!(iroha_executor_data_model::permission::asset::CanModifyAssetMetadata);
insert_into_test_map!(iroha_executor_data_model::permission::parameter::CanSetParameters);
insert_into_test_map!(iroha_executor_data_model::permission::role::CanManageRoles);
insert_into_test_map!(
iroha_executor_data_model::permission::trigger::CanRegisterAnyTrigger
);
insert_into_test_map!(
iroha_executor_data_model::permission::trigger::CanUnregisterAnyTrigger
);
insert_into_test_map!(iroha_executor_data_model::permission::trigger::CanRegisterTrigger);
insert_into_test_map!(iroha_executor_data_model::permission::trigger::CanExecuteTrigger);
insert_into_test_map!(iroha_executor_data_model::permission::trigger::CanUnregisterTrigger);
Expand Down
22 changes: 0 additions & 22 deletions defaults/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,6 @@
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanRegisterAnyTrigger",
"payload": null
},
"destination": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system"
}
}
},
{
"Grant": {
"Permission": {
"object": {
"name": "CanUnregisterAnyTrigger",
"payload": null
},
"destination": "ed0120D8B64D62FD8E09B9F29FE04D9C63E312EFB1CB29F1BF6AF00EBC263007AE75F7@system"
}
}
},
{
"Register": {
"Domain": {
Expand Down
2 changes: 0 additions & 2 deletions docs/source/references/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@
}
]
},
"CanRegisterAnyTrigger": null,
"CanRegisterAsset": {
"Struct": [
{
Expand Down Expand Up @@ -930,7 +929,6 @@
}
]
},
"CanUnregisterAnyTrigger": null,
"CanUnregisterAsset": {
"Struct": [
{
Expand Down

0 comments on commit e8e1316

Please sign in to comment.