Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
hard-nett committed Apr 2, 2024
1 parent 5f2a3b4 commit 689d29d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 57 deletions.
22 changes: 11 additions & 11 deletions contracts/revenue/auction/src/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ pub fn create_auction(
}

let auction = Auction {
auction_id: auction_id.clone(),
auction_id,
nft_contract: nft_contract.clone(),
token_id: token_id.clone(),
seller: seller.clone(),
duration: duration,
duration,
min_duration: config.min_duration,
denom: denom.clone(),
reserve_price: reserve_price,
reserve_price,
end_time: 0,
auction_type: auction_type.clone(),
bidder: None,
amount: reserve_price,
creator_address: creator_address,
royalty_fee: royalty_fee,
protocol_fee: config.protocol_fee.clone(),
creator_address,
royalty_fee,
protocol_fee: config.protocol_fee,
is_settled: false,
};
// save auction
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn set_royalty_fee(
let nft_contract_addr = deps.api.addr_validate(&contract_addr)?;
let creator_addr = deps.api.addr_validate(&creator)?;
let royalty = Royalty {
royalty_fee: royalty_fee,
royalty_fee,
creator: creator_addr,
};
ROYALTIES.save(deps.storage, &nft_contract_addr, &royalty)?;
Expand Down Expand Up @@ -234,8 +234,8 @@ pub fn place_bid(
.funds
.iter()
.find(|c| c.denom == auction.denom)
.map(|c| Uint128::from(c.amount))
.unwrap_or_else(|| Uint128::zero());
.map(|c| c.amount)
.unwrap_or_else(Uint128::zero);
//check time
let block_time = env.block.time.seconds();
let mut messages: Vec<CosmosMsg> = vec![];
Expand Down Expand Up @@ -340,7 +340,7 @@ pub fn place_bid(
};

let min_bid_amount =
calculate_min_bid_amount(config.min_increment.clone(), auction.amount.clone())?;
calculate_min_bid_amount(config.min_increment, auction.amount)?;
if bid_amount < min_bid_amount {
return Err(ContractError::InvalidAmount(
"bid amount too low".to_string(),
Expand Down Expand Up @@ -732,7 +732,7 @@ pub fn only_owner(deps: Deps, _env: &Env, info: MessageInfo) -> Result<bool, Con
if info.sender != config.owner {
return Err(ContractError::Unauthorized {});
}
return Ok(true);
Ok(true)
}

pub fn only_royalty_admin(
Expand Down
41 changes: 16 additions & 25 deletions contracts/revenue/auction/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn query_nft_owner(deps: Deps, nft_contract: String, token_id: String) -> St
include_expired: None,
})?,
}))?;
Ok(deps.api.addr_validate(&owner_response.owner)?)
deps.api.addr_validate(&owner_response.owner)
}

pub fn query_auction(deps: Deps, auction_id: Uint128) -> StdResult<AuctionResponse> {
Expand All @@ -61,14 +61,8 @@ pub fn query_auction(deps: Deps, auction_id: Uint128) -> StdResult<AuctionRespon
}

fn _query_auction(auction: Auction) -> StdResult<AuctionResponse> {
let creator_address = match auction.creator_address {
Some(v) => Some(v.to_string()),
None => None,
};
let bidder = match auction.bidder {
Some(v) => Some(v.to_string()),
None => None,
};
let creator_address = auction.creator_address.map(|v| v.to_string());
let bidder = auction.bidder.map(|v| v.to_string());
Ok(AuctionResponse {
auction_id: auction.auction_id,
auction_type: auction.auction_type,
Expand All @@ -80,10 +74,10 @@ fn _query_auction(auction: Auction) -> StdResult<AuctionResponse> {
denom: auction.denom,
reserve_price: auction.reserve_price,
end_time: auction.end_time,
bidder: bidder,
bidder,
amount: auction.amount,
is_settled: auction.is_settled,
creator_address: creator_address,
creator_address,
royalty_fee: auction.royalty_fee,
})
}
Expand Down Expand Up @@ -130,7 +124,7 @@ pub fn query_auction_by_nft(
auction_id
})
.collect::<Vec<u128>>();
return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_auction_by_seller(
Expand All @@ -150,7 +144,7 @@ pub fn query_auction_by_seller(
})
.collect::<Vec<u128>>();

