Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rest refactor #145

Merged
merged 24 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions contracts/JBTiered721DelegateStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
// Keep a reference to the last tier ID.
uint256 _lastTierId = _lastSortedTierIdOf(_nft);

// Retuen an empty array if there are no tiers.
if (_lastTierId == 0) return _tiers;

// Initialize an array with the appropriate length.
_tiers = new JB721Tier[](_size);

Expand Down Expand Up @@ -780,8 +783,7 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {

// Make sure there are enough units available.
if (
_storedTier.remainingQuantity - _numberOfReservedTokensOutstandingFor(msg.sender, _tierId, _storedTier)
== 0
_storedTier.remainingQuantity <= _numberOfReservedTokensOutstandingFor(msg.sender, _tierId, _storedTier)
) revert OUT();

// Mint the tokens.
Expand Down Expand Up @@ -954,10 +956,10 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
view
returns (uint256)
{
// No reserves outstanding if no mints or no reserved rate.
// No reserves outstanding if no mints, no reserved rate, or no beneficiary.
if (
_storedTier.reservedRate == 0 || _storedTier.initialQuantity == _storedTier.remainingQuantity
|| reservedTokenBeneficiaryOf(_nft, _tierId) == address(0)
|| reservedTokenBeneficiaryOf(_nft, _tierId) == address(0)
) return 0;

// The number of reserved tokens of the tier already minted.
Expand All @@ -969,6 +971,7 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
}

// Get a reference to the number of tokens already minted in the tier, not counting reserves or burned tokens.
// Take into account the reserved tokens into the remaining ones
uint256 _numberOfNonReservesMinted;
unchecked {
_numberOfNonReservesMinted =
Expand All @@ -981,6 +984,11 @@ contract JBTiered721DelegateStore is IJBTiered721DelegateStore {
// Round up.
if (_numberOfNonReservesMinted % _storedTier.reservedRate > 0) ++_numberReservedTokensMintable;

// Fill out the remaining supply with reserved tokens if needed.
if ((_storedTier.initialQuantity % _storedTier.reservedRate) + _numberReservedTokensMintable > _storedTier.initialQuantity) {
_numberReservedTokensMintable = _storedTier.remainingQuantity;
}

// Make sure there are more mintable than have been minted. This is possible if some tokens have been burned.
if (_reserveTokensMinted > _numberReservedTokensMintable) return 0;

Expand Down
211 changes: 0 additions & 211 deletions contracts/forge-test/Deployer_Unit.t.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pragma solidity ^0.8.16;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@jbx-protocol/juice-delegates-registry/src/JBDelegatesRegistry.sol";

import "../JBTiered721Delegate.sol";
import "../JBTiered721DelegateProjectDeployer.sol";
import "../JBTiered721DelegateDeployer.sol";
import "../JBTiered721DelegateStore.sol";
import "../../JBTiered721Delegate.sol";
import "../../JBTiered721DelegateProjectDeployer.sol";
import "../../JBTiered721DelegateDeployer.sol";
import "../../JBTiered721DelegateStore.sol";

import "./utils/TestBaseWorkflow.sol";
import "../interfaces/IJBTiered721Delegate.sol";
import "../utils/TestBaseWorkflow.sol";
import "../../interfaces/IJBTiered721Delegate.sol";
import {JBDelegateMetadataHelper} from '@jbx-protocol/juice-delegate-metadata-lib/src/JBDelegateMetadataHelper.sol';


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.8.16;

import "../E2E.t.sol";
import "./Pay_Mint_Redeem_E2E.t.sol";

import "../../JBTiered721GovernanceDelegate.sol";
import "../../abstract/ERC721.sol";
Expand Down
Loading
Loading