Skip to content

Conversation

@amatsonkali
Copy link
Contributor

No description provided.

amatsonkali and others added 30 commits July 20, 2022 18:04
and adds a RBAC custom pallet form the template
Permissions map needs to be changed, as they dont vary through scopes, but for roles
and polishes existing functions
Within a helper function
@amatsonkali amatsonkali added the enhancement New feature or request label Aug 16, 2022
@amatsonkali amatsonkali requested a review from tlacloc August 17, 2022 02:37
Copy link
Contributor

@sebastianmontero sebastianmontero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Pending the pallet_id solution.

/// - `scope_id`: The newly generated scope identifier.
fn create_scope(pallet_id: u64, scope_id: ScopeId)-> DispatchResult{
let pallet_id: u64 = pallet_id.try_into().unwrap();
fn create_scope(pallet_name: Vec<u8>, scope_id: ScopeId)-> DispatchResult{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to handle the pallet_name/pallet_id parameter as an enum, that can be either the pallet_name or the pallet_id(the hashed pallet name), this enum could have to functions:

  • to_id_enum() that returns the enum that contains a pallet_id
  • to_id() that returns the actual pallet_id
    This would enable:
  • the encapsulation of all the logic related to this parameter in a type
  • the hashing of the name only once in cases where a function that receives this parameter calls multiple other functions that also receives this parameter

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting solution, I developed a similar solution for role name or role id, but I discarded it because it adds some development complexity, I'll try that out again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this implementation look? I'm going to test this enum out

#[derive(Encode, Decode, Clone, Eq, PartialEq,)]
pub enum IdOrVec{
    Id([u8;32]),
    Vec(Vec<u8>)
}

impl IdOrVec{
    pub fn to_id_enum(&self)->Self{
        match self{
            Self::Id(_) => self.clone(),
            Self::Vec(_) => Self::Id(Self::to_id(&self))
        }
    }

    pub fn to_id(&self)->[u8;32]{
        match self{
            Self::Id(id) => id.clone(),
            Self::Vec(v) => v.clone().using_encoded(blake2_256)
        }
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good!

didiermis and others added 6 commits August 25, 2022 14:26
minor clippy optimizations
…eters, I changed the double hashing storagemaps. I removed the tight coupling of timestamp & uniques pallets. I deleted all unused imports. Update Unit tests.
and adds initial setup in RBAC readme
Copy link
Contributor

@didiermis didiermis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amatsonkali amatsonkali merged commit e568c84 into develop Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants