Skip to content

Commit

Permalink
set preset account for permissionable componenet
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Aug 26, 2024
1 parent 3390ac5 commit 2839c5e
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/presets/account_preset.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ pub mod AccountPreset {
use token_bound_accounts::components::account::account::AccountComponent;
use token_bound_accounts::components::upgradeable::upgradeable::UpgradeableComponent;
use token_bound_accounts::components::lockable::lockable::LockableComponent;
use token_bound_accounts::components::permissionable::permissionable::PermissionableComponent;
use token_bound_accounts::interfaces::{
IUpgradeable::IUpgradeable, IExecutable::IExecutable, ILockable::ILockable
IUpgradeable::IUpgradeable, IExecutable::IExecutable, ILockable::ILockable,
IPermissionable::IPermissionable
};

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);
component!(path: LockableComponent, storage: lockable, event: LockableEvent);
component!(path: PermissionableComponent, storage: permissionable, event: PermissionableEvent);

// Account
#[abi(embed_v0)]
Expand All @@ -22,6 +25,7 @@ pub mod AccountPreset {
impl AccountInternalImpl = AccountComponent::InternalImpl<ContractState>;
impl UpgradeableInternalImpl = UpgradeableComponent::Private<ContractState>;
impl LockableImpl = LockableComponent::LockableImpl<ContractState>;
impl PermissionableImpl = PermissionableComponent::PermissionableImpl<ContractState>;

// *************************************************************************
// STORAGE
Expand All @@ -34,6 +38,8 @@ pub mod AccountPreset {
upgradeable: UpgradeableComponent::Storage,
#[substorage(v0)]
lockable: LockableComponent::Storage,
#[substorage(v0)]
permissionable: PermissionableComponent::Storage,
}

// *************************************************************************
Expand All @@ -47,7 +53,9 @@ pub mod AccountPreset {
#[flat]
UpgradeableEvent: UpgradeableComponent::Event,
#[flat]
LockableEvent: LockableComponent::Event
LockableEvent: LockableComponent::Event,
#[flat]
PermissionableEvent: PermissionableComponent::Event
}

// *************************************************************************
Expand Down Expand Up @@ -96,4 +104,19 @@ pub mod AccountPreset {
self.lockable.is_locked()
}
}

// *************************************************************************
// PERMISSIONABLE IMPL
// *************************************************************************
#[abi(embed_v0)]
impl Permissionable of IPermissionable<ContractState> {
fn set_permission(ref self: ContractState, permission_addresses: Array<ContractAddress>,
permissions: Array<bool>) {
self.permissionable.set_permission( permission_addresses,
permissions)
}
fn has_permission(self: @ContractState, permission_addresses: ContractAddress) -> bool {
self.permissionable.has_permission(permission_addresses)
}
}
}

0 comments on commit 2839c5e

Please sign in to comment.