fix: asset dropdown list (#2622)

* fix(#2556): asset dropdown list fix

* fix: add ID to market list and make cell copyable

* fix: revert market list table
This commit is contained in:
m.ray 2023-01-17 05:02:46 -05:00 committed by GitHub
parent 45a4dd7009
commit e362d06b5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View File

@ -9,7 +9,6 @@ import compact from 'lodash/compact';
import type { ChangeEvent } from 'react';
import { useMemo, useState } from 'react';
import type { AccountHistoryQuery } from './__generated__/AccountHistory';
import { useAccountsWithBalanceQuery } from './__generated__/AccountHistory';
import { useAccountHistoryQuery } from './__generated__/AccountHistory';
import * as Schema from '@vegaprotocol/types';
import type { AssetFieldsFragment } from '@vegaprotocol/assets';
@ -26,6 +25,8 @@ import {
import { AccountTypeMapping } from '@vegaprotocol/types';
import { PriceChart } from 'pennant';
import 'pennant/dist/style.css';
import { accountsOnlyDataProvider } from '@vegaprotocol/accounts';
import { useDataProvider } from '@vegaprotocol/react-helpers';
const DateRange = {
RANGE_1D: '1D',
@ -95,17 +96,15 @@ const AccountHistoryManager = ({
[pubKey]
);
const assetsWithBalanceHistory = useAccountsWithBalanceQuery({
const { data: assetsWithBalanceHistory } = useDataProvider({
dataProvider: accountsOnlyDataProvider,
variables: variablesForOneTimeQuery,
skip: !pubKey,
});
const assetsWithBalance = useMemo(
() =>
assetsWithBalanceHistory.data?.balanceChanges.edges.map(
(e) => e?.node.assetId
) || [],
[assetsWithBalanceHistory.data?.balanceChanges.edges]
() => assetsWithBalanceHistory?.map((e) => e?.asset?.id) || [],
[assetsWithBalanceHistory]
);
const assets = useMemo(

View File

@ -125,12 +125,10 @@ const getTotalBalance = (accounts: AccountFieldsFragment[]) =>
accounts.reduce((acc, a) => acc + BigInt(a.balance), BigInt(0));
export const getAccountData = (data: Account[]): AccountFields[] => {
return getAssetIds(data)
.map((assetId) => {
const accounts = data.filter((a) => a.asset.id === assetId);
return accounts && getAssetAccountAggregation(accounts, assetId);
})
.filter((a) => a.deposited !== '0'); // filter empty accounts
return getAssetIds(data).map((assetId) => {
const accounts = data.filter((a) => a.asset.id === assetId);
return accounts && getAssetAccountAggregation(accounts, assetId);
});
};
const getAssetAccountAggregation = (