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) {
|
||||
if (typeof request !== "object")
|
||||
throw Error("Request is not an object");
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>Current FLO Rate: <span id="cur-rate"></span></div>
|
||||
<form id="login-form">
|
||||
<fieldset>
|
||||
<legend>Login</legend>
|
||||
@ -302,6 +303,14 @@
|
||||
}).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) {
|
||||
if (init)
|
||||
console.info("init");
|
||||
@ -310,6 +319,7 @@
|
||||
list_buy();
|
||||
list_sell();
|
||||
list_txns();
|
||||
get_rate();
|
||||
if (init || document.getElementById('user-container').style.display === "block")
|
||||
account();
|
||||
}
|
||||
|
||||
@ -50,8 +50,9 @@ module.exports = function App(secret, DB) {
|
||||
app.get('/list-sellorders', Request.ListSellOrders);
|
||||
app.get('/list-buyorders', Request.ListBuyOrders);
|
||||
|
||||
//list all process transactions
|
||||
//list all process transactions and rate
|
||||
app.get('/list-transactions', Request.ListTransactions);
|
||||
app.get('/get-rate', Request.getRate)
|
||||
|
||||
//get account details
|
||||
app.get('/account', Request.Account);
|
||||
|
||||
@ -52,8 +52,6 @@ const tokenAPI = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getRates() {
|
||||
return new Promise((resolve, reject) => {
|
||||
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) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floID || !floCrypto.validateAddr(floID))
|
||||
@ -657,6 +659,7 @@ function transactionReCheck() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
returnRates,
|
||||
addBuyOrder,
|
||||
addSellOrder,
|
||||
cancelOrder,
|
||||
|
||||
@ -243,6 +243,11 @@ function ListTransactions(req, res) {
|
||||
.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) {
|
||||
const setLogin = function(message) {
|
||||
let randID = floCrypto.randString(16, true);
|
||||
@ -409,6 +414,7 @@ module.exports = {
|
||||
ListSellOrders,
|
||||
ListBuyOrders,
|
||||
ListTransactions,
|
||||
getRate,
|
||||
Account,
|
||||
DepositFLO,
|
||||
WithdrawFLO,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user