Skip to content

Commit

Permalink
import permissionable component into account
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Aug 28, 2024
1 parent 1a8d1a6 commit a39f12a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/components/account/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,7 +81,8 @@ pub mod AccountComponent {
// *************************************************************************
#[embeddable_as(AccountImpl)]
pub impl Account<
TContractState, +HasComponent<TContractState>, +Drop<TContractState>
TContractState, +HasComponent<TContractState>, +Drop<TContractState>,
impl Permissionable: PermissionableComponent::HasComponent<TContractState>
> of IAccount<ComponentState<TContractState>> {
/// @notice used for signature validation
/// @param hash The message hash
Expand Down Expand Up @@ -140,7 +142,8 @@ pub mod AccountComponent {
// *************************************************************************
#[generate_trait]
pub impl InternalImpl<
TContractState, +HasComponent<TContractState>, +Drop<TContractState>
TContractState, +HasComponent<TContractState>, +Drop<TContractState>,
impl Permissionable: PermissionableComponent::HasComponent<TContractState>
> of InternalTrait<TContractState> {
/// @notice initializes the account by setting the initial token contract and token id
fn initializer(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a39f12a

Please sign in to comment.