Renaming files
Renamed tokenAPI to floTokenAPI Renamed exchangeAPI to floExchangeAPI
This commit is contained in:
parent
5e074f5e1d
commit
6add4625c8
@ -16,9 +16,9 @@
|
||||
<script src="scripts/lib.js"></script>
|
||||
<script src="scripts/floCrypto.js"></script>
|
||||
<script src="scripts/floBlockchainAPI.js"></script>
|
||||
<script src="scripts/tokenAPI.js"></script>
|
||||
<script src="scripts/exchangeAPI.js"></script>
|
||||
<script>console.debug(exchangeAPI);</script>
|
||||
<script src="scripts/floTokenAPI.js"></script>
|
||||
<script src="scripts/floExchangeAPI.js"></script>
|
||||
<script>console.debug(floExchangeAPI);</script>
|
||||
</head>
|
||||
|
||||
<body class="hide-completely">
|
||||
@ -91,7 +91,7 @@
|
||||
<p>Don't have FLO credentials?</p>
|
||||
<sm-button onclick="showPopup('sign_up_popup')">Generate FLO credentials</sm-button>
|
||||
</div>
|
||||
<sm-button onclick="exchangeAPI.clearAllLocalData()">clear local data</sm-button>
|
||||
<sm-button onclick="floExchangeAPI.clearAllLocalData()">clear local data</sm-button>
|
||||
</sm-form>
|
||||
<sm-form id="trade_form" class="user-content hide-completely">
|
||||
<div id="flo_exchange_rate" class="grid align-center">
|
||||
@ -1021,9 +1021,9 @@
|
||||
showProcess('trade_button_wrapper')
|
||||
try {
|
||||
if (tradeType === 'buy') {
|
||||
await exchangeAPI.buy(asset, quantity, price, proxy.userID, await proxy.secret)
|
||||
await floExchangeAPI.buy(asset, quantity, price, proxy.userID, await proxy.secret)
|
||||
} else {
|
||||
await exchangeAPI.sell(asset, quantity, price, proxy.userID, await proxy.secret)
|
||||
await floExchangeAPI.sell(asset, quantity, price, proxy.userID, await proxy.secret)
|
||||
}
|
||||
getRef('trade_button_wrapper').append(getRef('success_template').content.cloneNode(true))
|
||||
notify(`Placed ${tradeType} order`, 'success')
|
||||
@ -1165,16 +1165,16 @@
|
||||
if (type === 'deposit') {
|
||||
const privKey = getRef('get_private_key').value;
|
||||
if (asset === 'FLO') {
|
||||
await exchangeAPI.depositFLO(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||
await floExchangeAPI.depositFLO(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||
} else {
|
||||
await exchangeAPI.depositToken(asset, quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||
await floExchangeAPI.depositToken(asset, quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||
}
|
||||
showWalletResult('success', `Sent ${asset} deposit request`, 'This may take upto 30 mins to reflect in your wallet.')
|
||||
} else {
|
||||
if (asset === 'FLO') {
|
||||
await exchangeAPI.withdrawFLO(quantity, proxy.userID, proxySecret)
|
||||
await floExchangeAPI.withdrawFLO(quantity, proxy.userID, proxySecret)
|
||||
} else {
|
||||
await exchangeAPI.withdrawToken(asset, quantity, proxy.userID, proxySecret)
|
||||
await floExchangeAPI.withdrawToken(asset, quantity, proxy.userID, proxySecret)
|
||||
}
|
||||
showWalletResult('success', `Sent ${asset} withdraw request`, 'This may take upto 30 mins to reflect in your wallet.')
|
||||
}
|
||||
@ -1317,7 +1317,7 @@
|
||||
const target = e.target.closest('.order-card')
|
||||
const id = target.dataset.id
|
||||
const type = target.dataset.type
|
||||
exchangeAPI.cancelOrder(type, id, proxy.userID, await proxy.secret)
|
||||
floExchangeAPI.cancelOrder(type, id, proxy.userID, await proxy.secret)
|
||||
.then(() => {
|
||||
notify('Order cancelled', 'success')
|
||||
target.animate([
|
||||
@ -1369,7 +1369,7 @@
|
||||
if (res) {
|
||||
try {
|
||||
const proxy_secret = await proxy.secret;
|
||||
const promises = [...selectedOrders].map(([id, type]) => exchangeAPI.cancelOrder(type, id, proxy.userID, proxy_secret))
|
||||
const promises = [...selectedOrders].map(([id, type]) => floExchangeAPI.cancelOrder(type, id, proxy.userID, proxy_secret))
|
||||
await Promise.all(promises)
|
||||
selectedOrders.clear()
|
||||
hideMyOrdersOptions()
|
||||
@ -1439,7 +1439,7 @@
|
||||
const ordersType = getRef('market_orders_category_selector').value
|
||||
if (ordersType === 'open') {
|
||||
try {
|
||||
const [buyOrders, sellOrders] = await Promise.all([exchangeAPI.getBuyList(), exchangeAPI.getSellList()])
|
||||
const [buyOrders, sellOrders] = await Promise.all([floExchangeAPI.getBuyList(), floExchangeAPI.getSellList()])
|
||||
const allOpenOrders = [...buyOrders, ...sellOrders].sort((a, b) => new Date(b.time_placed).getTime() - new Date(a.time_placed).getTime())
|
||||
allOpenOrders.forEach(order => {
|
||||
const { floID, asset, quantity, minPrice = undefined, maxPrice = undefined, time_placed } = order
|
||||
@ -1459,7 +1459,7 @@
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const marketTransactions = await exchangeAPI.getTradeList()
|
||||
const marketTransactions = await floExchangeAPI.getTradeList()
|
||||
marketTransactions.forEach(transaction => {
|
||||
const { seller, buyer, asset, quantity, unitValue, tx_time } = transaction
|
||||
const transactionDetails = {
|
||||
@ -1604,7 +1604,7 @@
|
||||
|
||||
let floExchangeRate = 0
|
||||
function updateRate(init = false) {
|
||||
exchangeAPI.getRates().then(rates => {
|
||||
floExchangeAPI.getRates().then(rates => {
|
||||
console.debug(rates);
|
||||
if (init) {
|
||||
let assetList = getRef('get_asset');
|
||||
@ -1633,7 +1633,7 @@
|
||||
console.info("init");
|
||||
if (!proxy.userID) {
|
||||
getRef('home').classList.remove('signed-in');
|
||||
exchangeAPI.getLoginCode().then(response => {
|
||||
floExchangeAPI.getLoginCode().then(response => {
|
||||
getRef("login_form").classList.remove('hide-completely');
|
||||
document.querySelectorAll(".user-content").forEach(elem => elem.classList.add('hide-completely'))
|
||||
getRef('sign_in_code').value = response.code;
|
||||
@ -1666,7 +1666,7 @@
|
||||
|
||||
let accountDetails = {}
|
||||
async function account() {
|
||||
exchangeAPI.getAccount(proxy.userID, await proxy.secret).then(acc => {
|
||||
floExchangeAPI.getAccount(proxy.userID, await proxy.secret).then(acc => {
|
||||
getRef("login_form").classList.add('hide-completely')
|
||||
getRef('home').classList.add('signed-in')
|
||||
getRef('user_popup_button').classList.remove('hide-completely')
|
||||
@ -1706,7 +1706,7 @@
|
||||
if (!privKey)
|
||||
privKey = getRef('get_registration_key').value.trim()
|
||||
if (privKey !== '') {
|
||||
exchangeAPI.signUp(privKey, code, hash).then(result => {
|
||||
floExchangeAPI.signUp(privKey, code, hash).then(result => {
|
||||
console.info(result);
|
||||
notify("Account registered!", 'success')
|
||||
hidePopup()
|
||||
@ -1719,7 +1719,7 @@
|
||||
logout() {
|
||||
getConfirmation('Log out?', { cancelText: 'Stay', confirmText: 'Log out' }).then(async res => {
|
||||
if (res) {
|
||||
exchangeAPI.logout(proxy.userID, await proxy.secret).then(result => {
|
||||
floExchangeAPI.logout(proxy.userID, await proxy.secret).then(result => {
|
||||
console.warn(result);
|
||||
proxy.clear();
|
||||
location.reload();
|
||||
@ -1735,7 +1735,7 @@
|
||||
hash = getRef('sign_in_hash').value;
|
||||
let rememberMe = getRef('remember_me').checked;
|
||||
let tmpKey = floCrypto.generateNewID();
|
||||
exchangeAPI.login(privKey, tmpKey.pubKey, code, hash).then(result => {
|
||||
floExchangeAPI.login(privKey, tmpKey.pubKey, code, hash).then(result => {
|
||||
console.log(result);
|
||||
proxy.secret = tmpKey.privKey;
|
||||
proxy.userID = floCrypto.getFloID(privKey);
|
||||
@ -1756,7 +1756,7 @@
|
||||
}
|
||||
|
||||
window.addEventListener('load', e => {
|
||||
exchangeAPI.init().then(nodes => {
|
||||
floExchangeAPI.init().then(nodes => {
|
||||
console.log(nodes);
|
||||
refresh(true);
|
||||
}).catch(error => console.error(error))
|
||||
|
||||
@ -937,7 +937,7 @@
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.verifyPrivKey(privKey, floID))
|
||||
return reject("Invalid Private Key");
|
||||
tokenAPI.sendToken(privKey, quantity, sinkID, 'Deposit Rupee in market', token).then(txid => {
|
||||
floTokenAPI.sendToken(privKey, quantity, sinkID, 'Deposit Rupee in market', token).then(txid => {
|
||||
let request = {
|
||||
floID: floID,
|
||||
txid: txid,
|
||||
@ -1107,4 +1107,4 @@
|
||||
location.reload();
|
||||
}
|
||||
|
||||
})('object' === typeof module ? module.exports : window.exchangeAPI = {});
|
||||
})('object' === typeof module ? module.exports : window.floExchangeAPI = {});
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
/* Token Operator to send/receive tokens from blockchain using API calls*/
|
||||
(function(GLOBAL) {
|
||||
const tokenAPI = GLOBAL.tokenAPI = {
|
||||
const floTokenAPI = GLOBAL.floTokenAPI = {
|
||||
fetch_api: function(apicall) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(floGlobals.tokenURL + apicall);
|
||||
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const K_Bucket = require('../../docs/scripts/exchangeAPI').K_Bucket;
|
||||
const K_Bucket = require('../../docs/scripts/floExchangeAPI').K_Bucket;
|
||||
const slave = require('./slave');
|
||||
const sync = require('./sync');
|
||||
const WebSocket = require('ws');
|
||||
@ -65,7 +65,7 @@ function storeSink(sinkID, sinkPrivKey) {
|
||||
/*
|
||||
function transferMoneyToNewSink(oldSinkID, oldSinkKey, newSink) {
|
||||
const transferToken = token => new Promise((resolve, reject) => {
|
||||
tokenAPI.getBalance(oldSinkID, token).then(tokenBalance => {
|
||||
floTokenAPI.getBalance(oldSinkID, token).then(tokenBalance => {
|
||||
floBlockchainAPI.writeData(oldSinkID, `send ${tokenBalance} ${token}# |Exchange-market New sink`, oldSinkKey, newSink.floID, false)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
@ -86,7 +86,7 @@ function transferMoneyToNewSink(oldSinkID, oldSinkKey, newSink) {
|
||||
if (failedFlag)
|
||||
return reject("Some token transfer has failed");
|
||||
floBlockchainAPI.getBalance(oldSinkID).then(floBalance => {
|
||||
tokenAPI.getBalance(oldSinkID).then(cashBalance => {
|
||||
floTokenAPI.getBalance(oldSinkID).then(cashBalance => {
|
||||
floBlockchainAPI.sendTx(oldSinkID, newSink.floID, floBalance - floGlobals.fee, oldSinkKey, `send ${cashBalance} ${floGlobals.currency}# |Exchange-market New sink`)
|
||||
.then(result => resolve(result))
|
||||
.catch(error => reject(error))
|
||||
|
||||
@ -4,7 +4,7 @@ require('./set_globals');
|
||||
require('../docs/scripts/lib');
|
||||
require('../docs/scripts/floCrypto');
|
||||
require('../docs/scripts/floBlockchainAPI');
|
||||
require('../docs/scripts/tokenAPI');
|
||||
require('../docs/scripts/floTokenAPI');
|
||||
|
||||
const Database = require("./database");
|
||||
const App = require('./app');
|
||||
|
||||
@ -507,7 +507,7 @@ confirmDepositToken.checkTx = function(sender, txid) {
|
||||
let receiver = global.sinkID; //receiver should be market's floID (ie, sinkID)
|
||||
if (!receiver)
|
||||
return reject([false, 'sinkID not loaded']);
|
||||
tokenAPI.getTx(txid).then(tx => {
|
||||
floTokenAPI.getTx(txid).then(tx => {
|
||||
if (tx.parsedFloData.type !== "transfer")
|
||||
return reject([true, "Transaction type not 'transfer'"]);
|
||||
else if (tx.parsedFloData.transferType !== "token")
|
||||
@ -544,7 +544,7 @@ function withdrawToken(floID, token, amount) {
|
||||
consumeAsset(floID, token, amount, txQueries).then(txQueries => {
|
||||
DB.transaction(txQueries).then(result => {
|
||||
//Send FLO to user via blockchain API
|
||||
tokenAPI.sendToken(global.sinkPrivKey, amount, floID, '(withdrawal from market)', token).then(txid => {
|
||||
floTokenAPI.sendToken(global.sinkPrivKey, amount, floID, '(withdrawal from market)', token).then(txid => {
|
||||
if (!txid) throw Error("Transaction not successful");
|
||||
//Transaction was successful, Add in DB
|
||||
DB.query("INSERT INTO OutputToken (floID, token, amount, txid, status) VALUES (?, ?, ?, ?, ?)", [floID, token, amount, txid, "WAITING_CONFIRMATION"])
|
||||
@ -567,7 +567,7 @@ function withdrawToken(floID, token, amount) {
|
||||
function retryWithdrawalToken() {
|
||||
DB.query("SELECT id, floID, token, amount FROM OutputToken WHERE status=?", ["PENDING"]).then(results => {
|
||||
results.forEach(req => {
|
||||
tokenAPI.sendToken(global.sinkPrivKey, req.amount, req.floID, '(withdrawal from market)', req.token).then(txid => {
|
||||
floTokenAPI.sendToken(global.sinkPrivKey, req.amount, req.floID, '(withdrawal from market)', req.token).then(txid => {
|
||||
if (!txid)
|
||||
throw Error("Transaction not successful");
|
||||
//Transaction was successful, Add in DB
|
||||
@ -581,7 +581,7 @@ function retryWithdrawalToken() {
|
||||
function confirmWithdrawalToken() {
|
||||
DB.query("SELECT id, floID, token, amount, txid FROM OutputToken WHERE status=?", ["WAITING_CONFIRMATION"]).then(results => {
|
||||
results.forEach(req => {
|
||||
tokenAPI.getTx(req.txid).then(tx => {
|
||||
floTokenAPI.getTx(req.txid).then(tx => {
|
||||
DB.query("UPDATE OutputToken SET status=? WHERE id=?", ["SUCCESS", req.id])
|
||||
.then(result => console.debug("Token withdrawed:", req.floID, req.token, req.amount))
|
||||
.catch(error => console.error(error));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user