From ce7d2adcda6e64331ad1f7e8bbd4427684d6579b Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Wed, 2 Oct 2024 19:49:16 +0100 Subject: [PATCH] (circles): update check for calculate issuance to more accurately check an hour is available --- src/circles/Circles.sol | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/circles/Circles.sol b/src/circles/Circles.sol index 45d2c63..93d8661 100644 --- a/src/circles/Circles.sol +++ b/src/circles/Circles.sol @@ -91,12 +91,26 @@ contract Circles is ERC1155, ICirclesErrors { revert CirclesERC1155MintBlocked(_human, mintTime.mintV1Status); } - if (uint256(mintTime.lastMintTime) + 1 hours > block.timestamp) { - // Mint time is set to indefinite future for stopped mints in v2 - // and only complete hours get minted, so shortcut the calculation + // Early check for stopped mints + if (mintTime.lastMintTime == INDEFINITE_FUTURE) { return (0, 0, 0); } + // Check if at least one new completed hour is mintable + uint256 lastCompletedHour = mintTime.lastMintTime / 1 hours; + uint256 currentCompletedHour = block.timestamp / 1 hours; + + if (lastCompletedHour >= currentCompletedHour) { + // No new completed hour to mint + return (0, 0, 0); + } + + // if (uint256(mintTime.lastMintTime) + 1 hours > block.timestamp) { + // // Mint time is set to indefinite future for stopped mints in v2 + // // and only complete hours get minted, so shortcut the calculation + // return (0, 0, 0); + // } + // calculate the start of the claimable period uint256 startMint = _max(block.timestamp - MAX_CLAIM_DURATION, mintTime.lastMintTime);