From 24d97212e00c9d72d111a24a68bdb0d919dc6622 Mon Sep 17 00:00:00 2001 From: Adegbite Ademola Kelvin Date: Mon, 3 Jun 2024 02:01:37 +0100 Subject: [PATCH 1/3] ft: add template for publication --- src/base/types.cairo | 32 ++++++++++++++++++++++++++++- src/profile/profile.cairo | 2 +- src/publication/publication.cairo | 34 +++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/base/types.cairo b/src/base/types.cairo index f714171..53fb3a1 100644 --- a/src/base/types.cairo +++ b/src/base/types.cairo @@ -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 +} diff --git a/src/profile/profile.cairo b/src/profile/profile.cairo index 0faad7f..4d2e149 100644 --- a/src/profile/profile.cairo +++ b/src/profile/profile.cairo @@ -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 { diff --git a/src/publication/publication.cairo b/src/publication/publication.cairo index a0aac6e..5713eb7 100644 --- a/src/publication/publication.cairo +++ b/src/publication/publication.cairo @@ -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 @@ -22,10 +22,6 @@ pub trait IKarstPublications { 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, @@ -34,12 +30,16 @@ pub trait IKarstPublications { 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] @@ -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 { From 9f035188e2f9eab09d658cf08a5cf9cd67c3eb76 Mon Sep 17 00:00:00 2001 From: Adegbite Ademola Kelvin Date: Mon, 3 Jun 2024 02:06:25 +0100 Subject: [PATCH 2/3] fix: add imports --- src/base/types.cairo | 3 ++- src/publication/publication.cairo | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/base/types.cairo b/src/base/types.cairo index 53fb3a1..d142524 100644 --- a/src/base/types.cairo +++ b/src/base/types.cairo @@ -132,7 +132,8 @@ pub struct MirrorParams { // * @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 { +#[derive(Drop, Serde, starknet::Store)] +pub struct QuoteParams { profile_address: ContractAddress, content_URI: ByteArray, pointed_profile_address: ContractAddress, diff --git a/src/publication/publication.cairo b/src/publication/publication.cairo index 5713eb7..4bf7d71 100644 --- a/src/publication/publication.cairo +++ b/src/publication/publication.cairo @@ -2,7 +2,7 @@ // [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; @@ -49,7 +49,7 @@ 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}; @@ -157,10 +157,14 @@ pub mod Publications { // * // * @return uint256 The created publication's pubId. // */ - fn mirror(ref self: ContractState, mirrorParams: MirrorParams) -> u256 { // logic here + fn mirror(ref self: ContractState, mirrorParams: MirrorParams) -> u256 { + // logic here + 0 } - fn quote(ref self: ContractState, quoteParams: QuoteParams) -> u256 { // logic here + fn quote(ref self: ContractState, quoteParams: QuoteParams) -> u256 { + // logic here + 0 } ////////////////////////////////////////////////////////////// /// GETTERS////////////////////////////////////////////////// From 80e85db54f8d3eace9467b3ad2e8aa0a17382aca Mon Sep 17 00:00:00 2001 From: Adegbite Ademola Kelvin Date: Mon, 3 Jun 2024 02:07:58 +0100 Subject: [PATCH 3/3] fix: format code --- src/publication/publication.cairo | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/publication/publication.cairo b/src/publication/publication.cairo index 4bf7d71..e9d766e 100644 --- a/src/publication/publication.cairo +++ b/src/publication/publication.cairo @@ -2,7 +2,8 @@ // [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,MirrorParams, QuoteParams + PostParams, PublicationType, CommentParams, ReferencePubParams, Publication, MirrorParams, + QuoteParams }; use karst::interfaces::IProfile::{IKarstProfileDispatcher, IKarstProfileDispatcherTrait}; use core::option::OptionTrait; @@ -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,QuoteParams,MirrorParams + PostParams, Publication, PublicationType, ReferencePubParams, CommentParams, QuoteParams, + MirrorParams }; use super::IKarstPublications; use karst::interfaces::IProfile::{IKarstProfileDispatcher, IKarstProfileDispatcherTrait}; @@ -157,12 +159,12 @@ pub mod Publications { // * // * @return uint256 The created publication's pubId. // */ - fn mirror(ref self: ContractState, mirrorParams: MirrorParams) -> u256 { + fn mirror(ref self: ContractState, mirrorParams: MirrorParams) -> u256 { // logic here 0 } - fn quote(ref self: ContractState, quoteParams: QuoteParams) -> u256 { + fn quote(ref self: ContractState, quoteParams: QuoteParams) -> u256 { // logic here 0 }