Skip to content

Commit 118bfcb

Browse files
authored
Merge pull request #233 from wayzeek/fix-214-missing-events-incomplete-event-coverage
Add missing events for admin functions and pool operations
2 parents ac3f9c9 + da3c3f2 commit 118bfcb

File tree

8 files changed

+493
-28
lines changed

8 files changed

+493
-28
lines changed

src/base/events.cairo

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ pub mod Events {
1515
#[derive(Drop, starknet::Event)]
1616
pub struct BetPlaced {
1717
/// @notice The pool ID.
18+
#[key]
1819
pub pool_id: u256,
1920
/// @notice The address of the user who placed the bet.
21+
#[key]
2022
pub address: ContractAddress,
2123
/// @notice The option selected by the user.
2224
pub option: felt252,
@@ -32,7 +34,9 @@ pub mod Events {
3234
/// @param amount Amount of tokens staked
3335
#[derive(Drop, starknet::Event)]
3436
pub struct UserStaked {
37+
#[key]
3538
pub pool_id: u256,
39+
#[key]
3640
pub address: ContractAddress,
3741
pub amount: u256,
3842
}
@@ -68,6 +72,7 @@ pub mod Events {
6872
/// @param timestamp Time of the state transition
6973
#[derive(Drop, starknet::Event)]
7074
pub struct PoolStateTransition {
75+
#[key]
7176
pub pool_id: u256,
7277
pub previous_status: Status,
7378
pub new_status: Status,
@@ -82,6 +87,7 @@ pub mod Events {
8287
/// @param min_bet_amount Minimum bet requirement
8388
#[derive(Drop, starknet::Event)]
8489
pub struct PoolResolved {
90+
#[key]
8591
pub pool_id: u256,
8692
pub winning_option: bool,
8793
pub total_payout: u256,
@@ -116,7 +122,9 @@ pub mod Events {
116122
/// @param caller Address of the admin who performed the addition
117123
#[derive(Drop, starknet::Event)]
118124
pub struct ValidatorAdded {
125+
#[key]
119126
pub account: ContractAddress,
127+
#[key]
120128
pub caller: ContractAddress,
121129
}
122130

@@ -125,7 +133,9 @@ pub mod Events {
125133
/// @param caller Address of the admin who performed the removal
126134
#[derive(Drop, starknet::Event)]
127135
pub struct ValidatorRemoved {
136+
#[key]
128137
pub account: ContractAddress,
138+
#[key]
129139
pub caller: ContractAddress,
130140
}
131141

@@ -135,7 +145,9 @@ pub mod Events {
135145
/// @param timestamp Time of dispute initiation
136146
#[derive(Drop, starknet::Event)]
137147
pub struct DisputeRaised {
148+
#[key]
138149
pub pool_id: u256,
150+
#[key]
139151
pub user: ContractAddress,
140152
pub timestamp: u64,
141153
}
@@ -258,4 +270,101 @@ pub mod Events {
258270
pub admin: ContractAddress,
259271
pub timestamp: u64,
260272
}
273+
274+
// Configuration Events
275+
276+
/// @notice Emitted when the required validator confirmations count is updated.
277+
#[derive(Drop, starknet::Event)]
278+
pub struct ValidatorConfirmationsUpdated {
279+
pub previous_count: u256,
280+
pub new_count: u256,
281+
#[key]
282+
pub admin: ContractAddress,
283+
pub timestamp: u64,
284+
}
285+
286+
/// @notice Emitted when the dispute threshold is updated.
287+
#[derive(Drop, starknet::Event)]
288+
pub struct DisputeThresholdUpdated {
289+
pub previous_threshold: u256,
290+
pub new_threshold: u256,
291+
pub admin: ContractAddress,
292+
pub timestamp: u64,
293+
}
294+
295+
// Pool Lifecycle Events
296+
297+
/// @notice Emitted when a new pool is created.
298+
#[derive(Drop, starknet::Event)]
299+
pub struct PoolCreated {
300+
#[key]
301+
pub pool_id: u256,
302+
#[key]
303+
pub creator: ContractAddress,
304+
pub pool_name: felt252,
305+
#[key]
306+
pub category: felt252,
307+
pub end_time: u64,
308+
pub min_bet_amount: u256,
309+
pub max_bet_amount: u256,
310+
pub creator_fee: u8,
311+
pub timestamp: u64,
312+
}
313+
314+
// Contract Management Events
315+
316+
/// @notice Emitted when the contract is paused.
317+
#[derive(Drop, starknet::Event)]
318+
pub struct ContractPaused {
319+
#[key]
320+
pub admin: ContractAddress,
321+
pub timestamp: u64,
322+
}
323+
324+
/// @notice Emitted when the contract is unpaused.
325+
#[derive(Drop, starknet::Event)]
326+
pub struct ContractUnpaused {
327+
#[key]
328+
pub admin: ContractAddress,
329+
pub timestamp: u64,
330+
}
331+
332+
333+
// Fee Collection Events
334+
335+
/// @notice Emitted when protocol fees are collected.
336+
#[derive(Drop, starknet::Event)]
337+
pub struct ProtocolFeesCollected {
338+
pub pool_id: u256,
339+
pub amount: u256,
340+
pub recipient: ContractAddress,
341+
pub timestamp: u64,
342+
}
343+
344+
/// @notice Emitted when creator fees are collected.
345+
#[derive(Drop, starknet::Event)]
346+
pub struct CreatorFeesCollected {
347+
pub pool_id: u256,
348+
pub creator: ContractAddress,
349+
pub amount: u256,
350+
pub timestamp: u64,
351+
}
352+
353+
/// @notice Emitted when validator fees are distributed.
354+
#[derive(Drop, starknet::Event)]
355+
pub struct ValidatorFeesDistributed {
356+
pub pool_id: u256,
357+
pub total_amount: u256,
358+
pub validator_count: u256,
359+
pub timestamp: u64,
360+
}
361+
362+
/// @notice Emitted when pool creation fee is collected.
363+
#[derive(Drop, starknet::Event)]
364+
pub struct PoolCreationFeeCollected {
365+
pub pool_id: u256,
366+
pub creator: ContractAddress,
367+
pub amount: u256,
368+
pub timestamp: u64,
369+
}
261370
}

src/interfaces/ipredifi.cairo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ pub trait IPredifi<TContractState> {
119119
/// @notice Collects the pool creation fee from the creator.
120120
/// @dev Transfers 1 STRK from creator to contract.
121121
/// @param creator The creator's address.
122-
fn collect_pool_creation_fee(ref self: TContractState, creator: ContractAddress);
122+
/// @param pool_id The pool ID for which the fee is being collected.
123+
fn collect_pool_creation_fee(ref self: TContractState, creator: ContractAddress, pool_id: u256);
123124

124125
/// @notice Manually updates the state of a pool.
125126
/// @dev Only callable by admin or validator. Enforces valid state transitions.

0 commit comments

Comments
 (0)