Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add emit event to receiveDonation function #161

Merged
merged 6 commits into from
Oct 26, 2024
Merged
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
23 changes: 22 additions & 1 deletion contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ mod Fund {
#[derive(Drop, starknet::Event)]
enum Event {
DonationWithdraw: DonationWithdraw,
NewVoteReceived: NewVoteReceived
NewVoteReceived: NewVoteReceived,
DonationReceived: DonationReceived,
}

#[derive(Drop, starknet::Event)]
Expand All @@ -59,6 +60,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,
EmmanuelAR marked this conversation as resolved.
Show resolved Hide resolved
pub donated_strks: u256,
pub fund_contract_address: ContractAddress,
}
// *************************************************************************
// STORAGE
// *************************************************************************
Expand Down Expand Up @@ -163,6 +173,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
Loading