From 5ab435a652768a31a1543cb90122a151ee9b6969 Mon Sep 17 00:00:00 2001 From: mubarak23 Date: Mon, 2 Sep 2024 01:41:20 +0100 Subject: [PATCH] add check for caller address --- src/components/permissionable/permissionable.cairo | 3 +++ src/components/presets/account_preset.cairo | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/permissionable/permissionable.cairo b/src/components/permissionable/permissionable.cairo index 4b44751..c7ae7fc 100644 --- a/src/components/permissionable/permissionable.cairo +++ b/src/components/permissionable/permissionable.cairo @@ -51,6 +51,7 @@ pub mod PermissionableComponent { // ************************************************************************* pub mod Errors { pub const INVALID_LENGTH: felt252 = 'Account: invalid length'; + pub const UNAUTHORIZED: felt252 = 'Account: unauthorized'; } @@ -76,6 +77,8 @@ pub mod PermissionableComponent { let account_comp = get_dep_component!(@self, Account); let owner = account_comp.owner(); + assert(owner == get_caller_address(), Errors::UNAUTHORIZED); + let length = permissioned_addresses.len(); let mut index: u32 = 0; while index < length { diff --git a/src/components/presets/account_preset.cairo b/src/components/presets/account_preset.cairo index f31f428..5fa7848 100644 --- a/src/components/presets/account_preset.cairo +++ b/src/components/presets/account_preset.cairo @@ -155,10 +155,6 @@ pub mod AccountPreset { permissioned_addresses: Array, permissions: Array ) { - // validate signer - let caller = get_caller_address(); - assert(self.is_valid_signer(caller), 'Account: unauthorized'); - // set permissions self.permissionable.set_permission(permissioned_addresses, permissions) }