You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Also note that if the juror has some leftover PNK while not fully unstaked he'll have to manually unstake from all courts to trigger this function.
415
426
/// @param _account The juror whose PNK to withdraw.
416
427
function withdrawLeftoverPNK(address_account) externaloverride {
417
-
Juror storage juror = jurors[_account];
418
428
// Can withdraw the leftover PNK if fully unstaked, has no tokens locked and has positive balance.
419
429
// This withdrawal can't be triggered by calling setStake() in KlerosCore because current stake is technically 0, thus it is done via separate function.
420
-
if (juror.stakedPnk >0&& juror.courtIDs.length==0&& juror.lockedPnk ==0) {
421
-
uint256 amount = juror.stakedPnk;
422
-
juror.stakedPnk =0;
423
-
core.transferBySortitionModule(_account, amount);
424
-
emitLeftoverPNKWithdrawn(_account, amount);
425
-
} else {
426
-
revert("Not eligible for withdrawal.");
427
-
}
430
+
uint256 amount =getJurorLeftoverPNK(_account);
431
+
require(amount >0, "Not eligible for withdrawal.");
/// @param _account The account of the juror withdrawing PNK.
65
70
/// @param _amount The amount of PNK withdrawn.
@@ -280,17 +285,13 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable,
280
285
/// Also note that if the juror has some leftover PNK while not fully unstaked he'll have to manually unstake from all courts to trigger this function.
281
286
/// @param _account The juror whose PNK to withdraw.
282
287
function withdrawLeftoverPNK(address_account) externaloverride {
283
-
Juror storage juror = jurors[_account];
284
288
// Can withdraw the leftover PNK if fully unstaked, has no tokens locked and has positive balance.
285
289
// This withdrawal can't be triggered by calling setStake() in KlerosCore because current stake is technically 0, thus it is done via separate function.
286
-
if (juror.stakedPnk >0&& juror.courtIDs.length==0&& juror.lockedPnk ==0) {
287
-
uint256 amount = juror.stakedPnk;
288
-
juror.stakedPnk =0;
289
-
core.transferBySortitionModule(_account, amount);
290
-
emitLeftoverPNKWithdrawn(_account, amount);
291
-
} else {
292
-
revert("Not eligible for withdrawal.");
293
-
}
290
+
uint256 amount =getJurorLeftoverPNK(_account);
291
+
require(amount >0, "Not eligible for withdrawal.");
292
+
jurors[_account].stakedPnk =0;
293
+
core.transferBySortitionModule(_account, amount);
294
+
emitLeftoverPNKWithdrawn(_account, amount);
294
295
}
295
296
296
297
// ************************************* //
@@ -344,6 +345,14 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable,
344
345
return jurors[_juror].stakedPnk >0;
345
346
}
346
347
348
+
function getJurorLeftoverPNK(address_juror) publicviewoverridereturns (uint256) {
349
+
Juror storage juror = jurors[_juror];
350
+
if (juror.courtIDs.length==0&& juror.lockedPnk ==0) {
0 commit comments