Skip to content

Commit

Permalink
🐛 Don't fail on free fraktion mint if already one present
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Sep 8, 2023
1 parent 35db6fe commit ecb7ac3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion contracts/minter/Minter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/minter/Minter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ecb7ac3

Please sign in to comment.