fix: token holdings summary table sums tokens correctly (#16464)
This commit is contained in:
@ -151,12 +151,14 @@ function HoldingsSummaryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
|
|||||||
const mintAddress = token.mint.toBase58();
|
const mintAddress = token.mint.toBase58();
|
||||||
const totalByMint = mappedTokens.get(mintAddress);
|
const totalByMint = mappedTokens.get(mintAddress);
|
||||||
|
|
||||||
let amount = new BigNumber(token.tokenAmount.uiAmountString);
|
let amount = token.tokenAmount.uiAmountString;
|
||||||
if (totalByMint !== undefined) {
|
if (totalByMint !== undefined) {
|
||||||
amount.plus(totalByMint);
|
amount = new BigNumber(totalByMint)
|
||||||
|
.plus(token.tokenAmount.uiAmountString)
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
mappedTokens.set(mintAddress, amount.toString());
|
mappedTokens.set(mintAddress, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
const detailsList: React.ReactNode[] = [];
|
const detailsList: React.ReactNode[] = [];
|
||||||
|
@ -317,12 +317,14 @@ const FilterDropdown = ({ filter, toggle, show, tokens }: FilterProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const filterOptions: string[] = [ALL_TOKENS];
|
const filterOptions: string[] = [ALL_TOKENS];
|
||||||
const nameLookup: { [mint: string]: string } = {};
|
const nameLookup: Map<string, string> = new Map();
|
||||||
|
|
||||||
tokens.forEach((token) => {
|
tokens.forEach((token) => {
|
||||||
const pubkey = token.info.mint.toBase58();
|
const address = token.info.mint.toBase58();
|
||||||
filterOptions.push(pubkey);
|
if (!nameLookup.has(address)) {
|
||||||
nameLookup[pubkey] = formatTokenName(pubkey, cluster, tokenRegistry);
|
filterOptions.push(address);
|
||||||
|
nameLookup.set(address, formatTokenName(address, cluster, tokenRegistry));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -333,7 +335,7 @@ const FilterDropdown = ({ filter, toggle, show, tokens }: FilterProps) => {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
>
|
>
|
||||||
{filter === ALL_TOKENS ? "All Tokens" : nameLookup[filter]}
|
{filter === ALL_TOKENS ? "All Tokens" : nameLookup.get(filter)}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
className={`token-filter dropdown-menu-right dropdown-menu${
|
className={`token-filter dropdown-menu-right dropdown-menu${
|
||||||
|
Reference in New Issue
Block a user