Skip to content

Commit

Permalink
Merge pull request #56 from horuslabsio/ft_name_internal_functions
Browse files Browse the repository at this point in the history
Add underscore to internal functions of component
  • Loading branch information
Darlington02 authored Sep 25, 2024
2 parents 2310a1f + fa73da9 commit 25756e9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/accountV3/accountV3.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub mod AccountV3 {
assert(self.is_valid_signer(caller), Errors::UNAUTHORIZED);

// cannot make this call when the account is lock
let (is_locked, _) = self.lockable.is_locked();
let (is_locked, _) = self.lockable._is_locked();
assert(is_locked != true, Errors::ACCOUNT_LOCKED);

// execute calls
Expand All @@ -196,7 +196,7 @@ pub mod AccountV3 {
assert(self.signatory._base_signer_validation(caller), Errors::UNAUTHORIZED);

// cannot make this call when the account is lock
let (is_locked, _) = self.lockable.is_locked();
let (is_locked, _) = self.lockable._is_locked();
assert(is_locked != true, Errors::ACCOUNT_LOCKED);

// upgrade account
Expand All @@ -217,12 +217,12 @@ pub mod AccountV3 {
assert(self.is_valid_signer(caller), Errors::UNAUTHORIZED);

// lock account
self.lockable.lock(lock_until);
self.lockable._lock(lock_until);
}

// @notice returns the lock status of an account
fn is_locked(self: @ContractState) -> (bool, u64) {
self.lockable.is_locked()
self.lockable._is_locked()
}
}

Expand All @@ -240,7 +240,7 @@ pub mod AccountV3 {
permissions: Array<bool>
) {
// set permissions
self.permissionable.set_permission(permissioned_addresses, permissions)
self.permissionable._set_permission(permissioned_addresses, permissions)
}

// @notice returns if a user has permission or not
Expand All @@ -249,7 +249,7 @@ pub mod AccountV3 {
fn has_permission(
self: @ContractState, owner: ContractAddress, permissioned_address: ContractAddress
) -> bool {
self.permissionable.has_permission(owner, permissioned_address)
self.permissionable._has_permission(owner, permissioned_address)
}
}
}
6 changes: 3 additions & 3 deletions src/components/lockable/lockable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ pub mod LockableComponent {
> of LockablePrivateTrait<TContractState> {
// @notice locks an account
// @param lock_until time at which this account will no longer be locked
fn lock(ref self: ComponentState<TContractState>, lock_until: u64) {
fn _lock(ref self: ComponentState<TContractState>, lock_until: u64) {
let current_timestamp = get_block_timestamp();
assert(
lock_until <= current_timestamp + YEAR_TO_SECONDS, Errors::EXCEEDS_MAX_LOCK_TIME
);

let (lock_status, _) = self.is_locked();
let (lock_status, _) = self._is_locked();
assert(lock_status != true, Errors::LOCKED_ACCOUNT);

// update account state
Expand All @@ -100,7 +100,7 @@ pub mod LockableComponent {
}

// @notice returns the lock status of an account
fn is_locked(self: @ComponentState<TContractState>) -> (bool, u64) {
fn _is_locked(self: @ComponentState<TContractState>) -> (bool, u64) {
let unlock_timestamp = self.lock_until.read();
let current_time = get_block_timestamp();
if (current_time < unlock_timestamp) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/permissionable/permissionable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub mod PermissionableComponent {
// @notice sets permission for an account
// @permissioned_addresses array of addresses who's permission is to be updated
// @param permssions permission value <true, false>
fn set_permission(
fn _set_permission(
ref self: ComponentState<TContractState>,
permissioned_addresses: Array<ContractAddress>,
permissions: Array<bool>
Expand Down Expand Up @@ -105,7 +105,7 @@ pub mod PermissionableComponent {
// @notice returns if a user has permission or not
// @param owner tokenbound account owner
// @param permissioned_address address to check permission for
fn has_permission(
fn _has_permission(
self: @ComponentState<TContractState>,
owner: ContractAddress,
permissioned_address: ContractAddress
Expand Down
12 changes: 6 additions & 6 deletions src/components/presets/account_preset.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub mod AccountPreset {
assert(self.is_valid_signer(caller), 'Account: unauthorized');

// cannot make this call when the account is lock
let (is_locked, _) = self.lockable.is_locked();
let (is_locked, _) = self.lockable._is_locked();
assert(is_locked != true, 'Account: locked');

// execute calls
Expand All @@ -134,7 +134,7 @@ pub mod AccountPreset {
assert(self.is_valid_signer(caller), 'Account: unauthorized');

// cannot make this call when the account is lock
let (is_locked, _) = self.lockable.is_locked();
let (is_locked, _) = self.lockable._is_locked();
assert(is_locked != true, 'Account: locked');

// upgrade account
Expand All @@ -153,11 +153,11 @@ pub mod AccountPreset {
assert(self.is_valid_signer(caller), 'Account: unauthorized');

// lock account
self.lockable.lock(lock_until);
self.lockable._lock(lock_until);
}

fn is_locked(self: @ContractState) -> (bool, u64) {
self.lockable.is_locked()
self.lockable._is_locked()
}
}

Expand All @@ -172,13 +172,13 @@ pub mod AccountPreset {
permissions: Array<bool>
) {
// set permissions
self.permissionable.set_permission(permissioned_addresses, permissions)
self.permissionable._set_permission(permissioned_addresses, permissions)
}

fn has_permission(
self: @ContractState, owner: ContractAddress, permissioned_address: ContractAddress
) -> bool {
self.permissionable.has_permission(owner, permissioned_address)
self.permissionable._has_permission(owner, permissioned_address)
}
}
}
2 changes: 1 addition & 1 deletion src/components/signatory/signatory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub mod SignatoryComponent {

// check if signer has permissions
let permission = get_dep_component!(self, Permissionable);
let is_permissioned = permission.has_permission(owner, signer);
let is_permissioned = permission._has_permission(owner, signer);

// validate
if (signer == owner) {
Expand Down

0 comments on commit 25756e9

Please sign in to comment.