Skip to content

Commit

Permalink
Merge pull request #2024 from IntersectMBO/fix/2008-enable-voting-on-…
Browse files Browse the repository at this point in the history
…GAs-after-bootdtrapping

[#2008] fix condition for disabling voting on different GA types
  • Loading branch information
jdyczka authored Sep 12, 2024
2 parents 70c9204 + 594671c commit 69daf62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ changes.
- Correctly show all kinds of votes in the modal showing vote numbers [Issue 1941](https://github.com/IntersectMBO/govtool/issues/1941)
- Fixed terms and conditions link [Issue 1968](https://github.com/IntersectMBO/govtool/issues/1968)
- Hide Delegate button in DRep list and details if user has already delegated to this DRep [Issue 1982](https://github.com/IntersectMBO/govtool/issues/1982)
- Fix condition for disabling voting on different GA types [Issue 2008](https://github.com/IntersectMBO/govtool/issues/2008)

### Changed

Expand Down
18 changes: 4 additions & 14 deletions govtool/frontend/src/context/featureFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ import { GovernanceActionType } from "@/types/governanceAction";

import { useAppContext } from "./appContext";

const govActionVotingEnabledSinceProtocolVersion = {
[GovernanceActionType.InfoAction]: 9,
// TODO: Add minimum protocol versions for the following actions
[GovernanceActionType.HardForkInitiation]: Number.MAX_SAFE_INTEGER,
[GovernanceActionType.NewCommittee]: Number.MAX_SAFE_INTEGER,
[GovernanceActionType.NewConstitution]: Number.MAX_SAFE_INTEGER,
[GovernanceActionType.NoConfidence]: Number.MAX_SAFE_INTEGER,
[GovernanceActionType.ParameterChange]: Number.MAX_SAFE_INTEGER,
[GovernanceActionType.TreasuryWithdrawals]: Number.MAX_SAFE_INTEGER,
};
/**
* The feature flag context type.
*/
Expand All @@ -41,7 +31,7 @@ const FeatureFlagContext = createContext<FeatureFlagContextType>({
* @param children - The child components to render.
*/
const FeatureFlagProvider = ({ children }: PropsWithChildren) => {
const { epochParams, isAppInitializing } = useAppContext();
const { isAppInitializing, isInBootstrapPhase } = useAppContext();

/**
* Determines if voting on a governance action is enabled based on the protocol version.
Expand All @@ -50,9 +40,9 @@ const FeatureFlagProvider = ({ children }: PropsWithChildren) => {
*/
const isVotingOnGovernanceActionEnabled = useCallback(
(governanceActionType: GovernanceActionType) =>
(epochParams?.protocol_major || 0) >=
govActionVotingEnabledSinceProtocolVersion[governanceActionType],
[isAppInitializing],
governanceActionType === GovernanceActionType.InfoAction ||
!isInBootstrapPhase,
[isAppInitializing, isInBootstrapPhase],
);

const value = useMemo(
Expand Down

0 comments on commit 69daf62

Please sign in to comment.