Skip to content

Commit

Permalink
feat: add argument assertion on staking slashing (#157)
Browse files Browse the repository at this point in the history
* add argument assertion on staking slashing

* typo
  • Loading branch information
beer-1 authored Oct 31, 2024
1 parent 7255fbd commit 7d2dbd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Binary file modified precompile/binaries/stdlib/staking.mv
Binary file not shown.
5 changes: 5 additions & 0 deletions precompile/modules/initia_stdlib/sources/staking.move
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ module initia_std::staking {
/// Chain already has `StakingState` for the given metadata
const ESTAKING_STATE_ALREADY_EXISTS: u64 = 16;

/// Invalid slash fraction
const EINVALID_SLASH_FRACTION: u64 = 17;

// Constants

/// Max number of view function response items.
Expand Down Expand Up @@ -621,6 +624,8 @@ module initia_std::staking {
validator: String,
fraction: BigDecimal
) acquires ModuleStore {
assert!(bigdecimal::le(fraction, bigdecimal::one()), error::invalid_argument(EINVALID_SLASH_FRACTION));

check_chain_permission(chain);

let module_store = borrow_global_mut<ModuleStore>(@initia_std);
Expand Down

0 comments on commit 7d2dbd5

Please sign in to comment.