From 0942b2508892c18ff383a25df337b446385394c8 Mon Sep 17 00:00:00 2001 From: Milosz Muszynski Date: Tue, 27 Feb 2024 17:55:21 +0100 Subject: [PATCH] stake-contract: added slashed amount setter --- contracts/stake/src/lib.rs | 9 +++++++++ contracts/stake/src/state.rs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/contracts/stake/src/lib.rs b/contracts/stake/src/lib.rs index 2b6f51c464..570cd2f5a7 100644 --- a/contracts/stake/src/lib.rs +++ b/contracts/stake/src/lib.rs @@ -109,6 +109,15 @@ unsafe fn hard_slash(arg_len: u32) -> u32 { STATE.hard_slash(&pk, value); }) } + +#[no_mangle] +unsafe fn set_slashed_amount(arg_len: u32) -> u32 { + rusk_abi::wrap_call(arg_len, |amount| { + assert_external_caller(); + STATE.set_slashed_amount(amount) + }) +} + /// Asserts the call is made via the transfer contract. /// /// # Panics diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index 93cb9d01ab..29dbb5897c 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -265,6 +265,11 @@ impl StakeState { } } + /// Sets the slashed amount + pub fn set_slashed_amount(&mut self, amount: u64) { + self.slashed_amount = amount; + } + /// Feeds the host with the stakes. pub fn stakes(&self) { for (stake_data, pk) in self.stakes.values() {