Skip to content

Commit

Permalink
haha
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 20, 2024
1 parent e81b391 commit 4489b34
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/cosmwasm/order/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ pub const DEFAULT_BATCH_EPOCH: u32 = 2;

/// count of solutions at minimum which can be decided, just set 1 for ease of devtest
pub const DEFAULT_MIN_SOLUTION_COUNT: u32 = 1;

pub const MAX_ORDER_COUNT: usize = 100;
4 changes: 4 additions & 0 deletions contracts/cosmwasm/order/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pub(crate) fn expected_some_funds_in_route() -> StdError {
StdError::generic_err("Expected some funds in route")
}

pub fn max_order_count_reached(max: usize) -> StdError {
StdError::generic_err(format!("Max order count reached: {}", max))
}

pub fn banks_funds_must_be_at_least_routed(has: &Coin, expected: &Coin) -> StdError {
StdError::generic_err(format!(
"banks_funds_must_be_at_least_routed {:?} => {:?} ",
Expand Down
9 changes: 9 additions & 0 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use simulator::simulate_cows_via_bank;
use state::*;
pub use types::*;

use crate::constants::MAX_ORDER_COUNT;
pub use crate::sv::{ExecMsg, QueryMsg};

use cosmwasm_std::{wasm_execute, Addr, BankMsg, Coin, Event, Order, StdError, Storage};
Expand Down Expand Up @@ -84,6 +85,14 @@ impl OrderContract<'_> {
/// spamming), and stores order for searchers.
#[msg(exec)]
pub fn order(&self, ctx: ExecCtx, msg: OrderSubMsg) -> StdResult<Response> {
ensure!(
self.orders
.keys_raw(ctx.deps.storage, None, None, Order::Ascending)
.count()
< MAX_ORDER_COUNT,
errors::max_order_count_reached(MAX_ORDER_COUNT)
);

// for now we just use bank for ics20 tokens
let funds = ctx
.info
Expand Down

0 comments on commit 4489b34

Please sign in to comment.