Use sinkID for deposits
- Send Sink ID to users on get-account request - In user page, store sink ID and use it for deposit FLO/Rupee
This commit is contained in:
parent
cdc55dbdc9
commit
827bdcd793
10
public/fn.js
10
public/fn.js
@ -52,7 +52,7 @@ const tokenAPI = {
|
|||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
sendToken: function(privKey, amount, message = "", receiverID = floGlobals.adminID, token = 'rupee') {
|
sendToken: function(privKey, amount, receiverID, message = "", token = 'rupee') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let senderID = floCrypto.getFloID(privKey);
|
let senderID = floCrypto.getFloID(privKey);
|
||||||
if (typeof amount !== "number" || amount <= 0)
|
if (typeof amount !== "number" || amount <= 0)
|
||||||
@ -364,11 +364,11 @@ function cancelOrder(type, id, floID, proxySecret) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function depositFLO(quantity, floID, privKey, proxySecret) {
|
function depositFLO(quantity, floID, sinkID, privKey, proxySecret) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (typeof quantity !== "number" || quantity <= floGlobals.fee)
|
if (typeof quantity !== "number" || quantity <= floGlobals.fee)
|
||||||
return reject(`Invalid quantity (${quantity})`);
|
return reject(`Invalid quantity (${quantity})`);
|
||||||
floBlockchainAPI.sendTx(floID, floGlobals.adminID, quantity, privKey, 'Deposit FLO in market').then(txid => {
|
floBlockchainAPI.sendTx(floID, sinkID, quantity, privKey, 'Deposit FLO in market').then(txid => {
|
||||||
let request = {
|
let request = {
|
||||||
floID: floID,
|
floID: floID,
|
||||||
txid: txid,
|
txid: txid,
|
||||||
@ -422,11 +422,11 @@ function withdrawFLO(quantity, floID, proxySecret) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function depositRupee(quantity, floID, privKey, proxySecret) {
|
function depositRupee(quantity, floID, sinkID, privKey, proxySecret) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!floCrypto.verifyPrivKey(privKey, floID))
|
if (!floCrypto.verifyPrivKey(privKey, floID))
|
||||||
return reject("Invalid Private Key");
|
return reject("Invalid Private Key");
|
||||||
tokenAPI.sendToken(privKey, quantity, 'Deposit Rupee in market').then(txid => {
|
tokenAPI.sendToken(privKey, quantity, sinkID, 'Deposit Rupee in market').then(txid => {
|
||||||
let request = {
|
let request = {
|
||||||
floID: floID,
|
floID: floID,
|
||||||
txid: txid,
|
txid: txid,
|
||||||
|
|||||||
@ -382,6 +382,7 @@
|
|||||||
<h4 id="wallet_popup__title" class="capitalize"></h4>
|
<h4 id="wallet_popup__title" class="capitalize"></h4>
|
||||||
</header>
|
</header>
|
||||||
<sm-form id="wallet_form">
|
<sm-form id="wallet_form">
|
||||||
|
<input type="text" id="sink_id" style="display: none;" hidden />
|
||||||
<sm-input id="get_user_amount" variant="outlined" placeholder="Quantity" type="number" min="0.01"
|
<sm-input id="get_user_amount" variant="outlined" placeholder="Quantity" type="number" min="0.01"
|
||||||
step="0.00001" required hiderequired animate>
|
step="0.00001" required hiderequired animate>
|
||||||
</sm-input>
|
</sm-input>
|
||||||
@ -1194,9 +1195,9 @@
|
|||||||
if (type === 'deposit') {
|
if (type === 'deposit') {
|
||||||
const privKey = getRef('get_private_key').value;
|
const privKey = getRef('get_private_key').value;
|
||||||
if (asset === 'FLO') {
|
if (asset === 'FLO') {
|
||||||
await depositFLO(quantity, proxy.userID, privKey, proxySecret)
|
await depositFLO(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||||
} else {
|
} else {
|
||||||
await depositRupee(quantity, proxy.userID, privKey, proxySecret)
|
await depositRupee(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||||
}
|
}
|
||||||
showWalletResult('success', `Sent ${asset} deposit request`, 'This may take upto 30 mins to reflect in your wallet.')
|
showWalletResult('success', `Sent ${asset} deposit request`, 'This may take upto 30 mins to reflect in your wallet.')
|
||||||
} else {
|
} else {
|
||||||
@ -1565,6 +1566,9 @@
|
|||||||
this.private = null;
|
this.private = null;
|
||||||
this.public = null;
|
this.public = null;
|
||||||
},
|
},
|
||||||
|
get sinkID(){
|
||||||
|
return getRef("sink_id").value;
|
||||||
|
},
|
||||||
set userID(id){
|
set userID(id){
|
||||||
localStorage.setItem("user_ID", id);
|
localStorage.setItem("user_ID", id);
|
||||||
this.user = id;
|
this.user = id;
|
||||||
@ -1680,6 +1684,7 @@
|
|||||||
document.querySelectorAll(".user-content").forEach(elem => elem.classList.remove('hide-completely'))
|
document.querySelectorAll(".user-content").forEach(elem => elem.classList.remove('hide-completely'))
|
||||||
getRef('trade_form').classList.remove('hide-completely')
|
getRef('trade_form').classList.remove('hide-completely')
|
||||||
getRef("user_id").value = acc.floID;
|
getRef("user_id").value = acc.floID;
|
||||||
|
getRef("sink_id").value = acc.sinkID;
|
||||||
//FLO Balance
|
//FLO Balance
|
||||||
let flo_total = acc.coins.reduce((a, x) => a + x.quantity, 0);
|
let flo_total = acc.coins.reduce((a, x) => a + x.quantity, 0);
|
||||||
let flo_locked = acc.sellOrders.reduce((a, x) => a + x.quantity, 0);
|
let flo_locked = acc.sellOrders.reduce((a, x) => a + x.quantity, 0);
|
||||||
|
|||||||
@ -278,6 +278,7 @@ function Account(req, res) {
|
|||||||
timestamp: data.timestamp
|
timestamp: data.timestamp
|
||||||
}, data.sign, data.floID).then(req_str => {
|
}, data.sign, data.floID).then(req_str => {
|
||||||
market.getAccountDetails(data.floID).then(result => {
|
market.getAccountDetails(data.floID).then(result => {
|
||||||
|
result.sinkID = global.sinkID;
|
||||||
if (trustedIDs.includes(data.floID))
|
if (trustedIDs.includes(data.floID))
|
||||||
result.subAdmin = true;
|
result.subAdmin = true;
|
||||||
res.send(result);
|
res.send(result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user