Bug fix And UI for asset/token selection
- Fixed bugs in deposit and withdrawal - Added UI select option for token selection on deposit and withdrawal - Added UI style to buy/sell asset selection
This commit is contained in:
parent
a06c5b4c7b
commit
cab65161ba
@ -102,7 +102,7 @@
|
||||
<strip-option value="sell">Sell</strip-option>
|
||||
</strip-select>
|
||||
</div>
|
||||
<select id="get_asset"></select>
|
||||
<sm-select id="get_asset"></sm-select>
|
||||
<sm-input id="get_price" variant="outlined" placeholder="Max price (₹)" type="number" step="0.01"
|
||||
required hiderequired animate>
|
||||
</sm-input>
|
||||
@ -197,8 +197,6 @@
|
||||
<div id="wallet_actions">
|
||||
<p class="label">Select asset</p>
|
||||
<sm-select id="wallet_asset_selector">
|
||||
<sm-option value="FLO">FLO</sm-option>
|
||||
<sm-option value="Rupee">Rupee</sm-option>
|
||||
</sm-select>
|
||||
<div class="flex wallet_actions__wrapper">
|
||||
<button class="button" value="deposit">
|
||||
@ -1049,14 +1047,15 @@
|
||||
})
|
||||
async function tradeFlo() {
|
||||
const asset = getRef('get_asset').value;
|
||||
return console.debug(asset);
|
||||
const quantity = parseFloat(getRef('get_quantity').value)
|
||||
const price = parseFloat(getRef('get_price').value)
|
||||
showProcess('trade_button_wrapper')
|
||||
try {
|
||||
if (tradeType === 'buy') {
|
||||
await buy(asset, quantity, price, proxy.userID, await proxy.secret) //TODO: asset_name
|
||||
await buy(asset, quantity, price, proxy.userID, await proxy.secret)
|
||||
} else {
|
||||
await sell(asset, quantity, price, proxy.userID, await proxy.secret) //TODO: asset_name
|
||||
await 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')
|
||||
@ -1199,14 +1198,14 @@
|
||||
if (asset === 'FLO') {
|
||||
await depositFLO(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret)
|
||||
} else {
|
||||
await depositToken(quantity, proxy.userID, proxy.sinkID, privKey, proxySecret) //TODO: token_name
|
||||
await 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 withdrawFLO(quantity, proxy.userID, proxySecret)
|
||||
} else {
|
||||
await withdrawToken(quantity, proxy.userID, proxySecret) //TODO: token_name
|
||||
await withdrawToken(asset, quantity, proxy.userID, proxySecret)
|
||||
}
|
||||
showWalletResult('success', `Sent ${asset} withdraw request`, 'This may take upto 30 mins to reflect in your wallet.')
|
||||
}
|
||||
@ -1640,10 +1639,17 @@
|
||||
console.debug(rates);
|
||||
if(init){
|
||||
let assetList = getRef('get_asset');
|
||||
let walletList = getRef('wallet_asset_selector');
|
||||
let c = document.createElement('sm-option');
|
||||
c.setAttribute('value', floGlobals.currency);
|
||||
c.innerText = floGlobals.currency;
|
||||
walletList.appendChild(c);
|
||||
for(let asset in rates){
|
||||
let e = document.createElement('option');
|
||||
let e = document.createElement('sm-option');
|
||||
e.setAttribute('value', asset);
|
||||
e.innerText = asset;
|
||||
assetList.appendChild(e);
|
||||
walletList.appendChild(e.cloneNode(true));
|
||||
}
|
||||
}
|
||||
let flo_rate = rates["FLO"];
|
||||
|
||||
@ -99,7 +99,7 @@ function addBuyOrder(floID, asset, quantity, max_price) {
|
||||
return reject(INVALID(`Invalid max_price (${max_price})`));
|
||||
else if (!assetList.includes(asset))
|
||||
return reject(INVALID(`Invalid asset (${asset})`));
|
||||
getAssetBalance.check(floID, asset, quantity).then(_ => {
|
||||
getAssetBalance.check(floID, floGlobals.currency, quantity).then(_ => {
|
||||
DB.query("INSERT INTO BuyOrder(floID, asset, quantity, maxPrice) VALUES (?, ?, ?, ?)", [floID, asset, quantity, max_price])
|
||||
.then(result => resolve("Added BuyOrder to DB"))
|
||||
.catch(error => reject(error));
|
||||
@ -243,7 +243,7 @@ function withdrawFLO(floID, amount) {
|
||||
consumeAsset(floID, "FLO", amount).then(txQueries => {
|
||||
DB.transaction(txQueries).then(result => {
|
||||
//Send FLO to user via blockchain API
|
||||
floBlockchainAPI.sendTx(global.myFloID, floID, amount, global.myPrivKey, 'Withdraw FLO Coins from Market').then(txid => {
|
||||
floBlockchainAPI.sendTx(global.sinkID, floID, amount, global.sinkPrivKey, 'Withdraw FLO Coins from Market').then(txid => {
|
||||
if (!txid)
|
||||
throw Error("Transaction not successful");
|
||||
//Transaction was successful, Add in DB
|
||||
@ -265,7 +265,7 @@ function withdrawFLO(floID, amount) {
|
||||
function retryWithdrawalFLO() {
|
||||
DB.query("SELECT id, floID, amount FROM OutputFLO WHERE status=?", ["PENDING"]).then(results => {
|
||||
results.forEach(req => {
|
||||
floBlockchainAPI.sendTx(global.myFloID, req.floID, req.amount, global.myPrivKey, 'Withdraw FLO Coins from Market').then(txid => {
|
||||
floBlockchainAPI.sendTx(global.sinkID, req.floID, req.amount, global.sinkPrivKey, 'Withdraw FLO Coins from Market').then(txid => {
|
||||
if (!txid)
|
||||
throw Error("Transaction not successful");
|
||||
//Transaction was successful, Add in DB
|
||||
@ -353,7 +353,7 @@ confirmDepositToken.checkTx = function(sender, txid) {
|
||||
return reject([true, "Transaction transfer is not 'token'"]);
|
||||
var token_name = tx.parsedFloData.tokenIdentification,
|
||||
amount_token = tx.parsedFloData.tokenAmount;
|
||||
if (!assetList.includes(token_name) || token_name === "FLO")
|
||||
if ((!assetList.includes(token_name) && token_name !== floGlobals.currency) || token_name === "FLO")
|
||||
return reject([true, "Token not authorised"]);
|
||||
let vin_sender = tx.transactionDetails.vin.filter(v => v.addr === sender)
|
||||
if (!vin_sender.length)
|
||||
@ -373,7 +373,7 @@ function withdrawToken(floID, token, amount) {
|
||||
return reject(INVALID("Invalid FLO ID"));
|
||||
else if (typeof amount !== "number" || amount <= 0)
|
||||
return reject(INVALID(`Invalid amount (${amount})`));
|
||||
else if (!assetList.includes(token) || token === "FLO")
|
||||
else if ((!assetList.includes(token) && token !== floGlobals.currency) || token === "FLO")
|
||||
return reject(INVALID("Invalid Token"));
|
||||
//Check for FLO balance (transaction fee)
|
||||
const required_flo = floGlobals.sendAmt + floGlobals.fee;
|
||||
@ -383,7 +383,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.myPrivKey, amount, floID, '(withdrawal from market)', token).then(txid => {
|
||||
tokenAPI.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"])
|
||||
@ -406,7 +406,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.myPrivKey, req.amount, req.floID, '(withdrawal from market)', req.token).then(txid => {
|
||||
tokenAPI.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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user