Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
fix: replace attributes event_type to event
Browse files Browse the repository at this point in the history
  • Loading branch information
politeWall committed Nov 30, 2023
1 parent 5b69a3f commit bba4dbb
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 33 deletions.
7 changes: 4 additions & 3 deletions src/action/execute/cancel_margin_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pub fn cancel_margin_order(
amount: vec![order.collateral.clone()],
};

let resp = Response::new()
.add_attribute("event_type", "cancel_margin_order")
.add_attribute("margin_order_id", order.order_id.to_string());
let resp = Response::new().add_event(
Event::new("cancel_margin_order")
.add_attribute("margin_order_id", order.order_id.to_string()),
);

MARGIN_ORDER.save(deps.storage, &orders)?;

Expand Down
3 changes: 1 addition & 2 deletions src/action/execute/cancel_spot_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ pub fn cancel_spot_order(

let resp = Response::new()
.add_message(CosmosMsg::Bank(refund_msg))
.add_attribute("event_type", "cancel_spot_order")
.add_attribute("order_id", order_id.to_string());
.add_event(Event::new("cancel_spot_order").add_attribute("order_id", order_id.to_string()));

SPOT_ORDER.save(deps.storage, &orders_list)?;

Expand Down
14 changes: 8 additions & 6 deletions src/action/execute/create_margin_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ fn create_margin_open_order(

MARGIN_ORDER.save(deps.storage, &orders)?;

let resp = Response::new()
.add_attribute("event_type", "create_margin_open_order")
.add_attribute("margin_order_id", order_id.to_string());
let resp = Response::new().add_event(
Event::new("create_margin_open_order")
.add_attribute("margin_order_id", order_id.to_string()),
);

if order_type != MarketOpen {
return Ok(resp);
Expand Down Expand Up @@ -225,9 +226,10 @@ fn create_margin_close_order(

MARGIN_ORDER.save(deps.storage, &orders)?;

let resp = Response::new()
.add_attribute("event_type", "create_margin_close_order")
.add_attribute("margin_order_id", order_id.to_string());
let resp = Response::new().add_event(
Event::new("create_margin_close_order")
.add_attribute("margin_order_id", order_id.to_string()),
);

if order_type != MarketClose {
return Ok(resp);
Expand Down
6 changes: 4 additions & 2 deletions src/action/execute/create_spot_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ fn create_resp(
in_route: Vec<SwapAmountInRoute>,
) -> StdResult<Response<ElysMsg>> {
let resp = Response::new()
.add_attribute("event_type", "create_spot_order")
.add_attribute("order_id", new_order.order_id.to_string())
.add_event(
Event::new("create_spot_order")
.add_attribute("order_id", new_order.order_id.to_string()),
)
.add_message(bank_msg); // information message

if new_order.order_type != SpotOrderType::MarketBuy {
Expand Down
1 change: 1 addition & 0 deletions src/action/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{states::*, types::*, ContractError};
use cosmwasm_std::Event;
use cosmwasm_std::{BankMsg, CosmosMsg, DepsMut, Env, MessageInfo, Response};
use elys_bindings::*;

Expand Down
9 changes: 5 additions & 4 deletions src/action/reply/close_margin_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ pub fn reply_to_close_margin_order(

MARGIN_ORDER.save(deps.storage, &orders)?;

let resp: Response<ElysMsg> = Response::new()
.add_attribute("event_type", "reply_to_close_margin_order")
.add_attribute("margin_order_id", order_id.to_string())
.add_attribute("margin_trading_position_closed_id", res.id.to_string());
let resp: Response<ElysMsg> = Response::new().add_event(
Event::new("reply_to_close_margin_order")
.add_attribute("margin_order_id", order_id.to_string())
.add_attribute("margin_trading_position_closed_id", res.id.to_string()),
);

Ok(resp)
}
7 changes: 4 additions & 3 deletions src/action/reply/create_margin_order_market_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pub fn reply_to_create_margin_market_close(

order.status = Status::Processed;

let resp = Response::new()
.add_attribute("event_type", "reply_to_create_margin_market_close")
.add_attribute("margin_trading_position_id", margin_resp.id.to_string());
let resp = Response::new().add_event(
Event::new("reply_to_create_margin_market_close")
.add_attribute("margin_trading_position_id", margin_resp.id.to_string()),
);

Ok(resp)
}
7 changes: 4 additions & 3 deletions src/action/reply/create_margin_order_market_open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ pub fn reply_to_create_margin_market_open(
order.status = Status::Processed;
order.position_id = Some(margin_resp.id);

let resp = Response::new()
.add_attribute("event_type", "reply_to_create_margin_market_open")
.add_attribute("margin_trading_position_id", margin_resp.id.to_string());
let resp = Response::new().add_event(
Event::new("reply_to_create_margin_market_open")
.add_attribute("margin_trading_position_id", margin_resp.id.to_string()),
);

Ok(resp)
}
9 changes: 5 additions & 4 deletions src/action/reply/open_margin_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ pub fn reply_to_open_margin_position(

MARGIN_ORDER.save(deps.storage, &orders)?;

let resp: Response<ElysMsg> = Response::new()
.add_attribute("event_type", "reply_to_open_margin_position")
.add_attribute("margin_order_id", order_id.to_string())
.add_attribute("margin_trading_position_opened_id", res.id.to_string());
let resp: Response<ElysMsg> = Response::new().add_event(
Event::new("reply_to_open_margin_position")
.add_attribute("margin_order_id", order_id.to_string())
.add_attribute("margin_trading_position_opened_id", res.id.to_string()),
);

Ok(resp)
}
6 changes: 3 additions & 3 deletions src/action/reply/spot_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub fn reply_to_spot_order(

SPOT_ORDER.save(deps.storage, &orders)?;

let resp: Response<ElysMsg> = Response::new()
.add_attribute("event_type", "reply_to_spot_order")
.add_attribute("order_id", order_id.to_string());
let resp: Response<ElysMsg> = Response::new().add_event(
Event::new("reply_to_spot_order").add_attribute("order_id", order_id.to_string()),
);

Ok(resp)
}
6 changes: 3 additions & 3 deletions src/action/reply/spot_order_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub fn reply_to_spot_order_market(

SPOT_ORDER.save(deps.storage, &orders)?;

let resp: Response<ElysMsg> = Response::new()
.add_attribute("event_type", "reply_to_spot_order_market")
.add_attribute("order_id", order_id.to_string());
let resp: Response<ElysMsg> = Response::new().add_event(
Event::new("reply_to_spot_order_market").add_attribute("order_id", order_id.to_string()),
);

Ok(resp)
}

0 comments on commit bba4dbb

Please sign in to comment.