diff --git a/src/collectnft/collectnft.cairo b/src/collectnft/collectnft.cairo index fc31189..049cfb3 100644 --- a/src/collectnft/collectnft.cairo +++ b/src/collectnft/collectnft.cairo @@ -44,7 +44,7 @@ pub mod CollectNFT { use openzeppelin::token::erc721::interface::IERC721Metadata; use starknet::{ContractAddress, get_caller_address, get_block_timestamp}; use core::num::traits::zero::Zero; - use karst::interfaces::ICollect::ICollectNFT; + use karst::interfaces::ICollectNFT::ICollectNFT; use karst::interfaces::IHub::{IHubDispatcher, IHubDispatcherTrait}; use karst::base::{ utils::hubrestricted::HubRestricted::hub_only, @@ -129,7 +129,7 @@ pub mod CollectNFT { } #[abi(embed_v0)] - impl CollectImpl of ICollectNFT { + impl CollectNFTImpl of ICollectNFT { // ************************************************************************* // EXTERNAL // ************************************************************************* @@ -137,7 +137,6 @@ pub mod CollectNFT { /// @param address address of user trying to mint the collect NFT fn mint_nft(ref self: ContractState, address: ContractAddress) -> u256 { let balance = self.erc721.balance_of(address); - // hub_only(self.karst_hub.read()); //assert only hub assert(balance.is_zero(), ALREADY_MINTED); let mut token_id = self.last_minted_id.read() + 1; diff --git a/src/interfaces.cairo b/src/interfaces.cairo index 40f4678..8f396d4 100644 --- a/src/interfaces.cairo +++ b/src/interfaces.cairo @@ -7,4 +7,4 @@ pub mod IPublication; pub mod IHandle; pub mod IHandleRegistry; pub mod IHub; -pub mod ICollect; +pub mod ICollectNFT; diff --git a/src/interfaces/ICollect.cairo b/src/interfaces/ICollectNFT.cairo similarity index 100% rename from src/interfaces/ICollect.cairo rename to src/interfaces/ICollectNFT.cairo diff --git a/src/profile/profile.cairo b/src/profile/profile.cairo index fd3e824..141aff2 100644 --- a/src/profile/profile.cairo +++ b/src/profile/profile.cairo @@ -189,13 +189,7 @@ mod ProfileComponent { ) -> u256 { let mut profile: Profile = self.profile.read(profile_address); let new_pub_count = profile.pub_count + 1; - let updated_profile = Profile { - profile_address: profile.profile_address, - profile_owner: profile.profile_owner, - pub_count: new_pub_count, - metadata_URI: profile.metadata_URI, - follow_nft: profile.follow_nft - }; + let updated_profile = Profile { pub_count: new_pub_count, ..profile }; self.profile.write(profile_address, updated_profile); new_pub_count diff --git a/src/publication/publication.cairo b/src/publication/publication.cairo index 6ad7cb9..71bb0b8 100644 --- a/src/publication/publication.cairo +++ b/src/publication/publication.cairo @@ -3,7 +3,7 @@ pub mod PublicationComponent { // ************************************************************************* // IMPORTS // ************************************************************************* - use karst::interfaces::ICollect::ICollectNFTDispatcherTrait; + use karst::interfaces::ICollectNFT::ICollectNFTDispatcherTrait; use core::num::traits::zero::Zero; use core::starknet::SyscallResultTrait; use core::traits::TryInto; @@ -14,7 +14,7 @@ pub mod PublicationComponent { deploy_syscall, class_hash::ClassHash }; use karst::interfaces::IPublication::IKarstPublications; - use karst::interfaces::ICollect::{ICollectNFT, ICollectNFTDispatcher}; + use karst::interfaces::ICollectNFT::{ICollectNFT, ICollectNFTDispatcher}; use karst::base::{ constants::errors::Errors::{NOT_PROFILE_OWNER, UNSUPPORTED_PUB_TYPE, ALREADY_REACTED}, utils::hubrestricted::HubRestricted::hub_only, @@ -48,8 +48,8 @@ pub mod PublicationComponent { RepostCreated: RepostCreated, Upvoted: Upvoted, Downvoted: Downvoted, - CollectNFT: CollectNFT, - DeployCollectNFT: DeployCollectNFT + CollectedNFT: CollectedNFT, + DeployedCollectNFT: DeployedCollectNFT } #[derive(Drop, starknet::Event)] @@ -91,7 +91,7 @@ pub mod PublicationComponent { } #[derive(Drop, starknet::Event)] - pub struct CollectNFT { + pub struct CollectedNFT { publication_id: u256, transaction_executor: ContractAddress, token_id: u256, @@ -99,7 +99,7 @@ pub mod PublicationComponent { } #[derive(Drop, starknet::Event)] - pub struct DeployCollectNFT { + pub struct DeployedCollectNFT { publication_id: u256, profile_address: ContractAddress, collect_nft: ContractAddress, @@ -246,19 +246,7 @@ pub mod PublicationComponent { let has_voted = self.vote_status.read((caller, pub_id)); let upvote_current_count = publication.upvote + 1; assert(has_voted == false, ALREADY_REACTED); - let updated_publication = Publication { - pointed_profile_address: publication.pointed_profile_address, - pointed_pub_id: publication.pointed_pub_id, - content_URI: publication.content_URI, - pub_Type: publication.pub_Type, - root_profile_address: publication.root_profile_address, - root_pub_id: publication.root_pub_id, - upvote: upvote_current_count, - downvote: publication.downvote, - channel_id: publication.channel_id, - collect_nft: publication.collect_nft, - tipped_amount: publication.tipped_amount - }; + let updated_publication = Publication { upvote: upvote_current_count, ..publication }; self.vote_status.write((caller, pub_id), true); self.publication.write((profile_address, pub_id), updated_publication); @@ -283,17 +271,7 @@ pub mod PublicationComponent { let downvote_current_count = publication.downvote + 1; assert(has_voted == false, ALREADY_REACTED); let updated_publication = Publication { - pointed_profile_address: publication.pointed_profile_address, - pointed_pub_id: publication.pointed_pub_id, - content_URI: publication.content_URI, - pub_Type: publication.pub_Type, - root_profile_address: publication.root_profile_address, - root_pub_id: publication.root_pub_id, - upvote: publication.upvote, - downvote: downvote_current_count, - channel_id: publication.channel_id, - collect_nft: publication.collect_nft, - tipped_amount: publication.tipped_amount + downvote: downvote_current_count, ..publication }; self.publication.write((profile_address, pub_id), updated_publication); self.vote_status.write((caller, pub_id), true); @@ -320,17 +298,7 @@ pub mod PublicationComponent { let mut publication = self.get_publication(profile_address, pub_id); let current_tip_amount = publication.tipped_amount; let updated_publication = Publication { - pointed_profile_address: publication.pointed_profile_address, - pointed_pub_id: publication.pointed_pub_id, - content_URI: publication.content_URI, - pub_Type: publication.pub_Type, - root_profile_address: publication.root_profile_address, - root_pub_id: publication.root_pub_id, - upvote: publication.upvote, - downvote: publication.downvote, - channel_id: publication.channel_id, - collect_nft: publication.collect_nft, - tipped_amount: current_tip_amount + amount + tipped_amount: current_tip_amount + amount, ..publication }; self.publication.write((profile_address, pub_id), updated_publication) } @@ -351,7 +319,7 @@ pub mod PublicationComponent { self .emit( - CollectNFT { + CollectedNFT { publication_id: pub_id, transaction_executor: get_caller_address(), token_id: token_id, @@ -610,7 +578,7 @@ pub mod PublicationComponent { self .emit( - DeployCollectNFT { + DeployedCollectNFT { publication_id: pub_id, profile_address: profile_address, collect_nft: account_address, @@ -639,16 +607,8 @@ pub mod PublicationComponent { // Update the publication with the deployed Collect NFT address let updated_publication = Publication { pointed_profile_address: publication.pointed_profile_address, - pointed_pub_id: publication.pointed_pub_id, - content_URI: publication.content_URI, - pub_Type: publication.pub_Type, - root_profile_address: publication.root_profile_address, - root_pub_id: publication.root_pub_id, - upvote: publication.upvote, - downvote: publication.downvote, - channel_id: publication.channel_id, collect_nft: deployed_collect_nft_address, - tipped_amount: publication.tipped_amount + ..publication }; // Write the updated publication with the new Collect NFT address