From 8dc71308f17827bea3b9516507ea69804d34bc97 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Sat, 7 Sep 2024 14:50:40 +0200 Subject: [PATCH] stake-contract: fix prev_stake for Stake operation --- contracts/stake/src/state.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index 4414b5d12b..0ad8f083fb 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -79,6 +79,7 @@ impl StakeState { panic!("The stake must target the correct chain"); } + let prev_stake = self.get_stake(&account).copied(); let loaded_stake = self.load_or_create_stake_mut(&account); // ensure the stake is at least the minimum and that there isn't an @@ -122,7 +123,7 @@ impl StakeState { let key = account.to_bytes(); self.previous_block_state .entry(key) - .or_insert((None, account)); + .or_insert((prev_stake, account)); } pub fn unstake(&mut self, unstake: Withdraw) {