levana_perpswap_cosmos/contracts/tracker/
events.rs1use cosmwasm_std::Event;
2
3pub struct NewTracker {
4 pub admin: String,
5}
6
7impl From<NewTracker> for Event {
8 fn from(NewTracker { admin }: NewTracker) -> Self {
9 Event::new("levana-new-tracker").add_attribute("admin", admin)
10 }
11}
12
13pub struct NewCodeIdEvent {
14 pub contract_type: String,
15 pub code_id: u64,
16 pub hash: String,
17}
18
19impl From<NewCodeIdEvent> for Event {
20 fn from(
21 NewCodeIdEvent {
22 contract_type,
23 code_id,
24 hash,
25 }: NewCodeIdEvent,
26 ) -> Self {
27 Event::new("levana-new-code-id")
28 .add_attribute("contract-type", contract_type)
29 .add_attribute("code-id", code_id.to_string())
30 .add_attribute("hash", hash)
31 }
32}
33
34pub struct InstantiateEvent {
35 pub contract_type: String,
36 pub code_id: u64,
37 pub hash: String,
38 pub address: String,
39 pub family: String,
40 pub sequence: u32,
41}
42
43impl From<InstantiateEvent> for Event {
44 fn from(
45 InstantiateEvent {
46 contract_type,
47 code_id,
48 hash,
49 address,
50 family,
51 sequence,
52 }: InstantiateEvent,
53 ) -> Self {
54 Event::new("levana-instantiate-event")
55 .add_attribute("contract-type", contract_type)
56 .add_attribute("code-id", code_id.to_string())
57 .add_attribute("hash", hash)
58 .add_attribute("address", address)
59 .add_attribute("family", family)
60 .add_attribute("sequence", sequence.to_string())
61 }
62}
63
64pub struct MigrateEvent {
65 pub contract_type: String,
66 pub old_code_id: u64,
67 pub new_code_id: u64,
68 pub old_hash: String,
69 pub new_hash: String,
70 pub address: String,
71 pub family: String,
72 pub sequence: u32,
73 pub new_migrate_count: u32,
74}
75
76impl From<MigrateEvent> for Event {
77 fn from(
78 MigrateEvent {
79 contract_type,
80 old_code_id: prev_code_id,
81 new_code_id,
82 old_hash,
83 new_hash,
84 address,
85 family,
86 sequence,
87 new_migrate_count,
88 }: MigrateEvent,
89 ) -> Self {
90 Event::new("levana-migrate-event")
91 .add_attribute("contract-type", contract_type)
92 .add_attribute("old-code-id", prev_code_id.to_string())
93 .add_attribute("new-code-id", new_code_id.to_string())
94 .add_attribute("old-hash", old_hash)
95 .add_attribute("new-hash", new_hash)
96 .add_attribute("address", address)
97 .add_attribute("family", family)
98 .add_attribute("sequence", sequence.to_string())
99 .add_attribute("new-migrate-count", new_migrate_count.to_string())
100 }
101}