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
use super::entry::FaucetAsset;
use cosmwasm_std::Addr;
use shared::prelude::*;

pub struct TapEvent {
    pub recipient: Addr,
    pub amount: Number,
    pub asset: FaucetAsset,
}

impl From<TapEvent> for cosmwasm_std::Event {
    fn from(src: TapEvent) -> Self {
        let evt = cosmwasm_std::Event::new("faucet-tap").add_attributes(vec![
            ("recipient", src.recipient.to_string()),
            ("amount", src.amount.to_string()),
        ]);

        match src.asset {
            FaucetAsset::Cw20(addr) => {
                evt.add_attributes(vec![("asset-kind", "cw20"), ("asset-addr", addr.as_str())])
            }
            FaucetAsset::Native(denom) => {
                evt.add_attributes(vec![("asset-kind", "native"), ("asset-denom", &denom)])
            }
        }
    }
}