Skip to content

Commit

Permalink
Refactored imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszDepta committed Oct 6, 2023
1 parent a042922 commit 9aa70e2
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 62 deletions.
9 changes: 4 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ use crate::transactions::transactional;
use crate::wasm::{ContractData, Wasm, WasmKeeper, WasmSudo};
use crate::AppBuilder;
use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::testing::{MockApi, MockStorage};
use cosmwasm_std::{
from_slice,
testing::{MockApi, MockStorage},
to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CosmosMsg, CustomQuery, Empty, GovMsg,
IbcMsg, IbcQuery, Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage,
SystemError, SystemResult,
from_slice, to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CosmosMsg, CustomQuery,
Empty, GovMsg, IbcMsg, IbcQuery, Querier, QuerierResult, QuerierWrapper, QueryRequest, Record,
Storage, SystemError, SystemResult,
};
use schemars::JsonSchema;
use serde::{de::DeserializeOwned, Serialize};
Expand Down
14 changes: 6 additions & 8 deletions src/bank.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use crate::app::CosmosRouter;
use crate::executor::AppResponse;
use crate::module::Module;
use crate::prefixed_storage::{prefixed, prefixed_read};
use anyhow::{bail, Result as AnyResult};
use itertools::Itertools;
use schemars::JsonSchema;

use cosmwasm_std::{
coin, to_binary, Addr, AllBalanceResponse, Api, BalanceResponse, BankMsg, BankQuery, Binary,
BlockInfo, Coin, Event, Order, Querier, StdResult, Storage, SupplyResponse, Uint128,
};
use cw_storage_plus::Map;
use cw_utils::NativeBalance;

use crate::app::CosmosRouter;
use crate::executor::AppResponse;
use crate::module::Module;
use crate::prefixed_storage::{prefixed, prefixed_read};
use itertools::Itertools;
use schemars::JsonSchema;

const BALANCES: Map<&Addr, NativeBalance> = Map::new("balances");

Expand Down
12 changes: 5 additions & 7 deletions src/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use anyhow::{anyhow, bail, Result as AnyResult};
use cosmwasm_std::{
from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo,
QuerierWrapper, Reply, Response, SubMsg,
};
use schemars::JsonSchema;
use serde::de::DeserializeOwned;
use std::error::Error;
use std::fmt::{self, Debug, Display};
use std::ops::Deref;

use cosmwasm_std::{
from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo,
QuerierWrapper, Reply, Response, SubMsg,
};

use anyhow::{anyhow, bail, Result as AnyResult};

/// Interface to call into a `Contract`.
pub trait Contract<T, Q = Empty>
where
Expand Down
8 changes: 3 additions & 5 deletions src/custom_handler.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use crate::app::CosmosRouter;
use crate::{AppResponse, Module};
use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::{Addr, Api, Binary, BlockInfo, Empty, Querier, Storage};
use derivative::Derivative;
use std::cell::{Ref, RefCell};
use std::ops::Deref;
use std::rc::Rc;

use cosmwasm_std::{Addr, Api, Binary, BlockInfo, Empty, Querier, Storage};

use crate::app::CosmosRouter;
use crate::{AppResponse, Module};

/// Internal state of `CachingCustomHandler` wrapping internal mutability so it is not exposed to
/// user. Those have to be shared internal state, as after mock is passed to app it is not
/// possible to access mock internals which are not exposed by API.
Expand Down
6 changes: 2 additions & 4 deletions src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::fmt;

use anyhow::Result as AnyResult;
use cosmwasm_std::{
to_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgResponse, WasmMsg,
};
use cw_utils::{parse_execute_response_data, parse_instantiate_response_data};
use schemars::JsonSchema;
use serde::Serialize;

use anyhow::Result as AnyResult;
use std::fmt;

