Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Jan 16, 2024
1 parent b598a17 commit bc54640
Show file tree
Hide file tree
Showing 86 changed files with 654 additions and 694 deletions.
8 changes: 4 additions & 4 deletions contracts/liquidity_hub/epoch-manager/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{entry_point, to_binary, StdError};
use cosmwasm_std::{entry_point, to_json_binary, StdError};
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::{get_contract_version, set_contract_version};
use semver::Version;
Expand Down Expand Up @@ -79,9 +79,9 @@ pub fn execute(
#[entry_point]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Config {} => Ok(to_binary(&queries::query_config(deps)?)?),
QueryMsg::CurrentEpoch {} => Ok(to_binary(&queries::query_current_epoch(deps)?)?),
QueryMsg::Epoch { id } => Ok(to_binary(&queries::query_epoch(deps, id)?)?),
QueryMsg::Config {} => Ok(to_json_binary(&queries::query_config(deps)?)?),
QueryMsg::CurrentEpoch {} => Ok(to_json_binary(&queries::query_current_epoch(deps)?)?),
QueryMsg::Epoch { id } => Ok(to_json_binary(&queries::query_epoch(deps, id)?)?),

Check warning on line 84 in contracts/liquidity_hub/epoch-manager/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/epoch-manager/src/contract.rs#L82-L84

Added lines #L82 - L84 were not covered by tests
}
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/liquidity_hub/fee-distributor-mock/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint64,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint64,
};

