From f0b0ba905c939eadcf63e1c280ae46dec88d1988 Mon Sep 17 00:00:00 2001 From: Rana718 Date: Sat, 24 Aug 2024 19:28:47 +0530 Subject: [PATCH] [feat] Implement the functionality of removeMembers --- src/core/registry.cairo | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/core/registry.cairo b/src/core/registry.cairo index 44111e9..8b72ff5 100644 --- a/src/core/registry.cairo +++ b/src/core/registry.cairo @@ -34,6 +34,7 @@ pub trait IRegistry { ref self: TContractState, profile_id: u256, pending_owner: ContractAddress ); fn add_members(ref self: TContractState, profile_Id: u256, members: Array); + fn remove_members(ref self: TContractState, profile_Id: u256, members: Array); fn update_profile_metadata(ref self: TContractState, profile_id: u256, metadata: Metadata); } #[starknet::contract] @@ -238,10 +239,24 @@ pub mod Registry { i += 1; } } - // Issue no. #6 Implement the functionality of removeMembers - // Use u256 instead of bytes32 - // 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#L311 + // Issue no. #6 Implement the functionality of removeMembers + // Use u256 instead of bytes32 + // 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#L311 + fn remove_members(ref self: ContractState, profile_Id: u256, members: Array){ + let profile_id: felt252 = profile_Id.try_into().unwrap(); + self.member_length.write(members.len().into()); + let mut i = 0; + loop{ + if(i >= members.len().into()){ + break; + } + let member: ContractAddress = *members.at(i); + self.accessControl._revoke_role(profile_id, member); + i += 1; + + } + } // Issue no. #16 Implement the functionality of recoverFunds // Down below is the function that is to be implemented in the contract but in cairo.