Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Oct 12, 2024
1 parent 9a9c39c commit f886f67
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions contracts/delegation/dao-vote-delegation/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,14 @@ fn execute_delegate(
&delegate,
env.block.height,
|vp| -> StdResult<Uint128> {
Ok(vp
.unwrap_or_default()
vp.unwrap_or_default()
// remove the current delegated VP from the delegate's total and
// replace it with the new delegated VP. if this is a new
// delegation, this will be zero.
.checked_sub(current_delegated_vp)
.map_err(StdError::overflow)?
.checked_add(new_delegated_vp)
.map_err(StdError::overflow)?)
.map_err(StdError::overflow)
},
)?;
DELEGATED_VP_AMOUNTS.save(deps.storage, (&delegator, &delegate), &new_delegated_vp)?;

Check warning on line 281 in contracts/delegation/dao-vote-delegation/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/delegation/dao-vote-delegation/src/contract.rs#L258-L281

Added lines #L258 - L281 were not covered by tests
Expand Down Expand Up @@ -326,11 +325,11 @@ fn execute_undelegate(
&delegate,
env.block.height,
|vp| -> StdResult<Uint128> {
Ok(vp
vp
// must exist if delegation was added in the past
.ok_or(StdError::not_found("delegate's total delegated VP"))?
.checked_sub(current_delegated_vp)
.map_err(StdError::overflow)?)
.map_err(StdError::overflow)
},
)?;
DELEGATED_VP_AMOUNTS.remove(deps.storage, (&delegator, &delegate));
Expand Down
4 changes: 2 additions & 2 deletions contracts/delegation/dao-vote-delegation/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ pub fn get_udvp(
// total delegated VP at that height. UNVOTED_DELEGATED_VP gets set when the
// delegate or one of their delegators casts a vote. if empty, none of them
// have voted yet.
match UNVOTED_DELEGATED_VP.may_load(deps.storage, (&delegate, &proposal_module, proposal_id))? {
match UNVOTED_DELEGATED_VP.may_load(deps.storage, (delegate, proposal_module, proposal_id))? {
Some(vp) => Ok(vp),
None => Ok(DELEGATED_VP
.may_load_at_height(deps.storage, &delegate, height)?
.may_load_at_height(deps.storage, delegate, height)?
.unwrap_or_default()),

Check warning on line 70 in contracts/delegation/dao-vote-delegation/src/helpers.rs

View check run for this annotation

Codecov / codecov/patch

contracts/delegation/dao-vote-delegation/src/helpers.rs#L55-L70

Added lines #L55 - L70 were not covered by tests
}
}

Check warning on line 72 in contracts/delegation/dao-vote-delegation/src/helpers.rs

View check run for this annotation

Codecov / codecov/patch

contracts/delegation/dao-vote-delegation/src/helpers.rs#L72

Added line #L72 was not covered by tests
Expand Down
5 changes: 2 additions & 3 deletions contracts/delegation/dao-vote-delegation/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,11 @@ pub(crate) fn handle_voting_power_changed_hook(
&delegate,
env.block.height,
|vp| -> StdResult<Uint128> {
Ok(vp
.unwrap_or_default()
vp.unwrap_or_default()
.checked_sub(current_delegated_vp)
.map_err(StdError::overflow)?
.checked_add(new_delegated_vp)
.map_err(StdError::overflow)?)
.map_err(StdError::overflow)
},
)?;
DELEGATED_VP_AMOUNTS.save(deps.storage, (&delegator, &delegate), &new_delegated_vp)?;

Check warning on line 154 in contracts/delegation/dao-vote-delegation/src/hooks.rs

View check run for this annotation

Codecov / codecov/patch

contracts/delegation/dao-vote-delegation/src/hooks.rs#L130-L154

Added lines #L130 - L154 were not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions contracts/delegation/dao-vote-delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod hooks;
pub mod msg;
pub mod state;

#[cfg(test)]
mod testing;
// #[cfg(test)]
// mod testing;

pub use crate::error::ContractError;
1 change: 1 addition & 0 deletions packages/dao-hooks/src/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum VoteHookMsg {
/// Prepares new vote hook messages. These messages reply on error
/// and have even reply IDs.
/// IDs are set to odd numbers to then be interleaved with the proposal hooks.
#[allow(clippy::too_many_arguments)]
pub fn new_vote_hooks(
hooks: Hooks,
storage: &dyn Storage,
Expand Down

0 comments on commit f886f67

Please sign in to comment.