From 342f1e0f9a3f2a160505a27a9a3e0207c1b74f69 Mon Sep 17 00:00:00 2001 From: jacques Date: Mon, 19 Sep 2022 11:52:48 -0400 Subject: [PATCH 1/6] feat: add order_hash types --- Cargo.toml | 4 ++-- src/schema.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7c9cdc4..98f5926 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/wanderers-nft/opensea-stream-rs" categories = ["web-programming::websocket", "cryptography::cryptocurrencies"] keywords = ["opensea", "stream", "nft"] -version = "0.3.0" +version = "0.4.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -27,4 +27,4 @@ tokio = { version = "1.18.2", features = ["full"] } [features] default = ["rustls-tls-native-roots"] rustls-tls-native-roots = ["phyllo/rustls-tls-native-roots"] -rustls-tls-webpki-roots = ["phyllo/rustls-tls-webpki-roots"] \ No newline at end of file +rustls-tls-webpki-roots = ["phyllo/rustls-tls-webpki-roots"] diff --git a/src/schema.rs b/src/schema.rs index 3a743ae..0d4acb4 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -279,6 +279,8 @@ pub struct ItemListedData { /// Creator of the listing. #[serde(with = "address_fromjson")] pub maker: Address, + /// Hash id of the listing. + pub order_hash: H256, /// Token accepted for payment. pub payment_token: PaymentToken, /// Number of items on sale. This is always `1` for ERC-721 tokens. @@ -376,6 +378,11 @@ pub struct ItemCancelledData { pub event_timestamp: DateTime, /// Type of listing. `None` indicates the listing would've been a buyout. pub listing_type: Option, + /// Creator of the cancellation order. + #[serde(with = "address_fromjson")] + pub maker: Address, + /// Hash id of the listing. + pub order_hash: H256, /// Token accepted for payment. pub payment_token: PaymentToken, /// Number of items in listing. This is always `1` for ERC-721 tokens. @@ -403,6 +410,8 @@ pub struct ItemReceivedOfferData { /// Creator of the offer. #[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. @@ -431,6 +440,8 @@ pub struct ItemReceivedBidData { /// 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. From df2bde99c3738dfe305a91d1be9280e0e2fe20ca Mon Sep 17 00:00:00 2001 From: frankie <88221686+FrankieIsLost@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:41:21 -0700 Subject: [PATCH 2/6] chore: bump ethers-core to 2.0.0 (#6) Co-authored-by: Emerald --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 98f5926..b9f17e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" [dependencies] chrono = { version = "0.4.19", features = ["serde"] } -ethers-core = "0.17.0" +ethers-core = "2.0.0" serde = { version = "1.0.137", features = ["derive"] } serde_json = "1.0.81" From f79fb0c82b6badbad2cdddf7f5ea970b62e7fc5c Mon Sep 17 00:00:00 2001 From: Emerald Date: Sat, 11 Mar 2023 18:14:22 +0000 Subject: [PATCH 3/6] 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 4/6] 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 5/6] 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")] From e752aa54dc1da1878e8865603260540ef4e6e0f4 Mon Sep 17 00:00:00 2001 From: Emerald Date: Thu, 11 Jan 2024 19:04:11 +0000 Subject: [PATCH 6/6] feat: support more chains --- src/schema.rs | 87 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/src/schema.rs b/src/schema.rs index ea3ab73..f9b53a0 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -182,28 +182,54 @@ mod chain { /// Network an item is on. #[derive(Serialize, Deserialize, Debug, Clone, Copy)] - #[serde(tag = "name", rename_all = "lowercase")] + #[serde(tag = "name", rename_all = "snake_case")] #[non_exhaustive] pub enum Chain { - /// [Ethereum](https://ethereum.org) mainnet. + /// Ethereum Mainnet Ethereum, - /// [Polygon](https://polygon.technology/solutions/polygon-pos) mainnet. + /// Polygon Matic #[serde(rename = "matic")] Polygon, - /// [Klaytn](https://www.klaytn.foundation/) mainnet. + /// Klaytn Klaytn, - /// [Solana](https://solana.com/) mainnet. This variant (and all events for Solana assets) are not supported in this version. + /// BNB Chain + Bnb, + /// Arbitrum + Arbitrum, + /// Arbitrum Nova + ArbitrumNova, + /// Avalanche + Avalanche, + /// Optimism + Optimism, + /// Solana mainnet. This variant (and all events for Solana assets) are not supported in this version. Solana, - - /// [Goerli](https://ethereum.org/en/developers/docs/networks/#goerli) testnet (of Ethereum). - Goerli, - /// [Rinkeby](https://ethereum.org/en/developers/docs/networks/#rinkeby) testnet (of Ethereum). - #[deprecated = "OpenSea no longer supports Rinkeby as the testnet has been deprecated for The Merge."] - Rinkeby, - /// [Mumbai](https://docs.polygon.technology/docs/develop/network-details/network#mumbai-pos-testnet) testnet (of Polygon). + /// Base + Base, + /// Zora + Zora, + + /// Sepolia + Sepolia, + /// Polygon Mumbai Mumbai, - /// [Baobab](https://www.klaytn.foundation/) testnet (of Klaytn). + /// Klaytn Baobab Baobab, + /// BNB Testnet + #[serde(rename = "bsctestnet")] + BscTestnet, + /// Arbitrum Sepolia + ArbitrumSepolia, + /// Avalanche Fuji + AvalancheFuji, + /// Optimism Sepolia + OptimismSepolia, + /// Solana Devnet. This variant (and all events for Solana assets) are not supported in this version. + Soldev, + /// Base Sepolia + BaseSepolia, + /// Zora Sepolia + ZoraSepolia, } } pub use chain::Chain; @@ -216,11 +242,24 @@ impl FromStr for Chain { "ethereum" => Ok(Chain::Ethereum), "matic" => Ok(Chain::Polygon), "klaytn" => Ok(Chain::Klaytn), + "bsc" => Ok(Chain::Bnb), + "arbitrum" => Ok(Chain::Arbitrum), + "arbitrum_nova" => Ok(Chain::ArbitrumNova), + "avalanche" => Ok(Chain::Avalanche), + "optimism" => Ok(Chain::Optimism), "solana" => Ok(Chain::Solana), - #[allow(deprecated)] - "rinkeby" => Ok(Chain::Rinkeby), + "base" => Ok(Chain::Base), + "zora" => Ok(Chain::Zora), + "sepolia" => Ok(Chain::Sepolia), "mumbai" => Ok(Chain::Mumbai), "baobab" => Ok(Chain::Baobab), + "bsctestnet" => Ok(Chain::BscTestnet), + "arbitrum_sepolia" => Ok(Chain::ArbitrumSepolia), + "avalanche_fuji" => Ok(Chain::AvalancheFuji), + "optimism_sepolia" => Ok(Chain::OptimismSepolia), + "soldev" => Ok(Chain::Soldev), + "base_sepolia" => Ok(Chain::BaseSepolia), + "zora_sepolia" => Ok(Chain::ZoraSepolia), _ => Err(()), } } @@ -235,12 +274,24 @@ impl fmt::Display for Chain { Chain::Ethereum => "ethereum", Chain::Polygon => "matic", Chain::Klaytn => "klaytn", + Chain::Bnb => "bsc", + Chain::Arbitrum => "arbitrum", + Chain::ArbitrumNova => "arbitrum_nova", + Chain::Avalanche => "avalanche", + Chain::Optimism => "optimism", Chain::Solana => "solana", - #[allow(deprecated)] - Chain::Rinkeby => "rinkeby", + Chain::Base => "base", + Chain::Zora => "zora", + Chain::Sepolia => "sepolia", Chain::Mumbai => "mumbai", Chain::Baobab => "baobab", - Chain::Goerli => "goerli", + Chain::BscTestnet => "bsctestnet", + Chain::ArbitrumSepolia => "arbitrum_sepolia", + Chain::AvalancheFuji => "avalanche_fuji", + Chain::OptimismSepolia => "optimism_sepolia", + Chain::Soldev => "soldev", + Chain::BaseSepolia => "base_sepolia", + Chain::ZoraSepolia => "zora_sepolia", } ) }