From a39f12aa773e9e6d1b0abeae79afea2997326b9e Mon Sep 17 00:00:00 2001 From: mubarak23 Date: Wed, 28 Aug 2024 12:00:38 +0100 Subject: [PATCH] import permissionable component into account --- src/components/account/account.cairo | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/account/account.cairo b/src/components/account/account.cairo index b7a123e..415b62d 100644 --- a/src/components/account/account.cairo +++ b/src/components/account/account.cairo @@ -21,6 +21,7 @@ pub mod AccountComponent { use token_bound_accounts::interfaces::IAccount::{ IAccount, IAccountDispatcherTrait, IAccountDispatcher, TBA_INTERFACE_ID }; + use token_bound_accounts::components::permissionable::permissionable::PermissionableComponent; // ************************************************************************* // STORAGE @@ -80,7 +81,8 @@ pub mod AccountComponent { // ************************************************************************* #[embeddable_as(AccountImpl)] pub impl Account< - TContractState, +HasComponent, +Drop + TContractState, +HasComponent, +Drop, + impl Permissionable: PermissionableComponent::HasComponent > of IAccount> { /// @notice used for signature validation /// @param hash The message hash @@ -140,7 +142,8 @@ pub mod AccountComponent { // ************************************************************************* #[generate_trait] pub impl InternalImpl< - TContractState, +HasComponent, +Drop + TContractState, +HasComponent, +Drop, + impl Permissionable: PermissionableComponent::HasComponent > of InternalTrait { /// @notice initializes the account by setting the initial token contract and token id fn initializer( @@ -240,11 +243,24 @@ pub mod AccountComponent { ) -> bool { let owner = self ._get_owner(self.account_token_contract.read(), self.account_token_id.read()); - if (signer == owner) { + let permissionable_comp = get_dep_component!(ref self, Permissionable); + + let has_permission = permissionable_comp.has_permission(owner, signer); + + if(signer == owner){ return true; - } else { - return false; + } + + if (has_permission){ + return true } + return false; + // if (signer == owner) { + // return true; + // } else { + // // run the chek here + // return false; + // } } /// @notice internal function for signature validation