Bug fixes

This commit is contained in:
sairaj mote 2023-06-05 16:22:16 +05:30
parent 988bb1376b
commit deb52a3ca1

View File

@ -1354,7 +1354,6 @@
txDetailsAbortController = new AbortController(); txDetailsAbortController = new AbortController();
btcOperator.getTx(txid).then(result => { btcOperator.getTx(txid).then(result => {
const { block, time, size, fee, inputs, outputs, confirmations, total_input_value, total_output_value } = result; const { block, time, size, fee, inputs, outputs, confirmations, total_input_value, total_output_value } = result;
console.debug('tx', result); console.debug('tx', result);
renderElem(getRef('tx_details'), html` renderElem(getRef('tx_details'), html`
<table class="margin-bottom-1-5 justify-self-center"> <table class="margin-bottom-1-5 justify-self-center">
@ -1365,7 +1364,7 @@
</tr> </tr>
<tr> <tr>
<td>Block</td> <td>Block</td>
<td>${block}</td> <td>${block} ${!block ? html`<strong>Unconfirmed transaction</strong>` : ''}</td>
</tr> </tr>
<tr> <tr>
<td>Confirmations</td> <td>Confirmations</td>
@ -1492,37 +1491,40 @@
function roundUp(amount, precision = 2) { function roundUp(amount, precision = 2) {
return parseFloat((Math.ceil(amount * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(precision)) return parseFloat((Math.ceil(amount * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(precision))
} }
getRef('currency_selector').addEventListener('change', async e => { let previouslySelectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc';
localStorage.setItem('btc-wallet-currency', e.target.value); getRef('currency_selector').addEventListener('change', e => {
document.querySelectorAll('.currency-symbol').forEach(el => el.innerHTML = currencyIcons[e.target.value]) selectedCurrency = e.target.value;
localStorage.setItem('btc-wallet-currency', selectedCurrency);
document.querySelectorAll('.currency-symbol').forEach(el => el.innerHTML = currencyIcons[selectedCurrency])
document.querySelectorAll('.amount-shown').forEach(el => { document.querySelectorAll('.amount-shown').forEach(el => {
if (el.tagName.includes('SM-')) { if (el.tagName.includes('SM-')) {
const originalAmount = parseFloat(el.value.trim()); const originalAmount = parseFloat(el.value.trim());
let convertedAmount let convertedAmount
const rupeeRate = (globalExchangeRate.inr / globalExchangeRate.usd); const rupeeRate = (globalExchangeRate.inr / globalExchangeRate.usd);
switch (selectedCurrency) { switch (previouslySelectedCurrency) {
case 'usd': case 'usd':
if (e.target.value === 'inr') if (selectedCurrency === 'inr')
convertedAmount = roundUp(originalAmount * rupeeRate) convertedAmount = roundUp(originalAmount * rupeeRate)
else else
convertedAmount = roundUp((originalAmount / globalExchangeRate.usd), 8) convertedAmount = roundUp((originalAmount / globalExchangeRate.usd), 8)
break; break;
case 'inr': case 'inr':
if (e.target.value === 'usd') if (selectedCurrency === 'usd')
convertedAmount = roundUp((originalAmount / rupeeRate)) convertedAmount = roundUp((originalAmount / rupeeRate))
else else
convertedAmount = roundUp((originalAmount / globalExchangeRate.inr), 8) convertedAmount = roundUp((originalAmount / globalExchangeRate.inr), 8)
break; break;
case 'btc': case 'btc':
convertedAmount = roundUp(originalAmount * globalExchangeRate[e.target.value]) convertedAmount = roundUp(originalAmount * globalExchangeRate[selectedCurrency])
break; break;
} }
el.value = convertedAmount el.value = convertedAmount
} else { } else {
if (el.dataset.btcAmount === undefined) return
el.textContent = formatAmount(getConvertedAmount(el.dataset.btcAmount)) el.textContent = formatAmount(getConvertedAmount(el.dataset.btcAmount))
} }
}) })
selectedCurrency = e.target.value; previouslySelectedCurrency = selectedCurrency
}) })
getRef('filter_selector').addEventListener('change', async e => { getRef('filter_selector').addEventListener('change', async e => {
const address = getRef('search_query_input').value; const address = getRef('search_query_input').value;
@ -1862,6 +1864,7 @@
} }
fee = parseFloat((parseFloat(feeInput) / (globalExchangeRate[selectedCurrency] || 1)).toFixed(8)); fee = parseFloat((parseFloat(feeInput) / (globalExchangeRate[selectedCurrency] || 1)).toFixed(8));
} }
console.log(senders, privKeys, receivers, amounts, fee);
btcOperator.sendTx(senders, privKeys, receivers, amounts, fee).then(txid => { btcOperator.sendTx(senders, privKeys, receivers, amounts, fee).then(txid => {
console.log(txid); console.log(txid);
getRef('txid').value = txid; getRef('txid').value = txid;