Skip to content

Commit

Permalink
Merge pull request #230 from holaplex/abdul/fix-queued-mints
Browse files Browse the repository at this point in the history
Save deduction id for queued mints & filter holders where owner is null
  • Loading branch information
kespinola authored Sep 19, 2023
2 parents abab893 + a48f8f5 commit e961d39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions api/src/dataloaders/holders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl DataLoader<Uuid> 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")
Expand Down
22 changes: 12 additions & 10 deletions api/src/mutations/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl Mutation {
Actions::Mint
};

let TransactionId(_) = credits
let TransactionId(deduction_id) = credits
.submit_pending_deduction(
org_id,
user_id,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1136,7 +1137,7 @@ impl Mutation {
.all(conn)
.await?;

let TransactionId(_) = credits
let TransactionId(deduction_id) = credits
.submit_pending_deduction(
org_id,
user_id,
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit e961d39

Please sign in to comment.