From f79fb0c82b6badbad2cdddf7f5ea970b62e7fc5c Mon Sep 17 00:00:00 2001 From: Emerald Date: Sat, 11 Mar 2023 18:14:22 +0000 Subject: [PATCH 1/3] fix!: add non-exhaustive to payload, event enums --- src/protocol.rs | 1 + src/schema.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index 137d494..b9625f7 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -80,6 +80,7 @@ impl From for Url { /// [`Payload`](crate::schema::Payload). #[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, Eq, Hash)] #[serde(rename_all = "snake_case")] +#[non_exhaustive] pub enum Event { /// An item been listed for sale. ItemListed, diff --git a/src/schema.rs b/src/schema.rs index 0d4acb4..94057f8 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -25,6 +25,7 @@ pub struct StreamEvent { #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "event_type", content = "payload")] #[serde(rename_all = "snake_case")] +#[non_exhaustive] pub enum Payload { /// An item has been listed for sale. ItemListed(ItemListedData), From b0317f2137a912075944d8d4b87f23222603dd64 Mon Sep 17 00:00:00 2001 From: Emerald Date: Thu, 16 Mar 2023 00:56:45 +0000 Subject: [PATCH 2/3] feat: collection offer event --- src/protocol.rs | 2 ++ src/schema.rs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index b9625f7..d267d73 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -96,4 +96,6 @@ pub enum Event { ItemReceivedOffer, /// An item has received a bid. ItemReceivedBid, + /// A collection has received an offer. + CollectionOffer, } diff --git a/src/schema.rs b/src/schema.rs index 94057f8..9848040 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -41,6 +41,8 @@ pub enum Payload { ItemReceivedOffer(ItemReceivedOfferData), /// An item has received a bid. ItemReceivedBid(ItemReceivedBidData), + /// A collection has received an offer. + CollectionOffer(CollectionOfferData), } impl From for Event { @@ -53,6 +55,7 @@ impl From for Event { Payload::ItemCancelled(_) => Event::ItemCancelled, Payload::ItemReceivedOffer(_) => Event::ItemReceivedOffer, Payload::ItemReceivedBid(_) => Event::ItemReceivedBid, + Payload::CollectionOffer(_) => Event::CollectionOffer, } } } @@ -452,6 +455,40 @@ pub struct ItemReceivedBidData { pub taker: Option
, } +/// Payload data for [`Payload::CollectionOffer`]. +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct CollectionOfferData { + /// Context + #[serde(flatten)] + pub context: Context, + + /// Timestamp of when the bid was received. + pub event_timestamp: DateTime, + /// 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, + /// Timestamp of when the bid will expire. + pub expiration_date: DateTime, + /// 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
, + /// Collection criteria. + pub collection_criteria: serde_json::Value, + /// Asset contract criteria. + pub asset_contract_criteria: serde_json::Value, +} + /// Auctioning system used by the listing. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "lowercase")] From bb6a1f203e9f7a868acee06ddd5e8cbaf79b1caa Mon Sep 17 00:00:00 2001 From: Emerald Date: Mon, 6 Nov 2023 19:18:15 +0000 Subject: [PATCH 3/3] feat: trait offer event --- src/protocol.rs | 2 ++ src/schema.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index d267d73..36b634c 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -98,4 +98,6 @@ pub enum Event { ItemReceivedBid, /// A collection has received an offer. CollectionOffer, + /// A collection has received a trait offer. + TraitOffer, } diff --git a/src/schema.rs b/src/schema.rs index 9848040..ea3ab73 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -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 for Event { @@ -56,6 +58,7 @@ impl From for Event { Payload::ItemReceivedOffer(_) => Event::ItemReceivedOffer, Payload::ItemReceivedBid(_) => Event::ItemReceivedBid, Payload::CollectionOffer(_) => Event::CollectionOffer, + Payload::TraitOffer(_) => Event::TraitOffer, } } } @@ -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, + /// 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, + /// Timestamp of when the bid will expire. + pub expiration_date: DateTime, + /// 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
, + /// 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")]