@@ -465,7 +465,7 @@ abstract contract KlerosCoreXBase is IArbitratorV2, Initializable, UUPSProxiable
465465 /// @param _newStake The new stake.
466466 /// Note that the existing delayed stake will be nullified as non-relevant.
467467 function setStake (uint96 _courtID , uint256 _newStake ) external virtual whenNotPaused {
468- _setStake (msg .sender , _courtID, _newStake, OnError.Revert );
468+ _setStake (msg .sender , _courtID, _newStake);
469469 }
470470
471471 /// @notice Executes a stake change initiated by the system (e.g., processing a delayed stake).
@@ -479,8 +479,7 @@ abstract contract KlerosCoreXBase is IArbitratorV2, Initializable, UUPSProxiable
479479 uint96 _courtID ,
480480 uint256 _newStake
481481 ) external onlyStakeController returns (bool success ) {
482- // TODO: use TRY/CATCH ?? then delete _stakingFailed()
483- return _setStake (_account, _courtID, _newStake, OnError.Return);
482+ return _setStake (_account, _courtID, _newStake);
484483 }
485484
486485 /// @inheritdoc IArbitratorV2
@@ -1078,16 +1077,13 @@ abstract contract KlerosCoreXBase is IArbitratorV2, Initializable, UUPSProxiable
10781077 /// @param _account The account to set the stake for.
10791078 /// @param _courtID The ID of the court to set the stake for.
10801079 /// @param _newStake The new stake.
1081- /// @param _onError Whether to revert or return false on error.
1082- /// @return Whether the stake was successfully set or not.
1083- function _setStake (address _account , uint96 _courtID , uint256 _newStake , OnError _onError ) internal returns (bool ) {
1080+ /// @return success Whether the stake was successfully set or not.
1081+ function _setStake (address _account , uint96 _courtID , uint256 _newStake ) internal returns (bool success ) {
10841082 if (_courtID == FORKING_COURT || _courtID >= courts.length ) {
1085- _stakingFailed (_onError, StakingResult.CannotStakeInThisCourt); // Staking directly into the forking court is not allowed.
1086- return false ;
1083+ revert StakingNotPossibleInThisCourt ();
10871084 }
10881085 if (_newStake != 0 && _newStake < courts[_courtID].minStake) {
1089- _stakingFailed (_onError, StakingResult.CannotStakeLessThanMinStake); // Staking less than the minimum stake is not allowed.
1090- return false ;
1086+ revert StakingLessThanCourtMinStake ();
10911087 }
10921088 (uint256 pnkDeposit , uint256 pnkWithdrawal , StakingResult stakingResult ) = stakeController.setStake (
10931089 _account,
@@ -1097,40 +1093,21 @@ abstract contract KlerosCoreXBase is IArbitratorV2, Initializable, UUPSProxiable
10971093 if (stakingResult == StakingResult.Delayed) {
10981094 return true ;
10991095 }
1100- if (stakingResult != StakingResult.Successful) {
1101- _stakingFailed (_onError, stakingResult);
1102- return false ;
1103- }
11041096 if (pnkDeposit > 0 ) {
11051097 try vault.deposit (_account, pnkDeposit) {
1106- // Successfully deposited PNK
1098+ success = true ;
11071099 } catch {
1108- // Revert with a specific error or reuse existing one
1109- _stakingFailed (_onError, StakingResult.StakingTransferFailed); // Indicating failure in the deposit part of staking
1110- return false ;
1100+ success = false ;
11111101 }
11121102 }
11131103 if (pnkWithdrawal > 0 ) {
11141104 try vault.withdraw (_account, pnkWithdrawal) {
1115- // Successfully withdrew PNK via Vault
1105+ success = true ;
11161106 } catch {
1117- // Revert with a specific error or reuse existing one
1118- _stakingFailed (_onError, StakingResult.UnstakingTransferFailed); // Indicating failure in the withdrawal part of unstaking
1119- return false ;
1107+ success = false ;
11201108 }
11211109 }
1122- return true ;
1123- }
1124-
1125- /// @dev It may revert depending on the _onError parameter.
1126- function _stakingFailed (OnError _onError , StakingResult _result ) internal pure virtual {
1127- if (_onError == OnError.Return) return ;
1128- if (_result == StakingResult.StakingTransferFailed) revert StakingTransferFailed ();
1129- if (_result == StakingResult.UnstakingTransferFailed) revert UnstakingTransferFailed ();
1130- if (_result == StakingResult.CannotStakeInMoreCourts) revert StakingInTooManyCourts ();
1131- if (_result == StakingResult.CannotStakeInThisCourt) revert StakingNotPossibleInThisCourt ();
1132- if (_result == StakingResult.CannotStakeLessThanMinStake) revert StakingLessThanCourtMinStake ();
1133- if (_result == StakingResult.CannotStakeZeroWhenNoStake) revert StakingZeroWhenNoStake ();
1110+ return success;
11341111 }
11351112
11361113 /// @dev Gets a court ID, the minimum number of jurors and an ID of a dispute kit from a specified extra data bytes array.
@@ -1181,8 +1158,6 @@ abstract contract KlerosCoreXBase is IArbitratorV2, Initializable, UUPSProxiable
11811158 error InvalidForkingCourtAsParent ();
11821159 error WrongDisputeKitIndex ();
11831160 error CannotDisableClassicDK ();
1184- error StakingZeroWhenNoStake ();
1185- error StakingInTooManyCourts ();
11861161 error StakingNotPossibleInThisCourt ();
11871162 error StakingLessThanCourtMinStake ();
11881163 error StakingTransferFailed ();
0 commit comments