Created
October 14, 2022 09:05
-
-
Save zmovane/158a2180ee9c59a0176df48736cb0d45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module _1200_dollars_per_hour::my_module { | |
use _1200_dollars_per_hour::events::{Self, ListEvent, BuyEvent }; | |
public entry fun list() { | |
// ... | |
events::emit_list_event(0); | |
} | |
public entry fun buy() { | |
// ... | |
events::emit_buy_event(0); | |
} | |
} | |
module _1200_dollars_per_hour::events{ | |
friend _1200_dollars_per_hour::my_module; | |
use aptos_framework::event::{ Self, EventHandle }; | |
struct Events has key { | |
list_events: EventHandle<ListEvent>, | |
buy_events: EventHandle<BuyEvent>, | |
} | |
struct ListEvent has store, drop { | |
id: u64 | |
} | |
struct BuyEvent has store, drop { | |
id: u64 | |
} | |
public(friend) fun emit_list_event(id: u64) acquires Events { | |
let events = borrow_global_mut<Events>(@_1200_dollars_per_hour); | |
event::emit_event<ListEvent>(&mut events.list_events, ListEvent{ id }); | |
} | |
public(friend) fun emit_buy_event(id: u64) acquires Events { | |
let events = borrow_global_mut<Events>(@_1200_dollars_per_hour); | |
event::emit_event<BuyEvent>(&mut events.buy_events, BuyEvent{ id }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment