Skip to content

Commit

Permalink
feat: show id of order and tx hash when posting the discrete order (#169
Browse files Browse the repository at this point in the history
)

# Description
This PR is the most pressing change in the proposal to improve
debuggability of watch-tower described in
https://docs.google.com/document/d/1rNM4pqS-d17Yx1Ei_RMMvER5vJfK1c8I7Ik74PbOHSc/edit?tab=t.0


Basically, this PR allows us to connect the discrete orders with the
programmatic order that created them. This is really important, because
we can connect some issues on some orders that are wrongly created by a
smart contract, with the smart contract that created them in the first
place.
  • Loading branch information
anxolin authored Dec 5, 2024
1 parent 8c8f0f5 commit dbb2a8c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/domain/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ async function _processConditionalOrder(
): Promise<PollResult> {
const { provider, orderBookApi, dryRun, chainId } = context;
const { handler } = conditionalOrder.params;

const log = getLogger(
"checkForAndPlaceOrder:_processConditionalOrder",
orderRef
Expand Down Expand Up @@ -412,6 +413,7 @@ async function _processConditionalOrder(
if (!conditionalOrder.orders.has(orderUid)) {
// Place order
const placeOrderResult = await _placeOrder({
conditionalOrder,
orderUid,
order: { ...orderToSubmit, from: owner, signature },
orderBookApi,
Expand Down Expand Up @@ -500,6 +502,7 @@ export const _printUnfilledOrders = (orders: Map<BytesLike, OrderStatus>) => {
* @param apiUrl rest api url
*/
async function _placeOrder(params: {
conditionalOrder: ConditionalOrder;
orderUid: string;
order: any;
orderBookApi: OrderBookApi;
Expand All @@ -509,6 +512,7 @@ async function _placeOrder(params: {
metricLabels: string[];
}): Promise<Omit<PollResultSuccess, "order" | "signature"> | PollResultErrors> {
const {
conditionalOrder,
orderUid,
order,
orderBookApi,
Expand All @@ -518,7 +522,6 @@ async function _placeOrder(params: {
metricLabels,
} = params;
const log = getLogger("checkForAndPlaceOrder:_placeOrder", orderRef);
const { chainId } = orderBookApi.context;
try {
const postOrder: OrderCreation = {
kind: order.kind,
Expand All @@ -539,7 +542,9 @@ async function _placeOrder(params: {
};

// If the operation is a dry run, don't post to the API
log.info(`Post order ${orderUid} to OrderBook on chain ${chainId}`);
log.info(
`Post order ${orderUid} (ID=${conditionalOrder.id}, TX=${conditionalOrder.tx})`
);
log.debug(`Post order ${orderUid} details`, postOrder);
if (!dryRun) {
const orderUid = await orderBookApi.sendOrder(postOrder);
Expand Down

0 comments on commit dbb2a8c

Please sign in to comment.