Skip to content

Commit

Permalink
fix: event syntax (#517)
Browse files Browse the repository at this point in the history
* refactor: updated events syntax in space

* refactor: updated events syntax in factory

---------

Co-authored-by: Orlando <[email protected]>
Co-authored-by: Scott Piriou <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2023
1 parent 1174181 commit af2c1e6
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 111 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
Loading

0 comments on commit af2c1e6

Please sign in to comment.