From 3fbed496228ed4d641ce2b4765477e0e7f9d9257 Mon Sep 17 00:00:00 2001 From: Yash Patil Date: Tue, 5 Nov 2024 22:11:09 -0800 Subject: [PATCH] feat: update RC interface --- src/contracts/core/DelegationManager.sol | 2 +- src/contracts/core/RewardsCoordinator.sol | 9 +++--- .../interfaces/IAllocationManager.sol | 1 + .../interfaces/IRewardsCoordinator.sol | 16 +++++----- src/test/unit/RewardsCoordinatorUnit.t.sol | 30 +++++++++---------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/contracts/core/DelegationManager.sol b/src/contracts/core/DelegationManager.sol index 1146ff8dc..005990bd8 100644 --- a/src/contracts/core/DelegationManager.sol +++ b/src/contracts/core/DelegationManager.sol @@ -150,7 +150,7 @@ contract DelegationManager is require(staker != address(0), InputAddressZero()); address operator = delegatedTo[staker]; require( - msg.sender == staker || checkCanCall(operator) + msg.sender == staker || _checkCanCall(operator) || msg.sender == _operatorDetails[operator].delegationApprover, CallerCannotUndelegate() ); diff --git a/src/contracts/core/RewardsCoordinator.sol b/src/contracts/core/RewardsCoordinator.sol index 09bdfc20c..1b30c9395 100644 --- a/src/contracts/core/RewardsCoordinator.sol +++ b/src/contracts/core/RewardsCoordinator.sol @@ -217,18 +217,17 @@ contract RewardsCoordinator is } /// @inheritdoc IRewardsCoordinator - function setClaimerForStaker( + function setClaimerFor( address claimer ) external { - require(!delegationManager.isOperator(msg.sender), UnauthorizedCaller()); address earner = msg.sender; _setClaimer(earner, claimer); } /// @inheritdoc IRewardsCoordinator - function setClaimerForOperator(address operator, address claimer) external checkCanCall(operator) { - require(delegationManager.isOperator(operator), UnauthorizedCaller()); - _setClaimer(operator, claimer); + // TODO: stakers can still use this function, no way to introspect that caller is an AVS. Need to add storage in ALM if an avs exists + function setClaimerFor(address earner, address claimer) external checkCanCall(earner) { + _setClaimer(earner, claimer); } /// @inheritdoc IRewardsCoordinator diff --git a/src/contracts/interfaces/IAllocationManager.sol b/src/contracts/interfaces/IAllocationManager.sol index bd1a36de2..3948c00d7 100644 --- a/src/contracts/interfaces/IAllocationManager.sol +++ b/src/contracts/interfaces/IAllocationManager.sol @@ -309,6 +309,7 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo * @dev Note that the `metadataURI` is *never stored* and is only emitted in the `AVSMetadataURIUpdated` event. */ function updateAVSMetadataURI( + address avs, string calldata metadataURI ) external; diff --git a/src/contracts/interfaces/IRewardsCoordinator.sol b/src/contracts/interfaces/IRewardsCoordinator.sol index 5015543eb..3e5148df6 100644 --- a/src/contracts/interfaces/IRewardsCoordinator.sol +++ b/src/contracts/interfaces/IRewardsCoordinator.sol @@ -333,22 +333,22 @@ interface IRewardsCoordinator is IRewardsCoordinatorErrors, IRewardsCoordinatorE ) external; /** - * @notice Sets the address of the entity that can call `processClaim` on behalf of a staker + * @notice Sets the address of the entity that can call `processClaim` on ehalf of an earner * @param claimer The address of the entity that can call `processClaim` on behalf of the earner - * @dev Only callable by the `earner` if it is a staker + * @dev Assumes msg.sender is the earner */ - function setClaimerForStaker( + function setClaimerFor( address claimer ) external; /** - * @notice Sets the address of the entity that can call `processClaim` on behalf of an operator - * @param operator The address to set the claimer for + * @notice Sets the address of the entity that can call `processClaim` on behalf of an earner + * @param earner The address to set the claimer for * @param claimer The address of the entity that can call `processClaim` on behalf of the earner - * @dev Only callable by or on behalf of an operator. + * @dev Only callable by an address that configures the claimer */ - function setClaimerForOperator( - address operator, + function setClaimerFor( + address earner, address claimer ) external; diff --git a/src/test/unit/RewardsCoordinatorUnit.t.sol b/src/test/unit/RewardsCoordinatorUnit.t.sol index 091c84e19..219ace27c 100644 --- a/src/test/unit/RewardsCoordinatorUnit.t.sol +++ b/src/test/unit/RewardsCoordinatorUnit.t.sol @@ -285,11 +285,11 @@ contract RewardsCoordinatorUnitTests is EigenLayerUnitTestSetup, IRewardsCoordin } contract RewardsCoordinatorUnitTests_initializeAndSetters is RewardsCoordinatorUnitTests { - function testFuzz_setClaimerForStaker(address earner, address claimer) public filterFuzzedAddressInputs(earner) { + function testFuzz_setClaimerFor(address earner, address claimer) public filterFuzzedAddressInputs(earner) { cheats.startPrank(earner); cheats.expectEmit(true, true, true, true, address(rewardsCoordinator)); emit ClaimerForSet(earner, rewardsCoordinator.claimerFor(earner), claimer); - rewardsCoordinator.setClaimerForStaker(claimer); + rewardsCoordinator.setClaimerFor(claimer); assertEq(claimer, rewardsCoordinator.claimerFor(earner), "claimerFor not set"); cheats.stopPrank(); } @@ -1447,7 +1447,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1496,7 +1496,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1545,7 +1545,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1660,7 +1660,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1694,7 +1694,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1763,7 +1763,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1804,7 +1804,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1843,7 +1843,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1884,7 +1884,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1922,7 +1922,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -1960,7 +1960,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -2025,7 +2025,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner; @@ -2090,7 +2090,7 @@ contract RewardsCoordinatorUnitTests_processClaim is RewardsCoordinatorUnitTests address claimer; if (setClaimerFor) { cheats.prank(earner); - rewardsCoordinator.setClaimerForStaker(claimerFor); + rewardsCoordinator.setClaimerFor(claimerFor); claimer = claimerFor; } else { claimer = earner;