diff --git a/src/GovernanceStaker.sol b/src/GovernanceStaker.sol index e618514..4617a2c 100644 --- a/src/GovernanceStaker.sol +++ b/src/GovernanceStaker.sol @@ -84,9 +84,6 @@ abstract contract GovernanceStaker is INotifiableRewardReceiver, Multicall, EIP7 /// @notice Emitted when a reward notifier address is enabled or disabled. event RewardNotifierSet(address indexed account, bool isEnabled); - /// @notice Emitted when a surrogate contract is deployed. - event SurrogateDeployed(address indexed delegatee, address indexed surrogate); - /// @notice Thrown when an account attempts a call for which it lacks appropriate permission. /// @param reason Human readable code explaining why the call is unauthorized. /// @param caller The address that attempted the unauthorized call. @@ -822,23 +819,10 @@ abstract contract GovernanceStaker is INotifiableRewardReceiver, Multicall, EIP7 _useNonce(msg.sender); } - /// @notice Internal method which finds the existing surrogate contract—or deploys a new one if - /// none exists—for a given delegatee. - /// @param _delegatee Account for which a surrogate is sought. - /// @return _surrogate The address of the surrogate contract for the delegatee. function _fetchOrDeploySurrogate(address _delegatee) internal virtual - returns (DelegationSurrogate _surrogate) - { - _surrogate = surrogates[_delegatee]; - - if (address(_surrogate) == address(0)) { - _surrogate = new DelegationSurrogateVotes(STAKE_TOKEN, _delegatee); - surrogates[_delegatee] = _surrogate; - emit SurrogateDeployed(_delegatee, address(_surrogate)); - } - } + returns (DelegationSurrogate _surrogate); /// @notice Internal convenience method which calls the `transferFrom` method on the stake token /// contract and reverts on failure. diff --git a/src/GovernanceStakerDelegateSurrogateVotes.sol b/src/GovernanceStakerDelegateSurrogateVotes.sol new file mode 100644 index 0000000..00822f0 --- /dev/null +++ b/src/GovernanceStakerDelegateSurrogateVotes.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: AGPL-3.0-only +pragma solidity ^0.8.23; + +import {DelegationSurrogate} from "src/DelegationSurrogate.sol"; +import {DelegationSurrogateVotes} from "src/DelegationSurrogateVotes.sol"; +import {GovernanceStaker} from "src/GovernanceStaker.sol"; + +abstract contract GovernanceStakerDelegateSurrogateVotes is GovernanceStaker { + /// @notice Emitted when a surrogate contract is deployed. + event SurrogateDeployed(address indexed delegatee, address indexed surrogate); + + /// @notice Internal method which finds the existing surrogate contract—or deploys a new one if + /// none exists—for a given delegatee. + /// @param _delegatee Account for which a surrogate is sought. + /// @return _surrogate The address of the surrogate contract for the delegatee. + function _fetchOrDeploySurrogate(address _delegatee) + internal + virtual + override + returns (DelegationSurrogate _surrogate) + { + _surrogate = surrogates[_delegatee]; + + if (address(_surrogate) == address(0)) { + _surrogate = new DelegationSurrogateVotes(STAKE_TOKEN, _delegatee); + surrogates[_delegatee] = _surrogate; + emit SurrogateDeployed(_delegatee, address(_surrogate)); + } + } +} diff --git a/test/harnesses/GovernanceStakerHarness.sol b/test/harnesses/GovernanceStakerHarness.sol index c8a451b..83a8118 100644 --- a/test/harnesses/GovernanceStakerHarness.sol +++ b/test/harnesses/GovernanceStakerHarness.sol @@ -3,6 +3,8 @@ pragma solidity ^0.8.23; import {DelegationSurrogateVotes} from "src/DelegationSurrogateVotes.sol"; import {GovernanceStaker} from "src/GovernanceStaker.sol"; +import {GovernanceStakerDelegateSurrogateVotes} from + "src/GovernanceStakerDelegateSurrogateVotes.sol"; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol"; @@ -11,7 +13,7 @@ import {IERC20Delegates} from "src/interfaces/IERC20Delegates.sol"; import {IEarningPowerCalculator} from "src/interfaces/IEarningPowerCalculator.sol"; import {DelegationSurrogate} from "src/DelegationSurrogate.sol"; -contract GovernanceStakerHarness is GovernanceStaker { +contract GovernanceStakerHarness is GovernanceStaker, GovernanceStakerDelegateSurrogateVotes { constructor( IERC20 _rewardsToken, IERC20Delegates _stakeToken,