Skip to content
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
18 changes: 18 additions & 0 deletions contracts/geev-core/src/giveaway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ pub struct GiveawayWinnerSelected {
prize_amount: i128,
}

/// Emitted when a winner successfully claims their prize (`claim_prize`). Topics are
/// fixed `giveaway`, `claimed`, plus the winner address; data is
/// `[giveaway_id, net_amount]` as a Vec for downstream indexing.
#[contractevent(topics = ["giveaway", "claimed"], data_format = "vec")]
pub struct GiveawayPrizeClaimed {
#[topic]
winner: Address,
giveaway_id: u64,
net_amount: i128,
}

#[allow(clippy::too_many_arguments)]
#[contractimpl]
impl GiveawayContract {
Expand Down Expand Up @@ -404,6 +415,13 @@ impl GiveawayContract {
token_client.transfer(&env.current_contract_address(), &winner, &net_amount);
Self::add_collected_fees(&env, &giveaway.token, fee_amount);

GiveawayPrizeClaimed {
winner: winner.clone(),
giveaway_id,
net_amount,
}
.publish(&env);

env.storage().persistent().set(&claimed_key, &true);
giveaway.claimed_count += 1;

Expand Down
Loading
Loading