From 33a044e6ad3d3f3ddbbdd88324d78cae536eb86f Mon Sep 17 00:00:00 2001 From: Dexter Edwards Date: Wed, 3 Aug 2022 13:00:41 +0100 Subject: [PATCH] fix: governance page crashing when a freeform proposal exists (#941) --- apps/token/src/config/network-params.ts | 4 ++++ .../src/routes/governance/hooks/use-vote-information.ts | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/apps/token/src/config/network-params.ts b/apps/token/src/config/network-params.ts index 65d4c7bde..8ecd63225 100644 --- a/apps/token/src/config/network-params.ts +++ b/apps/token/src/config/network-params.ts @@ -17,5 +17,9 @@ export const NetworkParams = { 'governance.proposal.updateNetParam.requiredMajority', GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION: 'governance.proposal.updateNetParam.requiredParticipation', + GOV_FREEFORM_REQUIRED_PARTICIPATION: + 'governance.proposal.freeform.requiredParticipation', + GOV_FREEFORM_REQUIRED_MAJORITY: + 'governance.proposal.freeform.requiredMajority', VALIDATOR_DELEGATION_MIN_AMOUNT: 'validators.delegation.minAmount', }; diff --git a/apps/token/src/routes/governance/hooks/use-vote-information.ts b/apps/token/src/routes/governance/hooks/use-vote-information.ts index 208f52425..3a365a8a5 100644 --- a/apps/token/src/routes/governance/hooks/use-vote-information.ts +++ b/apps/token/src/routes/governance/hooks/use-vote-information.ts @@ -25,6 +25,8 @@ const useProposalNetworkParams = ({ NetworkParams.GOV_ASSET_REQUIRED_PARTICIPATION, NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_MAJORITY, NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION, + NetworkParams.GOV_FREEFORM_REQUIRED_MAJORITY, + NetworkParams.GOV_FREEFORM_REQUIRED_PARTICIPATION, ]); if (loading || !data) { return { @@ -42,6 +44,8 @@ const useProposalNetworkParams = ({ assetParticipation, paramMajority, paramParticipation, + freeformMajority, + freeformParticipation, ] = data; switch (proposal.terms.change.__typename) { @@ -65,6 +69,11 @@ const useProposalNetworkParams = ({ requiredMajority: newMarketMajority, requiredParticipation: new BigNumber(newMarketParticipation), }; + case 'NewFreeform': + return { + requiredMajority: freeformMajority, + requiredParticipation: freeformParticipation, + }; default: throw new Error('Unknown proposal type'); }