display current rate
Display FLO-INR rate in client page
This commit is contained in:
parent
9ec17b4d55
commit
8a014405f4
10
public/fn.js
10
public/fn.js
@ -114,6 +114,16 @@ function getTransactionList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRate() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
fetch('/get-rate')
|
||||||
|
.then(result => responseParse(result, false)
|
||||||
|
.then(result => resolve(result))
|
||||||
|
.catch(error => reject(error)))
|
||||||
|
.catch(error => reject(error));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function signRequest(request, privKey) {
|
function signRequest(request, privKey) {
|
||||||
if (typeof request !== "object")
|
if (typeof request !== "object")
|
||||||
throw Error("Request is not an object");
|
throw Error("Request is not an object");
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div>Current FLO Rate: <span id="cur-rate"></span></div>
|
||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Login</legend>
|
<legend>Login</legend>
|
||||||
@ -302,6 +303,14 @@
|
|||||||
}).catch(error => console.error(error))
|
}).catch(error => console.error(error))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_rate() {
|
||||||
|
getRate().then(rate => {
|
||||||
|
console.log("Rate: ", rate);
|
||||||
|
let container = document.getElementById("cur-rate");
|
||||||
|
container.textContent = "Rs " + parseFloat(rate).toFixed(2);
|
||||||
|
}).catch(error => console.error(error))
|
||||||
|
}
|
||||||
|
|
||||||
function refresh(init = false) {
|
function refresh(init = false) {
|
||||||
if (init)
|
if (init)
|
||||||
console.info("init");
|
console.info("init");
|
||||||
@ -310,6 +319,7 @@
|
|||||||
list_buy();
|
list_buy();
|
||||||
list_sell();
|
list_sell();
|
||||||
list_txns();
|
list_txns();
|
||||||
|
get_rate();
|
||||||
if (init || document.getElementById('user-container').style.display === "block")
|
if (init || document.getElementById('user-container').style.display === "block")
|
||||||
account();
|
account();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,8 +50,9 @@ module.exports = function App(secret, DB) {
|
|||||||
app.get('/list-sellorders', Request.ListSellOrders);
|
app.get('/list-sellorders', Request.ListSellOrders);
|
||||||
app.get('/list-buyorders', Request.ListBuyOrders);
|
app.get('/list-buyorders', Request.ListBuyOrders);
|
||||||
|
|
||||||
//list all process transactions
|
//list all process transactions and rate
|
||||||
app.get('/list-transactions', Request.ListTransactions);
|
app.get('/list-transactions', Request.ListTransactions);
|
||||||
|
app.get('/get-rate', Request.getRate)
|
||||||
|
|
||||||
//get account details
|
//get account details
|
||||||
app.get('/account', Request.Account);
|
app.get('/account', Request.Account);
|
||||||
|
|||||||
@ -52,8 +52,6 @@ const tokenAPI = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getRates() {
|
function getRates() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getRates.FLO_USD().then(FLO_rate => {
|
getRates.FLO_USD().then(FLO_rate => {
|
||||||
@ -92,6 +90,10 @@ getRates.USD_INR = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function returnRates() {
|
||||||
|
return net_FLO_price;
|
||||||
|
}
|
||||||
|
|
||||||
function addSellOrder(floID, quantity, min_price) {
|
function addSellOrder(floID, quantity, min_price) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!floID || !floCrypto.validateAddr(floID))
|
if (!floID || !floCrypto.validateAddr(floID))
|
||||||
@ -657,6 +659,7 @@ function transactionReCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
returnRates,
|
||||||
addBuyOrder,
|
addBuyOrder,
|
||||||
addSellOrder,
|
addSellOrder,
|
||||||
cancelOrder,
|
cancelOrder,
|
||||||
|
|||||||
@ -243,6 +243,11 @@ function ListTransactions(req, res) {
|
|||||||
.catch(error => res.status(INTERNAL.e_code).send("Try again later!"));
|
.catch(error => res.status(INTERNAL.e_code).send("Try again later!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRate(req, res) {
|
||||||
|
let rate = market.returnRates();
|
||||||
|
res.send(`${rate}`);
|
||||||
|
}
|
||||||
|
|
||||||
function Account(req, res) {
|
function Account(req, res) {
|
||||||
const setLogin = function(message) {
|
const setLogin = function(message) {
|
||||||
let randID = floCrypto.randString(16, true);
|
let randID = floCrypto.randString(16, true);
|
||||||
@ -409,6 +414,7 @@ module.exports = {
|
|||||||
ListSellOrders,
|
ListSellOrders,
|
||||||
ListBuyOrders,
|
ListBuyOrders,
|
||||||
ListTransactions,
|
ListTransactions,
|
||||||
|
getRate,
|
||||||
Account,
|
Account,
|
||||||
DepositFLO,
|
DepositFLO,
|
||||||
WithdrawFLO,
|
WithdrawFLO,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user