soroban_token_sdk/
event.rs1use soroban_sdk::{symbol_short, Address, Env, Symbol};
2
3pub struct Events {
4 env: Env,
5}
6
7#[allow(deprecated)]
8impl Events {
9 #[inline(always)]
10 pub fn new(env: &Env) -> Events {
11 Events { env: env.clone() }
12 }
13
14 #[deprecated = "use soroban_token_sdk::events::Approve::publish"]
15 pub fn approve(&self, from: Address, to: Address, amount: i128, expiration_ledger: u32) {
16 let topics = (Symbol::new(&self.env, "approve"), from, to);
17 self.env
18 .events()
19 .publish(topics, (amount, expiration_ledger));
20 }
21
22 #[deprecated = "use soroban_token_sdk::events::Transfer::publish"]
23 pub fn transfer(&self, from: Address, to: Address, amount: i128) {
24 let topics = (symbol_short!("transfer"), from, to);
25 self.env.events().publish(topics, amount);
26 }
27
28 #[deprecated = "use soroban_token_sdk::events::Mint::publish"]
29 pub fn mint(&self, admin: Address, to: Address, amount: i128) {
30 let topics = (symbol_short!("mint"), admin, to);
31 self.env.events().publish(topics, amount);
32 }
33
34 #[deprecated = "use soroban_token_sdk::events::Clawback::publish"]
35 pub fn clawback(&self, admin: Address, from: Address, amount: i128) {
36 let topics = (symbol_short!("clawback"), admin, from);
37 self.env.events().publish(topics, amount);
38 }
39
40 #[deprecated = "define a contractevent instead:\n\
41 #[contractevent(data_format = \"single-value\")]\n\
42 pub struct SetAuthorized {\n\
43 #[topic]\n\
44 admin: Address,\n\
45 #[topic]\n\
46 id: Address,\n\
47 authorize: bool,\n\
48 }"]
49 pub fn set_authorized(&self, admin: Address, id: Address, authorize: bool) {
50 let topics = (Symbol::new(&self.env, "set_authorized"), admin, id);
51 self.env.events().publish(topics, authorize);
52 }
53
54 #[deprecated = "define a contractevent instead:\n\
55 #[contractevent(data_format = \"single-value\")]\n\
56 pub struct SetAdmin {\n\
57 #[topic]\n\
58 admin: Address,\n\
59 new_admin: Address,\n\
60 }"]
61 pub fn set_admin(&self, admin: Address, new_admin: Address) {
62 let topics = (symbol_short!("set_admin"), admin);
63 self.env.events().publish(topics, new_admin);
64 }
65
66 #[deprecated = "use soroban_token_sdk::events::Burn::publish"]
67 pub fn burn(&self, from: Address, amount: i128) {
68 let topics = (symbol_short!("burn"), from);
69 self.env.events().publish(topics, amount);
70 }
71}