Skip to content

Commit

Permalink
fix: only check no zero supploy on edition type. increment supply whe…
Browse files Browse the repository at this point in the history
…n queue mint to open drop. increment total mints when user mints queued for open drop.
  • Loading branch information
kespinola committed Sep 18, 2023
1 parent b9fdd5b commit 7d219d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/mutations/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ impl CreateDropInput {
/// # Errors
/// - Err with an appropriate error message if any validation fails.
pub fn validate(&self) -> Result<()> {
if self.supply == Some(0) {
if self.supply == Some(0) && self.drop_type == DropType::Edition {
return Err(Error::new("Supply must be greater than 0 or undefined"));
};

Expand Down
14 changes: 14 additions & 0 deletions api/src/mutations/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ impl Mutation {

let collection_model = collection.ok_or(Error::new("collection not found"))?;

let mut collection_am: collections::ActiveModel = collection_model.clone().into();

collection_am.supply = Set(collection_model.supply.map(|supply| supply.add(1)));

collection_am.update(conn).await?;

let mint = collection_mints::ActiveModel {
collection_id: Set(drop.collection_id),
owner: Set(None),
Expand Down Expand Up @@ -990,6 +996,10 @@ impl Mutation {
)
.await?;

let mut collection_am = collections::ActiveModel::from(collection.clone());
collection_am.total_mints = Set(collection.total_mints.add(1));
collection_am.update(conn).await?;

match collection.blockchain {
BlockchainEnum::Solana => {
solana
Expand Down Expand Up @@ -1136,6 +1146,10 @@ impl Mutation {
)
.await?;

let mut collection_am = collections::ActiveModel::from(collection.clone());
collection_am.total_mints = Set(collection.total_mints.add(1));
collection_am.update(conn).await?;

match collection.blockchain {
BlockchainEnum::Solana => {
solana
Expand Down

0 comments on commit 7d219d4

Please sign in to comment.