use white_whale::fee_distributor::EpochResponse;
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn query(
match msg {
white_whale::fee_distributor::QueryMsg::Config {} => {}
white_whale::fee_distributor::QueryMsg::CurrentEpoch {} => {
return to_binary(&EpochResponse {
return to_json_binary(&EpochResponse {
epoch: CURRENT_EPOCH.load(deps.storage)?,
});
}
Expand All @@ -80,5 +80,5 @@ pub fn query(
white_whale::fee_distributor::QueryMsg::Claimable { .. } => {}
}

to_binary(&"")
to_json_binary(&"")

Check warning on line 83 in contracts/liquidity_hub/fee-distributor-mock/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/fee-distributor-mock/src/contract.rs#L83

Added line #L83 was not covered by tests
}
32 changes: 16 additions & 16 deletions contracts/liquidity_hub/fee_collector/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{
to_binary, Addr, BalanceResponse, BankQuery, Coin, CosmosMsg, Decimal, DepsMut, Env,
to_json_binary, Addr, BalanceResponse, BankQuery, Coin, CosmosMsg, Decimal, DepsMut, Env,
MessageInfo, QueryRequest, ReplyOn, Response, StdResult, SubMsg, Uint128, WasmMsg, WasmQuery,
};
use cw20::{Cw20ExecuteMsg, Cw20QueryMsg};
Expand Down Expand Up @@ -49,10 +49,10 @@ pub fn collect_fees(deps: DepsMut, collect_fees_for: FeesFor) -> Result<Response
fn collect_fees_for_contract(contract: Addr, contract_type: ContractType) -> StdResult<CosmosMsg> {
let collect_protocol_fees_msg = match contract_type {
ContractType::Vault {} => {
to_binary(&white_whale::vault_network::vault::ExecuteMsg::CollectProtocolFees {})?
to_json_binary(&white_whale::vault_network::vault::ExecuteMsg::CollectProtocolFees {})?
}
ContractType::Pool {} => {
to_binary(&white_whale::pool_network::pair::ExecuteMsg::CollectProtocolFees {})?
to_json_binary(&white_whale::pool_network::pair::ExecuteMsg::CollectProtocolFees {})?
}
};

Expand All @@ -76,7 +76,7 @@ fn collect_fees_for_factory(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -95,7 +95,7 @@ fn collect_fees_for_factory(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&QueryMsg::Pairs { start_after, limit })?,
}))?;

for pair in response.pairs {
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn aggregate_fees(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -198,7 +198,7 @@ pub fn aggregate_fees(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&QueryMsg::Pairs { start_after, limit })?,
}))?;

for pair in response.pairs {
Expand All @@ -224,7 +224,7 @@ pub fn aggregate_fees(
let balance_response: cw20::BalanceResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: contract_addr.to_string(),
msg: to_binary(&Cw20QueryMsg::Balance {
msg: to_json_binary(&Cw20QueryMsg::Balance {
address: env.contract.address.to_string(),
})?,
}))?;
Expand All @@ -234,7 +234,7 @@ pub fn aggregate_fees(
// Increase the allowance for the cw20 token so the router can perform the swap
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: contract_addr.to_string(),
msg: to_binary(&Cw20ExecuteMsg::IncreaseAllowance {
msg: to_json_binary(&Cw20ExecuteMsg::IncreaseAllowance {
spender: config.pool_router.to_string(),
amount: balance_response.balance,
expires: None,
Expand All @@ -261,7 +261,7 @@ pub fn aggregate_fees(
let operations_res: StdResult<Vec<SwapOperation>> =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.pool_router.to_string(),
msg: to_binary(&router::QueryMsg::SwapRoute {
msg: to_json_binary(&router::QueryMsg::SwapRoute {
offer_asset_info: offer_asset_info.clone(),
ask_asset_info: ask_asset_info.clone(),
})?,
Expand All @@ -270,7 +270,7 @@ pub fn aggregate_fees(
match operations_res {
Ok(operations) => {
let execute_swap_operations_msg =
to_binary(&router::ExecuteMsg::ExecuteSwapOperations {
to_json_binary(&router::ExecuteMsg::ExecuteSwapOperations {
operations,
minimum_receive: None,
to: None,
Expand All @@ -282,7 +282,7 @@ pub fn aggregate_fees(
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr,
funds: vec![],
msg: to_binary(&Cw20ExecuteMsg::Send {
msg: to_json_binary(&Cw20ExecuteMsg::Send {
contract: config.pool_router.to_string(),
amount: balance,
msg: execute_swap_operations_msg,
Expand Down Expand Up @@ -336,7 +336,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::CollectFees {
msg: to_json_binary(&ExecuteMsg::CollectFees {
collect_fees_for: FeesFor::Factory {
factory_addr: config.vault_factory.to_string(),
factory_type: FactoryType::Vault {
Expand All @@ -355,7 +355,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::CollectFees {
msg: to_json_binary(&ExecuteMsg::CollectFees {
collect_fees_for: FeesFor::Factory {
factory_addr: config.pool_factory.to_string(),
factory_type: FactoryType::Pool {
Expand All @@ -375,7 +375,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::AggregateFees {
msg: to_json_binary(&ExecuteMsg::AggregateFees {
aggregate_fees_for: FeesFor::Factory {
factory_addr: config.vault_factory.to_string(),
factory_type: FactoryType::Vault {
Expand All @@ -394,7 +394,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::AggregateFees {
msg: to_json_binary(&ExecuteMsg::AggregateFees {
aggregate_fees_for: FeesFor::Factory {
factory_addr: config.pool_factory.to_string(),
factory_type: FactoryType::Pool {
Expand Down
10 changes: 5 additions & 5 deletions contracts/liquidity_hub/fee_collector/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Addr, BalanceResponse, BankMsg, BankQuery, Binary, CosmosMsg, Deps, DepsMut, Env,
MessageInfo, QueryRequest, Reply, Response, StdResult, Uint128,
to_json_binary, Addr, BalanceResponse, BankMsg, BankQuery, Binary, CosmosMsg, Deps, DepsMut,
Env, MessageInfo, QueryRequest, Reply, Response, StdResult, Uint128,
};
use cw2::{get_contract_version, set_contract_version};
use semver::Version;
Expand Down Expand Up @@ -96,7 +96,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
.add_attribute("action", "reply")
.add_attribute("new_epoch", epoch.to_string())
.add_messages(messages)
.set_data(to_binary(&ForwardFeesResponse { epoch })?))
.set_data(to_json_binary(&ForwardFeesResponse { epoch })?))
} else {
Err(ContractError::UnknownReplyId(msg.id))
}
Expand Down Expand Up @@ -138,11 +138,11 @@ pub fn execute(
#[entry_point]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Config {} => to_binary(&queries::query_config(deps)?),
QueryMsg::Config {} => to_json_binary(&queries::query_config(deps)?),
QueryMsg::Fees {
query_fees_for,
all_time,
} => to_binary(&queries::query_fees(
} => to_json_binary(&queries::query_fees(
deps,
query_fees_for,
all_time.unwrap_or(false),
Expand Down
15 changes: 9 additions & 6 deletions contracts/liquidity_hub/fee_collector/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, Deps, QueryRequest, StdResult, WasmQuery};
use cosmwasm_std::{to_json_binary, Addr, Deps, QueryRequest, StdResult, WasmQuery};

use white_whale::fee_collector::{Config, ContractType, FactoryType, FeesFor};
use white_whale::pool_network;
Expand Down Expand Up @@ -75,7 +75,7 @@ fn query_fees_for_vault(deps: &Deps, vault: String, all_time: bool) -> StdResult
.querier
.query::<ProtocolVaultFeesResponse>(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: vault,
msg: to_binary(&white_whale::vault_network::vault::QueryMsg::ProtocolFees {
msg: to_json_binary(&white_whale::vault_network::vault::QueryMsg::ProtocolFees {
all_time,
})?,
}))?
Expand All @@ -90,7 +90,7 @@ fn query_fees_for_pair(deps: &Deps, pair: String, all_time: bool) -> StdResult<V
.querier
.query::<ProtocolPairFeesResponse>(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: pair,
msg: to_binary(&pool_network::pair::QueryMsg::ProtocolFees {
msg: to_json_binary(&pool_network::pair::QueryMsg::ProtocolFees {
all_time: Some(all_time),
asset_id: None,
})?,
Expand All @@ -114,7 +114,7 @@ fn query_fees_for_factory(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -131,7 +131,10 @@ fn query_fees_for_factory(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&pool_network::factory::QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&pool_network::factory::QueryMsg::Pairs {
start_after,
limit,
})?,
}))?;

for pair in response.pairs {
Expand All @@ -151,7 +154,7 @@ pub(crate) fn query_distribution_asset(deps: Deps) -> StdResult<AssetInfo> {
let fee_distributor_config: white_whale::fee_distributor::Config =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.fee_distributor.to_string(),
msg: to_binary(&white_whale::fee_distributor::QueryMsg::Config {})?,
msg: to_json_binary(&white_whale::fee_distributor::QueryMsg::Config {})?,
}))?;

Ok(fee_distributor_config.distribution_asset)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, BankMsg, Coin, Response};
use cosmwasm_std::{to_json_binary, Addr, BankMsg, Coin, Response};
use cw_multi_test::ContractWrapper;
use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down Expand Up @@ -28,6 +28,6 @@ pub fn create_dummy_flash_loan_contract(
}
},
|_deps, _env, _info, _msg| Ok(Response::new()),
|_deps, _env, _query| Ok(to_binary::<Vec<Coin>>(&vec![]).unwrap()),
|_deps, _env, _query| Ok(to_json_binary::<Vec<Coin>>(&vec![]).unwrap()),

Check warning on line 31 in contracts/liquidity_hub/fee_collector/src/tests/dummy_contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/fee_collector/src/tests/dummy_contract.rs#L31

Added line #L31 was not covered by tests
)
}
Loading

0 comments on commit bc54640

Please sign in to comment.