return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_auction_by_end_time(
Expand Down Expand Up @@ -181,7 +175,7 @@ pub fn query_auction_by_end_time(
})
.collect::<Vec<u128>>();

return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_not_started_auctions(
Expand Down Expand Up @@ -212,7 +206,7 @@ pub fn query_not_started_auctions(
auction_id
})
.collect::<Vec<u128>>();
return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_auction_by_bidder(
Expand All @@ -238,7 +232,7 @@ pub fn query_auction_by_bidder(
auction_id
})
.collect::<Vec<u128>>();
return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_auction_by_amount(
Expand All @@ -264,7 +258,7 @@ pub fn query_auction_by_amount(
})
.collect::<Vec<u128>>();

return Ok(auction_ids);
Ok(auction_ids)
}

pub fn query_calculate_price(
Expand Down Expand Up @@ -312,7 +306,7 @@ pub fn query_bid_history_by_auction_id(

pub fn query_bid_number(deps: Deps, auction_id: Uint128) -> StdResult<BidsCountResponse> {
let count = BID_COUNT_BY_AUCTION_ID.load(deps.storage, auction_id.u128())?;
Ok(BidsCountResponse { count: count })
Ok(BidsCountResponse { count })
}

pub fn query_all_royalty(
Expand All @@ -338,14 +332,11 @@ pub fn query_royalty_admin(deps: Deps, address: String) -> StdResult<RoyaltyAdmi
let address_raw = deps.api.addr_validate(&address)?;
let admin = ROYALTY_ADMINS.may_load(deps.storage, &address_raw)?;

let enable = match admin {
Some(v) => v,
None => false,
};
let enable = admin.unwrap_or(false);

Ok(RoyaltyAdminResponse {
address: address,
enable: enable,
address,
enable,
})
}

Expand All @@ -363,7 +354,7 @@ pub fn construct_action_response(
Err(_) => (),
};
}
Ok(AuctionListResponse { auctions: auctions })
Ok(AuctionListResponse { auctions })
}

fn parse_royalty(item: StdResult<(Addr, Royalty)>) -> StdResult<AllRoyaltyFeeResponse> {
Expand Down
4 changes: 2 additions & 2 deletions contracts/revenue/auction/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::cw_serde;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};



use cosmwasm_std::{Addr, Decimal, Uint128};
use cw_storage_plus::{Item, Map};
Expand Down
30 changes: 15 additions & 15 deletions contracts/revenue/auction/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use marketplace::auction::{
};
use std::str::FromStr;

use crate::auction::{calculate_fee, calculate_min_bid_amount};
use crate::contract::{execute, instantiate, query};

