Skip to content

Commit

Permalink
add sendPraise to interface, forge fmt, remove some checks
Browse files Browse the repository at this point in the history
  • Loading branch information
divine-comedian committed Feb 19, 2024
1 parent 1c30d00 commit ef0e40c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 2 additions & 5 deletions contracts/ModifiedTokenDistro.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IDistroModified.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 4 additions & 5 deletions test/ModifyTokenDistro.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ 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;

constructor() {
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));
Expand All @@ -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);
Expand Down

0 comments on commit ef0e40c

Please sign in to comment.