Skip to content

Commit

Permalink
feat: trait offer event
Browse files Browse the repository at this point in the history
  • Loading branch information
the-emerald committed Nov 6, 2023
1 parent b0317f2 commit bb6a1f2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@ pub enum Event {
ItemReceivedBid,
/// A collection has received an offer.
CollectionOffer,
/// A collection has received a trait offer.
TraitOffer,
}
39 changes: 39 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub enum Payload {
ItemReceivedBid(ItemReceivedBidData),
/// A collection has received an offer.
CollectionOffer(CollectionOfferData),
/// A collection has received a trait offer.
TraitOffer(TraitOfferData),
}

impl From<Payload> for Event {
Expand All @@ -56,6 +58,7 @@ impl From<Payload> for Event {
Payload::ItemReceivedOffer(_) => Event::ItemReceivedOffer,
Payload::ItemReceivedBid(_) => Event::ItemReceivedBid,
Payload::CollectionOffer(_) => Event::CollectionOffer,
Payload::TraitOffer(_) => Event::TraitOffer,
}
}
}
Expand Down Expand Up @@ -489,6 +492,42 @@ pub struct CollectionOfferData {
pub asset_contract_criteria: serde_json::Value,
}

/// Payload data for [`Payload::TraitOffer`].
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TraitOfferData {
/// Context
#[serde(flatten)]
pub context: Context,

/// Timestamp of when the bid was received.
pub event_timestamp: DateTime<Utc>,
/// Bid price. See `payment_token` for the actual value of each unit.
#[serde(with = "u256_fromstr_radix_10")]
pub base_price: U256,
/// Timestamp of when the bid was created.
pub created_date: DateTime<Utc>,
/// Timestamp of when the bid will expire.
pub expiration_date: DateTime<Utc>,
/// Creator of the bid.
#[serde(with = "address_fromjson")]
pub maker: Address,
/// Hash id of the listing.
pub order_hash: H256,
/// Token offered for payment.
pub payment_token: PaymentToken,
/// Number of items on the offer. This is always `1` for ERC-721 tokens.
pub quantity: u64,
/// Taker of the bid.
#[serde(with = "address_fromjson_opt", default)]
pub taker: Option<Address>,
/// Collection criteria.
pub collection_criteria: serde_json::Value,
/// Asset contract criteria.
pub asset_contract_criteria: serde_json::Value,
/// Trait criteria.
pub trait_criteria: serde_json::Value,
}

/// Auctioning system used by the listing.
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
Expand Down

0 comments on commit bb6a1f2

Please sign in to comment.