Skip to content

Commit

Permalink
feat(quote): emit QuoteCtreated event
Browse files Browse the repository at this point in the history
  • Loading branch information
EjembiEmmanuel committed Jun 14, 2024
1 parent f458a85 commit 6f5de51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ 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.
// */
#[derive(Drop, Serde, starknet::Store)]
#[derive(Drop, Serde, starknet::Store, Clone)]
pub struct QuoteParams {
profile_address: ContractAddress,
content_URI: ByteArray,
Expand Down
25 changes: 23 additions & 2 deletions src/publication/publication.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub mod Publications {
pub enum Event {
Post: Post,
MirrorCreated: MirrorCreated,
QuoteCreated: QuoteCreated,
}

// *************************************************************************
Expand All @@ -101,6 +102,14 @@ pub mod Publications {
pub block_timestamp: u64,
}

#[derive(Drop, starknet::Event)]
pub struct QuoteCreated {
pub quoteParams: QuoteParams,
pub publication_id: u256,
pub transaction_executor: ContractAddress,
pub block_timestamp: u64,
}


// *************************************************************************
// EXTERNAL FUNCTIONS
Expand Down Expand Up @@ -217,7 +226,9 @@ pub mod Publications {
quoteParams: QuoteParams,
profile_contract_address: ContractAddress
) -> u256 {
let pubIdAssigned = self
let ref_quoteParams = quoteParams.clone();

let pub_id_assigned = self
._createReferencePublication(
quoteParams.profile_address,
quoteParams.content_URI,
Expand All @@ -226,7 +237,17 @@ pub mod Publications {
PublicationType::Quote,
profile_contract_address
);
pubIdAssigned

self
.emit(
QuoteCreated {
quoteParams: ref_quoteParams,
publication_id: pub_id_assigned,
transaction_executor: quoteParams.profile_address,
block_timestamp: get_block_timestamp(),
}
);
pub_id_assigned
}
// *************************************************************************
// GETTERS
Expand Down

0 comments on commit 6f5de51

Please sign in to comment.