diff --git a/src/base/constants/errors.cairo b/src/base/constants/errors.cairo index 1d74e04..bb53dea 100644 --- a/src/base/constants/errors.cairo +++ b/src/base/constants/errors.cairo @@ -10,6 +10,7 @@ pub mod Errors { pub const FOLLOWING: felt252 = 'coloniz: already following!'; pub const NOT_FOLLOWING: felt252 = 'coloniz: user not following!'; pub const BLOCKED_STATUS: felt252 = 'coloniz: user is blocked!'; + pub const USER_NOT_BLOCKED: felt252 = 'coloniz: user is not blocked!'; pub const INVALID_POINTED_PUBLICATION: felt252 = 'coloniz: invalid pointed pub!'; pub const INVALID_OWNER: felt252 = 'coloniz: caller is not owner!'; pub const INVALID_PROFILE: felt252 = 'coloniz: profile is not owner!'; diff --git a/src/community/community.cairo b/src/community/community.cairo index add793e..7a93839 100644 --- a/src/community/community.cairo +++ b/src/community/community.cairo @@ -391,7 +391,8 @@ pub mod CommunityComponent { /// @param community_id The id of the community /// /// @param permissioned_addresses array of addresses to set for permissioned gatekeeping fn set_permissioned_addresses( - ref self: ComponentState, community_id: u256, + ref self: ComponentState, + community_id: u256, permissioned_addresses: Array ) { // check caller is owner diff --git a/src/follownft/follownft.cairo b/src/follownft/follownft.cairo index 71ca823..fc2e842 100644 --- a/src/follownft/follownft.cairo +++ b/src/follownft/follownft.cairo @@ -180,6 +180,7 @@ pub mod Follow { .read(follower_profile_address); assert(follow_id.is_non_zero(), Errors::NOT_FOLLOWING); let follow_data = self.follow_data_by_follow_id.read(follow_id); + self .follow_data_by_follow_id .write( @@ -191,6 +192,7 @@ pub mod Follow { block_status: true, } ); + self .emit( FollowerBlocked { @@ -212,8 +214,9 @@ pub mod Follow { let follow_id = self .follow_id_by_follower_profile_address .read(follower_profile_address); - assert(follow_id.is_non_zero(), Errors::NOT_FOLLOWING); let follow_data = self.follow_data_by_follow_id.read(follow_id); + assert(follow_data.block_status == true, Errors::USER_NOT_BLOCKED); + self .follow_data_by_follow_id .write( @@ -225,6 +228,7 @@ pub mod Follow { block_status: false, } ); + self .emit( FollowerUnblocked { @@ -234,6 +238,7 @@ pub mod Follow { timestamp: get_block_timestamp() } ); + return true; } diff --git a/src/interfaces/ICommunity.cairo b/src/interfaces/ICommunity.cairo index b773865..2b047d3 100644 --- a/src/interfaces/ICommunity.cairo +++ b/src/interfaces/ICommunity.cairo @@ -49,9 +49,7 @@ pub trait ICommunity { paid_gating_details: (ContractAddress, u256), ); fn set_permissioned_addresses( - ref self: TState, - community_id: u256, - permissioned_addresses: Array + ref self: TState, community_id: u256, permissioned_addresses: Array ); // ************************************************************************* diff --git a/tests/test_follownft.cairo b/tests/test_follownft.cairo index a962ed9..389d271 100644 --- a/tests/test_follownft.cairo +++ b/tests/test_follownft.cairo @@ -196,6 +196,7 @@ fn test_process_unblock() { let dispatcher = IFollowNFTDispatcher { contract_address: follow_nft_contract_address }; start_cheat_caller_address(follow_nft_contract_address, HUB_ADDRESS.try_into().unwrap()); dispatcher.follow(FOLLOWER1.try_into().unwrap()); + dispatcher.process_block(FOLLOWER1.try_into().unwrap()); dispatcher.process_unblock(FOLLOWER1.try_into().unwrap()); let follow_id = dispatcher.get_follow_id(FOLLOWER1.try_into().unwrap()); let follow_data = dispatcher.get_follow_data(follow_id); @@ -338,6 +339,7 @@ fn test_unblock_event() { let dispatcher = IFollowNFTDispatcher { contract_address: follow_nft_contract_address }; start_cheat_caller_address(follow_nft_contract_address, HUB_ADDRESS.try_into().unwrap()); dispatcher.follow(FOLLOWER1.try_into().unwrap()); + dispatcher.process_block(FOLLOWER1.try_into().unwrap()); let mut spy = spy_events(); dispatcher.process_unblock(FOLLOWER1.try_into().unwrap()); let follow_id = dispatcher.get_follow_id(FOLLOWER1.try_into().unwrap());