Skip to content

Commit

Permalink
fixed bank
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 13, 2024
1 parent cc4861b commit 300e8a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
21 changes: 8 additions & 13 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,15 @@ impl OrderContract<'_> {
let mut order: OrderItem = self.orders.load(storage, order_amount.u128())?;
order.fill(transfer_coin.amount, optimal_price)?;

// hey, need some other data structure for this
let solver_order = solver_orders
.iter_mut()
.find(|x| x.order.order_id == order.order_id)
.expect("solver order");

solver_order.order = order.clone();

let (event, remaining) = if order.given.amount.is_zero() {
// hey, need some other data structure for this
TOOD
let (_idx, solver_order) = solver_orders
.iter()
.find_position(|x| x.order.order_id == order.order_id)
.expect("solver order");

api.debug(&format!("mantis::order::filled::full {:?}", order.order_id));

Expand All @@ -533,13 +535,6 @@ impl OrderContract<'_> {
false,
)
} else {
let solver_order = solver_orders
.iter_mut()
.find(|x| x.order.order_id == order.order_id)
.expect("solver order");

solver_order.order = order.clone();

self.orders.save(storage, order.order_id.u128(), &order)?;
(
mantis_order_filled_partially(
Expand Down
4 changes: 2 additions & 2 deletions contracts/cosmwasm/outpost/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) fn force_asset(_: auth::Admin, deps: DepsMut, msg: AssetItem) -> Resu
pub(crate) fn get_asset_by_id(deps: Deps, asset_id: AssetId) -> Result<AssetItem> {
ASSETS
.may_load(deps.storage, asset_id)?
.ok_or(ContractError::AssetNotFound)
.ok_or(ContractError::AssetIdNotFound)
}

/// Fetches information about given asset by its local reference.
Expand All @@ -40,7 +40,7 @@ pub(crate) fn get_local_asset_by_reference(
) -> Result<AssetItem> {
LOCAL_ASSETS
.may_load(deps.storage, reference)?
.ok_or(ContractError::AssetNotFound)
.ok_or(ContractError::AssetIdNotFound)
}

/// Removes an existing asset from the registry; errors out if asset doesn’t
Expand Down
4 changes: 2 additions & 2 deletions contracts/cosmwasm/outpost/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub enum ContractError {
FailedIBCTransfer(String),
#[error("Could not serialize to JSON")]
FailedToSerialize,
#[error("Asset not been found in the registry.")]
AssetNotFound,
#[error("Asset not been found in the registry {0}.")]
AssetIdNotFound(AssetId),
#[error("Exchange not been found in the registry.")]
ExchangeNotFound,
#[error("The contract must be initialized first.")]
Expand Down

0 comments on commit 300e8a1

Please sign in to comment.