Skip to content

Commit

Permalink
Merge branch 'web3wagers:dev' into withdraw-event
Browse files Browse the repository at this point in the history
  • Loading branch information
MPSxDev authored Oct 25, 2024
2 parents e1d22ec + 40ff525 commit 213f06e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
25 changes: 23 additions & 2 deletions contracts/src/donatorManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ mod DonatorManager {
self.donator_class_hash.write(donator_class_hash.try_into().unwrap());
}

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

#[derive(Drop, starknet::Event)]
struct DonatorContractDeployed {
new_donator: ContractAddress,
owner: ContractAddress
}

// *************************************************************************
// EXTERNALS
// *************************************************************************
Expand All @@ -49,11 +64,17 @@ mod DonatorManager {
let mut calldata = ArrayTrait::<felt252>::new();
calldata.append(get_caller_address().try_into().unwrap());

let (address_0, _) = deploy_syscall(
let (new_donator_address, _) = deploy_syscall(
self.donator_class_hash.read(), 12345, calldata.span(), false
)
.unwrap();
self.donators.write(get_caller_address().try_into().unwrap(), address_0);
self.donators.write(get_caller_address().try_into().unwrap(), new_donator_address);
self
.emit(
DonatorContractDeployed {
owner: get_caller_address(), new_donator: new_donator_address
}
)
}
fn getOwner(self: @ContractState) -> ContractAddress {
return self.owner.read();
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ mod FundManager {
Serde::serialize(@get_caller_address(), ref call_data);
Serde::serialize(@name, ref call_data);
Serde::serialize(@goal, ref call_data);
let (address_0, _) = deploy_syscall(
let (new_fund_address, _) = deploy_syscall(
self.fund_class_hash.read(), 12345, call_data.span(), false
)
.unwrap();
self.funds.write(self.current_id.read(), address_0);
self.funds.write(self.current_id.read(), new_fund_address);
self.current_id.write(self.current_id.read() + 1);
}
fn getCurrentId(self: @ContractState) -> u128 {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ fn test_new_fund() {
let expected_fund_class_hash = get_class_hash(fund_manager_contract.getFund(1));
let current_id = fund_manager_contract.getCurrentId();
assert(expected_fund_class_hash == fund_class_hash, 'Invalid fund address');
assert(current_id == 2 , 'Invalid current ID');
assert(current_id == 2, 'Invalid current ID');
}

0 comments on commit 213f06e

Please sign in to comment.