Skip to content

Commit

Permalink
close, lots of missing imports
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPresident committed Oct 25, 2023
1 parent 7a6adf7 commit f08f252
Show file tree
Hide file tree
Showing 27 changed files with 73 additions and 1,526 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = [
# Packages
"packages/shade_protocol",
"packages/shadeswap_shared",
#"packages/shadeswap_shared",
# "packages/secretcli",
"packages/multi_test",
"packages/multi_derive",
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_book/lb_pair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde-json-wasm = { version = "0.5"}
thiserror = { version = "1" }
secret-storage-plus = { git = "https://github.com/securesecrets/secret-plus-utils", version = "0.13.4", optional = true }
ethnum = { version = "1" }
shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }
#shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }

[dev-dependencies]
anyhow = "1"
Expand Down
4 changes: 2 additions & 2 deletions contracts/liquidity_book/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ serde = { version = "1.0.114", default-features = false, features = [
schemars = "0.8.1"
cosmwasm-std = { package = "secret-cosmwasm-std", version = "=1.1.11", features = ["iterator"] }
cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "=1.1.11", features = ["iterator"] }
shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = [] }
# shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = ["swap"] }
[dev-dependencies]
cosmwasm-schema = { git = "https://github.com/CosmWasm/cosmwasm"}
secret-multi-test = { git = "https://github.com/securesecrets/secret-plus-utils", version = "0.13.4", features=["iterator"] }
37 changes: 13 additions & 24 deletions contracts/liquidity_book/router/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,20 @@ use crate::{
state::{config_r, config_w, registered_tokens_list_r, registered_tokens_list_w, Config},
};
use cosmwasm_std::{
entry_point,
from_binary,
to_binary,
Addr,
BankMsg,
Binary,
Coin,
CosmosMsg,
Deps,
DepsMut,
Env,
MessageInfo,
Reply,
Response,
StdError,
StdResult,
Uint128,
entry_point, from_binary, to_binary, Addr, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut,
Env, MessageInfo, Reply, Response, StdError, StdResult, Uint128,
};
use shade_protocol::{utils::liquidity_book::tokens::TokenType, Contract};
use shadeswap_shared::{
admin::helpers::{validate_admin, AdminPermissions},
use shade_protocol::contract_interfaces::swap::{
amm_pair::QueryMsgResponse as AMMPairQueryReponse,
core::TokenAmount,
core::{
admin::helpers::{validate_admin, AdminPermissions},
TokenAmount,
},
router::{ExecuteMsg, InitMsg, InvokeMsg, QueryMsg, QueryMsgResponse},
snip20::helpers::send_msg,
utils::{pad_handle_result, pad_query_result},
};
use shade_protocol::{utils::liquidity_book::tokens::TokenType, Contract};

/// Pad handle responses and log attributes to blocks
/// of 256 bytes to prevent leaking info based on response size
Expand Down Expand Up @@ -177,11 +164,13 @@ fn receiver_callback(
path,
recipient,
} => {
let pair_contract_config =
query::pair_contract_config(&deps.querier, Contract {
let pair_contract_config = query::pair_contract_config(
&deps.querier,
Contract {
address: deps.api.addr_validate(&path[0].addr.to_string())?,
code_hash: path[0].code_hash.clone(),
})?;
},
)?;

match pair_contract_config {
AMMPairQueryReponse::GetPairInfo {
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_book/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ shade-multi-test = { path = "../../../packages/multi_test", features = [
"lb_factory"
] }

shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }
# shadeswap-shared = { version = "0.1.0", path = "../../../packages/shadeswap_shared", features = [] }
2 changes: 1 addition & 1 deletion packages/multi_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mock_stkd = { version = "0.1.0", package = "mock_stkd_derivative", path = "../..
mock_sienna = { version = "0.1.0", package = "mock_sienna_pair", path = "../../contracts/mock/mock_sienna_pair", optional = true }
snip20_migration = { version = "0.1.0", path = "../../contracts/snip20_migration", optional = true }
shade-protocol = { path = "../shade_protocol", features = ["multi-test"] }
shadeswap-shared = { version = "0.1.0", path = "../../packages/shadeswap_shared", features = [] }
# shadeswap-shared = { version = "0.1.0", path = "../../packages/shadeswap_shared", features = [] }
anyhow = "1"

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
Expand Down
1 change: 1 addition & 0 deletions packages/shade_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ admin = ["interface"]
peg_stability = ["sky-utils", "adapter"]
snip20_migration = []
liquidity_book = ["interface"]
swap = ["snip20"]

chrono = ["dep:chrono"]

Expand Down
3 changes: 3 additions & 0 deletions packages/shade_protocol/src/contract_interfaces/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ pub mod basic_staking;

#[cfg(feature = "snip20_migration")]
pub mod snip20_migration;

#[cfg(feature = "swap")]
pub mod swap;
28 changes: 12 additions & 16 deletions packages/shade_protocol/src/contract_interfaces/swap/amm_pair.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
use crate::{
c_std::{
utils::{ExecuteCallback, InstantiateCallback, Query},
Addr, Binary, Uint128, BLOCK_SIZE,
},
c_std::{Addr, Binary, Decimal256, Uint128, Uint256},
cosmwasm_schema::cw_serde,
liquidity_book::lb_pair::SwapResult,
lb_pair::SwapResult,
snip20::Snip20ReceiveMsg,
utils::asset::RawContract,
utils::liquidity_book::tokens::TokenType,
Contract,
swap::core::{
ContractInstantiationInfo, CustomFee, Fee, StableTokenData, TokenAmount, TokenPair,
TokenPairAmount,
},
utils::{
asset::RawContract, liquidity_book::tokens::TokenType, ExecuteCallback,
InstantiateCallback, Query,
},
Contract, BLOCK_SIZE,
};

use std::fmt::{Debug, Display};

use super::*;
use core::{
ContractInstantiationInfo, ContractInstantiationInfo, CustomFee, Fee, StableTokenData,
TokenAmount, TokenPair, TokenPairAmount,
};
use staking::StakingContractInstantiateInfo;

use cosmwasm_std::{Addr, Decimal256, Uint256};
use crate::swap::staking::StakingContractInstantiateInfo;

/// Represents the address of an exchange and the pair that it manages
#[cw_serde]
Expand Down
37 changes: 0 additions & 37 deletions packages/shade_protocol/src/contract_interfaces/swap/core/admin.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cosmwasm_std::{Binary, CosmosMsg, WasmMsg};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use shade_protocol::Contract;
use crate::Contract;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
/// Info needed to have the other contract respond.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{Event, StdError, StdResult};
use crate::c_std::{Event, StdError, StdResult};

pub struct EventsParser;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod admin;
// mod admin;
mod callback;
mod custom_fee;
mod display;
Expand All @@ -8,7 +8,7 @@ mod token_pair;
mod token_pair_amount;
mod token_type;
mod viewing_keys;
pub use admin::*;
// pub use admin::*;
pub use callback::*;
pub use custom_fee::*;
pub use display::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::swap::core::TokenType;
use cosmwasm_std::StdResult;
use cosmwasm_std::{MessageInfo, Uint128};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use shade_protocol::utils::liquidity_book::tokens::TokenType;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct TokenAmount {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use cosmwasm_std::{Deps, StdResult, Uint128};
use crate::{
c_std::{Deps, StdResult, Uint128},
swap::core::{TokenPairAmount, TokenType},
Contract,
};
use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use shade_protocol::{utils::liquidity_book::tokens::TokenType, Contract};

use super::TokenPairAmount;

#[derive(Clone, Debug, JsonSchema)]
pub struct TokenPair(pub TokenType, pub TokenType, pub bool);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#[warn(unused_imports)]
use cosmwasm_std::{MessageInfo, StdError, StdResult, Uint128};
use crate::c_std::{MessageInfo, StdError, StdResult, Uint128};
use crate::utils::liquidity_book::tokens::TokenType;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use shade_protocol::utils::liquidity_book::tokens::TokenType;

use super::TokenPair;
use crate::swap::core::TokenPair;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct TokenPairAmount {
pub pair: TokenPair,
Expand Down Expand Up @@ -84,10 +85,10 @@ impl<'a> Iterator for TokenPairAmountIterator<'a> {
}

pub mod tests {
use cosmwasm_std::{Addr, Uint128};
use shade_protocol::utils::liquidity_book::tokens::TokenType;
use crate::c_std::{Addr, Uint128};
use crate::utils::liquidity_book::tokens::TokenType;

use crate::core::TokenPair;
use crate::swap::core::TokenPair;

use super::TokenPairAmount;

Expand Down Expand Up @@ -148,10 +149,8 @@ pub mod tests {
},
false,
);
assert!(
reverse_amount
.create_new_pair_amount_to_match_order_of(&broken_pair)
.is_err()
);
assert!(reverse_amount
.create_new_pair_amount_to_match_order_of(&broken_pair)
.is_err());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::liquidity_book::tokens::TokenType;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use shade_protocol::utils::liquidity_book::tokens::TokenType;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct StableTokenData {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cosmwasm_std::{Binary, Env, MessageInfo};
use crate::c_std::{Binary, Env, MessageInfo};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;
use subtle::ConstantTimeEq;

use shade_protocol::utils::crypto::{sha_256, Prng};
use crate::utils::crypto::{sha_256, Prng};

pub const VIEWING_KEY_SIZE: usize = 32;
const VIEWING_KEY_PREFIX: &str = "api_key_";
Expand Down
6 changes: 3 additions & 3 deletions packages/shade_protocol/src/contract_interfaces/swap/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core;
pub mod core;

use amm_pair;
use staking;
pub mod amm_pair;
pub mod staking;
12 changes: 7 additions & 5 deletions packages/shade_protocol/src/contract_interfaces/swap/staking.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
use crate::swap::core::{time, ContractInstantiationInfo, BLOCK_SIZE};
use crate::{
c_std::{
Addr, Addr, Binary, CosmosMsg, Decimal256, OverflowError, QuerierWrapper, StdError,
StdResult, Storage, Uint128, Uint128, Uint256, Uint256,
Addr, Binary, CosmosMsg, Decimal256, OverflowError, QuerierWrapper, StdError, StdResult,
Storage, Uint128, Uint256,
},
contract_interfaces::snip20::ExecuteMsg as Snip20ExecuteMsg,
cosmwasm_schema::{cw_serde, QueryResponses},
query_auth::QueryPermit,
secret_storage_plus::{Bincode2, Item, ItemStorage, Map},
snip20::ExecuteMsg as Snip20ExecuteMsg,
snip20::Snip20ReceiveMsg,
utils::{
asset::RawContract, liquidity_book::tokens::TokenType, ExecuteCallback,
InstantiateCallback, Query,
},
Contract,
};
use core::{time, ContractInstantiationInfo, BLOCK_SIZE};
use std::{cmp::min, collections::HashMap};

use super::{
/*
use crate::swap::core::{
ClaimRewardResponse, ClaimableRewardsResponse, ConfigResponse, PermitQueryResponse,
RewardTokenInfo,
};
*/

impl InstantiateCallback for InstantiateMsg {
const BLOCK_SIZE: usize = BLOCK_SIZE;
Expand Down
10 changes: 5 additions & 5 deletions packages/shade_protocol/src/utils/asset.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::vec;

use crate::{
c_std::{Addr, Api, BalanceResponse, BankQuery, ContractInfo, Deps, StdResult, Uint128},
c_std::{
Addr, Api, BalanceResponse, BankQuery, ContractInfo, CosmosMsg, Deps, DepsMut, Env,
StdResult, Uint128,
},
cosmwasm_schema::cw_serde,
BLOCK_SIZE,
};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{CosmosMsg, DepsMut, Env};

/// Validates an optional address.
pub fn optional_addr_validate(api: &dyn Api, addr: Option<String>) -> StdResult<Option<Addr>> {
Expand Down
Loading

0 comments on commit f08f252

Please sign in to comment.