From 9e847bb0717d67bf609dd721cec9f2494ea77e9a Mon Sep 17 00:00:00 2001 From: iain nash Date: Tue, 1 Aug 2023 11:16:34 -0400 Subject: [PATCH] =?UTF-8?q?code=20cleanup=20=E2=80=93=20naming=20and=20sli?= =?UTF-8?q?ther=20recommendations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ProtocolRewards.sol | 8 +++---- .../ERC721/ERC721RewardsStorageV1.sol | 2 +- src/abstract/RewardSplits.sol | 24 +++++++++---------- test/ProtocolRewardsTest.sol | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ProtocolRewards.sol b/src/ProtocolRewards.sol index fa55e34..5047189 100644 --- a/src/ProtocolRewards.sol +++ b/src/ProtocolRewards.sol @@ -150,6 +150,8 @@ contract ProtocolRewards is IProtocolRewards, EIP712 { balanceOf[owner] -= amount; } + emit Withdraw(owner, amount); + (bool success, ) = owner.call{value: amount, gas: WITHDRAW_GAS_LIMIT}( "" ); @@ -157,8 +159,6 @@ contract ProtocolRewards is IProtocolRewards, EIP712 { if (!success) { revert TRANSFER_FAILED(); } - - emit Withdraw(owner, amount); } function withdrawWithSig( @@ -203,6 +203,8 @@ contract ProtocolRewards is IProtocolRewards, EIP712 { balanceOf[owner] -= amount; } + emit Withdraw(owner, amount); + (bool success, ) = owner.call{value: amount, gas: WITHDRAW_GAS_LIMIT}( "" ); @@ -210,7 +212,5 @@ contract ProtocolRewards is IProtocolRewards, EIP712 { if (!success) { revert TRANSFER_FAILED(); } - - emit Withdraw(owner, amount); } } diff --git a/src/abstract/ERC721/ERC721RewardsStorageV1.sol b/src/abstract/ERC721/ERC721RewardsStorageV1.sol index 7bd0f27..0e352e5 100644 --- a/src/abstract/ERC721/ERC721RewardsStorageV1.sol +++ b/src/abstract/ERC721/ERC721RewardsStorageV1.sol @@ -3,4 +3,4 @@ pragma solidity 0.8.17; abstract contract ERC721RewardsStorageV1 { address public createReferral; -} \ No newline at end of file +} diff --git a/src/abstract/RewardSplits.sol b/src/abstract/RewardSplits.sol index 7a53c12..6baabe2 100644 --- a/src/abstract/RewardSplits.sol +++ b/src/abstract/RewardSplits.sol @@ -22,16 +22,16 @@ abstract contract RewardSplits { uint256 internal constant CREATE_REFERRAL_PAID_MINT_REWARD = 0.000222 ether; uint256 internal constant ZORA_PAID_MINT_REWARD = 0.000222 ether; - address internal immutable ZORA_REWARD_RECIPIENT; - IProtocolRewards internal immutable PROTOCOL_REWARDS; + address internal immutable zoraRewardRecipient; + IProtocolRewards internal immutable protocolRewards; constructor(address _protocolRewards, address _zoraRewardRecipient) payable { if (_protocolRewards == address(0) || _zoraRewardRecipient == address(0)) { revert INVALID_ADDRESS_ZERO(); } - PROTOCOL_REWARDS = IProtocolRewards(_protocolRewards); - ZORA_REWARD_RECIPIENT = _zoraRewardRecipient; + protocolRewards = IProtocolRewards(_protocolRewards); + zoraRewardRecipient = _zoraRewardRecipient; } function computeTotalReward(uint256 numTokens) public pure returns (uint256) { @@ -88,14 +88,14 @@ abstract contract RewardSplits { ) = computeFreeMintRewards(numTokens); if (mintReferral == address(0)) { - mintReferral = ZORA_REWARD_RECIPIENT; + mintReferral = zoraRewardRecipient; } if (createReferral == address(0)) { - createReferral = ZORA_REWARD_RECIPIENT; + createReferral = zoraRewardRecipient; } - PROTOCOL_REWARDS.depositRewards{ value: totalReward }( + protocolRewards.depositRewards{ value: totalReward }( creator, creatorReward, mintReferral, @@ -104,7 +104,7 @@ abstract contract RewardSplits { createReferralReward, creator, firstMinterReward, - ZORA_REWARD_RECIPIENT, + zoraRewardRecipient, zoraReward ); } @@ -120,14 +120,14 @@ abstract contract RewardSplits { computePaidMintRewards(numTokens); if (mintReferral == address(0)) { - mintReferral = ZORA_REWARD_RECIPIENT; + mintReferral = zoraRewardRecipient; } if (createReferral == address(0)) { - createReferral = ZORA_REWARD_RECIPIENT; + createReferral = zoraRewardRecipient; } - PROTOCOL_REWARDS.depositRewards{ value: totalReward }( + protocolRewards.depositRewards{ value: totalReward }( address(0), 0, mintReferral, @@ -136,7 +136,7 @@ abstract contract RewardSplits { createReferralReward, creator, firstMinterReward, - ZORA_REWARD_RECIPIENT, + zoraRewardRecipient, zoraReward ); } diff --git a/test/ProtocolRewardsTest.sol b/test/ProtocolRewardsTest.sol index 12c41df..1986bf1 100644 --- a/test/ProtocolRewardsTest.sol +++ b/test/ProtocolRewardsTest.sol @@ -19,7 +19,7 @@ contract ProtocolRewardsTest is Test { function setUp() public virtual { protocolRewards = new ProtocolRewards(); - vm.label(address(protocolRewards), "PROTOCOL_REWARDS"); + vm.label(address(protocolRewards), "protocolRewards"); collector = makeAddr("collector"); creator = makeAddr("creator");