Skip to content

Commit

Permalink
emit events from timelock as well
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Nov 7, 2023
1 parent dc417d4 commit f74c3ec
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/timelock.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ mod Timelock {
use traits::{Into};
use zeroable::{Zeroable};

#[derive(starknet::Event, Drop)]
struct Queued {
id: felt252,
calls: Span<Call>,
}

#[derive(starknet::Event, Drop)]
struct Canceled {
id: felt252,
}

#[derive(starknet::Event, Drop)]
struct Executed {
id: felt252,
}

#[derive(starknet::Event, Drop)]
#[event]
enum Event {
Queued: Queued,
Canceled: Canceled,
Executed: Executed,
}

#[storage]
struct Storage {
Expand Down Expand Up @@ -94,6 +117,9 @@ mod Timelock {
assert(self.execution_started.read(id).is_zero(), 'ALREADY_QUEUED');

self.execution_started.write(id, get_block_timestamp());

self.emit(Queued { id, calls, });

id
}

Expand All @@ -103,6 +129,8 @@ mod Timelock {
assert(self.executed.read(id).is_zero(), 'ALREADY_EXECUTED');

self.execution_started.write(id, 0);

self.emit(Canceled { id, });
}

fn execute(ref self: ContractState, mut calls: Span<Call>) -> Array<Span<felt252>> {
Expand All @@ -127,6 +155,8 @@ mod Timelock {
};
};

self.emit(Executed { id, });

results
}

Expand Down

0 comments on commit f74c3ec

Please sign in to comment.