hvym_file_token/
event.rs

1use soroban_sdk::{symbol_short, Address, Env, Symbol};
2
3pub struct Events {
4    env: Env,
5}
6
7impl Events {
8    #[inline(always)]
9    pub fn new(env: &Env) -> Events {
10        Events { env: env.clone() }
11    }
12
13    pub fn approve(&self, from: Address, to: Address, amount: i128, expiration_ledger: u32) {
14        let topics = (Symbol::new(&self.env, "approve"), from, to);
15        self.env
16            .events()
17            .publish(topics, (amount, expiration_ledger));
18    }
19
20    pub fn transfer(&self, from: Address, to: Address, amount: i128) {
21        let topics = (symbol_short!("transfer"), from, to);
22        self.env.events().publish(topics, amount);
23    }
24
25    pub fn mint(&self, admin: Address, to: Address, amount: i128) {
26        let topics = (symbol_short!("mint"), admin, to);
27        self.env.events().publish(topics, amount);
28    }
29
30    pub fn clawback(&self, admin: Address, from: Address, amount: i128) {
31        let topics = (symbol_short!("clawback"), admin, from);
32        self.env.events().publish(topics, amount);
33    }
34
35    pub fn set_authorized(&self, admin: Address, id: Address, authorize: bool) {
36        let topics = (Symbol::new(&self.env, "set_authorized"), admin, id);
37        self.env.events().publish(topics, authorize);
38    }
39
40    pub fn set_admin(&self, admin: Address, new_admin: Address) {
41        let topics = (symbol_short!("set_admin"), admin);
42        self.env.events().publish(topics, new_admin);
43    }
44
45    pub fn burn(&self, from: Address, amount: i128) {
46        let topics = (symbol_short!("burn"), from);
47        self.env.events().publish(topics, amount);
48    }
49}