Skip to content

Commit 89dee66

Browse files
committed
fix: remove redundant code (OZ N-01)
Signed-off-by: Tomás Migone <[email protected]>
1 parent c25cc25 commit 89dee66

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

packages/horizon/contracts/staking/HorizonStaking.sol

+7-26
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
295295
address verifier,
296296
uint256 shares
297297
) external override notPaused returns (bytes32) {
298-
return _undelegate(ThawRequestType.Delegation, serviceProvider, verifier, shares, msg.sender);
298+
return _undelegate(serviceProvider, verifier, shares);
299299
}
300300

301301
/// @inheritdoc IHorizonStakingMain
@@ -304,15 +304,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
304304
address verifier,
305305
uint256 nThawRequests
306306
) external override notPaused {
307-
_withdrawDelegated(
308-
ThawRequestType.Delegation,
309-
serviceProvider,
310-
verifier,
311-
address(0),
312-
address(0),
313-
0,
314-
nThawRequests
315-
);
307+
_withdrawDelegated(serviceProvider, verifier, address(0), address(0), 0, nThawRequests);
316308
}
317309

318310
/// @inheritdoc IHorizonStakingMain
@@ -327,7 +319,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
327319
require(newServiceProvider != address(0), HorizonStakingInvalidServiceProviderZeroAddress());
328320
require(newVerifier != address(0), HorizonStakingInvalidVerifierZeroAddress());
329321
_withdrawDelegated(
330-
ThawRequestType.Delegation,
331322
oldServiceProvider,
332323
oldVerifier,
333324
newServiceProvider,
@@ -358,7 +349,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
358349

359350
/// @inheritdoc IHorizonStakingMain
360351
function undelegate(address serviceProvider, uint256 shares) external override notPaused {
361-
_undelegate(ThawRequestType.Delegation, serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares, msg.sender);
352+
_undelegate(serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares);
362353
}
363354

364355
/// @inheritdoc IHorizonStakingMain
@@ -913,20 +904,12 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
913904
* invalidated.
914905
* @dev Note that delegation that is caught thawing when the pool is invalidated will be completely lost! However delegation shares
915906
* that were not thawing will be preserved.
916-
* @param _requestType The type of thaw request (Provision or Delegation).
917907
* @param _serviceProvider The service provider address
918908
* @param _verifier The verifier address
919909
* @param _shares The amount of shares to undelegate
920-
* @param _beneficiary The beneficiary address
921910
* @return The ID of the thaw request
922911
*/
923-
function _undelegate(
924-
ThawRequestType _requestType,
925-
address _serviceProvider,
926-
address _verifier,
927-
uint256 _shares,
928-
address _beneficiary
929-
) private returns (bytes32) {
912+
function _undelegate(address _serviceProvider, address _verifier, uint256 _shares) private returns (bytes32) {
930913
require(_shares > 0, HorizonStakingInvalidZeroShares());
931914
DelegationPoolInternal storage pool = _getDelegationPool(_serviceProvider, _verifier);
932915
DelegationInternal storage delegation = pool.delegators[msg.sender];
@@ -958,10 +941,10 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
958941
}
959942

960943
bytes32 thawRequestId = _createThawRequest(
961-
_requestType,
944+
ThawRequestType.Delegation,
962945
_serviceProvider,
963946
_verifier,
964-
_beneficiary,
947+
msg.sender,
965948
thawingShares,
966949
thawingUntil,
967950
pool.thawingNonce
@@ -978,7 +961,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
978961
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
979962
* @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill
980963
* the thaw requests with an amount equal to zero.
981-
* @param _requestType The type of thaw request (Provision or Delegation).
982964
* @param _serviceProvider The service provider address
983965
* @param _verifier The verifier address
984966
* @param _newServiceProvider The new service provider address
@@ -987,7 +969,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
987969
* @param _nThawRequests The number of thaw requests to fulfill. Set to 0 to fulfill all thaw requests.
988970
*/
989971
function _withdrawDelegated(
990-
ThawRequestType _requestType,
991972
address _serviceProvider,
992973
address _verifier,
993974
address _newServiceProvider,
@@ -1008,7 +989,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
1008989
uint256 tokensThawing = pool.tokensThawing;
1009990

1010991
FulfillThawRequestsParams memory params = FulfillThawRequestsParams({
1011-
requestType: _requestType,
992+
requestType: ThawRequestType.Delegation,
1012993
serviceProvider: _serviceProvider,
1013994
verifier: _verifier,
1014995
owner: msg.sender,

0 commit comments

Comments
 (0)