diff --git a/.gas-snapshot b/.gas-snapshot index adf4c2a..7262583 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -8,8 +8,8 @@ ContentPoolTest:test_participantStates_ok() (gas: 220730) ContentPoolTest:test_updateUserAndPool_WithRewardBeforeState_ok() (gas: 428687) ContentPoolTest:test_updateUserAndPool_ok() (gas: 325512) ContentPoolTest:test_updateUser_MultiTokenTransfer_ok() (gas: 539456) -ContentPoolTest:test_updateUser_WithRewardBeforeStateChange_ok() (gas: 713201) -ContentPoolTest:test_updateUser_ok() (gas: 400231) +ContentPoolTest:test_updateUser_WithRewardBeforeStateChange_ok() (gas: 713219) +ContentPoolTest:test_updateUser_ok() (gas: 400248) FrakTeasuryWalletTest:test_canBeDeployedAndInit_ok() (gas: 1773426) FrakTeasuryWalletTest:test_initialize_InitTwice_ko() (gas: 17937) FrakTeasuryWalletTest:test_transferBatch_InvalidArray_ko() (gas: 28753) @@ -24,7 +24,7 @@ FrakTeasuryWalletTest:test_transfer_NotEnoughTreasury_ko() (gas: 11304244) FrakTeasuryWalletTest:test_transfer_NotMinter_ko() (gas: 17684) FrakTeasuryWalletTest:test_transfer_RewardTooLarge_ko() (gas: 20534) FrakTeasuryWalletTest:test_transfer_ok() (gas: 136061) -FrakTokenTest:invariant_cap_lt_supply() (runs: 256, calls: 3840, reverts: 3601) +FrakTokenTest:invariant_cap_lt_supply() (runs: 256, calls: 3840, reverts: 3633) FrakTokenTest:test_burn_ok() (gas: 53287) FrakTokenTest:test_canBeDeployedAndInit_ok() (gas: 2502575) FrakTokenTest:test_cap_ok() (gas: 10366) @@ -41,36 +41,36 @@ FrakTokenTest:test_permit_ok() (gas: 77672) FrakTokenTest:test_symbol_ok() (gas: 14797) FraktionCostBadgesTest:test_defaultPrice_InvalidFraktionType_ko() (gas: 43272) FraktionCostBadgesTest:test_defaultPrice_ok() (gas: 26214) -FraktionCostBadgesTest:test_updatePrice_InvalidFraktionType_ko() (gas: 46174) -FraktionCostBadgesTest:test_updatePrice_InvalidRole_ko() (gas: 17638) -FraktionCostBadgesTest:test_updatePrice_ok() (gas: 126474) +FraktionCostBadgesTest:test_updatePrice_InvalidFraktionType_ko() (gas: 46266) +FraktionCostBadgesTest:test_updatePrice_InvalidRole_ko() (gas: 17661) +FraktionCostBadgesTest:test_updatePrice_ok() (gas: 126566) FraktionTokensTest:test_addContent_InvalidRole_ko() (gas: 18772) FraktionTokensTest:test_addContent_SupplyUpdateNotAllowed_ko() (gas: 69957) FraktionTokensTest:test_addContent_ok() (gas: 329982) FraktionTokensTest:test_batchBalance_ok() (gas: 59813) FraktionTokensTest:test_burn_ok() (gas: 49562) -FraktionTokensTest:test_canBeDeployedAndInit_ok() (gas: 3386823) -FraktionTokensTest:test_initialize_InitTwice_ko() (gas: 15986) +FraktionTokensTest:test_canBeDeployedAndInit_ok() (gas: 3382823) +FraktionTokensTest:test_initialize_InitTwice_ko() (gas: 16008) FraktionTokensTest:test_ownerOf_ok() (gas: 16844) FraktionTokensTest:test_setUpTransferCallback_ok() (gas: 367201) -FraktionTokensTest:test_supply_InvalidRole_ko() (gas: 53366) -FraktionTokensTest:test_supply_SupplyRemaining_ko() (gas: 22701) -FraktionTokensTest:test_supply_SupplyUpdateNotAllowed_ko() (gas: 45918) -FraktionTokensTest:test_supply_ok() (gas: 87732) -MinterTest:test_addContent_InvalidRole_ko() (gas: 17762) -MinterTest:test_addContent_InvalidSupply_ko() (gas: 55555) -MinterTest:test_addContent_ok() (gas: 194470) -MinterTest:test_canBeDeployedAndInit_ok() (gas: 2160631) -MinterTest:test_increaseSupply_InvalidRole_ko() (gas: 62405) -MinterTest:test_increaseSupply_ok() (gas: 75913) -MinterTest:test_initialize_InitTwice_ko() (gas: 22364) -MinterTest:test_mintFraktionForUser_ok() (gas: 212760) +FraktionTokensTest:test_supply_InvalidRole_ko() (gas: 53345) +FraktionTokensTest:test_supply_SupplyUpdateNotAllowed_ko() (gas: 45822) +FraktionTokensTest:test_supply_ok() (gas: 87692) +MinterTest:test_addContent_InvalidRole_ko() (gas: 17808) +MinterTest:test_addContent_InvalidSupply_ko() (gas: 55648) +MinterTest:test_addContent_ok() (gas: 194493) +MinterTest:test_benchmarkAddContent_ok() (gas: 695249) +MinterTest:test_canBeDeployedAndInit_ok() (gas: 2276712) +MinterTest:test_increaseSupply_InvalidRole_ko() (gas: 62383) +MinterTest:test_increaseSupply_ok() (gas: 75939) +MinterTest:test_initialize_InitTwice_ko() (gas: 22408) +MinterTest:test_mintFraktionForUser_ok() (gas: 212716) MinterTest:test_mintFraktion_TooManyFraktion_ko() (gas: 216239) -MinterTest:test_mintFraktion_ok() (gas: 210197) +MinterTest:test_mintFraktion_ok() (gas: 210175) MinterTest:test_mintFreeFraktionForUser_ok() (gas: 60193) MinterTest:test_mintFreeFraktion_ExpectingOnlyFreeFraktion_ko() (gas: 40161) MinterTest:test_mintFreeFraktion_TooManyFraktion_ko() (gas: 61061) -MinterTest:test_mintFreeFraktion_ok() (gas: 62919) +MinterTest:test_mintFreeFraktion_ok() (gas: 62897) MultiVestingWalletsTest:test_canBeDeployedAndInit_ok() (gas: 2667336) MultiVestingWalletsTest:test_createVestBatch() (gas: 210722) MultiVestingWalletsTest:test_createVestBatch_ArrayInvalidLength_ko() (gas: 79027) diff --git a/contracts/fraktions/FraktionTokens.sol b/contracts/fraktions/FraktionTokens.sol index 3f0991d..55f3421 100644 --- a/contracts/fraktions/FraktionTokens.sol +++ b/contracts/fraktions/FraktionTokens.sol @@ -25,9 +25,6 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable { /// @dev Error throwned when we try to update the supply of a non supply aware token error SupplyUpdateNotAllowed(); - /// @dev Error emitted when it remain some fraktion supply when wanting to increase it - error RemainingSupply(); - /// @dev 'bytes4(keccak256("InsuficiantSupply()"))' uint256 private constant _INSUFICIENT_SUPPLY_SELECTOR = 0xa24b545a; @@ -37,9 +34,6 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable { /// @dev 'bytes4(keccak256("SupplyUpdateNotAllowed()"))' uint256 private constant _SUPPLY_UPDATE_NOT_ALLOWED_SELECTOR = 0x48385ebd; - /// @dev 'bytes4(keccak256("RemainingSupply()"))' - uint256 private constant _REMAINING_SUPPLY_SELECTOR = 0x0180e6b4; - /* -------------------------------------------------------------------------- */ /* Event's */ /* -------------------------------------------------------------------------- */ @@ -172,7 +166,7 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable { } /// @dev Set the supply for the given fraktion id - function setSupply(FraktionId id, uint256 supply) external payable onlyRole(FrakRoles.MINTER) { + function addSupply(FraktionId id, uint256 supply) external payable onlyRole(FrakRoles.MINTER) { assembly { // Ensure the supply update of this fraktion type is allowed let fraktionType := and(id, 0xF) @@ -185,15 +179,8 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable { mstore(0, id) mstore(0x20, _availableSupplies.slot) let supplySlot := keccak256(0, 0x40) - // Ensure all the supply has been sold - let currentSupply := sload(supplySlot) - if currentSupply { - mstore(0x00, _REMAINING_SUPPLY_SELECTOR) - revert(0x1c, 0x04) - } - // Get the supply slot and update it - sstore(supplySlot, supply) + sstore(supplySlot, add(sload(supplySlot), supply)) // Emit the supply updated event mstore(0, supply) log2(0, 0x20, _SUPPLY_UPDATED_EVENT_SELECTOR, id) diff --git a/contracts/minter/Minter.sol b/contracts/minter/Minter.sol index 3d15bcd..53e271b 100644 --- a/contracts/minter/Minter.sol +++ b/contracts/minter/Minter.sol @@ -310,7 +310,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu */ function increaseSupply(FraktionId id, uint256 newSupply) external onlyRole(FrakRoles.MINTER) { // Update the supply - fraktionTokens.setSupply(id, newSupply); + fraktionTokens.addSupply(id, newSupply); } /** diff --git a/test/fraktions/FraktionTokens.t.sol b/test/fraktions/FraktionTokens.t.sol index 9c0cbdd..f523e4a 100644 --- a/test/fraktions/FraktionTokens.t.sol +++ b/test/fraktions/FraktionTokens.t.sol @@ -88,7 +88,7 @@ contract FraktionTokensTest is FrakTest { assertEq(fraktionTokens.supplyOf(commonFraktion), 0); // Increase it to one - fraktionTokens.setSupply(commonFraktion, 1); + fraktionTokens.addSupply(commonFraktion, 1); assertEq(fraktionTokens.supplyOf(commonFraktion), 1); // Ensure the fraktion is mintable and the supplies goes back to 0 @@ -98,26 +98,21 @@ contract FraktionTokensTest is FrakTest { function test_supply_InvalidRole_ko() public withEmptySupply(contentId.commonFraktionId()) { vm.expectRevert(NotAuthorized.selector); - fraktionTokens.setSupply(contentId.commonFraktionId(), 1); + fraktionTokens.addSupply(contentId.commonFraktionId(), 1); } function test_supply_SupplyUpdateNotAllowed_ko() public asDeployer { vm.expectRevert(FraktionTokens.SupplyUpdateNotAllowed.selector); - fraktionTokens.setSupply(contentId.toFraktionId(0), 1); + fraktionTokens.addSupply(contentId.toFraktionId(0), 1); vm.expectRevert(FraktionTokens.SupplyUpdateNotAllowed.selector); - fraktionTokens.setSupply(contentId.toFraktionId(1), 1); + fraktionTokens.addSupply(contentId.toFraktionId(1), 1); vm.expectRevert(FraktionTokens.SupplyUpdateNotAllowed.selector); - fraktionTokens.setSupply(contentId.toFraktionId(2), 1); + fraktionTokens.addSupply(contentId.toFraktionId(2), 1); vm.expectRevert(FraktionTokens.SupplyUpdateNotAllowed.selector); - fraktionTokens.setSupply(contentId.toFraktionId(7), 1); - } - - function test_supply_SupplyRemaining_ko() public asDeployer { - vm.expectRevert(FraktionTokens.RemainingSupply.selector); - fraktionTokens.setSupply(contentId.commonFraktionId(), 1); + fraktionTokens.addSupply(contentId.toFraktionId(7), 1); } /* -------------------------------------------------------------------------- */ diff --git a/test_old/minter/Minter.t.sol b/test_old/minter/Minter.t.sol index 2b931d9..02bc57b 100644 --- a/test_old/minter/Minter.t.sol +++ b/test_old/minter/Minter.t.sol @@ -439,14 +439,6 @@ contract MinterTest is FrkTokenTestHelper { minter.increaseSupply(contentId.creatorFraktionId(), 1); } - function test_fail_increaseSupply_RemainingSupply() public prankExecAsDeployer { - // Add an initial content - ContentId contentId = minter.addContent(address(1), 1, 1, 1, 0); - // Revert cause of free fraktion - vm.expectRevert(FraktionTokens.RemainingSupply.selector); - minter.increaseSupply(contentId.commonFraktionId(), 1); - } - /* * ===== TEST : multicall(bytes[] calldata data) ===== */