diff --git a/src/backup/KBucket.js b/public/KBucket.js
similarity index 98%
rename from src/backup/KBucket.js
rename to public/KBucket.js
index 51932b7..247896a 100644
--- a/src/backup/KBucket.js
+++ b/public/KBucket.js
@@ -1,5 +1,6 @@
'use strict';
+(function(){
/*Kademlia DHT K-bucket implementation as a binary tree.*/
/**
* Implementation of a Kademlia DHT k-bucket used for storing
@@ -7,7 +8,7 @@
*
* @extends EventEmitter
*/
-function BuildKBucket(options = {}) {
+ function BuildKBucket(options = {}) {
/**
* `options`:
* `distance`: Function
@@ -401,7 +402,7 @@ function BuildKBucket(options = {}) {
}
}
-module.exports = function K_Bucket(masterID, backupList) {
+function K_Bucket(masterID, backupList) {
const decodeID = function(floID) {
let k = bitjs.Base58.decode(floID);
k.shift();
@@ -457,4 +458,6 @@ module.exports = function K_Bucket(masterID, backupList) {
return (N == 1 ? nNodes[0] : nNodes);
};
-}
\ No newline at end of file
+};
+('object' === typeof module) ? module.exports = K_Bucket : window.K_Bucket = K_Bucket;
+})();
\ No newline at end of file
diff --git a/public/fn.js b/public/fn.js
index 85b8678..1b59c26 100644
--- a/public/fn.js
+++ b/public/fn.js
@@ -6,10 +6,9 @@ function exchangeAPI(api, options) {
let curPos = exchangeAPI.curPos || 0;
if (curPos >= nodeList.length)
return resolve('No Nodes online');
- let url = nodeURL[nodeList[curPos]];
+ let url = "http://" + nodeURL[nodeList[curPos]];
(options ? fetch(url + api, options) : fetch(url + api))
.then(result => resolve(result)).catch(error => {
- console.debug(error);
console.warn(nodeList[curPos], 'is offline');
//try next node
exchangeAPI.curPos = curPos + 1;
@@ -102,7 +101,7 @@ function getAccount(floID, proxySecret) {
};
request.sign = signRequest({
type: "get_account",
- timestamp: data.timestamp
+ timestamp: request.timestamp
}, proxySecret);
console.debug(request);
@@ -168,7 +167,7 @@ function signRequest(request, privKey) {
function getLoginCode() {
return new Promise((resolve, reject) => {
- exchangeAPI('/list-buyorders')
+ exchangeAPI('/get-login-code')
.then(result => responseParse(result)
.then(result => resolve(result))
.catch(error => reject(error)))
@@ -249,7 +248,7 @@ function logout(floID, proxySecret) {
};
request.sign = signRequest({
type: "logout",
- timestamp: data.timestamp
+ timestamp: request.timestamp
}, proxySecret);
console.debug(request);
@@ -543,8 +542,8 @@ function refreshDataFromBlockchain() {
return new Promise((resolve, reject) => {
let nodes, lastTx;
try {
- nodes = JSON.parse(localStorage.getItems('exhange-nodes'));
- if (typeof nodes !== 'object')
+ nodes = JSON.parse(localStorage.getItem('exchange-nodes'));
+ if (typeof nodes !== 'object' || nodes === null)
throw Error('nodes must be an object')
else
lastTx = parseInt(localStorage.getItem('exchange-lastTx')) || 0;
@@ -569,8 +568,8 @@ function refreshDataFromBlockchain() {
nodes[n] = content.Nodes.add[n];
}
});
- localStorage.setItem('exhange-lastTx', result.totalTxs);
- localStorage.setItem('exhange-nodes', JSON.stringify(nodes));
+ localStorage.setItem('exchange-lastTx', result.totalTxs);
+ localStorage.setItem('exchange-nodes', JSON.stringify(nodes));
nodeURL = nodes;
nodeKBucket = new K_Bucket(floGlobals.adminID, Object.keys(nodeURL));
nodeList = nodeKBucket.order;
diff --git a/public/home.html b/public/home.html
index fbec54b..5a978f0 100644
--- a/public/home.html
+++ b/public/home.html
@@ -12,27 +12,10 @@
-
+
+
@@ -1068,9 +1051,9 @@
showProcess('trade_button_wrapper')
try {
if (tradeType === 'buy') {
- await buy(quantity, price, await proxy.secret)
+ await buy(quantity, price, proxy.userID, await proxy.secret)
} else {
- await sell(quantity, price, await proxy.secret)
+ await sell(quantity, price, proxy.userID, await proxy.secret)
}
getRef('trade_button_wrapper').append(getRef('success_template').content.cloneNode(true))
notify(`Placed ${tradeType} order`, 'success')
@@ -1218,9 +1201,9 @@
showWalletResult('success', `Sent ${asset} deposit request`, 'This may take upto 30 mins to reflect in your wallet.')
} else {
if (asset === 'FLO') {
- await withdrawFLO(quantity, proxySecret)
+ await withdrawFLO(quantity, proxy.userID, proxySecret)
} else {
- await withdrawRupee(quantity, proxySecret)
+ await withdrawRupee(quantity, proxy.userID, proxySecret)
}
showWalletResult('success', `Sent ${asset} withdraw request`, 'This may take upto 30 mins to reflect in your wallet.')
}
@@ -1363,7 +1346,7 @@
const target = e.target.closest('.order-card')
const id = target.dataset.id
const type = target.dataset.type
- cancelOrder(type, id, await proxy.secret)
+ cancelOrder(type, id, proxy.userID, await proxy.secret)
.then(() => {
notify('Order cancelled', 'success')
target.animate([
@@ -1415,7 +1398,7 @@
if (res) {
try {
const proxy_secret = await proxy.secret;
- const promises = [...selectedOrders].map(([id, type]) => cancelOrder(type, id, proxy_secret))
+ const promises = [...selectedOrders].map(([id, type]) => cancelOrder(type, id, proxy.userID, proxy_secret))
await Promise.all(promises)
selectedOrders.clear()
hideMyOrdersOptions()
@@ -1687,7 +1670,7 @@
const balance = {}
let accountDetails = {}
- function account() {
+ async function account() {
getAccount(proxy.userID, await proxy.secret).then(acc => {
getRef("login_form").classList.add('hide-completely')
getRef('home').classList.add('signed-in')
@@ -1778,7 +1761,7 @@
refreshDataFromBlockchain().then(nodes => {
console.log(nodes);
refresh(true);
- }).catch(error => reject(error))
+ }).catch(error => console.error(error))
})