Skip to content

Commit 810ac8b

Browse files
committed
fix: type error on voting threshold value
1 parent bc801ce commit 810ac8b

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

govtool/frontend/src/components/molecules/VotesSubmitted.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ export const VotesSubmitted = ({
165165
abstainVotes={totalAbstainVotes}
166166
notVotedVotes={dRepNotVotedVotes}
167167
notVotedPercentage={dRepNotVotedVotesPercentage}
168-
threshold={(() => {
169-
const votingThresholdKey = getGovActionVotingThresholdKey({
170-
govActionType: type,
171-
protocolParams,
172-
voterType: "dReps",
173-
});
174-
return votingThresholdKey && epochParams?.[votingThresholdKey];
175-
})()}
168+
threshold={
169+
(() => {
170+
const votingThresholdKey = getGovActionVotingThresholdKey({
171+
govActionType: type,
172+
protocolParams,
173+
voterType: "dReps",
174+
});
175+
return votingThresholdKey && epochParams?.[votingThresholdKey];
176+
})() as number
177+
}
176178
/>
177179
)}
178180
{areSPOVoteTotalsDisplayed(type, isSecurityGroup()) && (
@@ -183,14 +185,16 @@ export const VotesSubmitted = ({
183185
noVotes={poolNoVotes}
184186
noVotesPercentage={poolNoVotesPercentage}
185187
abstainVotes={poolAbstainVotes}
186-
threshold={(() => {
187-
const votingThresholdKey = getGovActionVotingThresholdKey({
188-
govActionType: type,
189-
protocolParams,
190-
voterType: "sPos",
191-
});
192-
return votingThresholdKey && epochParams?.[votingThresholdKey];
193-
})()}
188+
threshold={
189+
(() => {
190+
const votingThresholdKey = getGovActionVotingThresholdKey({
191+
govActionType: type,
192+
protocolParams,
193+
voterType: "sPos",
194+
});
195+
return votingThresholdKey && epochParams?.[votingThresholdKey];
196+
})() as number
197+
}
194198
/>
195199
)}
196200
{areCCVoteTotalsDisplayed(type) && (

govtool/frontend/src/utils/getGovActionVotingThresholdKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { EpochParams } from "@/models";
99
import { GovernanceActionType } from "@/types/governanceAction";
1010

11-
type VotingThresholdKey = string | undefined;
11+
type VotingThresholdKey = keyof EpochParams | undefined;
1212

1313
type GetGovActionVotingThresholdKeyOptions = {
1414
govActionType: GovernanceActionType;

0 commit comments

Comments
 (0)