Skip to content

Commit

Permalink
connect community component with root
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Oct 3, 2024
1 parent 9cbc6ea commit 37fe188
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 223 deletions.
32 changes: 16 additions & 16 deletions src/base/constants/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ pub struct QuoteParams {

#[derive(Debug, Drop, Serde, starknet::Store, Clone)]
pub struct CommunityDetails {
community_id: u256,
community_owner: ContractAddress,
community_metadata_uri: ByteArray,
community_nft_address: ContractAddress,
community_total_members: u256,
community_premium_status: bool,
community_type: ByteArray
pub community_id: u256,
pub community_owner: ContractAddress,
pub community_metadata_uri: ByteArray,
pub community_nft_address: ContractAddress,
pub community_total_members: u256,
pub community_premium_status: bool,
pub community_type: CommunityType
}

// /**
Expand All @@ -179,20 +179,20 @@ pub struct CommunityDetails {
// */
#[derive(Debug, Drop, Serde, starknet::Store, Clone)]
pub struct CommunityMember {
profile_address: ContractAddress,
community_id: u256,
total_publications: u256,
community_token_id: u256,
ban_status: bool,
pub profile_address: ContractAddress,
pub community_id: u256,
pub total_publications: u256,
pub community_token_id: u256,
pub ban_status: bool,
}


#[derive(Debug, Drop, Serde, starknet::Store, Clone)]
pub struct CommunityGateKeepDetails {
community_id: u256,
gate_keep_type: ByteArray,
community_nft_address: ContractAddress,
entry_fee: u256
pub community_id: u256,
pub gate_keep_type: GateKeepType,
pub community_nft_address: ContractAddress,
pub entry_fee: u256
}

// permissioned_addresses: Vec<ContractAddress>,
Expand Down
1 change: 1 addition & 0 deletions src/base/token_uris.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod follow_token_uri;
pub mod handle_token_uri;
pub mod profile_token_uri;
pub mod community_token_uri;
pub mod traits;
1 change: 1 addition & 0 deletions src/community.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod community;
399 changes: 204 additions & 195 deletions src/community/community.cairo

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/communitynft.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod communitynft;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[starknet::contract]
pub mod CommunityNft {
use starknet::{ContractAddress, get_block_timestamp, get_caller_address};
use core::num::traits::zero::Zero;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc721::{ERC721Component, ERC721HooksEmptyImpl};

Expand All @@ -19,7 +20,6 @@ pub mod CommunityNft {
component!(path: SRC5Component, storage: src5, event: SRC5Event);

// ERC721 Mixin
#[abi(embed_v0)]
impl ERC721MixinImpl = ERC721Component::ERC721MixinImpl<ContractState>;
impl ERC721InternalImpl = ERC721Component::InternalImpl<ContractState>;

Expand Down Expand Up @@ -66,7 +66,7 @@ pub mod CommunityNft {

/// @notice mints the user community NFT
/// @param address address of user trying to mint the community NFT token
fn mint(ref self: ContractState, user_address: ContractAddress) -> u256 {
fn mint_nft(ref self: ContractState, user_address: ContractAddress) -> u256 {
let balance = self.erc721.balance_of(user_address);
assert(balance.is_zero(), ALREADY_MINTED);

Expand All @@ -81,8 +81,8 @@ pub mod CommunityNft {

/// @notice burn the user community NFT
/// @param address address of user trying to burn the community NFT token
fn burn(ref self: ContractState, user_address: ContractAddress, token_id: u256) {
let user_token_id = self.user_token_id.read();
fn burn_nft(ref self: ContractState, user_address: ContractAddress, token_id: u256) {
let user_token_id = self.user_token_id.read(user_address);
assert(user_token_id == token_id, NOT_TOKEN_OWNER);
// check the token exist in erc721
assert(self.erc721.exists(token_id), TOKEN_DOES_NOT_EXIST);
Expand Down Expand Up @@ -122,8 +122,8 @@ pub mod CommunityNft {

/// @notice returns the token_uri for a particular token_id
fn token_uri(self: @ContractState, token_id: u256) -> ByteArray {
let mint_timestamp: u64 = self.get_token_mint_timestamp(token_id);
get_token_uri(token_id, mint_timestamp)
let token_mint_timestamp = self.mint_timestamp.read(token_id);
get_token_uri(token_id, token_mint_timestamp)
}
}
}
1 change: 1 addition & 0 deletions src/interfaces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pub mod IHandleRegistry;
pub mod IHub;
pub mod ICommunity;
pub mod ICollectNFT;
pub mod ICommunityNft;

5 changes: 3 additions & 2 deletions src/interfaces/ICommunity.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub trait ICommunity<TState> {
community_id: u256,
gate_keep_type: GateKeepType,
nft_contract_address: ContractAddress,
permissioned_addresses: Array<ContractAddress>
permissioned_addresses: Array<ContractAddress>,
entry_fee: u256
);

// *************************************************************************
Expand All @@ -39,7 +40,7 @@ pub trait ICommunity<TState> {
) -> (bool, u256);
fn get_total_members(self: @TState, community_id: u256) -> u256;
fn is_community_mod(self: @TState, profile: ContractAddress, community_id: u256) -> bool;
fn get_ban_status(self: @TState, profile: ContractAddress, channel_id: u256) -> bool;
fn get_ban_status(self: @TState, profile: ContractAddress, community_id: u256) -> bool;
fn is_premium_community(self: @TState, community_id: u256) -> (bool, CommunityType);
fn is_gatekeeped(self: @TState, community_id: u256) -> (bool, GateKeepType);
}
8 changes: 4 additions & 4 deletions src/interfaces/ICommunityNft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pub trait ICommunityNft<TContractState> {
// *************************************************************************
// GETTERS
// *************************************************************************
fn get_user_token_id(self: @ContractState, user_address: ContractAddress) -> u256;
fn get_user_token_id(self: @TContractState, user_address: ContractAddress) -> u256;


// *************************************************************************
// METADATA
// *************************************************************************
fn name(self: @TState) -> ByteArray;
fn symbol(self: @TState) -> ByteArray;
fn token_uri(self: @TState, token_id: u256) -> ByteArray;
fn name(self: @TContractState) -> ByteArray;
fn symbol(self: @TContractState) -> ByteArray;
fn token_uri(self: @TContractState, token_id: u256) -> ByteArray;
}
2 changes: 2 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pub mod namespaces;
pub mod presets;
pub mod hub;
pub mod collectnft;
pub mod community;
pub mod communitynft;

0 comments on commit 37fe188

Please sign in to comment.