fix: governance page crashing when a freeform proposal exists (#941)

This commit is contained in:
Dexter Edwards 2022-08-03 13:00:41 +01:00 committed by GitHub
parent f11403b1af
commit 33a044e6ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -17,5 +17,9 @@ export const NetworkParams = {
'governance.proposal.updateNetParam.requiredMajority', 'governance.proposal.updateNetParam.requiredMajority',
GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION: GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION:
'governance.proposal.updateNetParam.requiredParticipation', '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', VALIDATOR_DELEGATION_MIN_AMOUNT: 'validators.delegation.minAmount',
}; };

View File

@ -25,6 +25,8 @@ const useProposalNetworkParams = ({
NetworkParams.GOV_ASSET_REQUIRED_PARTICIPATION, NetworkParams.GOV_ASSET_REQUIRED_PARTICIPATION,
NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_MAJORITY, NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_MAJORITY,
NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION, NetworkParams.GOV_UPDATE_NET_PARAM_REQUIRED_PARTICIPATION,
NetworkParams.GOV_FREEFORM_REQUIRED_MAJORITY,
NetworkParams.GOV_FREEFORM_REQUIRED_PARTICIPATION,
]); ]);
if (loading || !data) { if (loading || !data) {
return { return {
@ -42,6 +44,8 @@ const useProposalNetworkParams = ({
assetParticipation, assetParticipation,
paramMajority, paramMajority,
paramParticipation, paramParticipation,
freeformMajority,
freeformParticipation,
] = data; ] = data;
switch (proposal.terms.change.__typename) { switch (proposal.terms.change.__typename) {
@ -65,6 +69,11 @@ const useProposalNetworkParams = ({
requiredMajority: newMarketMajority, requiredMajority: newMarketMajority,
requiredParticipation: new BigNumber(newMarketParticipation), requiredParticipation: new BigNumber(newMarketParticipation),
}; };
case 'NewFreeform':
return {
requiredMajority: freeformMajority,
requiredParticipation: freeformParticipation,
};
default: default:
throw new Error('Unknown proposal type'); throw new Error('Unknown proposal type');
} }