Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ft: add template for publication #14

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/base/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,41 @@ struct CommentParams {


#[derive(Drop, Serde, starknet::Store)]
struct ReferencePubParams {
pub struct ReferencePubParams {
profile_address: ContractAddress,
content_URI: ByteArray,
pointed_profile_address: ContractAddress,
pointed_pub_id: u256
}

// /**
// * @notice A struct containing the parameters required for the `mirror()` function.
// *
// * @param profile_address The address of the profile to publish to.
// * @param metadata_URI the URI containing metadata attributes to attach to this mirror publication.
// * @param pointed_profile_id The profile address to point the mirror to.
// * @param pointed_pub_id The publication ID to point the mirror to.
// */
#[derive(Drop, Serde, starknet::Store)]
pub struct MirrorParams {
profile_address: ContractAddress,
metadata_URI: ByteArray,
pointed_profile_address: ContractAddress,
pointed_pub_id: u256
}

// /**
// * @notice A struct containing the parameters required for the `quote()` function.
// *
// * @param profile_address The address of the profile to publish to.
// * @param content_URI The URI to set for this new publication.
// * @param pointed_profile_address The profile address of the publication author that is quoted.
// * @param pointed_pub_id The publication ID that is quoted.
// */
#[derive(Drop, Serde, starknet::Store)]
pub struct QuoteParams {
profile_address: ContractAddress,
content_URI: ByteArray,
pointed_profile_address: ContractAddress,
pointed_pub_id: u256
}
2 changes: 1 addition & 1 deletion src/profile/profile.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod KarstProfile {

/// @notice increments user's publication count
/// @params profile_address the targeted profile address
/// how do we get the function? it acts an pub_count increase for all publication type.
/// how do we gate the function? it acts an pub_count increase for all publication type.
fn increment_publication_count(
ref self: ContractState, profile_address: ContractAddress
) -> u256 {
Expand Down
44 changes: 33 additions & 11 deletions src/publication/publication.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Contract for Karst Publications

//! Contract for Karst Publications V1
// [Len Publication Contract](https://github.com/lens-protocol/core/blob/master/contracts/libraries/PublicationLib.sol)
use starknet::{ContractAddress, get_caller_address};
use karst::base::types::{
PostParams, PublicationType, CommentParams, ReferencePubParams, Publication
PostParams, PublicationType, CommentParams, ReferencePubParams, Publication, MirrorParams,
QuoteParams
};
use karst::interfaces::IProfile::{IKarstProfileDispatcher, IKarstProfileDispatcherTrait};
use core::option::OptionTrait;
Expand All @@ -22,10 +23,6 @@ pub trait IKarstPublications<T> {
profile_address: ContractAddress,
profile_contract_address: ContractAddress
) -> u256;
fn get_publication(self: @T, user: ContractAddress, pubIdAssigned: u256) -> Publication;
fn get_publication_type(
self: @T, profile_address: ContractAddress, pub_id_assigned: u256
) -> PublicationType;
fn comment(
ref self: T,
profile_address: ContractAddress,
Expand All @@ -34,12 +31,16 @@ pub trait IKarstPublications<T> {
pointed_pub_id: u256,
profile_contract_address: ContractAddress,
) -> u256;
fn mirror(ref self: T, mirrorParams: MirrorParams) -> u256;
fn quote(ref self: T, quoteParams: QuoteParams) -> u256;
////// Getters//////
fn get_publication(self: @T, user: ContractAddress, pubIdAssigned: u256) -> Publication;
fn get_publication_type(
self: @T, profile_address: ContractAddress, pub_id_assigned: u256
) -> PublicationType;
fn get_publication_content_uri(
self: @T, profile_address: ContractAddress, pub_id: u256
) -> ByteArray;
// *************************************************************************
// PROFILE INTERACTION FUNCTIONS
// *************************************************************************
}

#[starknet::contract]
Expand All @@ -49,7 +50,8 @@ pub mod Publications {
// *************************************************************************
use starknet::{ContractAddress, get_contract_address, get_caller_address};
use karst::base::types::{
PostParams, Publication, PublicationType, ReferencePubParams, CommentParams
PostParams, Publication, PublicationType, ReferencePubParams, CommentParams, QuoteParams,
MirrorParams
};
use super::IKarstPublications;
use karst::interfaces::IProfile::{IKarstProfileDispatcher, IKarstProfileDispatcherTrait};
Expand Down Expand Up @@ -149,6 +151,26 @@ pub mod Publications {
);
pubIdAssigned
}

// /**
// * @notice Publishes a mirror to a given profile.
// *
// * @param mirrorParams the MirrorParams struct reference types.cairo to know MirrorParams.
// *
// * @return uint256 The created publication's pubId.
// */
fn mirror(ref self: ContractState, mirrorParams: MirrorParams) -> u256 {
// logic here
0
}

fn quote(ref self: ContractState, quoteParams: QuoteParams) -> u256 {
// logic here
0
}
//////////////////////////////////////////////////////////////
/// GETTERS//////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////
fn get_publication_content_uri(
self: @ContractState, profile_address: ContractAddress, pub_id: u256
) -> ByteArray {
Expand Down
Loading