#[derive(Default, Clone, Debug)]
pub struct AppResponse {
Expand Down
3 changes: 1 addition & 2 deletions src/gov.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cosmwasm_std::{Empty, GovMsg};

use crate::{FailingModule, Module};
use cosmwasm_std::{Empty, GovMsg};

pub trait Gov: Module<ExecT = GovMsg, QueryT = Empty, SudoT = Empty> {}

Expand Down
3 changes: 1 addition & 2 deletions src/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cosmwasm_std::{Binary, Empty, IbcMsg, IbcQuery};

use crate::{AppResponse, FailingModule, Module};
use cosmwasm_std::{Binary, Empty, IbcMsg, IbcQuery};

pub trait Ibc: Module<ExecT = IbcMsg, QueryT = IbcQuery, SudoT = Empty> {}

Expand Down
8 changes: 3 additions & 5 deletions src/module.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::marker::PhantomData;

use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::{Addr, Api, Binary, BlockInfo, CustomQuery, Querier, Storage};

use crate::app::CosmosRouter;
use crate::AppResponse;
use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::{Addr, Api, Binary, BlockInfo, CustomQuery, Querier, Storage};
use schemars::JsonSchema;
use serde::de::DeserializeOwned;
use std::marker::PhantomData;

/// Interface of the module.
pub trait Module {
Expand Down
7 changes: 3 additions & 4 deletions src/prefixed_storage.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
mod length_prefixed;
mod namespace_helpers;

use cosmwasm_std::Storage;
#[cfg(feature = "iterator")]
use cosmwasm_std::{Order, Record};

use length_prefixed::{to_length_prefixed, to_length_prefixed_nested};
#[cfg(feature = "iterator")]
use namespace_helpers::range_with_prefix;
use namespace_helpers::{get_with_prefix, remove_with_prefix, set_with_prefix};

mod length_prefixed;
mod namespace_helpers;

/// An alias of PrefixedStorage::new for less verbose usage
pub fn prefixed<'a>(storage: &'a mut dyn Storage, namespace: &[u8]) -> PrefixedStorage<'a> {
PrefixedStorage::new(storage, namespace)
Expand Down
15 changes: 6 additions & 9 deletions src/staking.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use std::collections::{BTreeSet, VecDeque};

use crate::app::CosmosRouter;
use crate::executor::AppResponse;
use crate::prefixed_storage::{prefixed, prefixed_read};
use crate::{BankSudo, Module};
use anyhow::{anyhow, bail, Result as AnyResult};
use schemars::JsonSchema;

use cosmwasm_std::{
coin, ensure, ensure_eq, to_binary, Addr, AllDelegationsResponse, AllValidatorsResponse, Api,
BankMsg, Binary, BlockInfo, BondedDenomResponse, Coin, CustomQuery, Decimal, Delegation,
DelegationResponse, DistributionMsg, Empty, Event, FullDelegation, Querier, StakingMsg,
StakingQuery, Storage, Timestamp, Uint128, Validator, ValidatorResponse,
};
use cw_storage_plus::{Deque, Item, Map};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::app::CosmosRouter;
use crate::executor::AppResponse;
use crate::prefixed_storage::{prefixed, prefixed_read};
use crate::{BankSudo, Module};
use std::collections::{BTreeSet, VecDeque};

// Contains some general staking parameters
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down
9 changes: 4 additions & 5 deletions src/tests/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ use crate::{
Router, Staking, Wasm, WasmSudo,
};
use anyhow::{bail, Result as AnyResult};
use cosmwasm_std::testing::{mock_env, MockQuerier};
use cosmwasm_std::testing::{mock_env, MockApi, MockQuerier};
use cosmwasm_std::{
coin, coins, from_slice, testing::MockApi, to_binary, Addr, AllBalanceResponse, Api, Attribute,
BankMsg, BankQuery, Binary, BlockInfo, Coin, CosmosMsg, CustomQuery, Empty, Event,
OverflowError, OverflowOperation, Querier, Reply, StdError, StdResult, Storage, SubMsg,
WasmMsg,
coin, coins, from_slice, to_binary, Addr, AllBalanceResponse, Api, Attribute, BankMsg,
BankQuery, Binary, BlockInfo, Coin, CosmosMsg, CustomQuery, Empty, Event, OverflowError,
OverflowOperation, Querier, Reply, StdError, StdResult, Storage, SubMsg, WasmMsg,
};
use cw_storage_plus::Item;
use cw_utils::parse_instantiate_response_data;
Expand Down
10 changes: 4 additions & 6 deletions src/transactions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use anyhow::Result as AnyResult;
use cosmwasm_std::Storage;
#[cfg(feature = "iterator")]
use cosmwasm_std::{Order, Record};
#[cfg(feature = "iterator")]
use std::cmp::Ordering;
use std::collections::BTreeMap;
Expand All @@ -8,12 +12,6 @@ use std::iter::Peekable;
#[cfg(feature = "iterator")]
use std::ops::{Bound, RangeBounds};

use cosmwasm_std::Storage;
#[cfg(feature = "iterator")]
use cosmwasm_std::{Order, Record};

use anyhow::Result as AnyResult;

#[cfg(feature = "iterator")]
/// The BTreeMap specific key-value pair reference type, as returned by `BTreeMap<Vec<u8>, T>::range`.
/// This is internal as it can change any time if the map implementation is swapped out.
Expand Down

0 comments on commit 9aa70e2

Please sign in to comment.