Skip to content

Commit

Permalink
refactor: updated events syntax in factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Orlando committed Aug 24, 2023
1 parent f90385c commit 75d7222
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions starknet/src/factory/factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use starknet::ClassHash;
#[starknet::interface]
trait IFactory<TContractState> {
fn deploy(
self: @TContractState,
ref self: TContractState,
class_hash: ClassHash,
contract_address_salt: felt252,
initialize_calldata: Span<felt252>
Expand All @@ -24,15 +24,24 @@ mod Factory {
use sx::utils::constants::INITIALIZE_SELECTOR;

#[event]
fn SpaceDeployed(class_hash: ClassHash, space_address: ContractAddress) {}
#[derive(Drop, starknet::Event)]
enum Event {
SpaceDeployed: SpaceDeployed
}

#[derive(Drop, starknet::Event)]
struct SpaceDeployed {
class_hash: ClassHash,
space_address: ContractAddress
}

#[storage]
struct Storage {}

#[external(v0)]
impl Factory of IFactory<ContractState> {
fn deploy(
self: @ContractState,
ref self: ContractState,
class_hash: ClassHash,
contract_address_salt: felt252,
initialize_calldata: Span<felt252>
Expand All @@ -46,7 +55,7 @@ mod Factory {
call_contract_syscall(space_address, INITIALIZE_SELECTOR, initialize_calldata)
.unwrap_syscall();

SpaceDeployed(class_hash, space_address);
self.emit(Event::SpaceDeployed(SpaceDeployed { class_hash, space_address }));

space_address
}
Expand Down

0 comments on commit 75d7222

Please sign in to comment.