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] Emit event when fund contract is deployed #136 #158

Merged
Changes from 2 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
32 changes: 31 additions & 1 deletion contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,29 @@ mod FundManager {
self.current_id.write(1);
}


// ***************************************************************************************
// EVENTS
// ***************************************************************************************
#[event]
#[derive(Drop, starknet::Event)]
pub enum Event {
FundDeployed: FundDeployed,
}

#[derive(Drop, starknet::Event)]
pub struct FundDeployed {
#[key]
pub owner: ContractAddress,
pub fund_address: ContractAddress,
pub fund_id: u128,
}


// ***************************************************************************************
// EXTERNALS
// ***************************************************************************************

#[abi(embed_v0)]
impl FundManagerImpl of super::IFundManager<ContractState> {
fn newFund(ref self: ContractState, name: felt252, goal: u256) {
Expand All @@ -60,7 +80,17 @@ mod FundManager {
self.fund_class_hash.read(), 12345, call_data.span(), false
)
.unwrap();
self.funds.write(self.current_id.read(), new_fund_address);

self.funds.write(self.current_id.read(), address_0);
Gianfranco99 marked this conversation as resolved.
Show resolved Hide resolved
self
.emit(
FundDeployed {
owner: get_caller_address(),
fund_address: address_0,
fund_id: self.current_id.read()
}
);

self.current_id.write(self.current_id.read() + 1);
}
fn getCurrentId(self: @ContractState) -> u128 {
Expand Down