Skip to content

Commit af31add

Browse files
committed
build success
1 parent 23b7960 commit af31add

File tree

12 files changed

+31
-52
lines changed

12 files changed

+31
-52
lines changed

contracts/liquidity_book/lb_factory/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ backtraces = ["cosmwasm-std/backtraces"]
1919

2020
[dependencies]
2121
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = ["liquidity_book_impl"] }
22+
schemars = "0.8.16"
2223
serde = { version = "1.0" }
24+
cosmwasm-schema = "1.5"
2325
thiserror = { version = "1.0" }
2426
ethnum = { version = "1.5" }
2527

2628
[dev-dependencies]
2729
anyhow = "1"
2830
cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.1.11" }
29-
30-
[[bin]]
31-
name = "schema"

contracts/liquidity_book/lb_factory/src/bin/schema.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

contracts/liquidity_book/lb_factory/src/contract.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use shade_protocol::{
1717
DepsMut,
1818
Env,
1919
MessageInfo,
20+
Order::Ascending,
2021
Reply,
2122
Response,
2223
StdError,
@@ -25,19 +26,19 @@ use shade_protocol::{
2526
SubMsgResult,
2627
WasmMsg,
2728
},
29+
lb_libraries::{
30+
math::encoded_sample::EncodedSample,
31+
pair_parameter_helper::PairParameters,
32+
price_helper::PriceHelper,
33+
types::{Bytes32, ContractInstantiationInfo, StaticFeeParameters},
34+
},
2835
liquidity_book::{
2936
lb_factory::*,
3037
lb_pair::ExecuteMsg::{ForceDecay as LbPairForceDecay, SetStaticFeeParameters},
3138
},
3239
swap::core::TokenType,
3340
utils::{
3441
callback::ExecuteCallback,
35-
liquidity_book::{
36-
math::encoded_sample::EncodedSample,
37-
pair_parameter_helper::PairParameters,
38-
price_helper::PriceHelper,
39-
types::{Bytes32, ContractInstantiationInfo, StaticFeeParameters},
40-
},
4142
},
4243
};
4344

