Skip to content

Commit

Permalink
stake-contract: change unstake to withdraw the whole stake amount
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Aug 31, 2024
1 parent 14c14c0 commit b08e899
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand All @@ -162,7 +163,7 @@ impl StakeState {
"unstake",
StakeWithReceiverEvent {
account,
value: staked_value,
value: withdrawal_value,
receiver: Some(*transfer_withdraw.receiver()),
},
);
Expand Down

0 comments on commit b08e899

Please sign in to comment.