From 424aba262f6cc54310f17b3e9d16cb9ee29bf829 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 5c7eccee26..b52de63b94 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -190,8 +190,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 @@ -207,7 +207,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 {