Skip to content

Commit

Permalink
ft: add template for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
Adegbite Ademola Kelvin authored and Adegbite Ademola Kelvin committed Jun 3, 2024
1 parent 6c854e3 commit 24d9721
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
32 changes: 31 additions & 1 deletion src/base/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,40 @@ 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.
// */
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
34 changes: 25 additions & 9 deletions src/publication/publication.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! 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
Expand All @@ -22,10 +22,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 +30,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 Down Expand Up @@ -149,6 +149,22 @@ 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
}

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

0 comments on commit 24d9721

Please sign in to comment.