From a48f8f5f1f2e4eeb3c7ee54f6817e88dd3c1155b Mon Sep 17 00:00:00 2001 From: imabdulbasit Date: Tue, 19 Sep 2023 16:59:46 +0500 Subject: [PATCH] Save deduction id for queued mints & filter holders where owner is null --- api/src/dataloaders/holders.rs | 1 + api/src/mutations/mint.rs | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api/src/dataloaders/holders.rs b/api/src/dataloaders/holders.rs index 46914b8..dbed271 100644 --- a/api/src/dataloaders/holders.rs +++ b/api/src/dataloaders/holders.rs @@ -28,6 +28,7 @@ impl DataLoader for Loader { .filter( collection_mints::Column::CollectionId.is_in(keys.iter().map(ToOwned::to_owned)), ) + .filter(collection_mints::Column::Owner.is_not_null()) .select_only() .column(collection_mints::Column::CollectionId) .column_as(collection_mints::Column::Owner, "address") diff --git a/api/src/mutations/mint.rs b/api/src/mutations/mint.rs index a6eab6d..c60cfd9 100644 --- a/api/src/mutations/mint.rs +++ b/api/src/mutations/mint.rs @@ -986,7 +986,7 @@ impl Mutation { Actions::Mint }; - let TransactionId(_) = credits + let TransactionId(deduction_id) = credits .submit_pending_deduction( org_id, user_id, @@ -1000,6 +1000,11 @@ impl Mutation { collection_am.total_mints = Set(collection.total_mints.add(1)); collection_am.update(conn).await?; + let mut mint_am: collection_mints::ActiveModel = mint.clone().into(); + mint_am.credits_deduction_id = Set(Some(deduction_id)); + mint_am.creation_status = Set(CreationStatus::Pending); + mint_am.update(conn).await?; + match collection.blockchain { BlockchainEnum::Solana => { solana @@ -1027,10 +1032,6 @@ impl Mutation { }, }; - let mut mint_am: collection_mints::ActiveModel = mint.into(); - mint_am.creation_status = Set(CreationStatus::Pending); - let mint = mint_am.update(conn).await?; - let drop = drops::Entity::find() .filter(drops::Column::CollectionId.eq(collection.id)) .one(conn) @@ -1136,7 +1137,7 @@ impl Mutation { .all(conn) .await?; - let TransactionId(_) = credits + let TransactionId(deduction_id) = credits .submit_pending_deduction( org_id, user_id, @@ -1150,6 +1151,11 @@ impl Mutation { collection_am.total_mints = Set(collection.total_mints.add(1)); collection_am.update(conn).await?; + let mut mint_am: collection_mints::ActiveModel = mint.clone().into(); + mint_am.credits_deduction_id = Set(Some(deduction_id)); + mint_am.creation_status = Set(CreationStatus::Pending); + mint_am.update(conn).await?; + match collection.blockchain { BlockchainEnum::Solana => { solana @@ -1177,10 +1183,6 @@ impl Mutation { }, }; - let mut mint_am: collection_mints::ActiveModel = mint.into(); - mint_am.creation_status = Set(CreationStatus::Pending); - let mint = mint_am.update(conn).await?; - let mint_history_am = mint_histories::ActiveModel { mint_id: Set(mint.id), wallet: Set(input.recipient),