Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
chore(perms): permissions store is moved to top index
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Jun 29, 2023
1 parent c50afa9 commit ea3c23c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bucket/ddc_bucket/perm/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use crate::ddc_bucket::perm::entity::Permission;
impl DdcBucket {

pub fn grant_permission(&mut self, account_id: AccountId, permission: Permission) -> Result<()> {
self.perms.grant_permission(account_id, &permission);
self.perms.grant_permission(account_id, permission);
Ok(())
}

pub fn revoke_permission(&mut self, account_id: AccountId, permission: Permission) -> Result<()> {
self.perms.revoke_permission(account_id, &permission);
self.perms.revoke_permission(account_id, permission);
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions bucket/ddc_bucket/perm/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ pub struct PermStore {


impl PermStore {
pub fn grant_permission(&mut self, account_id: AccountId, permission: &Permission) {
pub fn grant_permission(&mut self, account_id: AccountId, permission: Permission) {
let key = (account_id, permission).encode();
self.perms.insert(key, &true);
}

pub fn revoke_permission(&mut self, account_id: AccountId, permission: &Permission) {
pub fn revoke_permission(&mut self, account_id: AccountId, permission: Permission) {
let key = (account_id, permission).encode();
self.perms.remove(&key);
}
Expand Down
4 changes: 2 additions & 2 deletions bucket/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ pub mod ddc_bucket {
#[ink(storage)]
#[derive(SpreadAllocate, Default)]
pub struct DdcBucket {
perms: PermStore,
buckets: BucketStore,
clusters: ClusterStore,
cdn_nodes: CdnNodeStore,
nodes: NodeStore,
accounts: AccountStore,
perms: PermStore,
network_fee: NetworkFeeStore,
committer_store: CommitterStore,
protocol_store: ProtocolStore,
Expand All @@ -72,7 +72,7 @@ pub mod ddc_bucket {
ink_lang::utils::initialize_contract(|contract: &mut Self| {
let admin = Self::env().caller();
// Make the creator of this contract a super-admin.
contract.perms.grant_permission(admin, &Permission::SuperAdmin);
contract.perms.grant_permission(admin, Permission::SuperAdmin);
contract.committer_store.init(admin);
contract.protocol_store.init(admin, DEFAULT_BASIS_POINTS);
})
Expand Down

0 comments on commit ea3c23c

Please sign in to comment.