fixed various ui issues related to trade, deposit and withdraw

This commit is contained in:
Abhishek Sinha 2020-04-18 21:40:53 +05:30
parent 1e6dcd1904
commit b04ec508c7

View File

@ -1191,22 +1191,8 @@
</svg> </svg>
</button> </button>
</div> </div>
<!--<svg id="background" viewBox="0 0 2064.612 1967.514">
<defs>
<filter id="Rectangle_12" x="0" y="0" width="1502.184" height="1449.184" filterUnits="userSpaceOnUse">
<feComposite in="SourceGraphic"/>
</filter>
</defs>
<rect id="Rectangle_4" data-name="Rectangle 4" width="1387" height="637" rx="60" transform="translate(71 1517.087) rotate(-45)" fill="#17bf65"/>
<g transform="matrix(1, 0, 0, 1, 0, 0)" filter="url(#Rectangle_12)">
<rect id="Rectangle_12-2" data-name="Rectangle 12" width="1387" height="637" rx="60" transform="translate(521.43 6) rotate(45)" fill="#6decb9"/>
</g>
<circle id="Ellipse_3" data-name="Ellipse 3" cx="34.5" cy="34.5" r="34.5" transform="translate(1502.612 769.248)" fill="#b2ffe8"/>
<circle id="Ellipse_2" data-name="Ellipse 2" cx="98" cy="98" r="98" transform="translate(1868.612 1036.248)" fill="#b2b2ff"/>
</svg>-->
<!--Sign in popup--> <!--Sign in popup-->
<div class="popup-container solid-background"> <div class="popup-container solid-background hide">
<div id="sign_in_popup" class="popup"> <div id="sign_in_popup" class="popup">
<div class="container-header"> <div class="container-header">
<h1>Sign In</h1> <h1>Sign In</h1>
@ -1216,7 +1202,7 @@
<input id="get_priv_key_field" type="password" required> <input id="get_priv_key_field" type="password" required>
<div class="label">Private Key</div> <div class="label">Private Key</div>
</label> </label>
<div class="action expand" onclick="signIn(this)"> <div class="action expand" id="signInBtn">
<button class="primary-btn expand" type="submit" disabled> <button class="primary-btn expand" type="submit" disabled>
Sign In Sign In
</button> </button>
@ -1460,7 +1446,7 @@
</svg> </svg>
<h3>Buy Crypto</h3> <h3>Buy Crypto</h3>
<div class="action" id="trade_buy_button"> <div class="action" id="trade_buy_button">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
Buy Buy
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1474,11 +1460,6 @@
<div class="crypto-selector flex expand" id="selectListFiatBuy"></div> <div class="crypto-selector flex expand" id="selectListFiatBuy"></div>
<h5>Select Amount</h5> <h5>Select Amount</h5>
<div class="crypto-selector flex expand" id="selectListTradingAmountBuy"></div> <div class="crypto-selector flex expand" id="selectListTradingAmountBuy"></div>
<label class="input">
<input type="number" inputmode="numeric" required>
<div class="label">Buy worth of</div>
</label>
</div> </div>
</div> </div>
<div class="popup-container hide"> <div class="popup-container hide">
@ -1490,7 +1471,7 @@
</svg> </svg>
<h3>Sell Crypto</h3> <h3>Sell Crypto</h3>
<div class="action" id="trade_sell_button"> <div class="action" id="trade_sell_button">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
Sell Sell
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1504,10 +1485,6 @@
<div class="crypto-selector flex expand" id="selectListFiatSell"></div> <div class="crypto-selector flex expand" id="selectListFiatSell"></div>
<h5>Select Amount</h5> <h5>Select Amount</h5>
<div class="crypto-selector flex expand" id="selectListTradingAmountSell"></div> <div class="crypto-selector flex expand" id="selectListTradingAmountSell"></div>
<label class="input">
<input type="number" inputmode="numeric" required>
<div class="label">Sell worth of</div>
</label>
</div> </div>
</div> </div>
<!-- Crypto section--> <!-- Crypto section-->
@ -1543,7 +1520,7 @@
<div class="label">Reciever's FLO ID</div> <div class="label">Reciever's FLO ID</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" inputmode="numeric" required> <input name="amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1568,17 +1545,18 @@
<h5>Select Crypto</h5> <h5>Select Crypto</h5>
<div class="crypto-selector flex expand" id="deposit_crypto_div"></div> <div class="crypto-selector flex expand" id="deposit_crypto_div"></div>
<label class="input"> <label class="input">
<input id="trade_amount_select" type="number" inputmode="numeric" required> <input id="trade_amount_select" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
<h5>Click After Sending Crypto To Exchange</h5> <h5>Click After Sending Crypto To Exchange</h5>
<div class="flex expand" id="cnf_crypto_deposit"></div> <div class="flex expand" id="cnf_crypto_deposit">
<label class="input"> <div class="action">
<input type="button"> <button class="btn">
<div class="label">Confirm Deposit</div> <div class="label">Confirm Deposit</div>
</label>
</div> </div>
</div> </div>
</div>
<div class="popup-container hide"> <div class="popup-container hide">
<div id="withdraw_crypto_popup" class="popup"> <div id="withdraw_crypto_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
@ -1588,7 +1566,7 @@
</svg> </svg>
<h3>Withdraw Crypto</h3> <h3>Withdraw Crypto</h3>
<div class="action" id="withdrawCryptoButton"> <div class="action" id="withdrawCryptoButton">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
withdraw withdraw
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1603,7 +1581,7 @@
<div class="label">Recieving crypto Address</div> <div class="label">Recieving crypto Address</div>
</label> </label>
<label class="input"> <label class="input">
<input id="crypto_withdraw_amount" type="number" inputmode="numeric" required> <input id="crypto_withdraw_amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1631,7 +1609,7 @@
<div class="label">Depositer's UPI address</div> <div class="label">Depositer's UPI address</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" inputmode="numeric" required> <input name="amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
<h3 id="upiToAddress" class="hide-completely"></h3> <h3 id="upiToAddress" class="hide-completely"></h3>
@ -1659,7 +1637,7 @@
<div class="label">Recieving UPI address</div> <div class="label">Recieving UPI address</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" name="hi" inputmode="numeric" required> <input name="amount" type="number" name="hi" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1678,12 +1656,13 @@
card.classList.add('order', 'grid', 'grid-2') card.classList.add('order', 'grid', 'grid-2')
currency === 'INR' ? currencySymbol = '₹' : currencySymbol = '$'; currency === 'INR' ? currencySymbol = '₹' : currencySymbol = '$';
card.innerHTML = `<div class="details"> card.innerHTML = `<div class="details">
<h3>${type}</h3> <h3>${type.toUpperCase()}</h3>
${product} worth ${currencySymbol}${price} ${product} worth ${currencySymbol}${price}
<h5>Trade Id</h5> <h5>Trade Id</h5>
<span class="breakable">${tradeId}</span> <span class="breakable">${tradeId}</span>
</div> </div>
<button id="${tradeId}" class="cancel-order">Cancel</button>`; <button id="${tradeId}-${localbitcoinplusplus.wallets.my_local_flo_address}-${type}"
class="cancel-order">Cancel</button>`;
return card; return card;
} }
} }
@ -1779,7 +1758,7 @@
currentTimeout = setTimeout(()=>{ currentTimeout = setTimeout(()=>{
banner.classList.add('hide') banner.classList.add('hide')
banner.classList.remove('no-transformations') banner.classList.remove('no-transformations')
}, 4000) }, 10000)
} }
// displays a popup for asking permission. Use this instead of JS confirm // displays a popup for asking permission. Use this instead of JS confirm
let askConfirmation = function(message){ let askConfirmation = function(message){
@ -1990,18 +1969,16 @@
let resp_obj = JSON.parse(res.txid); let resp_obj = JSON.parse(res.txid);
let resp_txid = resp_obj.txid.result || resp_obj.txid; let resp_txid = resp_obj.txid.result || resp_obj.txid;
let msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`; let msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`;
notify(msg); showMessage(msg);
msg = `Signed Raw Tx for your deposited crypto asset: ${res.signedTxHash}`;
notify(msg); notify(msg);
return true; return true;
} catch (error) { } catch (error) {
console.warn(error); console.warn(error);
showMessage(error);
notify(error); notify(error);
} }
} }
} });
);
setTimeout(() => { setTimeout(() => {
btnLoading(btn, 'stop') btnLoading(btn, 'stop')
@ -2010,19 +1987,6 @@
}, 1000) }, 1000)
} }
function signIn(btn){
let parentPopup = btn.closest('.popup');
btnLoading(btn, 'start')
//if operation completes{
setTimeout(() => {
btnLoading(btn, 'stop')
hidePopup(parentPopup)
notify('Signed In')
document.querySelector('main').classList.remove('hide-completely')
}, 1000)
//}
}
function refreshBalance(type, btn){ function refreshBalance(type, btn){
let newBalance ; let newBalance ;
@ -16561,11 +16525,18 @@
return false; return false;
}, },
manually_assign_my_private_key: function() { manually_assign_my_private_key: function() {
document.querySelector('main').classList.add('hide-completely')
notify('Please provide your FLO private key to Sign in.');
showPopup('sign_in_popup');
const signInBtn = document.getElementById('signInBtn');
signInBtn.onclick = function() {
readDB("localbitcoinUser", "00-01") readDB("localbitcoinUser", "00-01")
.then(usr => { .then(usr => {
if (typeof usr == "object" && usr.myLocalFLOAddress.length > 0) { if (typeof usr == "object" && usr.myLocalFLOAddress.length > 0) {
const RM_WALLET = new localbitcoinplusplus.wallets(); const RM_WALLET = new localbitcoinplusplus.wallets();
const pk_manual = prompt("Please enter your private key: "); //const pk_manual = prompt("Please enter your private key: ");
const pk_manual = document.getElementById('get_priv_key_field').value;
let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual); let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
if (gen_new_keys.address == usr.myLocalFLOAddress) { if (gen_new_keys.address == usr.myLocalFLOAddress) {
Object.defineProperty( Object.defineProperty(
@ -16578,6 +16549,9 @@
enumerable: false enumerable: false
} }
); );
notify('Signed in successfully.')
document.querySelector('main').classList.remove('hide-completely')
hidePopup('sign_in_popup');
if (localbitcoinplusplus.is_ui_loaded == false) { if (localbitcoinplusplus.is_ui_loaded == false) {
dataBaseUIOperations(); dataBaseUIOperations();
} }
@ -16605,6 +16579,8 @@
showMessage(mes); showMessage(mes);
Promise.reject(mes); Promise.reject(mes);
}); });
}
}, },
rebuild_my_private_key: function(transactionKey) { rebuild_my_private_key: function(transactionKey) {
const RM_WALLET = new localbitcoinplusplus.wallets(); const RM_WALLET = new localbitcoinplusplus.wallets();
@ -18177,7 +18153,13 @@
} }
reactor.dispatchEvent('message_for_user', msg_response); reactor.dispatchEvent('message_for_user', msg_response);
} }
); ).catch(e=>{
msg_response = {
user_flo_addr: cancel_request.trader_flo_address,
msg: `Failed to delete Order id ${cancel_request.trade_id}.`
}
reactor.dispatchEvent('message_for_user', msg_response);
});
} else { } else {
err_response = { err_response = {
user_flo_addr: cancel_request.trader_flo_address, user_flo_addr: cancel_request.trader_flo_address,
@ -18323,6 +18305,9 @@
let transaction_key = localbitcoinplusplus.actions let transaction_key = localbitcoinplusplus.actions
.master_decrypt(btc_reserves.supernode_transaction_key); .master_decrypt(btc_reserves.supernode_transaction_key);
if(typeof transaction_key=="string") {
transaction_key = JSON.parse(transaction_key);
}
if (transaction_key.length > 0) { if (transaction_key.length > 0) {
let btc_private_key = RM_WALLET.rebuild_private_key( let btc_private_key = RM_WALLET.rebuild_private_key(
btc_pk_shares_array, btc_pk_shares_array,
@ -19979,7 +19964,13 @@
reactor.dispatchEvent('message_for_user', err_response); reactor.dispatchEvent('message_for_user', err_response);
} }
); ).catch(e=>{
msg_response = {
user_flo_addr: cancel_request.trader_flo_address,
msg: `Failed to delete Order id ${cancel_request.trade_id}.`
}
reactor.dispatchEvent('message_for_user', msg_response);
});
} else { } else {
err_response = { err_response = {
user_flo_addr: cancel_request.trader_flo_address, user_flo_addr: cancel_request.trader_flo_address,
@ -20150,6 +20141,9 @@
let transaction_key = localbitcoinplusplus.actions let transaction_key = localbitcoinplusplus.actions
.master_decrypt(btc_reserves.supernode_transaction_key); .master_decrypt(btc_reserves.supernode_transaction_key);
if(typeof transaction_key=="string") {
transaction_key = JSON.parse(transaction_key);
}
if (transaction_key.length > 0) { if (transaction_key.length > 0) {
let btc_private_key = RM_WALLET.rebuild_private_key( let btc_private_key = RM_WALLET.rebuild_private_key(
btc_pk_shares_array, btc_pk_shares_array,
@ -21775,7 +21769,6 @@
console.log(trx); console.log(trx);
let signedTxHash = trx.sign(utxo_addr_wif, 1); //SIGHASH_ALL DEFAULT 1 let signedTxHash = trx.sign(utxo_addr_wif, 1); //SIGHASH_ALL DEFAULT 1
showMessage(`Signed Transaction Hash: ${signedTxHash}`);
console.log(signedTxHash); console.log(signedTxHash);
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
@ -22719,15 +22712,14 @@
RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF) RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF)
.then(() => privateKeyBuilder()) .then(() => privateKeyBuilder())
.finally(() => { .finally(() => {
setTimeout(function() { setTimeout(async function() {
if ( if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY !== "string" || .MY_SUPERNODE_PRIVATE_KEY !== "string" ||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
.length < 1 .length < 1
) { ) {
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == "string" && .MY_SUPERNODE_PRIVATE_KEY == "string" &&
@ -22839,14 +22831,13 @@
// rebuild private key // rebuild private key
await privateKeyBuilder(); await privateKeyBuilder();
setTimeout(function() { setTimeout(async function() {
if ( if (
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !== typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !==
"string" || "string" ||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY.length < 1 localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY.length < 1
) { ) {
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY == typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
"string" && "string" &&
@ -23092,7 +23083,7 @@
// Connection established, build private key and UI // Connection established, build private key and UI
await privateKeyBuilder(); await privateKeyBuilder();
localbitcoinplusplus.actions.delay(10000).then(() => { localbitcoinplusplus.actions.delay(10000).then(async() => {
if ( if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY !== "string" || .MY_SUPERNODE_PRIVATE_KEY !== "string" ||
@ -23100,8 +23091,7 @@
1 1
) { ) {
const RM_WALLET = new localbitcoinplusplus.wallets(); const RM_WALLET = new localbitcoinplusplus.wallets();
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == "string" && .MY_SUPERNODE_PRIVATE_KEY == "string" &&
@ -23545,7 +23535,8 @@
addDB("buyOrders", buyOrders_data).then(() => { addDB("buyOrders", buyOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===buyOrders_data.trader_flo_address) { ===buyOrders_data.trader_flo_address) {
showMessage(`Your buy order is placed successfully.`); displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
notify(`Your buy order is placed successfully.`);
} }
}); });
} }
@ -23581,9 +23572,8 @@
addDB("sellOrders", sellOrders_data).then(() => { addDB("sellOrders", sellOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===sellOrders_data.trader_flo_address) { ===sellOrders_data.trader_flo_address) {
showMessage( displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
`Your sell order is placed successfully.` notify(`Your sell order is placed successfully.`);
);
} }
}); });
@ -23889,11 +23879,13 @@
); );
Promise.all([p1,p2,p3,p4]).then(()=>{ Promise.all([p1,p2,p3,p4]).then(()=>{
displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
showMessage("Balances updated.") notify("Trade successfull. Balances updated.")
showMessage("Trade successfull. Balances updated.")
}) })
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
@ -23999,6 +23991,8 @@
typeof res_obj.nodePubKey != "string" typeof res_obj.nodePubKey != "string"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys || !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) return; ) return;
readDB( readDB(
@ -25118,7 +25112,8 @@
addDB("buyOrders", buyOrders_data).then(() => { addDB("buyOrders", buyOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===buyOrders_data.trader_flo_address) { ===buyOrders_data.trader_flo_address) {
showMessage(`Your buy order is placed successfully.`); displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
notify(`Your buy order is placed successfully.`);
} }
}); });
} }
@ -25147,11 +25142,6 @@
if ( if (
typeof localbitcoinplusplus.master_configurations typeof localbitcoinplusplus.master_configurations
.supernodesPubKeys == "object" .supernodesPubKeys == "object"
// Commented this because it prevents usernode to register data in db
// while a backup supernode sends it any data like trade_buy
// && localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
// sellOrders_data.supernodePubKey)
) { ) {
let isDataSignedBySuperNode = RM_WALLET.verify( let isDataSignedBySuperNode = RM_WALLET.verify(
sellOrders_data.data_hash, sellOrders_data.data_hash,
@ -25163,9 +25153,8 @@
addDB("sellOrders", sellOrders_data).then(() => { addDB("sellOrders", sellOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===sellOrders_data.trader_flo_address) { ===sellOrders_data.trader_flo_address) {
showMessage( displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
`Your sell order is placed successfully.` notify(`Your sell order is placed successfully.`);
);
} }
}); });
} }
@ -25483,10 +25472,13 @@
); );
Promise.all([pr1,pr2,pr3,pr4]).then(()=>{ Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
notify("Trade successfull. Balances updated.")
showMessage("Trade successfull. Balances updated.")
}) })
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
@ -25653,6 +25645,8 @@
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst] || typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst]
!== "object" !== "object"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) )
return; return;
@ -27095,12 +27089,7 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{ Promise.all([b1,b2,b3,b4])
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
@ -27461,6 +27450,8 @@
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst] || typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst]
!== "object" !== "object"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) )
return; return;
@ -29411,7 +29402,9 @@
let objectStoreRequest = request.get(key); let objectStoreRequest = request.get(key);
objectStoreRequest.onsuccess = function (event) { objectStoreRequest.onsuccess = function (event) {
var myRecord = objectStoreRequest.result; var myRecord = objectStoreRequest.result;
if (typeof myRecord !== "object") { if (myRecord==null
|| myRecord== undefined
|| typeof myRecord !== "object") {
Obj.vectorClock = Obj.vectorClock =
typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0; typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0;
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
@ -29420,11 +29413,16 @@
request = db.transaction([tablename], "readwrite") request = db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj); .objectStore(tablename).put(Obj);
} else if (myRecord.vectorClock < Obj.vectorClock) { } else if (myRecord.vectorClock < Obj.vectorClock) {
// Don't sign rather verify data here
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
Obj = signDBData(Obj); if(verifyDBData(Obj)===true) {
}
request = db.transaction([tablename], "readwrite") request = db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj); .objectStore(tablename).put(Obj);
} else {
console.trace(Obj);
throw new Error('Failed verification at db update');
}
}
} else { } else {
resolve(Obj); resolve(Obj);
} }
@ -30061,7 +30059,9 @@
let objectStoreRequest = this.request.get(key); let objectStoreRequest = this.request.get(key);
objectStoreRequest.onsuccess = function(event) { objectStoreRequest.onsuccess = function(event) {
var myRecord = objectStoreRequest.result; var myRecord = objectStoreRequest.result;
if (typeof myRecord !== "object") { if (myRecord==null
|| myRecord== undefined
|| typeof myRecord !== "object") {
Obj.vectorClock = Obj.vectorClock =
typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0; typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0;
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
@ -30076,8 +30076,8 @@
this.request = this.db.transaction([tablename], "readwrite") this.request = this.db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj); .objectStore(tablename).put(Obj);
} else { } else {
console.error('failed verification at backup update');
console.trace(Obj); console.trace(Obj);
throw new Error('failed verification at backup update');
} }
} }
@ -30552,27 +30552,22 @@
my_trades_div.innerHTML = '<h4>No trade orders yet.</h4>' my_trades_div.innerHTML = '<h4>No trade orders yet.</h4>'
my_trades_div.append(frag); my_trades_div.append(frag);
var delclassname = document.getElementsByClassName("CANCEL_TRADE"); // Function for cancelling trade orders
document.getElementById('orders_container').addEventListener('click', (e) => {
Array.from(delclassname).forEach(function(element) {
element.addEventListener("click", function(e) {
let container = document.getElementById('orders_container'); let container = document.getElementById('orders_container');
if(e.target.closest('.cancel-order')) if(e.target.closest('.cancel-order'))
askConfirmation('Are you sure to cancel this trade order?').then((result) => { askConfirmation('Are you sure to cancel this trade order?').then((result) => {
if(result){ if(result){
let cancel_td = this.id;
let trade_opts = cancel_td.split("-");
RM_TRADE.cancelTrade(trade_opts[0], trade_opts[1], trade_opts[2]);
let tradeId = e.target.closest('.cancel-order').id; let tradeId = e.target.closest('.cancel-order').id;
let trade_opts = tradeId.split("-");
RM_TRADE.cancelTrade(trade_opts[0], trade_opts[1], trade_opts[2]);
e.target.closest('.order').remove(); e.target.closest('.order').remove();
notify(`Order id: ${tradeId} cancelled.`) showMessage('', `Order id: ${trade_opts[0]} cancelled.`)
if(container.children.length === 0) if(container.children.length === 0)
container.innerHTML = '<h4>No trade orders yet.</h4>' container.innerHTML = '<h4>No trade orders yet.</h4>'
} }
}) })
}); })
});
}); });
}; };
@ -30684,7 +30679,7 @@
let parentPopup = this.closest('.popup'), let parentPopup = this.closest('.popup'),
selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value, selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value,
selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value, selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value,
buyWorth = parentPopup.querySelector('.input input').value; buyWorth = parentPopup.querySelector("input[name='trading_amount']:checked").value;
RM_TRADE.place_order( RM_TRADE.place_order(
"buy", "buy",
@ -30708,7 +30703,7 @@
let parentPopup = this.closest('.popup'), let parentPopup = this.closest('.popup'),
selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value, selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value,
selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value, selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value,
sellWorth = parentPopup.querySelector('.input input').value; sellWorth = parentPopup.querySelector("input[name='trading_amount']:checked").value;
RM_TRADE.place_order( RM_TRADE.place_order(
"sell", "sell",
@ -30776,9 +30771,9 @@
withdrawCryptoButton.addEventListener("click", function(params) { withdrawCryptoButton.addEventListener("click", function(params) {
let parentPopup = this.closest('.popup'); let parentPopup = this.closest('.popup');
let asset_type = document.querySelector("input[name='crypto']:checked").value; let asset_type = document.querySelector("input[name='crypto']:checked").value;
let receivinAddress = document.getElementById('withdraw_recving_addr') let receivinAddress = document.getElementById('withdraw_recving_addr').value
let withdraw_amount= document.getElementById('crypto_withdraw_amount') let withdraw_amount= document.getElementById('crypto_withdraw_amount')
if (receivinAddress == null || receivinAddress.trim == "") { if (receivinAddress == null || receivinAddress.trim() == "") {
err_msg =`You must specify a valid ${asset_type} address to continue.`; err_msg =`You must specify a valid ${asset_type} address to continue.`;
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
@ -31056,7 +31051,6 @@
function buildBroadcastTxUI() { function buildBroadcastTxUI() {
const broadcast_tx_ui = document.getElementById("send_crypto_select_div"); const broadcast_tx_ui = document.getElementById("send_crypto_select_div");
get_crypto_svg_selection_html('broadcastTx', broadcast_tx_ui); get_crypto_svg_selection_html('broadcastTx', broadcast_tx_ui);
//broadcast_tx_ui.insertAdjacentHTML('beforeend', selectCryptoHtml)
} }
</script> </script>