Skip to content

Commit

Permalink
chore: use private function for joining community
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Oct 10, 2024
1 parent e9ad018 commit 193edc7
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions src/community/community.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -218,37 +218,7 @@ pub mod CommunityComponent {
assert(is_community_member != true, ALREADY_MEMBER);
assert(is_banned != true, BANNED_MEMBER);

// mint a community token to new joiner
let minted_token_id = self
._mint_community_nft(profile, community.community_nft_address);

let community_member = CommunityMember {
profile_address: profile,
community_id: community_id,
total_publications: 0,
community_token_id: minted_token_id,
ban_status: false
};

// update storage
self.community_member.write((community_id, profile), community_member);
let community_total_members = community.community_total_members + 1;
let updated_community = CommunityDetails {
community_total_members: community_total_members, ..community
};
self.communities.write(community_id, updated_community);

// emit event
self
.emit(
JoinedCommunity {
community_id: community_id,
transaction_executor: get_caller_address(),
token_id: minted_token_id,
profile: profile,
block_timestamp: get_block_timestamp(),
}
);
self._join_community(profile, community.community_nft_address, community_id);
}

/// @notice removes a member from a community
Expand Down

0 comments on commit 193edc7

Please sign in to comment.