Debugging

This commit is contained in:
sairajzero 2021-09-25 00:29:48 +05:30
parent 73c0ee9821
commit 9ec17b4d55
4 changed files with 10 additions and 12 deletions

View File

@ -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);

View File

@ -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);
})

View File

@ -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 => {

View File

@ -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));
}