From 9ec17b4d5536d18bddc10f78ea91870ac35c42c6 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sat, 25 Sep 2021 00:29:48 +0530 Subject: [PATCH] Debugging --- public/fn.js | 2 +- public/home.html | 16 ++++++++-------- src/market.js | 3 --- src/request.js | 1 + 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/public/fn.js b/public/fn.js index 895a403..8b64a9e 100644 --- a/public/fn.js +++ b/public/fn.js @@ -268,7 +268,7 @@ function cancelOrder(type, id, proxySecret) { type: "cancel_order", order: type, id: id, - timestamp: data.timestamp + timestamp: request.timestamp }, proxySecret); console.debug(request); diff --git a/public/home.html b/public/home.html index da3e667..d33a1d5 100644 --- a/public/home.html +++ b/public/home.html @@ -303,14 +303,9 @@ } function refresh(init = false) { - if (init) { + if (init) console.info("init"); - try { - proxy.secret; - } catch (error) { - console.warn(error); - } - } else + else console.info("refresh"); list_buy(); list_sell(); @@ -381,7 +376,11 @@ row.insertCell().textContent = o.unitValue; row.insertCell().textContent = new Date(o.tx_time); }); - + try { + proxy.secret; + } catch (error) { + console.warn(error); + } }).catch(error => { if (error instanceof ResponseError) { let response = JSON.parse(error.data) @@ -390,6 +389,7 @@ document.getElementById('user-container').style.display = "none"; document.getElementById("login-form").style.display = "block"; document.forms['login-form']["sid"].value = response.sid; + proxy.clear(); } else console.error(error); }) diff --git a/src/market.js b/src/market.js index 3209a88..f85bdc6 100644 --- a/src/market.js +++ b/src/market.js @@ -107,7 +107,6 @@ function addSellOrder(floID, quantity, min_price) { DB.query("SELECT SUM(quantity) AS locked FROM SellOrder WHERE floID=?", [floID]).then(result => { let locked = result.pop()["locked"] || 0; let available = total - locked; - console.debug(total, locked, available); if (available < quantity) return reject(INVALID("Insufficient FLO (Some FLO are locked in another sell order)")); DB.query("INSERT INTO SellOrder(floID, quantity, minPrice) VALUES (?, ?, ?)", [floID, quantity, min_price]) @@ -135,7 +134,6 @@ function addBuyOrder(floID, quantity, max_price) { DB.query("SELECT SUM(maxPrice * quantity) AS locked FROM BuyOrder WHERE floID=?", [floID]).then(result => { let locked = result.pop()["locked"] || 0; let available = total - locked; - console.debug(total, locked, available); if (available < quantity * max_price) return reject(INVALID("Insufficient Rupee balance (Some rupee tokens are locked in another buy order)")); DB.query("INSERT INTO BuyOrder(floID, quantity, maxPrice) VALUES (?, ?, ?)", [floID, quantity, max_price]) @@ -569,7 +567,6 @@ function withdrawRupee(floID, amount) { DB.query("SELECT SUM(quantity) AS locked FROM SellOrder WHERE floID=?", [floID]).then(result => { let locked = result.pop()["locked"] || 0; let available = total - locked; - console.debug(total, locked, available); if (available < required_flo) return reject(INVALID(`Insufficient FLO (Some FLO are locked in sell orders)! Required ${required_flo} FLO to withdraw tokens`)); DB.query("SELECT rupeeBalance FROM Users WHERE floID=?", [floID]).then(result => { diff --git a/src/request.js b/src/request.js index e48fa04..9dc2b1f 100644 --- a/src/request.js +++ b/src/request.js @@ -45,6 +45,7 @@ function validateRequest(request, sign, pubKey) { } function storeRequest(floID, req_str, sign) { + console.debug(floID, req_str); DB.query("INSERT INTO Request_Log (floID, request, sign) VALUES (?,?,?)", [floID, req_str, sign]) .then(_ => null).catch(error => console.error(error)); }