From 1f507facba391338c46bade05872bc52cc8d2c92 Mon Sep 17 00:00:00 2001 From: Sam Keen Date: Wed, 27 Sep 2023 14:55:43 +0100 Subject: [PATCH] feat(governance): show perp or future pills (#4863) --- apps/governance-e2e/.env.devnet | 1 + apps/governance-e2e/.env.mainnet | 1 + apps/governance-e2e/.env.testnet | 1 + apps/governance/.env | 1 + apps/governance/.env.capsule | 1 + apps/governance/.env.devnet | 1 + apps/governance/.env.mainnet | 1 + apps/governance/.env.stagnet1 | 1 + apps/governance/.env.testnet | 1 + apps/governance/.env.validators-testnet | 1 + .../governance/src/i18n/translations/dev.json | 3 ++ apps/governance/src/routes/home/index.tsx | 22 +++++++++---- .../proposal-header.tsx | 8 +++-- .../components/proposal/proposal.tsx | 3 +- .../proposals-list-item.tsx | 3 +- .../proposals-list/proposals-list.tsx | 12 +++---- .../rejected-proposals-list.tsx | 7 ++-- .../proposals/proposal/Proposal.graphql | 17 +++++++++- .../proposal/__generated__/Proposal.ts | 27 +++++++++++++--- .../proposals/proposal/proposal-container.tsx | 5 ++- .../proposals/proposals/Proposals.graphql | 17 +++++++++- .../proposals/__generated__/Proposals.ts | 32 ++++++++++++++++--- .../proposals/proposals-container.tsx | 19 +++++++---- .../rejected/rejected-proposals-container.tsx | 25 +++++++++------ libs/types/src/__generated__/types.ts | 2 +- 25 files changed, 158 insertions(+), 54 deletions(-) diff --git a/apps/governance-e2e/.env.devnet b/apps/governance-e2e/.env.devnet index 7a3080201..124d10968 100644 --- a/apps/governance-e2e/.env.devnet +++ b/apps/governance-e2e/.env.devnet @@ -4,3 +4,4 @@ NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance-e2e/.env.mainnet b/apps/governance-e2e/.env.mainnet index 9a252e56e..f59b0939c 100644 --- a/apps/governance-e2e/.env.mainnet +++ b/apps/governance-e2e/.env.mainnet @@ -4,3 +4,4 @@ NX_VEGA_URL=https://api.vega.community/graphql NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://etherscan.io NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_PRODUCT_PERPETUALS=false diff --git a/apps/governance-e2e/.env.testnet b/apps/governance-e2e/.env.testnet index 76a430550..2f39b6fbd 100644 --- a/apps/governance-e2e/.env.testnet +++ b/apps/governance-e2e/.env.testnet @@ -4,3 +4,4 @@ NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance/.env b/apps/governance/.env index b29f0272c..ee6d94009 100644 --- a/apps/governance/.env +++ b/apps/governance/.env @@ -32,3 +32,4 @@ LC_ALL="en_US.UTF-8" # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true NX_METAMASK_SNAPS=true +NX_PRODUCT_PERPETUALS=false diff --git a/apps/governance/.env.capsule b/apps/governance/.env.capsule index 64d641033..34bb656e2 100644 --- a/apps/governance/.env.capsule +++ b/apps/governance/.env.capsule @@ -33,3 +33,4 @@ CYPRESS_FAIRGROUND=false # Cosmic elevator flags NX_SUCCESSOR_MARKETS=false NX_METAMASK_SNAPS=false +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance/.env.devnet b/apps/governance/.env.devnet index 3acb4de4d..a0a31c6dd 100644 --- a/apps/governance/.env.devnet +++ b/apps/governance/.env.devnet @@ -25,3 +25,4 @@ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/m # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true NX_METAMASK_SNAPS=true +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance/.env.mainnet b/apps/governance/.env.mainnet index 9208e58b4..7b75bc106 100644 --- a/apps/governance/.env.mainnet +++ b/apps/governance/.env.mainnet @@ -24,3 +24,4 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket # Cosmic elevator flags NX_SUCCESSOR_MARKETS=false NX_METAMASK_SNAPS=false +NX_PRODUCT_PERPETUALS=false diff --git a/apps/governance/.env.stagnet1 b/apps/governance/.env.stagnet1 index 29d15032f..8664b009e 100644 --- a/apps/governance/.env.stagnet1 +++ b/apps/governance/.env.stagnet1 @@ -20,3 +20,4 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true NX_METAMASK_SNAPS=true +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance/.env.testnet b/apps/governance/.env.testnet index 38cf946ce..b3973792b 100644 --- a/apps/governance/.env.testnet +++ b/apps/governance/.env.testnet @@ -25,3 +25,4 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true NX_METAMASK_SNAPS=true +NX_PRODUCT_PERPETUALS=true diff --git a/apps/governance/.env.validators-testnet b/apps/governance/.env.validators-testnet index 7be31358f..8bfc69f68 100644 --- a/apps/governance/.env.validators-testnet +++ b/apps/governance/.env.validators-testnet @@ -22,3 +22,4 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega. # Cosmic elevator flags NX_SUCCESSOR_MARKETS=false NX_METAMASK_SNAPS=false +NX_PRODUCT_PERPETUALS=false diff --git a/apps/governance/src/i18n/translations/dev.json b/apps/governance/src/i18n/translations/dev.json index c26283560..8c796af5f 100644 --- a/apps/governance/src/i18n/translations/dev.json +++ b/apps/governance/src/i18n/translations/dev.json @@ -717,6 +717,9 @@ "ProposalDocsPrefix": "For guidance on how to make proposals, see", "NetworkParameter": "Network parameter", "NewMarket": "New market", + "NewMarketPerpetualProduct": "New market - perpetual", + "NewMarketFutureProduct": "New market - future", + "NewMarketSpotProduct": "New market - spot", "UpdateMarket": "Update market", "NewAsset": "New asset", "UpdateAsset": "Update asset", diff --git a/apps/governance/src/routes/home/index.tsx b/apps/governance/src/routes/home/index.tsx index a2ae40d6a..253182e85 100644 --- a/apps/governance/src/routes/home/index.tsx +++ b/apps/governance/src/routes/home/index.tsx @@ -12,7 +12,7 @@ import { useRefreshAfterEpoch } from '../../hooks/use-refresh-after-epoch'; import { ProposalsListItem } from '../proposals/components/proposals-list-item'; import { ProtocolUpgradeProposalsListItem } from '../proposals/components/protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item'; import Routes from '../routes'; -import { ExternalLinks } from '@vegaprotocol/environment'; +import { ExternalLinks, FLAGS } from '@vegaprotocol/environment'; import { removePaginationWrapper } from '@vegaprotocol/utils'; import { useNodesQuery } from '../staking/home/__generated__/Nodes'; import { useProposalsQuery } from '../proposals/proposals/__generated__/Proposals'; @@ -23,7 +23,6 @@ import { import { Heading, SubHeading } from '../../components/heading'; import * as Schema from '@vegaprotocol/types'; import type { RouteChildProps } from '..'; -import type { ProposalFieldsFragment } from '../proposals/proposals/__generated__/Proposals'; import type { NodesFragmentFragment } from '../staking/home/__generated__/Nodes'; import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; import { useProtocolUpgradeProposalsQuery } from '@vegaprotocol/proposals'; @@ -32,6 +31,7 @@ import { orderByUpgradeBlockHeight, } from '../proposals/components/proposals-list/proposals-list'; import { BigNumber } from '../../lib/bignumber'; +import type { ProposalQuery } from '../proposals/proposal/__generated__/Proposal'; const nodesToShow = 6; @@ -39,7 +39,7 @@ const HomeProposals = ({ proposals, protocolUpgradeProposals, }: { - proposals: ProposalFieldsFragment[]; + proposals: ProposalQuery['proposal'][]; protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[]; }) => { const { t } = useTranslation(); @@ -60,9 +60,12 @@ const HomeProposals = ({ ))} - {proposals.map((proposal) => ( - - ))} + {proposals.map( + (proposal) => + proposal?.id && ( + + ) + )}
@@ -182,6 +185,9 @@ const GovernanceHome = ({ name }: RouteChildProps) => { pollInterval: 5000, fetchPolicy: 'network-only', errorPolicy: 'ignore', + variables: { + includeNewMarketProductFields: !!FLAGS.PRODUCT_PERPETUALS, + }, }); const { @@ -206,7 +212,9 @@ const GovernanceHome = ({ name }: RouteChildProps) => { const proposals = useMemo( () => proposalsData - ? getNotRejectedProposals(proposalsData.proposalsConnection) + ? getNotRejectedProposals( + removePaginationWrapper(proposalsData.proposalsConnection?.edges) + ) : [], [proposalsData] ); diff --git a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx index a1d59cbe9..017dcce5c 100644 --- a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx @@ -3,7 +3,6 @@ import { Lozenge, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import { shorten } from '@vegaprotocol/utils'; import { Heading, SubHeading } from '../../../../components/heading'; import type { ReactNode } from 'react'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { truncateMiddle } from '../../../../lib/truncate-middle'; import { CurrentProposalState } from '../current-proposal-state'; @@ -20,7 +19,7 @@ export const ProposalHeader = ({ isListItem = true, voteState, }: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: ProposalQuery['proposal']; isListItem?: boolean; voteState?: VoteState | null; }) => { @@ -37,7 +36,10 @@ export const ProposalHeader = ({ switch (change?.__typename) { case 'NewMarket': { - proposalType = 'NewMarket'; + proposalType = + FLAGS.PRODUCT_PERPETUALS && change?.instrument?.product?.__typename + ? `NewMarket${change?.instrument?.product?.__typename}` + : 'NewMarket'; fallbackTitle = t('NewMarketProposal'); details = ( <> diff --git a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx index 327d84cfe..9bf1800e7 100644 --- a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx +++ b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx @@ -10,7 +10,6 @@ import { UserVote } from '../vote-details'; import { ListAsset } from '../list-asset'; import Routes from '../../../routes'; import { ProposalMarketData } from '../proposal-market-data'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import type { MarketInfo } from '@vegaprotocol/markets'; import type { AssetQuery } from '@vegaprotocol/assets'; @@ -22,7 +21,7 @@ import { useVoteSubmit } from '@vegaprotocol/proposals'; import { useUserVote } from '../vote-details/use-user-vote'; export interface ProposalProps { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: ProposalQuery['proposal']; networkParams: Partial; newMarketData?: MarketInfo | null; parentMarketData?: MarketInfo | null; diff --git a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx index 815aa3f3f..09747d2b6 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx @@ -2,11 +2,10 @@ import { RoundedWrapper } from '@vegaprotocol/ui-toolkit'; import { ProposalHeader } from '../proposal-detail-header/proposal-header'; import { ProposalsListItemDetails } from './proposals-list-item-details'; import { useUserVote } from '../vote-details/use-user-vote'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; interface ProposalsListItemProps { - proposal?: ProposalFieldsFragment | ProposalQuery['proposal'] | null; + proposal?: ProposalQuery['proposal'] | null; } export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => { diff --git a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx index 91322b088..b6d651856 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx @@ -16,14 +16,14 @@ import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/propos import { ExternalLinks } from '@vegaprotocol/environment'; interface ProposalsListProps { - proposals: Array; + proposals: Array; protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[]; lastBlockHeight?: string; } interface SortedProposalsProps { - open: Array; - closed: Array; + open: ProposalQuery['proposal'][]; + closed: ProposalQuery['proposal'][]; } interface SortedProtocolUpgradeProposalsProps { @@ -31,7 +31,7 @@ interface SortedProtocolUpgradeProposalsProps { closed: ProtocolUpgradeProposalFieldsFragment[]; } -export const orderByDate = (arr: ProposalFieldsFragment[]) => +export const orderByDate = (arr: ProposalQuery['proposal'][]) => orderBy( arr, [ @@ -92,12 +92,12 @@ export const ProposalsList = ({ return { open: initialSorting.open.length > 0 - ? orderByDate(initialSorting.open as ProposalFieldsFragment[]) + ? orderByDate(initialSorting.open as ProposalQuery['proposal'][]) : [], closed: initialSorting.closed.length > 0 ? orderByDate( - initialSorting.closed as ProposalFieldsFragment[] + initialSorting.closed as ProposalQuery['proposal'][] ).reverse() : [], }; diff --git a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx index 0b128df9d..64a90752a 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx @@ -3,20 +3,17 @@ import { useTranslation } from 'react-i18next'; import { Heading } from '../../../../components/heading'; import { ProposalsListItem } from '../proposals-list-item'; import { ProposalsListFilter } from '../proposals-list-filter'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; interface ProposalsListProps { - proposals: Array; + proposals: ProposalQuery['proposal'][]; } export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => { const { t } = useTranslation(); const [filterString, setFilterString] = useState(''); - const filterPredicate = ( - p: ProposalFieldsFragment | ProposalQuery['proposal'] - ) => + const filterPredicate = (p: ProposalQuery['proposal']) => p?.id?.includes(filterString) || p?.party?.id?.toString().includes(filterString); diff --git a/apps/governance/src/routes/proposals/proposal/Proposal.graphql b/apps/governance/src/routes/proposals/proposal/Proposal.graphql index 8cc991576..d5afe0add 100644 --- a/apps/governance/src/routes/proposals/proposal/Proposal.graphql +++ b/apps/governance/src/routes/proposals/proposal/Proposal.graphql @@ -1,4 +1,18 @@ -query Proposal($proposalId: ID!) { +fragment NewMarketProductField on Proposal { + terms { + change { + ... on NewMarket { + instrument { + product { + __typename + } + } + } + } + } +} + +query Proposal($proposalId: ID!, $includeNewMarketProductField: Boolean!) { proposal(id: $proposalId) { id rationale { @@ -13,6 +27,7 @@ query Proposal($proposalId: ID!) { id } errorDetails + ...NewMarketProductField @include(if: $includeNewMarketProductField) terms { closingDatetime enactmentDatetime diff --git a/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts b/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts index fa7e80408..2aed6a862 100644 --- a/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts +++ b/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts @@ -3,16 +3,33 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; +export type NewMarketProductFieldFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } }; + export type ProposalQueryVariables = Types.Exact<{ proposalId: Types.Scalars['ID']; + includeNewMarketProductField: Types.Scalars['Boolean']; }>; -export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array | null, positionDecimalPlaces: number, linearSlippageFactor: string, quadraticSlippageFactor: string, riskParameters: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', mu: number, r: number, sigma: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | null }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string, updateMarketConfiguration: { __typename?: 'UpdateMarketConfiguration', metadata?: Array | null, instrument: { __typename?: 'UpdateInstrumentConfiguration', code: string, product: { __typename?: 'UpdateFutureProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'UpdatePerpetualProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, riskParameters: { __typename?: 'UpdateMarketLogNormalRiskModel', logNormal?: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | null } | { __typename?: 'UpdateMarketSimpleRiskModel', simple?: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } | null } } } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } | null }; - +export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array | null, positionDecimalPlaces: number, linearSlippageFactor: string, quadraticSlippageFactor: string, riskParameters: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', mu: number, r: number, sigma: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | null, product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string, updateMarketConfiguration: { __typename?: 'UpdateMarketConfiguration', metadata?: Array | null, instrument: { __typename?: 'UpdateInstrumentConfiguration', code: string, product: { __typename?: 'UpdateFutureProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'UpdatePerpetualProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, riskParameters: { __typename?: 'UpdateMarketLogNormalRiskModel', logNormal?: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | null } | { __typename?: 'UpdateMarketSimpleRiskModel', simple?: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } | null } } } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } | null }; +export const NewMarketProductFieldFragmentDoc = gql` + fragment NewMarketProductField on Proposal { + terms { + change { + ... on NewMarket { + instrument { + product { + __typename + } + } + } + } + } +} + `; export const ProposalDocument = gql` - query Proposal($proposalId: ID!) { + query Proposal($proposalId: ID!, $includeNewMarketProductField: Boolean!) { proposal(id: $proposalId) { id rationale { @@ -27,6 +44,7 @@ export const ProposalDocument = gql` id } errorDetails + ...NewMarketProductField @include(if: $includeNewMarketProductField) terms { closingDatetime enactmentDatetime @@ -313,7 +331,7 @@ export const ProposalDocument = gql` } } } - `; + ${NewMarketProductFieldFragmentDoc}`; /** * __useProposalQuery__ @@ -328,6 +346,7 @@ export const ProposalDocument = gql` * const { data, loading, error } = useProposalQuery({ * variables: { * proposalId: // value for 'proposalId' + * includeNewMarketProductField: // value for 'includeNewMarketProductField' * }, * }); */ diff --git a/apps/governance/src/routes/proposals/proposal/proposal-container.tsx b/apps/governance/src/routes/proposals/proposal/proposal-container.tsx index 7f2114eed..a097e9d54 100644 --- a/apps/governance/src/routes/proposals/proposal/proposal-container.tsx +++ b/apps/governance/src/routes/proposals/proposal/proposal-container.tsx @@ -53,7 +53,10 @@ export const ProposalContainer = () => { const { data, loading, error, refetch } = useProposalQuery({ fetchPolicy: 'network-only', errorPolicy: 'ignore', - variables: { proposalId: params.proposalId || '' }, + variables: { + proposalId: params.proposalId || '', + includeNewMarketProductField: !!FLAGS.PRODUCT_PERPETUALS, + }, skip: !params.proposalId, }); diff --git a/apps/governance/src/routes/proposals/proposals/Proposals.graphql b/apps/governance/src/routes/proposals/proposals/Proposals.graphql index ef67a2e9c..8b26532ee 100644 --- a/apps/governance/src/routes/proposals/proposals/Proposals.graphql +++ b/apps/governance/src/routes/proposals/proposals/Proposals.graphql @@ -1,3 +1,17 @@ +fragment NewMarketProductFields on Proposal { + terms { + change { + ... on NewMarket { + instrument { + product { + __typename + } + } + } + } + } +} + fragment ProposalFields on Proposal { id rationale { @@ -79,11 +93,12 @@ fragment ProposalFields on Proposal { } } -query Proposals { +query Proposals($includeNewMarketProductFields: Boolean!) { proposalsConnection { edges { node { ...ProposalFields + ...NewMarketProductFields @include(if: $includeNewMarketProductFields) } } } diff --git a/apps/governance/src/routes/proposals/proposals/__generated__/Proposals.ts b/apps/governance/src/routes/proposals/proposals/__generated__/Proposals.ts index 8f8d7e443..f60005df4 100644 --- a/apps/governance/src/routes/proposals/proposals/__generated__/Proposals.ts +++ b/apps/governance/src/routes/proposals/proposals/__generated__/Proposals.ts @@ -3,13 +3,32 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; +export type NewMarketProductFieldsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } }; + export type ProposalFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } }; -export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>; +export type ProposalsQueryVariables = Types.Exact<{ + includeNewMarketProductFields: Types.Scalars['Boolean']; +}>; -export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null }; +export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null, product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null }; +export const NewMarketProductFieldsFragmentDoc = gql` + fragment NewMarketProductFields on Proposal { + terms { + change { + ... on NewMarket { + instrument { + product { + __typename + } + } + } + } + } +} + `; export const ProposalFieldsFragmentDoc = gql` fragment ProposalFields on Proposal { id @@ -93,16 +112,18 @@ export const ProposalFieldsFragmentDoc = gql` } `; export const ProposalsDocument = gql` - query Proposals { + query Proposals($includeNewMarketProductFields: Boolean!) { proposalsConnection { edges { node { ...ProposalFields + ...NewMarketProductFields @include(if: $includeNewMarketProductFields) } } } } - ${ProposalFieldsFragmentDoc}`; + ${ProposalFieldsFragmentDoc} +${NewMarketProductFieldsFragmentDoc}`; /** * __useProposalsQuery__ @@ -116,10 +137,11 @@ export const ProposalsDocument = gql` * @example * const { data, loading, error } = useProposalsQuery({ * variables: { + * includeNewMarketProductFields: // value for 'includeNewMarketProductFields' * }, * }); */ -export function useProposalsQuery(baseOptions?: Apollo.QueryHookOptions) { +export function useProposalsQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(ProposalsDocument, options); } diff --git a/apps/governance/src/routes/proposals/proposals/proposals-container.tsx b/apps/governance/src/routes/proposals/proposals/proposals-container.tsx index 16790f082..fbc2293e1 100644 --- a/apps/governance/src/routes/proposals/proposals/proposals-container.tsx +++ b/apps/governance/src/routes/proposals/proposals/proposals-container.tsx @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'; import { SplashLoader } from '../../../components/splash-loader'; import { ProposalsList } from '../components/proposals-list'; import { useProposalsQuery } from './__generated__/Proposals'; -import { getNodes } from '@vegaprotocol/utils'; +import { getNodes, removePaginationWrapper } from '@vegaprotocol/utils'; import { ProposalState, ProtocolUpgradeProposalStatus, @@ -15,14 +15,13 @@ import type { NodeConnection, NodeEdge } from '@vegaprotocol/utils'; import type { ProposalFieldsFragment } from './__generated__/Proposals'; import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; import { useProtocolUpgradeProposalsQuery } from '@vegaprotocol/proposals'; +import { FLAGS } from '@vegaprotocol/environment'; -export function getNotRejectedProposals( - data?: NodeConnection> | null -): T[] { +export function getNotRejectedProposals(data?: ProposalFieldsFragment[]) { return flow([ (data) => - getNodes(data, (p) => - p ? p.state !== ProposalState.STATE_REJECTED : false + data.filter( + (p: ProposalFieldsFragment) => p?.state !== ProposalState.STATE_REJECTED ), ])(data); } @@ -47,6 +46,9 @@ export const ProposalsContainer = () => { pollInterval: 5000, fetchPolicy: 'network-only', errorPolicy: 'ignore', + variables: { + includeNewMarketProductFields: !!FLAGS.PRODUCT_PERPETUALS, + }, }); const { @@ -60,7 +62,10 @@ export const ProposalsContainer = () => { }); const proposals = useMemo( - () => getNotRejectedProposals(data?.proposalsConnection), + () => + getNotRejectedProposals( + removePaginationWrapper(data?.proposalsConnection?.edges) + ), [data] ); diff --git a/apps/governance/src/routes/proposals/rejected/rejected-proposals-container.tsx b/apps/governance/src/routes/proposals/rejected/rejected-proposals-container.tsx index bf20b4ee7..784131261 100644 --- a/apps/governance/src/routes/proposals/rejected/rejected-proposals-container.tsx +++ b/apps/governance/src/routes/proposals/rejected/rejected-proposals-container.tsx @@ -6,11 +6,11 @@ import { SplashLoader } from '../../../components/splash-loader'; import { RejectedProposalsList } from '../components/proposals-list'; import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals'; import { useProposalsQuery } from '../proposals/__generated__/Proposals'; -import type { NodeConnection, NodeEdge } from '@vegaprotocol/utils'; -import { getNodes } from '@vegaprotocol/utils'; +import { removePaginationWrapper } from '@vegaprotocol/utils'; import flow from 'lodash/flow'; import orderBy from 'lodash/orderBy'; import { ProposalState } from '@vegaprotocol/types'; +import { FLAGS } from '@vegaprotocol/environment'; const orderByDate = (arr: ProposalFieldsFragment[]) => orderBy( @@ -22,13 +22,11 @@ const orderByDate = (arr: ProposalFieldsFragment[]) => ['desc', 'desc'] ); -export function getRejectedProposals( - data?: NodeConnection> | null -): T[] { +export function getRejectedProposals(data?: ProposalFieldsFragment[] | null) { return flow([ (data) => - getNodes(data, (p) => - p ? p?.state === ProposalState.STATE_REJECTED : false + data.filter( + (p: ProposalFieldsFragment) => p?.state === ProposalState.STATE_REJECTED ), orderByDate, ])(data); @@ -36,11 +34,20 @@ export function getRejectedProposals( export const RejectedProposalsContainer = () => { const { t } = useTranslation(); - const { data, loading, error } = useProposalsQuery(); + const { data, loading, error } = useProposalsQuery({ + pollInterval: 5000, + fetchPolicy: 'network-only', + errorPolicy: 'ignore', + variables: { + includeNewMarketProductFields: !!FLAGS.PRODUCT_PERPETUALS, + }, + }); const proposals = useMemo( () => - getRejectedProposals(data?.proposalsConnection), + getRejectedProposals( + removePaginationWrapper(data?.proposalsConnection?.edges) + ), [data] ); diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index bf63dee41..273f0710f 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -4637,7 +4637,7 @@ export type ReferralSet = { * Referral set statistics for the latest or specific epoch. * If provided the results can be filtered for a specific referee */ - stats: ReferralSetStats; + stats?: Maybe; /** Timestamp as RFC3339Nano when the referral set was updated. */ updatedAt: Scalars['Timestamp']; };