Skip to content

Commit

Permalink
Fix code formatting in permissions pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
F3Joule committed Jul 14, 2022
1 parent 0655dc0 commit 17b9e6e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pallets/permissions/src/default_permissions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{SpacePermission as SP, SpacePermissions};

use sp_std::vec;
use frame_support::parameter_types;
use sp_std::vec;

parameter_types! {
pub DefaultSpacePermissions: SpacePermissions = SpacePermissions {
Expand Down
11 changes: 6 additions & 5 deletions pallets/permissions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use sp_std::collections::btree_set::BTreeSet;

pub mod default_permissions;
mod types;

pub use types::*;

#[frame_support::pallet]
Expand Down Expand Up @@ -61,17 +62,17 @@ pub mod pallet {

// Check if this permission is forbidden:
if permission.is_present_in_role(perms_by_role.none) {
return Some(false);
return Some(false)
}

let is_space_owner = ctx.is_space_owner;
let is_follower = is_space_owner || ctx.is_space_follower;

if permission.is_present_in_role(perms_by_role.everyone)
|| is_follower && permission.is_present_in_role(perms_by_role.follower)
|| is_space_owner && permission.is_present_in_role(perms_by_role.space_owner)
if permission.is_present_in_role(perms_by_role.everyone) ||
is_follower && permission.is_present_in_role(perms_by_role.follower) ||
is_space_owner && permission.is_present_in_role(perms_by_role.space_owner)
{
return Some(true);
return Some(true)
}

None
Expand Down
27 changes: 11 additions & 16 deletions pallets/permissions/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use codec::{Decode, Encode};
use frame_support::{dispatch::{DispatchError, DispatchResult}};
use frame_support::dispatch::{DispatchError, DispatchResult};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;

Expand Down Expand Up @@ -86,20 +86,20 @@ pub type SpacePermissionSet = BTreeSet<SpacePermission>;
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct SpacePermissions {
/// None represents a set of permissions which is not capable of being performed by anyone.
/// For example, if you want to create a space similar to Twitter, you would set the permissions
/// for `UpdateOwnPosts`, `UpdateOwnComments`, and `Downvote` to `none`.
/// For example, if you want to create a space similar to Twitter, you would set the
/// permissions for `UpdateOwnPosts`, `UpdateOwnComments`, and `Downvote` to `none`.
pub none: Option<SpacePermissionSet>,

/// Everyone represents a set of permissions which are capable of being performed by every account
/// in a given space.
/// Everyone represents a set of permissions which are capable of being performed by every
/// account in a given space.
pub everyone: Option<SpacePermissionSet>,

/// Follower represents a set of permissions which are capable of being performed by every account
/// that follows a given space.
/// Follower represents a set of permissions which are capable of being performed by every
/// account that follows a given space.
pub follower: Option<SpacePermissionSet>,

/// Space owner represents a set of permissions which are capable of being performed by an account
/// that is a current owner of a given space.
/// Space owner represents a set of permissions which are capable of being performed by an
/// account that is a current owner of a given space.
pub space_owner: Option<SpacePermissionSet>,
}

Expand All @@ -115,7 +115,7 @@ impl SpacePermission {
pub(super) fn is_present_in_role(&self, perms_opt: Option<SpacePermissionSet>) -> bool {
if let Some(perms) = perms_opt {
if perms.contains(self) {
return true;
return true
}
}
false
Expand All @@ -138,11 +138,6 @@ pub trait PermissionChecker {
permission: SpacePermission,
error: DispatchError,
) -> DispatchResult {
Self::ensure_user_has_space_permission(
User::Account(account),
ctx,
permission,
error
)
Self::ensure_user_has_space_permission(User::Account(account), ctx, permission, error)
}
}

0 comments on commit 17b9e6e

Please sign in to comment.