From ef0e40c0ffa1667d5b1aa3cef43e88b530073d40 Mon Sep 17 00:00:00 2001 From: Mitch Oz Date: Mon, 19 Feb 2024 13:15:53 -0600 Subject: [PATCH] add sendPraise to interface, forge fmt, remove some checks --- contracts/ModifiedTokenDistro.sol | 7 ++----- contracts/interfaces/IDistroModified.sol | 2 ++ test/ModifyTokenDistro.t.sol | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/contracts/ModifiedTokenDistro.sol b/contracts/ModifiedTokenDistro.sol index 4ce0444..0bbef6c 100644 --- a/contracts/ModifiedTokenDistro.sol +++ b/contracts/ModifiedTokenDistro.sol @@ -12,7 +12,7 @@ import './interfaces/IDistroModified.sol'; * The distributor is in charge of releasing the corresponding amounts to its recipients. * This distributor is expected to be another smart contract, such as a merkledrop or the liquidity mining smart contract */ -contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgradeable { +contract TokenDistroV1 is Initializable, IDistro, AccessControlEnumerableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; // bytes32 public constant DISTRIBUTOR_ROLE = keccak256("DISTRIBUTOR_ROLE"); @@ -261,7 +261,6 @@ contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgrade function claimableAt(address recipient, uint256 timestamp) public view override returns (uint256) { require(!hasRole(DISTRIBUTOR_ROLE, recipient), 'TokenDistro::claimableAt: DISTRIBUTOR_ROLE_CANNOT_CLAIM'); require(timestamp >= getTimestamp(), 'TokenDistro::claimableAt: NOT_VALID_PAST_TIMESTAMP'); - require(totalTokens > 0, 'TokenDistro::claimableAt: TOTAL_TOKENS_ZERO'); uint256 unlockedAmount = (globallyClaimableAt(timestamp) * balances[recipient].allocatedTokens) / totalTokens; if (unlockedAmount > balances[recipient].claimed) return unlockedAmount - balances[recipient].claimed; return 0; @@ -324,9 +323,7 @@ contract TokenDistroV2 is Initializable, IDistro, AccessControlEnumerableUpgrade function _transferAllocation(address prevRecipient, address newRecipient) internal { require( - balances[prevRecipient].allocatedTokens > 0 - && balances[prevRecipient].allocatedTokens != balances[prevRecipient].claimed, - 'TokenDistro::transferAllocation: NO_ALLOCATION_TO_TRANSFER' + balances[prevRecipient].allocatedTokens > 0, 'TokenDistro::transferAllocation: NO_ALLOCATION_TO_TRANSFER' ); require( !hasRole(DISTRIBUTOR_ROLE, prevRecipient) && !hasRole(DISTRIBUTOR_ROLE, newRecipient), diff --git a/contracts/interfaces/IDistroModified.sol b/contracts/interfaces/IDistroModified.sol index 1709e57..bcac027 100644 --- a/contracts/interfaces/IDistroModified.sol +++ b/contracts/interfaces/IDistroModified.sol @@ -99,4 +99,6 @@ interface IDistro { function claimableNow(address recipient) external view returns (uint256); function transferAllocation(address prevRecipient, address newRecipient) external; + + function sendPraiseRewards(address[] memory recipients, uint256[] memory amounts) external; } diff --git a/test/ModifyTokenDistro.t.sol b/test/ModifyTokenDistro.t.sol index f492cb7..e6e5531 100644 --- a/test/ModifyTokenDistro.t.sol +++ b/test/ModifyTokenDistro.t.sol @@ -27,8 +27,8 @@ contract TestModifyDistro is Test { // deploy the token distro TransparentUpgradeableProxy tokenDistroProxy; IDistro tokenDistroInterface; - TokenDistroV2 tokenDistro; - TokenDistroV2 tokenDistroImplementation; + TokenDistroV1 tokenDistro; + TokenDistroV1 tokenDistroImplementation; uint256 assignedAmount = 10000000000000000000000000; uint256 forkBlock = 22501098; @@ -36,7 +36,7 @@ contract TestModifyDistro is Test { uint256 forkId = vm.createFork('https://rpc.ankr.com/gnosis', forkBlock); //https://xdai-archive.blockscout.com/ vm.selectFork(forkId); proxyAdmin = ProxyAdmin(address(0x076C250700D210e6cf8A27D1EB1Fd754FB487986)); - tokenDistro = TokenDistroV2(address(0xc0dbDcA66a0636236fAbe1B3C16B1bD4C84bB1E1)); + tokenDistro = TokenDistroV1(address(0xc0dbDcA66a0636236fAbe1B3C16B1bD4C84bB1E1)); tokenDistroProxy = TransparentUpgradeableProxy(payable(address(0xc0dbDcA66a0636236fAbe1B3C16B1bD4C84bB1E1))); givethMultisig = 0x4D9339dd97db55e3B9bCBE65dE39fF9c04d1C2cd; givToken = IERC20Upgradeable(address(0x4f4F9b8D5B4d0Dc10506e5551B0513B61fD59e75)); @@ -48,8 +48,7 @@ contract TestModifyDistro is Test { function setUp() public { vm.startPrank(givethMultisig); - tokenDistroImplementation = new TokenDistroV2(); - // proxyAdmin.upgradeAndCall(tokenDistroProxy, address(tokenDistroImplementation), abi.encodeWithSelector(TokenDistroV2(tokenDistroImplementation).initialize.selector, 2000000000000000000000000000, 1640361600, 1640361600, 157680000, givToken, true)); + tokenDistroImplementation = new TokenDistroV1(); proxyAdmin.upgrade(tokenDistroProxy, address(tokenDistroImplementation)); tokenDistro.grantRole(keccak256('DISTRIBUTOR_ROLE'), distributor); tokenDistro.assign(distributor, assignedAmount);