Skip to content

Commit

Permalink
event
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Nov 22, 2023
1 parent 46cef33 commit c078c96
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ impl OrderContract<'_> {
};
self.orders.save(ctx.deps.storage, order_id, &order)?;
self.next_order_id.save(ctx.deps.storage, &(order_id + 1))?;
let order_created =
Event::new("mantis-order-created").add_attribute("order_id", order_id.to_string());
let order_created = order_created(order_id, &order);
ctx.deps
.api
.debug(&format!("mantis::order::created: {:?}", order));
Expand Down Expand Up @@ -431,6 +430,17 @@ impl OrderContract<'_> {
}
}

fn order_created(order_id: u128, order: &OrderItem) -> Event {
let order_created = Event::new("mantis-order-created")
.add_attribute("order_id", order_id.to_string())
.add_attribute("order_given_amount", order.given.amount.to_string())
.add_attribute("order_given_denom", order.given.denom.to_string())
.add_attribute("order_owner", order.owner.to_string())
.add_attribute("order_wants_amount", order.msg.wants.amount.to_string())
.add_attribute("order_wants_denom", order.msg.wants.denom.to_string());
order_created
}

/// given all orders amounts aggregated into common pool,
/// ensure that solution does not violates this pull
/// and return proper action to handle settling funds locally according solution
Expand Down

0 comments on commit c078c96

Please sign in to comment.