diff --git a/scripts/composables/use_settings.js b/scripts/composables/use_settings.js index 0717bdb62..d20498d2c 100644 --- a/scripts/composables/use_settings.js +++ b/scripts/composables/use_settings.js @@ -46,7 +46,7 @@ export function useSettings() { getEventEmitter().on('advanced-mode', (fAdvancedMode) => { advancedMode.value = fAdvancedMode; }); - getEventEmitter().on('balance-update', async () => { + getEventEmitter().on('price-update', async () => { displayDecimals.value = nDisplayDecimals; }); getEventEmitter().on('auto-lock-wallet', (fAutoLockWallet) => { diff --git a/scripts/composables/use_wallet.js b/scripts/composables/use_wallet.js index 8faeac520..15f1a5fa6 100644 --- a/scripts/composables/use_wallet.js +++ b/scripts/composables/use_wallet.js @@ -134,10 +134,12 @@ export const useWallet = defineStore('wallet', () => { getEventEmitter().on('balance-update', async () => { balance.value = wallet.balance; immatureBalance.value = wallet.immatureBalance; - currency.value = strCurrency.toUpperCase(); shieldBalance.value = await wallet.getShieldBalance(); pendingShieldBalance.value = await wallet.getPendingShieldBalance(); coldBalance.value = wallet.coldBalance; + }); + getEventEmitter().on('price-update', async () => { + currency.value = strCurrency.toUpperCase(); price.value = cOracle.getCachedPrice(strCurrency); }); diff --git a/scripts/dashboard/Activity.vue b/scripts/dashboard/Activity.vue index 6cf402253..8c92da0ba 100644 --- a/scripts/dashboard/Activity.vue +++ b/scripts/dashboard/Activity.vue @@ -11,6 +11,7 @@ import { getEventEmitter } from '../event_bus'; import iCheck from '../../assets/icons/icon-check.svg'; import iHourglass from '../../assets/icons/icon-hourglass.svg'; +import { blockCount } from '../global.js'; const props = defineProps({ title: String, @@ -117,47 +118,40 @@ async function update(txToAdd = 0) { // If there are less than 10 txs loaded, append rather than update the list if (txCount < 10 && txToAdd == 0) txToAdd = 10; - let found = 0; - // Since ECMAScript 2019 .sort is stable. - // https://caniuse.com/mdn-javascript_builtins_array_sort_stable - const orderedTxs = Array.from(wallet.getTransactions()).sort( - (a, b) => a.blockHeight - b.blockHeight - ); + const historicalTxs = wallet.getHistoricalTxs(); // For Rewards: aggregate the total amount if (props.rewards) { - for (const tx of orderedTxs) { + for (const tx of historicalTxs) { // If this Tx Height is under our last scanned height, we stop if (tx.blockHeight <= nRewardUpdateHeight) break; // Only compute rewards - if (!tx.isCoinStake()) continue; + if (tx.type != HistoricalTxType.STAKE) continue; // Aggregate the total rewards - rewardAmount.value += ( - await wallet.toHistoricalTXs([tx]) - )[0].amount; + rewardAmount.value += tx.amount; } // Keep track of the scan block height - if (orderedTxs.length) { - nRewardUpdateHeight = orderedTxs[0].blockHeight; + if (historicalTxs.length) { + nRewardUpdateHeight = historicalTxs[0].blockHeight; } } - // Prepare the Tx History list + let i = 0; + let found = 0; while (found < txCount + txToAdd) { - if (orderedTxs.length == 0) { + if (i === historicalTxs.length) { isHistorySynced.value = true; break; } - const tx = orderedTxs.pop(); - if (props.rewards && !tx.isCoinStake()) continue; + const tx = historicalTxs[i]; + i += 1; + if (props.rewards && tx.type != HistoricalTxType.STAKE) continue; newTxs.push(tx); found++; } - // Convert to MPW's Activity format and render it - const arrTXs = await wallet.toHistoricalTXs(newTxs); - await parseTXs(arrTXs); txCount = found; + await parseTXs(newTxs); updating.value = false; } @@ -215,6 +209,13 @@ async function parseTXs(arrTXs) { let amountToShow = Math.abs(cTx.amount + cTx.shieldAmount); + // Coinbase Transactions (rewards) require coinbaseMaturity confs + const fConfirmed = + blockCount - cTx.blockHeight >= + (cTx.type === HistoricalTxType.STAKE + ? cChainParams.current.coinbaseMaturity + : 6); + // Take the icon, colour and content based on the type of the transaction let { icon, colour, content } = txMap.value[cTx.type]; const match = content.match(/{(.)}/); @@ -277,7 +278,7 @@ async function parseTXs(arrTXs) { content: props.rewards ? cTx.id : content, formattedAmt, amount: amountToShow, - confirmed: cTx.isConfirmed, + confirmed: fConfirmed, icon, colour, }); diff --git a/scripts/dashboard/Dashboard.vue b/scripts/dashboard/Dashboard.vue index a9b881e82..1e2006e8c 100644 --- a/scripts/dashboard/Dashboard.vue +++ b/scripts/dashboard/Dashboard.vue @@ -935,7 +935,6 @@ defineExpose({ :publicMode="wallet.publicMode" :price="price" :currency="currency" - :shieldEnabled="hasShield" v-model:amount="transferAmount" :desc="transferDescription" v-model:address="transferAddress" diff --git a/scripts/dashboard/TransferMenu.vue b/scripts/dashboard/TransferMenu.vue index 787ba95cd..81a79a83b 100644 --- a/scripts/dashboard/TransferMenu.vue +++ b/scripts/dashboard/TransferMenu.vue @@ -1,10 +1,9 @@