Skip to content

Commit

Permalink
Fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Jan 31, 2024
1 parent b7b01cb commit 834e16e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
54 changes: 26 additions & 28 deletions contracts/external/dao-proposal-incentives/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,34 @@ pub fn proposal_hook(
)?;

// Check prop status and type of hook
match msg {
ProposalHookMsg::ProposalStatusChanged { id, new_status, .. } => {
// If prop status is success, add message to pay out rewards
// Otherwise, do nothing
if new_status == Status::Passed.to_string() {
// Query for the proposal
let proposal_info: GenericProposalInfo = deps.querier.query_wasm_smart(
info.sender,
&dao_interface::proposal::Query::GenericProposalInfo { proposal_id: id },
)?;

// Load proposal incentives config
let proposal_incentives = PROPOSAL_INCENTIVES
.may_load_at_height(deps.storage, proposal_info.start_height)?;

// Append the message if found
if let Some(proposal_incentives) = proposal_incentives {
msgs.push(proposal_incentives.denom.get_transfer_to_message(
&proposal_info.proposer,
proposal_incentives.rewards_per_proposal,
)?);
attrs = proposal_incentives.into_attributes();
attrs.push(Attribute {
key: "proposer".to_string(),
value: proposal_info.proposer.to_string(),
});
}

if let ProposalHookMsg::ProposalStatusChanged { id, new_status, .. } = msg {
// If prop status is success, add message to pay out rewards
// Otherwise, do nothing
if new_status == Status::Passed.to_string() {
// Query for the proposal
let proposal_info: GenericProposalInfo = deps.querier.query_wasm_smart(
info.sender,
&dao_interface::proposal::Query::GenericProposalInfo { proposal_id: id },
)?;

// Load proposal incentives config
let proposal_incentives = PROPOSAL_INCENTIVES
.may_load_at_height(deps.storage, proposal_info.start_height)?;

// Append the message if found
if let Some(proposal_incentives) = proposal_incentives {
msgs.push(proposal_incentives.denom.get_transfer_to_message(
&proposal_info.proposer,
proposal_incentives.rewards_per_proposal,
)?);
attrs = proposal_incentives.into_attributes();
attrs.push(Attribute {
key: "proposer".to_string(),
value: proposal_info.proposer.to_string(),
});
}
}
_ => {}
}
}

Expand Down
16 changes: 8 additions & 8 deletions contracts/external/dao-voting-incentives/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ pub fn execute(
// TODO how to claim for many epochs efficiently?
pub fn execute_claim(
deps: DepsMut,
env: Env,
info: MessageInfo,
_env: Env,
_info: MessageInfo,
) -> Result<Response, ContractError> {
// Check epoch should advance

Expand All @@ -69,7 +69,7 @@ pub fn execute_claim(
// Load prop count for epoch

// Load voting incentives config
let voting_incentives = VOTING_INCENTIVES.load(deps.storage)?;
let _voting_incentives = VOTING_INCENTIVES.load(deps.storage)?;

// Need total vote count for epoch
// Rewards = (user vote count / prop count) / total_vote_count * voting incentives
Expand All @@ -82,10 +82,10 @@ pub fn execute_claim(
// TODO support cw20 tokens
// TODO make sure config can't lock DAO
pub fn execute_vote_hook(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: VoteHookMsg,
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: VoteHookMsg,
) -> Result<Response, ContractError> {
// Check epoch should advance

Expand All @@ -102,7 +102,7 @@ pub fn execute_vote_hook(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Rewards { address } => unimplemented!(),
QueryMsg::Rewards { address: _ } => unimplemented!(),
QueryMsg::Config {} => unimplemented!(),
}
}
Expand Down
3 changes: 0 additions & 3 deletions contracts/external/dao-voting-incentives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ mod error;
pub mod msg;
pub mod state;

#[cfg(test)]
mod tests;

pub use crate::error::ContractError;

0 comments on commit 834e16e

Please sign in to comment.