Skip to content

Commit

Permalink
refactor: rename trusted claimer to trusted receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
jparklev committed Sep 2, 2024
1 parent d093359 commit 33454cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 8 additions & 8 deletions contracts/PointTokenVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall

mapping(address => uint256) public caps; // asset => deposit cap

mapping(address => mapping(address => bool)) public trustedClaimers; // owner => delegate => trustedClaimers
mapping(address => mapping(address => bool)) public trustedReceivers; // owner => delegate => trustedReceivers

// Fees
uint256 public mintFee;
Expand All @@ -66,7 +66,7 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall

event Deposit(address indexed depositor, address indexed receiver, address indexed token, uint256 amount);
event Withdraw(address indexed withdrawer, address indexed receiver, address indexed token, uint256 amount);
event TrustClaimer(address indexed owner, address indexed delegate, bool isTrusted);
event TrustReceiver(address indexed owner, address indexed delegate, bool isTrusted);
event RootUpdated(bytes32 prevRoot, bytes32 newRoot);
event PTokensClaimed(
address indexed account, address indexed receiver, bytes32 indexed pointsId, uint256 amount, uint256 fee
Expand Down Expand Up @@ -95,7 +95,7 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
error DepositExceedsCap();
error PTokenNotDeployed();
error AmountTooSmall();
error NotTrustedClaimer();
error NotTrustedReceiver();

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
Expand Down Expand Up @@ -149,8 +149,8 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
revert PTokenNotDeployed();
}

if (_account != _receiver && !trustedClaimers[_account][_receiver]) {
revert NotTrustedClaimer();
if (_account != _receiver && !trustedReceivers[_account][_receiver]) {
revert NotTrustedReceiver();
}

uint256 pTokenFee = FixedPointMathLib.mulWadUp(_claim.amountToClaim, mintFee);
Expand All @@ -161,9 +161,9 @@ contract PointTokenVault is UUPSUpgradeable, AccessControlUpgradeable, Multicall
emit PTokensClaimed(_account, _receiver, pointsId, _claim.amountToClaim, pTokenFee);
}

function trustClaimer(address _account, bool _isTrusted) public {
trustedClaimers[msg.sender][_account] = _isTrusted;
emit TrustClaimer(msg.sender, _account, _isTrusted);
function trustReceiver(address _account, bool _isTrusted) public {
trustedReceivers[msg.sender][_account] = _isTrusted;
emit TrustReceiver(msg.sender, _account, _isTrusted);
}

/// @notice Redeems point tokens for rewards
Expand Down
14 changes: 8 additions & 6 deletions contracts/test/PointTokenVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ contract PointTokenVaultTest is Test {
assertEq(pointTokenVault.pTokens(eigenPointsId).balanceOf(vitalik), 1e18);
}

function test_TrustedClaimer() public {
function test_TrustedReceiver() public {
bytes32 root = 0x4e40a10ce33f33a4786960a8bb843fe0e170b651acd83da27abc97176c4bed3c;

bytes32[] memory proof = new bytes32[](1);
Expand All @@ -489,12 +489,12 @@ contract PointTokenVaultTest is Test {

// Toly tries to claim vitalik's pTokens (should fail)
vm.prank(toly);
vm.expectRevert(PointTokenVault.NotTrustedClaimer.selector);
vm.expectRevert(PointTokenVault.NotTrustedReceiver.selector);
pointTokenVault.claimPTokens(PointTokenVault.Claim(eigenPointsId, 1e18, 0.6e18, proof), vitalik, toly);

// Vitalik delegates claiming rights to Toly
vm.prank(vitalik);
pointTokenVault.trustClaimer(toly, true);
pointTokenVault.trustReceiver(toly, true);

// Toly claims the half of Vitalik's pTokens
vm.prank(toly);
Expand Down Expand Up @@ -565,16 +565,18 @@ contract PointTokenVaultTest is Test {
}

event FeeCollectorSet(address feeCollector);

function test_setFeeCollector() public {
vm.prank(admin);
vm.expectEmit(true,true,true,true);
vm.expectEmit(true, true, true, true);
emit FeeCollectorSet(toly);
pointTokenVault.setFeeCollector(toly);

vm.expectRevert(
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector, address(vitalik), pointTokenVault.DEFAULT_ADMIN_ROLE()
IAccessControl.AccessControlUnauthorizedAccount.selector,
address(vitalik),
pointTokenVault.DEFAULT_ADMIN_ROLE()
)
);
vm.prank(vitalik);
Expand Down

0 comments on commit 33454cd

Please sign in to comment.