@@ -297,20 +297,20 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
297297 address verifier ,
298298 uint256 shares
299299 ) external override notPaused returns (bytes32 ) {
300- return _undelegate (serviceProvider, verifier, shares, msg .sender );
300+ return _undelegate (ThawRequestType.Delegation, serviceProvider, verifier, shares, msg .sender );
301301 }
302302
303303 /**
304304 * @notice See {IHorizonStakingMain-undelegate}.
305305 */
306- function undelegate (
306+ function undelegateWithBeneficiary (
307307 address serviceProvider ,
308308 address verifier ,
309309 uint256 shares ,
310310 address beneficiary
311311 ) external override notPaused returns (bytes32 ) {
312312 require (beneficiary != address (0 ), HorizonStakingInvalidBeneficiaryZeroAddress ());
313- return _undelegate (serviceProvider, verifier, shares, beneficiary);
313+ return _undelegate (ThawRequestType.DelegationWithBeneficiary, serviceProvider, verifier, shares, beneficiary);
314314 }
315315
316316 /**
@@ -321,7 +321,34 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
321321 address verifier ,
322322 uint256 nThawRequests
323323 ) external override notPaused {
324- _withdrawDelegated (serviceProvider, verifier, address (0 ), address (0 ), 0 , nThawRequests);
324+ _withdrawDelegated (
325+ ThawRequestType.Delegation,
326+ serviceProvider,
327+ verifier,
328+ address (0 ),
329+ address (0 ),
330+ 0 ,
331+ nThawRequests
332+ );
333+ }
334+
335+ /**
336+ * @notice See {IHorizonStakingMain-withdrawDelegatedWithBeneficiary}.
337+ */
338+ function withdrawDelegatedWithBeneficiary (
339+ address serviceProvider ,
340+ address verifier ,
341+ uint256 nThawRequests
342+ ) external override notPaused {
343+ _withdrawDelegated (
344+ ThawRequestType.DelegationWithBeneficiary,
345+ serviceProvider,
346+ verifier,
347+ address (0 ),
348+ address (0 ),
349+ 0 ,
350+ nThawRequests
351+ );
325352 }
326353
327354 /**
@@ -338,6 +365,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
338365 require (newServiceProvider != address (0 ), HorizonStakingInvalidServiceProviderZeroAddress ());
339366 require (newVerifier != address (0 ), HorizonStakingInvalidVerifierZeroAddress ());
340367 _withdrawDelegated (
368+ ThawRequestType.Delegation,
341369 oldServiceProvider,
342370 oldVerifier,
343371 newServiceProvider,
@@ -374,14 +402,15 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
374402 * @notice See {IHorizonStakingMain-undelegate}.
375403 */
376404 function undelegate (address serviceProvider , uint256 shares ) external override notPaused {
377- _undelegate (serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares, msg .sender );
405+ _undelegate (ThawRequestType.Delegation, serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares, msg .sender );
378406 }
379407
380408 /**
381409 * @notice See {IHorizonStakingMain-withdrawDelegated}.
382410 */
383411 function withdrawDelegated (address serviceProvider , address newServiceProvider ) external override notPaused {
384412 _withdrawDelegated (
413+ ThawRequestType.Delegation,
385414 serviceProvider,
386415 SUBGRAPH_DATA_SERVICE_ADDRESS,
387416 newServiceProvider,
@@ -837,6 +866,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
837866 * that were not thawing will be preserved.
838867 */
839868 function _undelegate (
869+ ThawRequestType _requestType ,
840870 address _serviceProvider ,
841871 address _verifier ,
842872 uint256 _shares ,
@@ -864,7 +894,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
864894 delegation.shares = delegation.shares - _shares;
865895
866896 bytes32 thawRequestId = _createThawRequest (
867- ThawRequestType.Delegation ,
897+ _requestType ,
868898 _serviceProvider,
869899 _verifier,
870900 _beneficiary,
@@ -881,6 +911,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
881911 * @notice See {IHorizonStakingMain-withdrawDelegated}.
882912 */
883913 function _withdrawDelegated (
914+ ThawRequestType _requestType ,
884915 address _serviceProvider ,
885916 address _verifier ,
886917 address _newServiceProvider ,
@@ -901,7 +932,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
901932 uint256 tokensThawing = pool.tokensThawing;
902933
903934 FulfillThawRequestsParams memory params = FulfillThawRequestsParams ({
904- requestType: ThawRequestType.Delegation ,
935+ requestType: _requestType ,
905936 serviceProvider: _serviceProvider,
906937 verifier: _verifier,
907938 owner: msg .sender ,
@@ -1082,8 +1113,10 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
10821113 return _deleteProvisionThawRequest;
10831114 } else if (_requestType == ThawRequestType.Delegation) {
10841115 return _deleteDelegationThawRequest;
1116+ } else if (_requestType == ThawRequestType.DelegationWithBeneficiary) {
1117+ return _deleteDelegationWithBeneficiaryThawRequest;
10851118 } else {
1086- revert ( " Unknown ThawRequestType " );
1119+ revert HorizonStakingInvalidThawRequestType ( );
10871120 }
10881121 }
10891122
@@ -1103,6 +1136,14 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
11031136 delete _delegationThawRequests[_thawRequestId];
11041137 }
11051138
1139+ /**
1140+ * @notice Deletes a thaw request for a delegation with a beneficiary.
1141+ * @param _thawRequestId The ID of the thaw request to delete.
1142+ */
1143+ function _deleteDelegationWithBeneficiaryThawRequest (bytes32 _thawRequestId ) private {
1144+ delete _delegationWithBeneficiaryThawRequests[_thawRequestId];
1145+ }
1146+
11061147 /**
11071148 * @notice See {IHorizonStakingMain-setOperator}.
11081149 * @dev Note that this function handles the special case where the verifier is the subgraph data service,
0 commit comments