Skip to content

Commit

Permalink
feat: added the function is_member_of_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
rahultripathi21 committed Sep 8, 2024
1 parent 86b0bca commit 195ae3b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/core/registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ struct Metadata {
#[starknet::interface]
pub trait IRegistry<TContractState> {
fn is_owner_of_profile(self: @TContractState, profile_id: u256, owner: ContractAddress) -> bool;
fn is_member_of_profile(
self: @TContractState, profile_id: u256, member: ContractAddress
) -> bool;
fn update_profile_pending_owner(
ref self: TContractState, profile_id: u256, pending_owner: ContractAddress
);
Expand Down Expand Up @@ -207,6 +210,12 @@ pub mod Registry {
// Issue no. #5 Implement the functionality of isMemberOfProfile
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L245
fn is_member_of_profile(
self: @ContractState, profile_id: u256, member: ContractAddress
) -> bool {
let profile_id_u128: u128 = profile_id.low.into(); // Cast to u128 (lower part of u256)
return self._is_member_of_profile(profile_id_u128, member);
}

// Issue no. #9 Implement the functionality of UpdateProfilePendingOwner
// Down below is the function that is to be implemented in the contract but in cairo.
Expand Down Expand Up @@ -293,9 +302,15 @@ pub mod Registry {
) -> bool {
return self.profiles_by_id.read(_profile_id).owner == _owner;
}
// Issue n. #5 Implement the functionality of _isMemberOfProfile
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L384C14-L384C32

// Issue n. #5 Implement the functionality of _isMemberOfProfile
// Down below is the function that is to be implemented in the contract but in cairo.
// https://github.com/allo-protocol/allo-v2/blob/4dd0ea34a504a16ac90e80f49a5570b8be9b30e9/contracts/core/Registry.sol#L384C14-L384C32
fn _is_member_of_profile(
self: @ContractState, _profile_id: u128, _member: ContractAddress
) -> bool {
let profile_id_felt: felt252 = _profile_id.into(); // Cast u128 to felt252
return AccessControlComponentImpl::has_role(self, profile_id_felt, _member);
}
}
}

0 comments on commit 195ae3b

Please sign in to comment.