Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly display voting members with token balances after after SDK update #1355

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/@aragon/ods-old/components/listItem/voter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ListItemVoter: FC<ListItemVoterProps> = ({
{walletTag && <Tag {...walletTag} className="mx-2" />}
</p>
<p className="flex font-semibold text-neutral-600 ft-text-sm">
{tokenInfo?.amount} {tokenInfo?.symbol}
{tokenInfo?.amount}
</p>
</LeftContent>
</LeftSection>
Expand Down
34 changes: 20 additions & 14 deletions src/containers/votingTerminal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {ProposalStatus} from '@aragon/sdk-client-common';
import {useTranslation} from 'react-i18next';
import styled from 'styled-components';
import {useProviders} from 'context/providers';
import {formatUnits} from 'ethers/lib/utils';
import {usePastVotingPowerAsync} from 'services/aragon-sdk/queries/use-past-voting-power';
import {Web3Address, shortenAddress} from 'utils/library';
import BreakdownTab from './breakdownTab';
Expand Down Expand Up @@ -131,21 +130,27 @@ export const VotingTerminal: React.FC<VotingTerminalProps> = ({
async function fetchEns() {
const response = await Promise.all(
voters.map(async voter => {
const wallet = await Web3Address.create(provider, voter.wallet);
let balance;
if (daoToken?.address && wallet.address) {
balance = await fetchPastVotingPower({
tokenAddress: daoToken.address as string,
address: wallet.address as string,
blockNumber: blockNumber as number,
network,
});
}
const wallet = await Web3Address.create(
provider,
isMultisigProposal
? voter.wallet
: voter.wallet.toLowerCase().split('_')[1]
);

// commenting out for now to just use token
// let balance;

// if (daoToken?.address && wallet.address) {
// balance = await fetchPastVotingPower({
// tokenAddress: daoToken.address as string,
// address: voter.wallet.toLowerCase().split('_')[1],
// blockNumber: blockNumber as number,
// network,
// });
// }
return {
...voter,
tokenAmount: balance
? formatUnits(balance, daoToken?.decimals)
: voter.tokenAmount,
tokenAmount: voter.tokenAmount,
tokenSymbol: daoToken?.symbol,
wallet: (wallet.ensName ?? wallet.address) as string,
src: (wallet.avatar || wallet.address) as string,
Expand All @@ -164,6 +169,7 @@ export const VotingTerminal: React.FC<VotingTerminalProps> = ({
daoToken?.decimals,
daoToken?.symbol,
fetchPastVotingPower,
isMultisigProposal,
network,
provider,
voters,
Expand Down
Loading