use crate::contract::{execute, instantiate};
use crate::error::ContractError;
use crate::mock_querier::mock_dependencies;
use crate::querier::{
Expand All @@ -26,7 +26,7 @@ fn setup_contract(deps: DepsMut, accepted_denom: Vec<String>) {
min_increment: Decimal::from_str("0.1").unwrap(),
duration: 86400,
min_duration: 900,
accepted_denom: accepted_denom,
accepted_denom,
protocol_addr: "collector".to_string(),
max_royalty_fee: Decimal::percent(20), // 20%
};
Expand Down Expand Up @@ -365,11 +365,11 @@ fn settle_buynow() {
auction_id: Uint128::zero(),
};
env.block.time = Timestamp::from_seconds(120);
let info = mock_info("random", &vec![]);
let info = mock_info("random", &[]);
let res = execute(deps.as_mut(), env.clone(), info, settle_msg.clone()).unwrap();
assert_eq!(4, res.messages.len());

let send_fund_collector_msg = res.messages.get(0).expect("no message");
let send_fund_collector_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_collector_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down Expand Up @@ -560,11 +560,11 @@ fn settle_buynow_with_royalty() {
auction_id: Uint128::zero(),
};
env.block.time = Timestamp::from_seconds(120);
let info = mock_info("random", &vec![]);
let info = mock_info("random", &[]);
let res = execute(deps.as_mut(), env.clone(), info, settle_msg.clone()).unwrap();
assert_eq!(5, res.messages.len());

let send_fund_collector_msg = res.messages.get(0).expect("no message");
let send_fund_collector_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_collector_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down Expand Up @@ -752,7 +752,7 @@ fn settle_auction() {
let info = mock_info("fliper", &[Coin::new(1_100000, "uluna")]);
let res = execute(deps.as_mut(), env.clone(), info, place_bid_msg.clone()).unwrap();
assert_eq!(1, res.messages.len());
let send_fund_buyer_msg = res.messages.get(0).expect("no message");
let send_fund_buyer_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_buyer_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down Expand Up @@ -786,7 +786,7 @@ fn settle_auction() {
let info = mock_info("buyer", &[Coin::new(1_210000, "uluna")]);
let res = execute(deps.as_mut(), env.clone(), info, place_bid_msg.clone()).unwrap();
assert_eq!(1, res.messages.len());
let send_fund_fliper_msg = res.messages.get(0).expect("no message");
let send_fund_fliper_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_fliper_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down Expand Up @@ -819,7 +819,7 @@ fn settle_auction() {
let settle_msg = ExecuteMsg::Settle {
auction_id: Uint128::zero(),
};
let info = mock_info("random", &vec![]);
let info = mock_info("random", &[]);
let err = execute(deps.as_mut(), env.clone(), info, settle_msg.clone()).unwrap_err();
match err {
ContractError::InvalidAuction { .. } => {}
Expand All @@ -828,11 +828,11 @@ fn settle_auction() {

// settle
env.block.time = Timestamp::from_seconds(86900);
let info = mock_info("random", &vec![]);
let info = mock_info("random", &[]);
let res = execute(deps.as_mut(), env.clone(), info, settle_msg.clone()).unwrap();
assert_eq!(4, res.messages.len());

let send_fund_collector_msg = res.messages.get(0).expect("no message");
let send_fund_collector_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_collector_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down Expand Up @@ -1024,7 +1024,7 @@ fn check_freeze_and_cancel_auction() {
let res = execute(deps.as_mut(), env, info, cancel_msg).unwrap();
assert_eq!(2, res.messages.len());

let send_nft_msg = res.messages.get(0).expect("no message");
let send_nft_msg = res.messages.first().expect("no message");
assert_eq!(
&send_nft_msg.msg,
&CosmosMsg::Wasm(WasmMsg::Execute {
Expand Down Expand Up @@ -1116,7 +1116,7 @@ fn admin_cancel() {
};
let res = execute(deps.as_mut(), env, info, admin_cancel_msg).unwrap();
assert_eq!(1, res.messages.len());
let send_nft_msg = res.messages.get(0).expect("no message");
let send_nft_msg = res.messages.first().expect("no message");
assert_eq!(
&send_nft_msg.msg,
&CosmosMsg::Wasm(WasmMsg::Execute {
Expand Down Expand Up @@ -1172,7 +1172,7 @@ fn admin_cancel() {
let res = execute(deps.as_mut(), env, info, admin_cancel_msg).unwrap();
assert_eq!(2, res.messages.len());

let send_fund_bidder_msg = res.messages.get(0).expect("no message");
let send_fund_bidder_msg = res.messages.first().expect("no message");
assert_eq!(
&send_fund_bidder_msg.msg,
&CosmosMsg::Bank(BankMsg::Send {
Expand Down
6 changes: 3 additions & 3 deletions contracts/revenue/fair-burn/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn execute_fair_burn(
Some(recipient) => {
payout_map
.entry(recipient.to_string())
.or_insert(vec![])
.or_default()
.push(dist_coin.clone());
}
None => {
Expand All @@ -114,14 +114,14 @@ pub fn execute_fair_burn(

payout_map
.entry(fair_burn_pool_key.clone())
.or_insert(vec![])
.or_default()
.push(fee_coin.clone());

if let Some(dist_coin) = dist_coin {
let recipient = recipient.as_ref().unwrap().to_string();
payout_map
.entry(recipient)
.or_insert(vec![])
.or_default()
.push(dist_coin.clone());
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/mint-hooks/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn merge_variants(metadata: TokenStream, left: TokenStream, right: TokenStream)
};

// insert variants from the right to the left
variants.extend(to_add.into_iter());
variants.extend(to_add);

quote! { #left }.into()
}
Expand Down

0 comments on commit 689d29d

Please sign in to comment.