diff --git a/contracts/raffle/src/events.rs b/contracts/raffle/src/events.rs index 98184e7..e7b89f9 100644 --- a/contracts/raffle/src/events.rs +++ b/contracts/raffle/src/events.rs @@ -7,7 +7,7 @@ use crate::AdminOp; // LIFECYCLE EVENTS // ============================================================================ -/// Emitted when a new raffle is initialized +/// Emitted when a new raffle instance is initialized #[derive(Clone)] #[contracttype] pub struct RaffleCreated { @@ -51,6 +51,7 @@ pub struct TicketPurchased { pub buyer: Address, pub ticket_ids: Vec, pub quantity: u32, + pub ticket_price: i128, pub total_paid: i128, pub timestamp: u64, } @@ -119,6 +120,7 @@ pub struct RaffleCancelled { pub creator: Address, pub reason: CancelReason, pub tickets_sold: u32, + pub prize_refunded: bool, pub timestamp: u64, } @@ -127,7 +129,7 @@ pub struct RaffleCancelled { #[contracttype] pub struct TicketRefunded { pub buyer: Address, - pub ticket_id: u32, + pub ticket_number: u32, pub amount: i128, pub timestamp: u64, } @@ -148,6 +150,7 @@ pub struct CreatorVerified { pub struct PrizeClaimed { pub winner: Address, pub tier_index: u32, + pub payment_token: Address, pub gross_amount: i128, pub net_amount: i128, pub platform_fee: i128, @@ -159,6 +162,7 @@ pub struct PrizeClaimed { #[contracttype] pub struct BuybackAndBurnExecuted { pub router: Address, + pub payment_token: Address, pub tikka_token: Address, pub amount_in: i128, pub amount_out: i128, @@ -210,7 +214,7 @@ pub struct TreasuryUpdated { pub timestamp: u64, } -/// Emitted when accumulated fees are withdrawn +/// Emitted when accumulated fees are withdrawn to the treasury #[derive(Clone)] #[contracttype] pub struct FeesWithdrawn { @@ -313,11 +317,44 @@ pub struct AdminOpCancelled { pub cancelled_at: u64, } +// ============================================================================ +// FACTORY EVENTS +// ============================================================================ + +/// Emitted when the factory is initialized +#[derive(Clone)] +#[contracttype] +pub struct FactoryInitialized { + pub admin: Address, + pub protocol_fee_bp: u32, + pub treasury: Address, + pub timestamp: u64, +} + +/// Emitted when a new raffle instance is deployed by the factory +#[derive(Clone)] +#[contracttype] +pub struct RaffleDeployed { + pub raffle_address: Address, + pub creator: Address, + pub timestamp: u64, +} + +/// Emitted when the factory protocol fee or treasury is updated via set_config +#[derive(Clone)] +#[contracttype] +pub struct FactoryConfigUpdated { + pub protocol_fee_bp: u32, + pub treasury: Address, + pub updated_by: Address, + pub timestamp: u64, +} + // ============================================================================ // INTERNAL STATE CHANGE EVENT // ============================================================================ -/// Emitted when raffle status changes +/// Emitted on every raffle status transition #[derive(Clone)] #[contracttype] pub struct RaffleStatusChanged { diff --git a/contracts/raffle/src/instance/mod.rs b/contracts/raffle/src/instance/mod.rs index aa0b3d1..a025448 100644 --- a/contracts/raffle/src/instance/mod.rs +++ b/contracts/raffle/src/instance/mod.rs @@ -1536,6 +1536,7 @@ impl Contract { "buyback_and_burn_executed", crate::events::BuybackAndBurnExecuted { router: contract_address.clone(), + payment_token: raffle.payment_token.clone(), tikka_token: tikka.clone(), amount_in: platform_fee, amount_out: platform_fee, @@ -1560,6 +1561,7 @@ impl Contract { PrizeClaimed { winner: winner.clone(), tier_index, + payment_token: raffle.payment_token.clone(), gross_amount: tier_prize_amount, net_amount, platform_fee, @@ -1672,9 +1674,9 @@ impl Contract { publish_event( &env, "ticket_refunded", - crate::events::TicketRefunded { + TicketRefunded { buyer: ticket.owner.clone(), - ticket_id, + ticket_number: ticket_id, amount: raffle.ticket_price, timestamp: env.ledger().timestamp(), }, diff --git a/contracts/raffle/src/lib.rs b/contracts/raffle/src/lib.rs index e088e5e..3437399 100644 --- a/contracts/raffle/src/lib.rs +++ b/contracts/raffle/src/lib.rs @@ -208,6 +208,18 @@ impl RaffleFactory { env.storage() .persistent() .set(&DataKey::Treasury, &treasury); + + publish_factory_event( + &env, + "factory_initialized", + events::FactoryInitialized { + admin, + protocol_fee_bp, + treasury, + timestamp: env.ledger().timestamp(), + }, + ); + Ok(()) }