From f66542388ef80b2b55778def4487dbdd556a9a3f Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Sat, 31 Aug 2024 14:52:02 +0200 Subject: [PATCH] stake-contract: allow partial reward withdrawal --- contracts/stake/src/state.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index 36e7f111b3..d46afddf9e 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -194,8 +194,8 @@ impl StakeState { panic!("There is no reward available to withdraw"); } - if value != loaded_stake.reward { - panic!("Value withdrawn different from available reward"); + if value > loaded_stake.reward { + panic!("Value withdrawn higher than available reward"); } // check signature is correct @@ -211,7 +211,7 @@ impl StakeState { .expect("Withdrawing reward should succeed"); // update the state accordingly - loaded_stake.reward = 0; + loaded_stake.reward -= value; rusk_abi::emit( "withdraw", StakeWithReceiverEvent {