From 4ebb91f9ccf6631e4ab64246974a6140d6107144 Mon Sep 17 00:00:00 2001 From: imabdulbasit Date: Mon, 11 Sep 2023 19:17:13 +0500 Subject: [PATCH 1/2] Assemble and submit open drop transactions --- consumer/src/events.rs | 250 ++++++++++++++++++++++++++++++++--------- core/proto.lock | 12 +- core/proto.toml | 8 +- 3 files changed, 209 insertions(+), 61 deletions(-) diff --git a/consumer/src/events.rs b/consumer/src/events.rs index 5d92493..da646e1 100644 --- a/consumer/src/events.rs +++ b/consumer/src/events.rs @@ -103,12 +103,18 @@ impl ErrorSource { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EventKind { - CreateDrop, - MintDrop, - UpdateDrop, + CreateOpenDrop, + MintOpenDrop, + UpdateOpenDrop, + RetryCreateOpenDrop, + RetryMintOpenDrop, + + CreateEditionDrop, + MintEditionDrop, + UpdateEditionDrop, TransferAsset, - RetryCreateDrop, - RetryMintDrop, + RetryCreateEditionDrop, + RetryMintEditionDrop, CreateCollection, RetryCreateCollection, UpdateCollection, @@ -122,12 +128,12 @@ pub enum EventKind { impl EventKind { fn name(self) -> &'static str { match self { - Self::CreateDrop => "drop creation", - Self::MintDrop => "drop mint", - Self::UpdateDrop => "drop update", + Self::CreateEditionDrop => "edition drop creation", + Self::MintEditionDrop => "edition drop mint", + Self::UpdateEditionDrop => "edition drop update", Self::TransferAsset => "asset transfer", - Self::RetryCreateDrop => "drop creation retry", - Self::RetryMintDrop => "drop mint retry", + Self::RetryCreateEditionDrop => "editiondrop creation retry", + Self::RetryMintEditionDrop => "edition drop mint retry", Self::CreateCollection => "collection creation", Self::RetryCreateCollection => "collection creation retry", Self::UpdateCollection => "collection update", @@ -136,17 +142,26 @@ impl EventKind { Self::UpdateCollectionMint => "collection mint update", Self::RetryUpdateCollectionMint => "collection mint update retry", Self::SwitchMintCollection => "switch mint collection", + Self::CreateOpenDrop => "open drop creation", + Self::MintOpenDrop => "open drop mint", + Self::UpdateOpenDrop => "open drop update", + Self::RetryCreateOpenDrop => "open drop creation retry", + Self::RetryMintOpenDrop => "open drop mint retry", } } fn into_sign_request(self, tx: SolanaPendingTransaction) -> SolanaNftEvent { match self { - EventKind::CreateDrop => SolanaNftEvent::CreateDropSigningRequested(tx), - EventKind::MintDrop => SolanaNftEvent::MintDropSigningRequested(tx), - EventKind::UpdateDrop => SolanaNftEvent::UpdateDropSigningRequested(tx), + EventKind::CreateEditionDrop => SolanaNftEvent::CreateEditionDropSigningRequested(tx), + EventKind::MintEditionDrop => SolanaNftEvent::MintEditionDropSigningRequested(tx), + EventKind::UpdateEditionDrop => SolanaNftEvent::UpdateEditionDropSigningRequested(tx), EventKind::TransferAsset => SolanaNftEvent::TransferAssetSigningRequested(tx), - EventKind::RetryCreateDrop => SolanaNftEvent::RetryCreateDropSigningRequested(tx), - EventKind::RetryMintDrop => SolanaNftEvent::RetryMintDropSigningRequested(tx), + EventKind::RetryCreateEditionDrop => { + SolanaNftEvent::RetryCreateEditionDropSigningRequested(tx) + }, + EventKind::RetryMintEditionDrop => { + SolanaNftEvent::RetryMintEditionDropSigningRequested(tx) + }, EventKind::CreateCollection => SolanaNftEvent::CreateCollectionSigningRequested(tx), EventKind::UpdateCollection => SolanaNftEvent::UpdateCollectionSigningRequested(tx), EventKind::RetryCreateCollection => { @@ -165,6 +180,13 @@ impl EventKind { EventKind::SwitchMintCollection => { SolanaNftEvent::SwitchMintCollectionSigningRequested(tx) }, + EventKind::CreateOpenDrop => SolanaNftEvent::CreateOpenDropSigningRequested(tx), + EventKind::MintOpenDrop => SolanaNftEvent::MintOpenDropSigningRequested(tx), + EventKind::UpdateOpenDrop => SolanaNftEvent::UpdateOpenDropSigningRequested(tx), + EventKind::RetryCreateOpenDrop => { + SolanaNftEvent::RetryCreateOpenDropSigningRequested(tx) + }, + EventKind::RetryMintOpenDrop => SolanaNftEvent::RetryMintOpenDropSigningRequested(tx), } } @@ -178,13 +200,13 @@ impl EventKind { let id = || Uuid::parse_str(&key.id); Ok(match self { - Self::CreateDrop => { + Self::CreateEditionDrop => { let id = id()?; let collection = Collection::find_by_id(conn, id) .await? .ok_or(ProcessorErrorKind::RecordNotFound)?; - SolanaNftEvent::CreateDropSubmitted(SolanaCompletedMintTransaction { + SolanaNftEvent::CreateEditionDropSubmitted(SolanaCompletedMintTransaction { signature, address: collection.mint, }) @@ -254,43 +276,45 @@ impl EventKind { address, }) }, - Self::MintDrop => { + Self::MintEditionDrop => { let id = id()?; let collection_mint = CollectionMint::find_by_id(conn, id) .await? .ok_or(ProcessorErrorKind::RecordNotFound)?; - SolanaNftEvent::MintDropSubmitted(SolanaCompletedMintTransaction { + SolanaNftEvent::MintEditionDropSubmitted(SolanaCompletedMintTransaction { signature, address: collection_mint.mint, }) }, - Self::UpdateDrop => { - SolanaNftEvent::UpdateDropSubmitted(SolanaCompletedUpdateTransaction { signature }) + Self::UpdateEditionDrop => { + SolanaNftEvent::UpdateEditionDropSubmitted(SolanaCompletedUpdateTransaction { + signature, + }) }, Self::TransferAsset => { SolanaNftEvent::TransferAssetSubmitted(SolanaCompletedTransferTransaction { signature, }) }, - Self::RetryCreateDrop => { + Self::RetryCreateEditionDrop => { let id = id()?; let collection = Collection::find_by_id(conn, id) .await? .ok_or(ProcessorErrorKind::RecordNotFound)?; - SolanaNftEvent::RetryCreateDropSubmitted(SolanaCompletedMintTransaction { + SolanaNftEvent::RetryCreateEditionDropSubmitted(SolanaCompletedMintTransaction { signature, address: collection.mint, }) }, - Self::RetryMintDrop => { + Self::RetryMintEditionDrop => { let id = id()?; let collection_mint = CollectionMint::find_by_id(conn, id) .await? .ok_or(ProcessorErrorKind::RecordNotFound)?; - SolanaNftEvent::RetryMintDropSubmitted(SolanaCompletedMintTransaction { + SolanaNftEvent::RetryMintEditionDropSubmitted(SolanaCompletedMintTransaction { signature, address: collection_mint.mint, }) @@ -321,17 +345,66 @@ impl EventKind { signature, }) }, + Self::CreateOpenDrop => { + let id = id()?; + let collection = Collection::find_by_id(conn, id) + .await? + .ok_or(ProcessorErrorKind::RecordNotFound)?; + + SolanaNftEvent::CreateOpenDropSubmitted(SolanaCompletedMintTransaction { + signature, + address: collection.mint, + }) + }, + Self::MintOpenDrop => { + let id = id()?; + let collection_mint = CollectionMint::find_by_id(conn, id) + .await? + .ok_or(ProcessorErrorKind::RecordNotFound)?; + + SolanaNftEvent::MintOpenDropSubmitted(SolanaCompletedMintTransaction { + signature, + address: collection_mint.mint, + }) + }, + Self::UpdateOpenDrop => { + SolanaNftEvent::UpdateOpenDropSubmitted(SolanaCompletedUpdateTransaction { + signature, + }) + }, + Self::RetryCreateOpenDrop => { + let id = id()?; + let collection = Collection::find_by_id(conn, id) + .await? + .ok_or(ProcessorErrorKind::RecordNotFound)?; + + SolanaNftEvent::RetryCreateOpenDropSubmitted(SolanaCompletedMintTransaction { + signature, + address: collection.mint, + }) + }, + Self::RetryMintOpenDrop => { + let id = id()?; + let collection_mint = CollectionMint::find_by_id(conn, id) + .await? + .ok_or(ProcessorErrorKind::RecordNotFound)?; + + SolanaNftEvent::RetryMintOpenDropSubmitted(SolanaCompletedMintTransaction { + signature, + address: collection_mint.mint, + }) + }, }) } fn into_failure(self, tx: SolanaFailedTransaction) -> SolanaNftEvent { match self { - Self::CreateDrop => SolanaNftEvent::CreateDropFailed(tx), - Self::MintDrop => SolanaNftEvent::MintDropFailed(tx), - Self::UpdateDrop => SolanaNftEvent::UpdateDropFailed(tx), + Self::CreateEditionDrop => SolanaNftEvent::CreateEditionDropFailed(tx), + Self::MintEditionDrop => SolanaNftEvent::MintEditionDropFailed(tx), + Self::UpdateEditionDrop => SolanaNftEvent::UpdateEditionDropFailed(tx), Self::TransferAsset => SolanaNftEvent::TransferAssetFailed(tx), - Self::RetryCreateDrop => SolanaNftEvent::RetryCreateDropFailed(tx), - Self::RetryMintDrop => SolanaNftEvent::RetryMintDropFailed(tx), + Self::RetryCreateEditionDrop => SolanaNftEvent::RetryCreateEditionDropFailed(tx), + Self::RetryMintEditionDrop => SolanaNftEvent::RetryMintEditionDropFailed(tx), Self::CreateCollection => SolanaNftEvent::CreateCollectionFailed(tx), Self::RetryCreateCollection => SolanaNftEvent::RetryCreateCollectionFailed(tx), Self::UpdateCollection => SolanaNftEvent::UpdateCollectionFailed(tx), @@ -340,6 +413,11 @@ impl EventKind { Self::UpdateCollectionMint => SolanaNftEvent::UpdateCollectionMintFailed(tx), Self::RetryUpdateCollectionMint => SolanaNftEvent::RetryUpdateMintFailed(tx), Self::SwitchMintCollection => SolanaNftEvent::SwitchMintCollectionFailed(tx), + Self::CreateOpenDrop => SolanaNftEvent::CreateOpenDropFailed(tx), + Self::MintOpenDrop => SolanaNftEvent::MintOpenDropFailed(tx), + Self::UpdateOpenDrop => SolanaNftEvent::UpdateOpenDropFailed(tx), + Self::RetryCreateOpenDrop => SolanaNftEvent::RetryCreateOpenDropFailed(tx), + Self::RetryMintOpenDrop => SolanaNftEvent::RetryMintOpenDropFailed(tx), } } } @@ -373,9 +451,9 @@ impl Processor { let key = SolanaNftEventKey::from(key); match msg.event { - Some(NftEvent::SolanaCreateDrop(payload)) => { + Some(NftEvent::SolanaCreateEditionDrop(payload)) => { self.process_nft( - EventKind::CreateDrop, + EventKind::CreateEditionDrop, &key, self.create_collection(&UncompressedRef(self.solana()), &key, payload), ) @@ -389,9 +467,9 @@ impl Processor { ) .await }, - Some(NftEvent::SolanaMintDrop(payload)) => { + Some(NftEvent::SolanaMintEditionDrop(payload)) => { self.process_nft( - EventKind::MintDrop, + EventKind::MintEditionDrop, &key, self.mint_drop(&EditionRef(self.solana()), &key, payload), ) @@ -405,9 +483,9 @@ impl Processor { ) .await }, - Some(NftEvent::SolanaUpdateDrop(payload)) => { + Some(NftEvent::SolanaUpdateEditionDrop(payload)) => { self.process_nft( - EventKind::UpdateDrop, + EventKind::UpdateEditionDrop, &key, self.update_collection(&UncompressedRef(self.solana()), &key, payload), ) @@ -429,9 +507,9 @@ impl Processor { ) .await }, - Some(NftEvent::SolanaRetryDrop(payload)) => { + Some(NftEvent::SolanaRetryEditionDrop(payload)) => { self.process_nft( - EventKind::RetryCreateDrop, + EventKind::RetryCreateEditionDrop, &key, self.retry_create_collection( &UncompressedRef(self.solana()), @@ -453,9 +531,9 @@ impl Processor { ) .await }, - Some(NftEvent::SolanaRetryMintDrop(payload)) => { + Some(NftEvent::SolanaRetryMintEditionDrop(payload)) => { self.process_nft( - EventKind::RetryMintDrop, + EventKind::RetryMintEditionDrop, &key, self.retry_mint_drop(&EditionRef(self.solana()), &key, payload), ) @@ -504,7 +582,54 @@ impl Processor { ) .await }, - + Some(NftEvent::SolanaCreateOpenDrop(payload)) => { + self.process_nft( + EventKind::CreateOpenDrop, + &key, + self.create_collection(&UncompressedRef(self.solana()), &key, payload), + ) + .await + }, + Some(NftEvent::SolanaMintOpenDrop(payload)) => { + self.process_nft( + EventKind::MintOpenDrop, + &key, + self.mint_to_collection(&key, payload), + ) + .await + }, + Some(NftEvent::SolanaUpdateOpenDrop(payload)) => { + self.process_nft( + EventKind::UpdateOpenDrop, + &key, + self.update_collection(&UncompressedRef(self.solana()), &key, payload), + ) + .await + }, + Some(NftEvent::SolanaRetryOpenDrop(payload)) => { + self.process_nft( + EventKind::RetryCreateOpenDrop, + &key, + self.retry_create_collection( + &UncompressedRef(self.solana()), + &key, + payload, + ), + ) + .await + }, + Some(NftEvent::SolanaRetryMintOpenDrop(payload)) => { + self.process_nft( + EventKind::RetryMintOpenDrop, + &key, + self.retry_mint_to_collection( + &UncompressedRef(self.solana()), + &key, + payload, + ), + ) + .await + }, _ => Ok(()), } }, @@ -512,25 +637,28 @@ impl Processor { let key = SolanaNftEventKey::from(key); match msg.event { - Some(TreasuryEvent::SolanaCreateDropSigned(res)) => { - self.process_treasury(EventKind::CreateDrop, key, res).await + Some(TreasuryEvent::SolanaCreateEditionDropSigned(res)) => { + self.process_treasury(EventKind::CreateEditionDrop, key, res) + .await }, - Some(TreasuryEvent::SolanaMintDropSigned(res)) => { - self.process_treasury(EventKind::MintDrop, key, res).await + Some(TreasuryEvent::SolanaMintEditionDropSigned(res)) => { + self.process_treasury(EventKind::MintEditionDrop, key, res) + .await }, - Some(TreasuryEvent::SolanaUpdateDropSigned(res)) => { - self.process_treasury(EventKind::UpdateDrop, key, res).await + Some(TreasuryEvent::SolanaUpdateEditionDropSigned(res)) => { + self.process_treasury(EventKind::UpdateEditionDrop, key, res) + .await }, Some(TreasuryEvent::SolanaTransferAssetSigned(res)) => { self.process_treasury(EventKind::TransferAsset, key, res) .await }, - Some(TreasuryEvent::SolanaRetryCreateDropSigned(res)) => { - self.process_treasury(EventKind::RetryCreateDrop, key, res) + Some(TreasuryEvent::SolanaRetryCreateEditionDropSigned(res)) => { + self.process_treasury(EventKind::RetryCreateEditionDrop, key, res) .await }, - Some(TreasuryEvent::SolanaRetryMintDropSigned(res)) => { - self.process_treasury(EventKind::RetryMintDrop, key, res) + Some(TreasuryEvent::SolanaRetryMintEditionDropSigned(res)) => { + self.process_treasury(EventKind::RetryMintEditionDrop, key, res) .await }, Some(TreasuryEvent::SolanaMintToCollectionSigned(res)) => { @@ -565,6 +693,26 @@ impl Processor { self.process_treasury(EventKind::SwitchMintCollection, key, res) .await }, + Some(TreasuryEvent::SolanaCreateOpenDropSigned(res)) => { + self.process_treasury(EventKind::CreateOpenDrop, key, res) + .await + }, + Some(TreasuryEvent::SolanaMintOpenDropSigned(res)) => { + self.process_treasury(EventKind::MintOpenDrop, key, res) + .await + }, + Some(TreasuryEvent::SolanaUpdateOpenDropSigned(res)) => { + self.process_treasury(EventKind::UpdateOpenDrop, key, res) + .await + }, + Some(TreasuryEvent::SolanaRetryCreateOpenDropSigned(res)) => { + self.process_treasury(EventKind::RetryCreateOpenDrop, key, res) + .await + }, + Some(TreasuryEvent::SolanaRetryMintOpenDropSigned(res)) => { + self.process_treasury(EventKind::RetryMintOpenDrop, key, res) + .await + }, _ => Ok(()), } }, diff --git a/core/proto.lock b/core/proto.lock index 14f6b5d..ed7b295 100644 --- a/core/proto.lock +++ b/core/proto.lock @@ -1,14 +1,14 @@ [[schemas]] subject = "nfts" -version = 27 -sha512 = "ec52dffa482eb3beb72b1ae1745f3b8cb1b6d321d20fdc30078f4362c924b0f75ebe3dc53c54e5de92ea55163b64f09fe4e2b749c1bc5bc64d92f8356835eb90" +version = 2 +sha512 = "db8fa9f4b2874ab79305997c3b255a9b9c1b04d291c66f1cb97f332b32758055c01e6ba0e7a4089255c664324c51fc4fe25a9d138698b7a999b1f4d2b5503a48" [[schemas]] subject = "solana_nfts" -version = 10 -sha512 = "1bcb166ab5dfdf4841d60caa07a4098dcec03d7e3b0e63adb090ed2f5fe990c1e13826867e8df7521ec631027d5a931a08865fd2cf2daa905807c4b7dca40213" +version = 4 +sha512 = "967fefde938a0f6ce05194e4fca15673e681caac54d8aeec114c5d38418632b9696dbaf5362345a15114e5abb49de55d0af8b9edcc0f2c91f9ef1ccc4ff55d68" [[schemas]] subject = "treasury" -version = 22 -sha512 = "bde788b07f818aa52e684dcbd91e1f1e3db82f242f616ec2a42ab6d412df33a1461677c229f2f9bae345938c2f325e6332a95caef2c7e01a47531af53e39bf03" +version = 3 +sha512 = "0e4d77999767d5971122e720c1cee7a57c3e47ce69f58a582f1762d8e65e031ea3bd9024cfc21bd7da5db6e38a71657151c58cdfa21d9ff643fb2fc657105cf5" diff --git a/core/proto.toml b/core/proto.toml index 5d1fe9f..305d46f 100644 --- a/core/proto.toml +++ b/core/proto.toml @@ -1,7 +1,7 @@ [registry] -endpoint = "https://schemas.holaplex.tools" +endpoint = "http://localhost:8081" [schemas] -nfts = 27 -treasury = 22 -solana_nfts = 10 \ No newline at end of file +nfts = 2 +treasury = 3 +solana_nfts = 4 \ No newline at end of file From fda292e899983186c9cd1c358f8b27758fb0c176 Mon Sep 17 00:00:00 2001 From: imabdulbasit Date: Tue, 12 Sep 2023 18:24:20 +0500 Subject: [PATCH 2/2] update proto schemas version --- consumer/src/events.rs | 36 ++++++++++++++---------------------- core/proto.lock | 8 ++++---- core/proto.toml | 8 ++++---- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/consumer/src/events.rs b/consumer/src/events.rs index da646e1..f5290b5 100644 --- a/consumer/src/events.rs +++ b/consumer/src/events.rs @@ -103,12 +103,6 @@ impl ErrorSource { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EventKind { - CreateOpenDrop, - MintOpenDrop, - UpdateOpenDrop, - RetryCreateOpenDrop, - RetryMintOpenDrop, - CreateEditionDrop, MintEditionDrop, UpdateEditionDrop, @@ -123,6 +117,11 @@ pub enum EventKind { UpdateCollectionMint, RetryUpdateCollectionMint, SwitchMintCollection, + CreateOpenDrop, + MintOpenDrop, + UpdateOpenDrop, + RetryCreateOpenDrop, + RetryMintOpenDrop, } impl EventKind { @@ -240,7 +239,7 @@ impl EventKind { signature, }) }, - Self::MintToCollection => { + Self::MintToCollection | Self::MintOpenDrop => { let id = id()?; let collection_mint = CollectionMint::find_by_id(conn, id).await?; @@ -270,11 +269,15 @@ impl EventKind { .ok_or(ProcessorErrorKind::RecordNotFound)? .mint }; + let transaction = SolanaCompletedMintTransaction { signature, address }; - SolanaNftEvent::MintToCollectionSubmitted(SolanaCompletedMintTransaction { - signature, - address, - }) + match self { + Self::MintToCollection => { + SolanaNftEvent::MintToCollectionSubmitted(transaction) + }, + Self::MintOpenDrop => SolanaNftEvent::MintOpenDropSubmitted(transaction), + _ => unreachable!(), + } }, Self::MintEditionDrop => { let id = id()?; @@ -356,17 +359,6 @@ impl EventKind { address: collection.mint, }) }, - Self::MintOpenDrop => { - let id = id()?; - let collection_mint = CollectionMint::find_by_id(conn, id) - .await? - .ok_or(ProcessorErrorKind::RecordNotFound)?; - - SolanaNftEvent::MintOpenDropSubmitted(SolanaCompletedMintTransaction { - signature, - address: collection_mint.mint, - }) - }, Self::UpdateOpenDrop => { SolanaNftEvent::UpdateOpenDropSubmitted(SolanaCompletedUpdateTransaction { signature, diff --git a/core/proto.lock b/core/proto.lock index ed7b295..1c4fe4d 100644 --- a/core/proto.lock +++ b/core/proto.lock @@ -1,14 +1,14 @@ [[schemas]] subject = "nfts" -version = 2 -sha512 = "db8fa9f4b2874ab79305997c3b255a9b9c1b04d291c66f1cb97f332b32758055c01e6ba0e7a4089255c664324c51fc4fe25a9d138698b7a999b1f4d2b5503a48" +version = 29 +sha512 = "b3b2136bd6c7a136d317da84395661de5fc056e8270510575a3281d78884d99a0d89f444754ed02cb18ad26dcc7cd65300c1df73b9d74d2edc6bcc8d552465d0" [[schemas]] subject = "solana_nfts" -version = 4 +version = 11 sha512 = "967fefde938a0f6ce05194e4fca15673e681caac54d8aeec114c5d38418632b9696dbaf5362345a15114e5abb49de55d0af8b9edcc0f2c91f9ef1ccc4ff55d68" [[schemas]] subject = "treasury" -version = 3 +version = 23 sha512 = "0e4d77999767d5971122e720c1cee7a57c3e47ce69f58a582f1762d8e65e031ea3bd9024cfc21bd7da5db6e38a71657151c58cdfa21d9ff643fb2fc657105cf5" diff --git a/core/proto.toml b/core/proto.toml index 305d46f..62864f2 100644 --- a/core/proto.toml +++ b/core/proto.toml @@ -1,7 +1,7 @@ [registry] -endpoint = "http://localhost:8081" +endpoint = "https://schemas.holaplex.tools" [schemas] -nfts = 2 -treasury = 3 -solana_nfts = 4 \ No newline at end of file +nfts = 29 +treasury = 23 +solana_nfts = 11 \ No newline at end of file