From ecb7ac3826ab8ecd1f5815a1227bcdf62cab73ae Mon Sep 17 00:00:00 2001 From: KONFeature Date: Fri, 8 Sep 2023 09:36:20 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20fail=20on=20free=20frakt?= =?UTF-8?q?ion=20mint=20if=20already=20one=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 6 +++--- contracts/minter/Minter.sol | 2 +- test/minter/Minter.t.sol | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 7262583..e974f49 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -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: 3633) +FrakTokenTest:invariant_cap_lt_supply() (runs: 256, calls: 3840, reverts: 3621) FrakTokenTest:test_burn_ok() (gas: 53287) FrakTokenTest:test_canBeDeployedAndInit_ok() (gas: 2502575) FrakTokenTest:test_cap_ok() (gas: 10366) @@ -60,7 +60,7 @@ 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_canBeDeployedAndInit_ok() (gas: 2267698) MinterTest:test_increaseSupply_InvalidRole_ko() (gas: 62383) MinterTest:test_increaseSupply_ok() (gas: 75939) MinterTest:test_initialize_InitTwice_ko() (gas: 22408) @@ -69,7 +69,7 @@ MinterTest:test_mintFraktion_TooManyFraktion_ko() (gas: 216239) 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_TooManyFraktion_ko() (gas: 66087) MinterTest:test_mintFreeFraktion_ok() (gas: 62897) MultiVestingWalletsTest:test_canBeDeployedAndInit_ok() (gas: 2667336) MultiVestingWalletsTest:test_createVestBatch() (gas: 210722) diff --git a/contracts/minter/Minter.sol b/contracts/minter/Minter.sol index 53e271b..14179fe 100644 --- a/contracts/minter/Minter.sol +++ b/contracts/minter/Minter.sol @@ -379,7 +379,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu // Get the current user balance, and exit if he already got a fraktion of this type uint256 balance = fraktionTokens.balanceOf(to, FraktionId.unwrap(id)); if (balance != 0) { - revert TooManyFraktion(); + return; } // If we are all good, mint the free fraktion to the user diff --git a/test/minter/Minter.t.sol b/test/minter/Minter.t.sol index 650b916..dffff8d 100644 --- a/test/minter/Minter.t.sol +++ b/test/minter/Minter.t.sol @@ -131,10 +131,11 @@ contract MinterTest is FrakTest { FraktionId freeFraktionId = contentId.freeFraktionId(); vm.prank(user); minter.mintFreeFraktion(freeFraktionId); + uint256 freeFraktionBalance = fraktionTokens.balanceOf(user, FraktionId.unwrap(freeFraktionId)); - vm.expectRevert(IMinter.TooManyFraktion.selector); vm.prank(user); minter.mintFreeFraktion(freeFraktionId); + assertEq(fraktionTokens.balanceOf(user, FraktionId.unwrap(freeFraktionId)), freeFraktionBalance); } function test_mintFreeFraktion_ExpectingOnlyFreeFraktion_ko() public {