Skip to content

Commit 34508b2

Browse files
authored
fix: add proposalId to voterKey (#140)
* fix: add proposalId to voterKey * chore: remove unnecessary type casting
1 parent bc06e52 commit 34508b2

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/proposals/components/proposal/VotersList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function VotersList({
236236
.map((vote) => (
237237
<VotersListItem
238238
vote={vote}
239-
key={vote.transactionHash}
239+
key={`${vote.transactionHash}-${vote.proposalId}`}
240240
activeAddress={
241241
representative.address ||
242242
activeWallet?.address ||

src/proposals/components/proposal/VotersListLoading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function VotersListLoading({
4646
representative.address || activeWallet?.address || zeroAddress
4747
}
4848
vote={vote}
49-
key={vote.transactionHash}
49+
key={`${vote.transactionHash}-${vote.proposalId}`}
5050
/>
5151
))}
5252
</Box>

src/proposals/components/proposal/VotersModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ function VotersTable({
148148
{texts.proposals.votersListVotingPower}
149149
</Box>
150150
</ListItem>
151-
{voters.map((vote, index) => (
152-
<ListItem key={index}>
151+
{voters.map((vote) => (
152+
<ListItem key={`${vote.transactionHash}-${vote.proposalId}`}>
153153
<ListItemAddress vote={vote} />
154154
<FormattedNumber value={vote.votingPower} visibleDecimals={3} />
155155
</ListItem>
@@ -272,7 +272,7 @@ export function VotersModal({
272272
</ListItem>
273273

274274
{voters.map((vote) => (
275-
<ListItem key={vote.transactionHash}>
275+
<ListItem key={`${vote.transactionHash}-${vote.proposalId}`}>
276276
<ListItemAddress vote={vote} />
277277
<Box
278278
sx={{

src/proposals/store/proposalsSelectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export const selectConfigByAccessLevel = (
326326
};
327327

328328
export const selectVotersByProposalId = (
329-
voters: Record<`0x${string}`, VotersData>,
329+
voters: Record<string, VotersData>,
330330
id: number,
331331
) => {
332332
const votersLocal = Object.values(voters).filter(

src/proposals/store/proposalsSlice.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export interface IProposalsSlice {
146146
underlyingAssets: string[],
147147
) => Promise<void>;
148148

149-
voters: Record<Hex, VotersData>;
149+
voters: Record<string, VotersData>;
150150
setVoters: (voters: VotersData[]) => void;
151151
getVoters: (
152152
proposalId: number,
@@ -1029,7 +1029,8 @@ export const createProposalsSlice: StoreSlice<
10291029
set((state) =>
10301030
produce(state, (draft) => {
10311031
votersData.forEach((vote) => {
1032-
draft.voters[vote.transactionHash] = {
1032+
const voterKey = `${vote.transactionHash}-${vote.proposalId}`;
1033+
draft.voters[voterKey] = {
10331034
...vote,
10341035
ensName: ENSDataExists(
10351036
get().ensData,
@@ -1069,7 +1070,8 @@ export const createProposalsSlice: StoreSlice<
10691070
set((state) =>
10701071
produce(state, (draft) => {
10711072
topVotersByProposalIdWithENS.forEach((vote) => {
1072-
draft.voters[vote.transactionHash] = {
1073+
const voterKey = `${vote.transactionHash}-${vote.proposalId}`;
1074+
draft.voters[voterKey] = {
10731075
...vote,
10741076
ensName: ENSDataExists(
10751077
get().ensData,

0 commit comments

Comments
 (0)