Skip to content

Commit

Permalink
emit Finalized if not enough room for another contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
0xble committed Nov 20, 2023
1 parent 60787f2 commit 3ab0afe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/authorities/SellPartyCardsAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ contract SellPartyCardsAuthority {
revert OutOfBoundsContributionsError(amount, maxContribution);
}

uint96 minContribution = state.minContribution;
uint96 newTotalContributions = totalContributions + amount;
if (newTotalContributions >= maxTotalContributions) {
// This occurs before refunding excess contribution to act as a
Expand All @@ -543,12 +544,17 @@ contract SellPartyCardsAuthority {
} else {
_saleStates[party][saleId]
.totalContributions = totalContributions = newTotalContributions;

// Check if not enough room for another contribution. If so, sale is
// finalized.
if (minContribution > maxTotalContributions - newTotalContributions) {
emit Finalized(party, saleId);
}
}

// Check that the contribution amount is at or above the minimum. This
// is done after `amount` is potentially reduced if refunding excess
// contribution.
uint96 minContribution = state.minContribution;
if (amount < minContribution) {
revert OutOfBoundsContributionsError(amount, minContribution);
}
Expand Down

0 comments on commit 3ab0afe

Please sign in to comment.