From 5a5acd0c5a744e380f1e91fd22931ce91f7e949c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 31 May 2024 17:33:33 +0200 Subject: [PATCH] Fix clippy warnings --- contracts/staking/src/contract.rs | 5 +++-- packages/std/src/testing/assertions.rs | 1 + packages/vm/src/cache.rs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/contracts/staking/src/contract.rs b/contracts/staking/src/contract.rs index aad97a9849..43350dc91b 100644 --- a/contracts/staking/src/contract.rs +++ b/contracts/staking/src/contract.rs @@ -322,13 +322,14 @@ pub fn _bond_all_tokens( // we deduct pending claims from our account balance before reinvesting. // if there is not enough funds, we just return a no-op - match update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { + let updated = update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { balance.amount = balance.amount.checked_sub(supply.claims)?; // this just triggers the "no op" case if we don't have min_withdrawal left to reinvest balance.amount.checked_sub(invest.min_withdrawal)?; supply.bonded += balance.amount; Ok(supply) - }) { + }); + match updated { Ok(_) => {} // if it is below the minimum, we do a no-op (do not revert other state from withdrawal) Err(StdError::Overflow { .. }) => return Ok(Response::default()), diff --git a/packages/std/src/testing/assertions.rs b/packages/std/src/testing/assertions.rs index f091acedba..dcf98459a8 100644 --- a/packages/std/src/testing/assertions.rs +++ b/packages/std/src/testing/assertions.rs @@ -170,6 +170,7 @@ mod tests { )] fn assert_approx_with_custom_panic_msg() { let adjective = "extra"; + #[allow(dead_code)] #[derive(Debug)] struct Foo(u32); assert_approx_eq!( diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 40ba51c8da..8518ea6aae 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -488,6 +488,7 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult let mut file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(filepath) .map_err(|e| VmError::cache_err(format!("Error opening Wasm file for writing: {e}")))?; file.write_all(wasm)