Skip to content

Commit

Permalink
fix: fmt and fix one leftover import
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFable committed Feb 5, 2024
1 parent 65c2d9b commit 3001207
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 37 deletions.
4 changes: 3 additions & 1 deletion contracts/liquidity_hub/epoch-manager/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use cosmwasm_std::{DepsMut, MessageInfo, Response, Uint64};

use epoch_manager::contract::{execute, instantiate};
use epoch_manager::ContractError;
use white_whale_std::epoch_manager::epoch_manager::{EpochV2, EpochConfig, ExecuteMsg, InstantiateMsg};
use white_whale_std::epoch_manager::epoch_manager::{
EpochConfig, EpochV2, ExecuteMsg, InstantiateMsg,
};

/// Mocks contract instantiation.
pub(crate) fn mock_instantiation(
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_hub/epoch-manager/tests/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cosmwasm_std::testing::{mock_env, mock_info};

use epoch_manager::contract::{execute, query};
use epoch_manager::ContractError;
use white_whale_std::epoch_manager::epoch_manager::{EpochV2, EpochResponse, ExecuteMsg, QueryMsg};
use white_whale_std::epoch_manager::epoch_manager::{EpochResponse, EpochV2, ExecuteMsg, QueryMsg};
use white_whale_std::epoch_manager::hooks::EpochChangedHookMsg;
use white_whale_std::pool_network::mock_querier::mock_dependencies;

Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_hub/epoch-manager/tests/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmwasm_std::{from_json, Addr, Uint64};
use epoch_manager::contract::{instantiate, query};
use epoch_manager::ContractError;
use white_whale_std::epoch_manager::epoch_manager::{
ConfigResponse, EpochV2, EpochConfig, InstantiateMsg, QueryMsg,
ConfigResponse, EpochConfig, EpochV2, InstantiateMsg, QueryMsg,
};
use white_whale_std::pool_network::mock_querier::mock_dependencies;

Expand Down
4 changes: 3 additions & 1 deletion contracts/liquidity_hub/pool-manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use cosmwasm_std::{
use cw2::set_contract_version;
use cw20::Cw20ReceiveMsg;
use semver::Version;
use white_whale_std::pool_manager::{Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use white_whale_std::pool_manager::{
Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg,
};
use white_whale_std::pool_network::asset::{Asset, AssetInfo};
use white_whale_std::pool_network::pair::FeatureToggle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub fn create_pair(
feature = "osmosis_token_factory",
feature = "injective"
))]
Ok(tokenfactory::create_denom::create_denom(
Ok(white_whale_std::tokenfactory::create_denom::create_denom(
env.contract.address,
lp_symbol,

Check warning on line 214 in contracts/liquidity_hub/pool-manager/src/manager/commands.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-manager/src/manager/commands.rs#L212-L214

Added lines #L212 - L214 were not covered by tests
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ pub fn deposit_pair(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, Con
},
)?;
let has_existing_position = positions.positions.into_iter().any(|position| {
let QueryPosition::OpenPosition { unbonding_duration: position_unbonding_duration, .. } = position else {
return false;
};
let QueryPosition::OpenPosition {
unbonding_duration: position_unbonding_duration,

Check warning on line 100 in contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs#L99-L100

Added lines #L99 - L100 were not covered by tests
..
} = position
else {
return false;

Check warning on line 104 in contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs#L104

Added line #L104 was not covered by tests
};

unbonding_duration == position_unbonding_duration
unbonding_duration == position_unbonding_duration

Check warning on line 107 in contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-network/frontend_helper/src/reply/deposit_pair.rs#L107

Added line #L107 was not covered by tests
});

Ok(Response::default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ pub fn instantiate_fees(
}

/// Creates a new LP token for this pool
pub fn create_lp_token(
pub fn create_lp_token(
deps: DepsMut,
env: &Env,
msg: &InstantiateMsg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use white_whale_std::pool_network::token::InstantiateMsg as TokenInstantiateMsg;
feature = "osmosis_token_factory",
feature = "injective"
))]
use white_whale::tokenfactory;
use white_whale_std::tokenfactory;
use white_whale_std::vault_manager::{LpTokenType, Vault, VaultFee};

use crate::state::{get_vault_by_identifier, CONFIG, VAULTS, VAULT_COUNTER};
Expand Down Expand Up @@ -132,7 +132,6 @@ pub fn create_vault(
hasher.update(seed.as_bytes());
let salt: Binary = hasher.finalize().to_vec().into();


let vault_lp_address = deps.api.addr_humanize(
&instantiate2_address(&checksum, &creator, &salt)
.map_err(|e| StdError::generic_err(e.to_string()))?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub fn next_loan(
&white_whale_std::vault_network::vault_factory::QueryMsg::Vault {
asset_info: source_vault_asset,
},
)? else {
)?
else {
return Err(VaultRouterError::Unauthorized {});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ impl Display for EpochV2 {
self.id, self.start_time,
)
}
}
}
2 changes: 1 addition & 1 deletion packages/white-whale-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pub mod fee_collector;
pub mod fee_distributor;
pub mod lp_common;
pub mod migrate_guards;
pub mod pool_manager;
pub mod pool_network;
pub mod token_factory;
pub mod tokenfactory;
pub mod traits;
pub mod pool_manager;
pub mod vault_manager;
pub mod vault_network;
pub mod whale_lair;
20 changes: 7 additions & 13 deletions packages/white-whale-std/src/pool_manager.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::fmt;

use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Decimal, Uint128};
use cw20::Cw20ReceiveMsg;
use cw_ownable::{cw_ownable_execute, cw_ownable_query};
use crate::pool_network::{
asset::{Asset, AssetInfo, PairType},
factory::NativeTokenDecimalsResponse,
pair::{PoolFee, ReverseSimulationResponse, SimulationResponse},
};

use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Decimal, Uint128};
use cw20::Cw20ReceiveMsg;
use cw_ownable::{cw_ownable_execute, cw_ownable_query};

#[cw_serde]
pub enum Cw20HookMsg {
Expand All @@ -25,8 +24,6 @@ pub enum Cw20HookMsg {
WithdrawLiquidity { pair_identifier: String },
}



#[cw_serde]
pub enum SwapOperation {
WhaleSwap {
Expand Down Expand Up @@ -55,7 +52,7 @@ impl fmt::Display for SwapOperation {
f,
"WhaleSwap {{ token_in_info: {token_in_info}, token_out_info: {token_out_info}, pool_identifier: {pool_identifier} }}"
),

}
}
}
Expand Down Expand Up @@ -85,7 +82,6 @@ impl fmt::Display for SwapRoute {
}
}


// Define a structure for Fees which names a number of defined fee collection types, maybe leaving room for a custom room a user can use to pass a fee with a defined custom name
#[cw_serde]
pub enum Fee {
Expand All @@ -100,7 +96,7 @@ pub struct StableSwapParams {
pub initial_amp: String,
pub future_amp: String,
pub initial_amp_block: String,
pub future_amp_block: String
pub future_amp_block: String,
}

// Store PairInfo to N
Expand All @@ -119,7 +115,6 @@ pub struct NPairInfo {
}
impl NPairInfo {}


#[cw_serde]
pub struct InstantiateMsg {
pub fee_collector_addr: String,
Expand Down Expand Up @@ -195,7 +190,7 @@ pub enum ExecuteMsg {
/// Adds swap routes to the router.
AddSwapRoutes {
swap_routes: Vec<SwapRoute>,
},
},
// CW20 Methods
Receive(Cw20ReceiveMsg),
}
Expand Down Expand Up @@ -247,7 +242,6 @@ pub enum QueryMsg {
// ask_amount: Uint128,
// operations: Vec<SwapOperation>,
// },

#[returns(NPairInfo)]
Pair { pair_identifier: String },
}
2 changes: 0 additions & 2 deletions packages/white-whale-std/src/pool_network/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ impl AssetInfo {
}
}



pub fn equal(&self, asset: &AssetInfo) -> bool {
match self {
AssetInfo::Token { contract_addr, .. } => {
Expand Down
14 changes: 9 additions & 5 deletions packages/white-whale-std/src/pool_network/mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use std::iter::FromIterator;
use std::marker::PhantomData;
use std::panic;

use cosmwasm_std::testing::{MockQuerier, MockApi, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
from_json, to_json_binary, Coin, ContractInfoResponse, ContractResult, Empty, OwnedDeps,
Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, CodeInfoResponse, Addr, HexBinary, to_binary,
from_json, to_binary, to_json_binary, Addr, CodeInfoResponse, Coin, ContractInfoResponse,
ContractResult, Empty, HexBinary, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError,
SystemResult, Uint128, WasmQuery,
};
use cw20::{BalanceResponse as Cw20BalanceResponse, Cw20QueryMsg, TokenInfoResponse};

Expand Down Expand Up @@ -348,15 +349,18 @@ impl WasmMockQuerier {
SystemResult::Ok(ContractResult::Ok(
to_json_binary(&contract_info_response).unwrap(),
))
},
}
QueryRequest::Wasm(WasmQuery::CodeInfo { code_id }) => {
let mut default = CodeInfoResponse::default();

match code_id {
11 => {
default.code_id = 67;
default.creator = Addr::unchecked("creator").to_string();
default.checksum =HexBinary::from_hex(&sha256::digest(format!("code_checksum_{}", code_id)))
default.checksum = HexBinary::from_hex(&sha256::digest(format!(
"code_checksum_{}",
code_id
)))
.unwrap();
SystemResult::Ok(to_binary(&default).into())
}
Expand Down
2 changes: 1 addition & 1 deletion packages/white-whale-std/src/pool_network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub mod pair;
pub mod querier;
pub mod router;
pub mod swap;
pub mod temp_mock_api;
pub mod token;
pub mod trio;
pub mod temp_mock_api;

#[cfg(test)]
mod testing;
Expand Down
2 changes: 1 addition & 1 deletion packages/white-whale-std/src/pool_network/temp_mock_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ impl Api for MockSimpleApi {
fn debug(&self, message: &str) {
println!("{}", message);
}
}
}

0 comments on commit 3001207

Please sign in to comment.