1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use cosmwasm_std::{Response, Uint128};
use cw0::Event;
pub struct TransferEvent<'a> {
pub from: Option<&'a str>,
pub to: Option<&'a str>,
pub token_id: &'a str,
pub amount: Uint128,
}
impl<'a> Event for TransferEvent<'a> {
fn add_attributes(&self, rsp: &mut Response) {
rsp.add_attribute("action", "transfer");
rsp.add_attribute("token_id", self.token_id);
rsp.add_attribute("amount", self.amount);
if let Some(from) = self.from {
rsp.add_attribute("from", from.to_string());
}
if let Some(to) = self.to {
rsp.add_attribute("to", to.to_string());
}
}
}
pub struct MetadataEvent<'a> {
pub url: &'a str,
pub token_id: &'a str,
}
impl<'a> Event for MetadataEvent<'a> {
fn add_attributes(&self, rsp: &mut Response) {
rsp.add_attribute("action", "set_metadata");
rsp.add_attribute("url", self.url);
rsp.add_attribute("token_id", self.token_id);
}
}
pub struct ApproveAllEvent<'a> {
pub sender: &'a str,
pub operator: &'a str,
pub approved: bool,
}
impl<'a> Event for ApproveAllEvent<'a> {
fn add_attributes(&self, rsp: &mut Response) {
rsp.add_attribute("action", "approve_all");
rsp.add_attribute("sender", self.sender.to_string());
rsp.add_attribute("operator", self.operator.to_string());
rsp.add_attribute("approved", (self.approved as u32).to_string());
}
}