From b08e8994b90791d787b6b7c3860aad785bc93e7d Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Sat, 31 Aug 2024 14:47:06 +0200 Subject: [PATCH] stake-contract: change unstake to withdraw the whole stake amount --- contracts/stake/src/state.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index f3fa3f4894..5c7eccee26 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -134,12 +134,13 @@ impl StakeState { // ensure there is a value staked, and that the withdrawal is exactly // the same amount - let staked_value = loaded_stake + let stake = loaded_stake .amount - .expect("There must be an amount to unstake") - .value; + .as_ref() + .expect("There must be an amount to unstake"); + let withdrawal_value = stake.locked + stake.value; - if value != staked_value { + if value != withdrawal_value { panic!("Value withdrawn different from staked amount"); } @@ -162,7 +163,7 @@ impl StakeState { "unstake", StakeWithReceiverEvent { account, - value: staked_value, + value: withdrawal_value, receiver: Some(*transfer_withdraw.receiver()), }, );