Skip to content

Commit

Permalink
Merge pull request #161 from NueloSE/donation-event
Browse files Browse the repository at this point in the history
feat: add emit event to receiveDonation function
  • Loading branch information
EmmanuelAR authored Oct 26, 2024
2 parents 1083b6c + 964db5d commit 6a16df5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ mod Fund {
#[derive(Drop, starknet::Event)]
enum Event {
DonationWithdraw: DonationWithdraw,
NewVoteReceived: NewVoteReceived
NewVoteReceived: NewVoteReceived,
DonationReceived: DonationReceived,
}

#[derive(Drop, starknet::Event)]
Expand All @@ -61,6 +62,15 @@ mod Fund {
pub fund: ContractAddress,
pub votes: u32
}

#[derive(Drop, starknet::Event)]
pub struct DonationReceived {
#[key]
pub donator_address: ContractAddress,
pub current_balance: u256,
pub donated_strks: u256,
pub fund_contract_address: ContractAddress,
}
// *************************************************************************
// STORAGE
// *************************************************************************
Expand Down Expand Up @@ -165,6 +175,17 @@ mod Fund {
if self.current_goal_state.read() >= self.goal.read() {
self.state.write(FundStates::CLOSED);
}

// Emit receiveDonation event
self
.emit(
DonationReceived {
current_balance: self.current_goal_state.read(),
donated_strks: strks,
donator_address: get_caller_address(),
fund_contract_address: get_contract_address(),
}
)
}
fn getCurrentGoalState(self: @ContractState) -> u256 {
return self.current_goal_state.read();
Expand Down

0 comments on commit 6a16df5

Please sign in to comment.