-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
3,352 additions
and
6,775 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,97 @@ | ||
use crate::state::Ask; | ||
use crate::{ | ||
orders::{Ask, CollectionOffer, Offer}, | ||
state::{AllowDenoms, Config}, | ||
}; | ||
|
||
use cosmwasm_std::Event; | ||
use cosmwasm_std::{attr, Addr, Event}; | ||
use std::vec; | ||
|
||
pub struct AskEvent<'a> { | ||
pub struct ConfigEvent<'a> { | ||
pub ty: &'a str, | ||
pub ask: &'a Ask, | ||
pub config: &'a Config<Addr>, | ||
} | ||
|
||
impl<'a> From<AskEvent<'a>> for Event { | ||
fn from(ae: AskEvent) -> Self { | ||
Event::new(ae.ty.to_string()).add_attributes(ae.ask.get_event_attrs(vec![ | ||
"collection", | ||
"token_id", | ||
"creator", | ||
"price", | ||
"asset_recipient", | ||
"finders_fee_bps", | ||
"expiration", | ||
"removal_reward", | ||
])) | ||
impl<'a> From<ConfigEvent<'a>> for Event { | ||
fn from(ce: ConfigEvent) -> Self { | ||
Event::new(ce.ty.to_string()).add_attributes(vec![ | ||
attr("fee_manager", ce.config.fee_manager.to_string()), | ||
attr("royalty_registry", ce.config.royalty_registry.to_string()), | ||
attr("protocol_fee_bps", ce.config.protocol_fee_bps.to_string()), | ||
attr( | ||
"max_royalty_fee_bps", | ||
ce.config.max_royalty_fee_bps.to_string(), | ||
), | ||
attr("maker_reward_bps", ce.config.maker_reward_bps.to_string()), | ||
attr("taker_reward_bps", ce.config.taker_reward_bps.to_string()), | ||
]) | ||
} | ||
} | ||
|
||
// pub struct UpdatePairEvent<'a> { | ||
// pub ty: &'a str, | ||
// pub pair: &'a Pair, | ||
// } | ||
|
||
// impl<'a> From<UpdatePairEvent<'a>> for Event { | ||
// fn from(pe: UpdatePairEvent) -> Self { | ||
// Event::new(pe.ty.to_string()).add_attributes(pe.pair.get_event_attrs(vec![ | ||
// "pair_type", | ||
// "swap_fee_percent", | ||
// "reinvest_tokens", | ||
// "reinvest_nfts", | ||
// "bonding_curve", | ||
// "spot_price", | ||
// "delta", | ||
// "is_active", | ||
// "asset_recipient", | ||
// ])) | ||
// } | ||
// } | ||
|
||
// pub struct NftTransferEvent<'a> { | ||
// pub ty: &'a str, | ||
// pub pair: &'a Pair, | ||
// pub token_ids: &'a Vec<String>, | ||
// } | ||
|
||
// impl<'a> From<NftTransferEvent<'a>> for Event { | ||
// fn from(nte: NftTransferEvent) -> Self { | ||
// Event::new(nte.ty.to_string()) | ||
// .add_attributes(nte.pair.get_event_attrs(vec!["total_nfts"])) | ||
// .add_attributes(nte.token_ids.iter().map(|token_id| ("token_id", token_id))) | ||
// } | ||
// } | ||
|
||
// pub struct TokenTransferEvent<'a> { | ||
// pub ty: &'a str, | ||
// pub funds: &'a Coin, | ||
// } | ||
|
||
// impl<'a> From<TokenTransferEvent<'a>> for Event { | ||
// fn from(tte: TokenTransferEvent) -> Self { | ||
// Event::new(tte.ty.to_string()).add_attribute("funds", tte.funds.to_string()) | ||
// } | ||
// } | ||
pub struct AllowDenomsEvent<'a> { | ||
pub ty: &'a str, | ||
pub allow_denoms: &'a AllowDenoms, | ||
} | ||
|
||
// pub struct SwapEvent<'a> { | ||
// pub ty: &'a str, | ||
// pub pair: &'a Pair, | ||
// pub token_id: &'a str, | ||
// pub sender_recipient: &'a Addr, | ||
// pub quote_summary: &'a QuoteSummary, | ||
// } | ||
impl<'a> From<AllowDenomsEvent<'a>> for Event { | ||
fn from(ade: AllowDenomsEvent) -> Self { | ||
let mut event = Event::new(ade.ty.to_string()); | ||
|
||
let enum_type = match &ade.allow_denoms { | ||
AllowDenoms::Includes(_) => "includes", | ||
AllowDenoms::Excludes(_) => "excludes", | ||
}; | ||
event = event.add_attribute("type", enum_type); | ||
|
||
match &ade.allow_denoms { | ||
AllowDenoms::Includes(denoms) => { | ||
for denom in denoms { | ||
event = event.add_attribute("denom", denom); | ||
} | ||
} | ||
AllowDenoms::Excludes(denoms) => { | ||
for denom in denoms { | ||
event = event.add_attribute("denom", denom); | ||
} | ||
} | ||
} | ||
|
||
event | ||
} | ||
} | ||
|
||
// impl<'a> From<SwapEvent<'a>> for Event { | ||
// fn from(se: SwapEvent) -> Self { | ||
// let mut event = Event::new(se.ty.to_string()) | ||
// .add_attributes(se.pair.get_event_attrs(vec!["spot_price", "is_active"])); | ||
pub struct AskEvent<'a> { | ||
pub ty: &'a str, | ||
pub ask: &'a Ask, | ||
pub attr_keys: Vec<&'a str>, | ||
} | ||
|
||
// event = event.add_attributes(vec![ | ||
// attr("token_id", se.token_id), | ||
// attr("sender_recipient", se.sender_recipient), | ||
// attr("fair_burn_fee", se.quote_summary.fair_burn.amount), | ||
// attr("seller_amount", se.quote_summary.seller_amount), | ||
// ]); | ||
impl<'a> From<AskEvent<'a>> for Event { | ||
fn from(ae: AskEvent) -> Self { | ||
Event::new(ae.ty.to_string()).add_attributes(ae.ask.get_event_attrs(ae.attr_keys)) | ||
} | ||
} | ||
|
||
// if let Some(royalty) = se.quote_summary.royalty.as_ref() { | ||
// event = event.add_attribute("royalty_fee", royalty.amount); | ||
// } | ||
// if let Some(swap) = se.quote_summary.swap.as_ref() { | ||
// event = event.add_attribute("swap_fee", swap.amount); | ||
// } | ||
pub struct OfferEvent<'a> { | ||
pub ty: &'a str, | ||
pub offer: &'a Offer, | ||
pub attr_keys: Vec<&'a str>, | ||
} | ||
|
||
// event | ||
// } | ||
// } | ||
impl<'a> From<OfferEvent<'a>> for Event { | ||
fn from(oe: OfferEvent) -> Self { | ||
Event::new(oe.ty.to_string()).add_attributes(oe.offer.get_event_attrs(oe.attr_keys)) | ||
} | ||
} | ||
|
||
// pub struct PairInternalEvent<'a> { | ||
// pub pair: &'a Pair, | ||
// } | ||
pub struct CollectionOfferEvent<'a> { | ||
pub ty: &'a str, | ||
pub collection_offer: &'a CollectionOffer, | ||
pub attr_keys: Vec<&'a str>, | ||
} | ||
|
||
// impl<'a> From<PairInternalEvent<'a>> for Event { | ||
// fn from(pie: PairInternalEvent) -> Self { | ||
// Event::new("pair-internal".to_string()).add_attributes(pie.pair.get_event_attrs(vec![ | ||
// "total_tokens", | ||
// "sell_to_pair_quote", | ||
// "buy_from_pair_quote", | ||
// ])) | ||
// } | ||
// } | ||
impl<'a> From<CollectionOfferEvent<'a>> for Event { | ||
fn from(coe: CollectionOfferEvent) -> Self { | ||
Event::new(coe.ty.to_string()) | ||
.add_attributes(coe.collection_offer.get_event_attrs(coe.attr_keys)) | ||
} | ||
} |
Oops, something went wrong.