@@ -1166,7 +1167,7 @@ fn query_all_bin_steps(deps: Deps) -> Result<Binary> {
11661167

11671168
let mut bin_step_with_preset = Vec::<u16>::new();
11681169

1169-
let iterator = PRESETS.range(deps.storage, None, None, cosmwasm_std::Order::Ascending);
1170+
let iterator = PRESETS.range(deps.storage, None, None, Ascending);
11701171

11711172
for result in iterator {
11721173
let (bin_step, _preset) = result.map_err(Error::CwErr)?;
@@ -1204,7 +1205,7 @@ fn query_open_bin_steps(deps: Deps) -> Result<Binary> {
12041205

12051206
let mut open_bin_steps = Vec::<u16>::new();
12061207

1207-
let iterator = PRESETS.range(deps.storage, None, None, cosmwasm_std::Order::Ascending);
1208+
let iterator = PRESETS.range(deps.storage, None, None, Ascending);
12081209

12091210
for result in iterator {
12101211
let (bin_step, preset) = result.map_err(Error::CwErr)?;

contracts/liquidity_book/lb_factory/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! ### Custom Errors for LB_Factory contract.
22
33
use shade_protocol::{
4-
c_std::Addr,
4+
c_std::{Addr, StdError},
55
lb_libraries::{
66
bin_helper::BinError,
77
fee_helper::FeeError,
@@ -97,7 +97,7 @@ pub enum LBFactoryError {
9797
TransactionBlock(),
9898

9999
#[error(transparent)]
100-
CwErr(#[from] cosmwasm_std::StdError),
100+
CwErr(#[from] StdError),
101101

102102
#[error(transparent)]
103103
BinErr(#[from] BinError),

contracts/liquidity_book/lb_pair/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ backtraces = ["cosmwasm-std/backtraces"]
1919

2020
[dependencies]
2121
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = ["liquidity_book_impl"] }
22+
schemars = "0.8.16"
2223
serde = { version = "1.0" }
2324
serde-json-wasm = { version = "1.0"}
25+
cosmwasm-schema = "1.5"
2426
thiserror = { version = "1.0" }
2527
ethnum = { version = "1.5" }
2628

@@ -33,6 +35,3 @@ shade-multi-test = { path = "../../../packages/multi_test", features = [
3335
"lb_token",
3436
"snip20",
3537
] }
36-
37-
[[bin]]
38-
name = "schema"

contracts/liquidity_book/lb_pair/src/bin/schema.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

contracts/liquidity_book/lb_pair/src/contract.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn instantiate(
177177
CONFIG.save(deps.storage, &state)?;
178178
ORACLE.save(deps.storage, &oracle)?;
179179
CONTRACT_STATUS.save(deps.storage, &ContractStatus::Active)?;
180-
CONTRACT_STATUS.save(deps.storage, &ContractStatus::Active);
180+
CONTRACT_STATUS.save(deps.storage, &ContractStatus::Active)?;
181181
BIN_TREE.save(deps.storage, &tree)?;
182182

183183
ephemeral_storage_w(deps.storage).save(&NextTokenKey {
@@ -436,7 +436,8 @@ fn try_swap(
436436
CONFIG.update(deps.storage, |mut state| {
437437
state.protocol_fees = protocol_fees;
438438
// TODO - map the error to a StdError
439-
state.pair_parameters.set_active_id(active_id);
439+
state.pair_parameters.set_active_id(active_id)
440+
.map_err(|err| StdError::generic_err(err.to_string()))?;
440441
state.reserves = reserves;
441442
Ok::<State, StdError>(state)
442443
})?;

contracts/liquidity_book/lb_pair/src/error.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use ethnum::U256;
44
use shade_protocol::{
5-
c_std::Uint128,
5+
c_std::{Uint128, StdError},
66
lb_libraries::{
77
bin_helper::BinError,
88
fee_helper::FeeError,
@@ -69,6 +69,8 @@ pub enum LBPairError {
6969
#[error("Zero amount for bin id: {id}")]
7070
ZeroAmount { id: u32 },
7171

72+
// TODO - why return amount_to_burn and total_supply? They will be illegible as U256 anyway.
73+
// Would like to remove U256 dependency for error messages.
7274
#[error(
7375
"Zero amounts out for bin id: {id} amount to burn: {amount_to_burn} total supply: {total_supply} "
7476
)]
@@ -86,8 +88,9 @@ pub enum LBPairError {
8688
#[error("Max total fee exceeded!")]
8789
MaxTotalFeeExceeded,
8890

91+
// TODO - organize errors better. move error conversions to separate section perhaps.
8992
#[error(transparent)]
90-
CwErr(#[from] cosmwasm_std::StdError),
93+
CwErr(#[from] StdError),
9194

9295
#[error(transparent)]
9396
BinErr(#[from] BinError),

contracts/liquidity_book/router/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ default = []
2121
[dependencies]
2222
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = ["liquidity_book_impl"] }
2323
snafu = { version = "0.7.1" }
24+
schemars = "0.8.16"
2425
serde = { version = "1.0.114", default-features = false, features = [
2526
"derive",
2627
"alloc"
2728
] }
29+
cosmwasm-schema = "1.5"
2830

2931
[dev-dependencies]
3032
secret-multi-test = { git = "https://github.com/securesecrets/secret-plus-utils", version = "0.13.4", features=["iterator"] }

contracts/liquidity_book/router/src/contract.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use shade_protocol::{
2323
Response,
2424
StdError,
2525
StdResult,
26+
SubMsgResult,
2627
Uint128,
2728
},
2829
snip20::helpers::send_msg,
@@ -276,10 +277,10 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> StdResult<Response> {
276277
pad_handle_result(
277278
match msg.id {
278279
SWAP_REPLY_ID => match msg.result {
279-
cosmwasm_std::SubMsgResult::Ok(_) => {
280+
SubMsgResult::Ok(_) => {
280281
return next_swap(deps, env, Response::new());
281282
}
282-
cosmwasm_std::SubMsgResult::Err(e) => Err(StdError::generic_err(format!(
283+
SubMsgResult::Err(e) => Err(StdError::generic_err(format!(
283284
"Swap failed with message: {e}"
284285
))),
285286
},

contracts/liquidity_book/router/src/state.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ use shade_protocol::{
22
c_std::{Addr, Storage, Uint128},
33
cosmwasm_schema::cw_serde,
44
storage::{
5-
bucket,
6-
bucket_read,
7-
singleton,
8-
singleton_read,
9-
Bucket,
10-
ReadonlyBucket,
11-
ReadonlySingleton,
5+
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
126
Singleton,
137
},
148
swap::{
@@ -38,7 +32,6 @@ pub fn config_r(storage: &dyn Storage) -> ReadonlySingleton<Config> {
3832
singleton_read(storage, CONFIG)
3933
}
4034

41-
// { addr: code_hash }
4235
pub fn registered_tokens_w(storage: &mut dyn Storage) -> Bucket<String> {
4336
bucket(storage, REGISTERED_TOKENS)
4437
}
@@ -70,6 +63,6 @@ pub struct CurrentSwapInfo {
7063
pub path: Vec<Hop>,
7164
pub recipient: Addr,
7265
pub current_index: u32,
73-
//The next token that will be in the hop
66+
// The next token that will be in the hop
7467
pub next_token_in: TokenType,
7568
}

contracts/liquidity_book/tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"]
1919

2020
[dependencies]
2121
shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = ["liquidity_book_impl"] }
22+
schemars = "0.8.16"
2223
serde = { version = "1.0" }
2324
serde-json-wasm = { version = "1.0"}
2425
ethnum = { version = "1.5" }

0 commit comments

Comments
 (0)