Skip to content

Commit

Permalink
fix(frontend): breakdown for eth from staking not showing (rotki#8367)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi authored and OjusWiZard committed Aug 9, 2024
1 parent c962058 commit 8d157d4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@
Changelog
=========

* :bug:`-` Fix issue where ETH from staking doesn't appear under the ETH breakdown on the dashboard.
* :bug:`8334` Importing addresses from MetaMask should work when multiple browser wallets are installed.
* :bug:`-` rotki will now properly run background tasks when logging out and logging in again.
* :bug:`-` The task to read new curve pools from the chain will be faster now.
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/components/AssetBalances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 172,15 @@ function expand(item: AssetBalanceWithPrice) {
v-if="!hideBreakdown && isEvmNativeToken(row.asset)"
blockchain-only
:identifier="row.asset"
class="bg-white dark:bg-[#1E1E1E]"
class="bg-white dark:bg-[#1E1E1E] my-2"
/>
<AssetBalances
v-else
v-bind="props"
hide-total
:balances="row.breakdown ?? []"
:sticky-header="false"
class="bg-white dark:bg-[#1E1E1E]"
class="bg-white dark:bg-[#1E1E1E] my-2"
/>
</template>
<template #item.expand="{ row }">
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/components/dashboard/DashboardAssetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 332,14 @@ watch(search, () => setPage(1));
show-percentage
:total="row.usdValue"
:identifier="row.asset"
class="bg-white dark:bg-[#1E1E1E]"
class="bg-white dark:bg-[#1E1E1E] my-2"
/>
<AssetBalances
v-else
hide-total
v-bind="props"
:balances="row.breakdown ?? []"
class="bg-white dark:bg-[#1E1E1E]"
class="bg-white dark:bg-[#1E1E1E] my-2"
/>
</template>
<template #item.expand="{ row }">
Expand Down
16 changes: 16 additions & 0 deletions frontend/app/src/composables/assets/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 30,21 @@ export function useAssetInfoRetrieval() {
): ComputedRef<string> =>
computed(() => get(assetAssociationMap)[identifier] ?? identifier);

const getAssetAssociationIdentifiers = (
identifier: string,
): ComputedRef<string[]> => computed(() => {
const assets = [identifier];

Object.entries(get(assetAssociationMap)).forEach(([key, item]) => {
if (item !== identifier)
return;

assets.push(key);
});

return assets;
});

const getAssetNameFallback = (id: string) => {
if (isEvmIdentifier(id)) {
const address = getAddressFromEvmIdentifier(id);
Expand Down Expand Up @@ -185,6 200,7 @@ export function useAssetInfoRetrieval() {
return {
fetchTokenDetails,
getAssociatedAssetIdentifier,
getAssetAssociationIdentifiers,
assetInfo,
refetchAssetInfo: queueIdentifier,
assetSymbol,
Expand Down
23 changes: 14 additions & 9 deletions frontend/app/src/store/blockchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 198,8 @@ export const useBlockchainStore = defineStore('blockchain', () => {

const getAddresses = (chain: string): string[] => get(addresses)[chain] ?? [];

const { getAssetAssociationIdentifiers } = useAssetInfoRetrieval();

const getBreakdown = (asset: string, chain?: string): AssetBreakdown[] => {
const breakdown: AssetBreakdown[] = [];
const balanceData = get(balances);
Expand All @@ -213,15 215,18 @@ export const useBlockchainStore = defineStore('blockchain', () => {

for (const address in chainBalanceData) {
const balance = chainBalanceData[address];
const assetBalance = balance.assets[asset];
if (!assetBalance)
continue;

breakdown.push({
address,
location: chain,
...assetBalance,
tags: chainAccounts.find(account => getAccountAddress(account) === address && account.chain === chain)?.tags,
const assetAssociations = get(getAssetAssociationIdentifiers(asset));
assetAssociations.forEach((asset) => {
const assetBalance = balance.assets[asset];
if (!assetBalance)
return;

breakdown.push({
address,
location: chain,
...assetBalance,
tags: chainAccounts.find(account => getAccountAddress(account) === address && account.chain === chain)?.tags,
});
});
}
}
Expand Down

0 comments on commit 8d157d4

Please sign in to comment.