From 08ac9c5248616015069bbc77c426a089c0d43665 Mon Sep 17 00:00:00 2001 From: 0xFable <0xfable@protonmail.com> Date: Mon, 15 Apr 2024 12:47:33 +0100 Subject: [PATCH] fix: More clippy --- .../bonding-manager/src/commands.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/contracts/liquidity_hub/bonding-manager/src/commands.rs b/contracts/liquidity_hub/bonding-manager/src/commands.rs index d26728e6..6219a2cc 100644 --- a/contracts/liquidity_hub/bonding-manager/src/commands.rs +++ b/contracts/liquidity_hub/bonding-manager/src/commands.rs @@ -22,12 +22,11 @@ pub(crate) fn bond( env: Env, asset: Coin, ) -> Result { - let denom = asset.denom.clone(); - helpers::validate_funds(&deps, &info, &asset, denom.clone())?; + helpers::validate_funds(&deps, &info, &asset.clone(), asset.denom.clone())?; helpers::validate_claimed(&deps, &info)?; helpers::validate_bonding_for_current_epoch(&deps, &env)?; let mut bond = BOND - .key((&info.sender, &denom)) + .key((&info.sender, &asset.denom)) .may_load(deps.storage)? .unwrap_or(Bond { asset: Coin { @@ -42,7 +41,7 @@ pub(crate) fn bond( // let new_bond_weight = get_weight(timestamp, bond.weight, asset.amount, config.growth_rate, bond.timestamp)?; bond.weight = bond.weight.checked_add(asset.amount)?; bond = update_local_weight(&mut deps, info.sender.clone(), timestamp, bond)?; - BOND.save(deps.storage, (&info.sender, &denom), &bond)?; + BOND.save(deps.storage, (&info.sender, &asset.denom), &bond)?; // update global values let mut global_index = GLOBAL.may_load(deps.storage)?.unwrap_or_default(); @@ -77,11 +76,13 @@ pub(crate) fn unbond( ContractError::InvalidUnbondingAmount {} ); - let denom = asset.denom.clone(); helpers::validate_claimed(&deps, &info)?; helpers::validate_bonding_for_current_epoch(&deps, &env)?; - if let Some(mut unbond) = BOND.key((&info.sender, &denom)).may_load(deps.storage)? { + if let Some(mut unbond) = BOND + .key((&info.sender, &asset.denom)) + .may_load(deps.storage)? + { // check if the address has enough bond ensure!( unbond.asset.amount >= asset.amount, @@ -95,14 +96,14 @@ pub(crate) fn unbond( unbond.asset.amount = unbond.asset.amount.checked_sub(asset.amount)?; if unbond.asset.amount.is_zero() { - BOND.remove(deps.storage, (&info.sender, &denom)); + BOND.remove(deps.storage, (&info.sender, &asset.denom)); } else { - BOND.save(deps.storage, (&info.sender, &denom), &unbond)?; + BOND.save(deps.storage, (&info.sender, &asset.denom), &unbond)?; } // record the unbonding UNBOND.save( deps.storage, - (&info.sender, &denom, timestamp.nanos()), + (&info.sender, &asset.denom, timestamp.nanos()), &Bond { asset: asset.clone(), weight: Uint128::zero(),