diff --git a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx index 56b6421bb..045bec5ef 100644 --- a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx +++ b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx @@ -1,11 +1,7 @@ import { useMemo } from 'react'; import { parseISO, isValid, isAfter } from 'date-fns'; import classNames from 'classnames'; -import { - useProposalOfMarketQuery, - type ProposalOfMarketQuery, - type SingleProposal, -} from '@vegaprotocol/proposals'; +import { useProposalOfMarketQuery } from '@vegaprotocol/proposals'; import { DocsLinks } from '@vegaprotocol/environment'; import { getDateTimeFormat } from '@vegaprotocol/utils'; import * as Schema from '@vegaprotocol/types'; @@ -40,15 +36,21 @@ export const TradingModeTooltip = ({ marketTradingMode, }); - // We only fetch Proposals (and not BatchProposals) - const proposal = proposalData?.proposal as SingleProposal< - ProposalOfMarketQuery['proposal'] - >; - if (!market || !marketData) { return null; } - const enactmentDate = parseISO(proposal?.terms.enactmentDatetime); + + let enactmentDate; + const proposal = proposalData?.proposal; + + if (proposal?.__typename === 'Proposal') { + enactmentDate = parseISO(proposal.terms.enactmentDatetime); + } else if (proposal?.__typename === 'BatchProposal') { + const change = proposal.batchTerms?.changes.find( + (c) => c?.change.__typename === 'NewMarket' + ); + enactmentDate = change ? parseISO(change.enactmentDatetime) : undefined; + } const compiledGrid = !skipGrid && compileGridData(t, market, marketData, onSelect); @@ -67,14 +69,16 @@ export const TradingModeTooltip = ({ return (

- {isValid(enactmentDate) && isAfter(new Date(), enactmentDate) ? ( + {enactmentDate && + isValid(enactmentDate) && + isAfter(new Date(), enactmentDate) ? ( <> {`${Schema.MarketTradingModeMapping[marketTradingMode]}: ${t( @@ -91,7 +95,7 @@ export const TradingModeTooltip = ({ <> {isValid(enactmentDate) && ( {`${ @@ -109,10 +113,7 @@ export const TradingModeTooltip = ({ )} {DocsLinks && ( - + {t('Find out more')} )} diff --git a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql index 009fa78dd..e9165a980 100644 --- a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql +++ b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql @@ -45,6 +45,19 @@ query ProposalOfMarket($marketId: ID!) { enactmentDatetime } } + ... on BatchProposal { + id + batchTerms { + changes { + enactmentDatetime + change { + ... on NewMarket { + __typename + } + } + } + } + } } } diff --git a/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts b/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts index d4e1a5cd4..83a090536 100644 --- a/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts +++ b/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts @@ -25,7 +25,7 @@ export type ProposalOfMarketQueryVariables = Types.Exact<{ }>; -export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null }; +export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal', id?: string | null, batchTerms?: { __typename?: 'BatchProposalTerms', changes: Array<{ __typename?: 'BatchProposalTermsChange', enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } | null> } | null } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null }; export type SuccessorMarketProposalDetailsQueryVariables = Types.Exact<{ proposalId: Types.Scalars['ID']; @@ -152,6 +152,19 @@ export const ProposalOfMarketDocument = gql` enactmentDatetime } } + ... on BatchProposal { + id + batchTerms { + changes { + enactmentDatetime + change { + ... on NewMarket { + __typename + } + } + } + } + } } } `; diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index ec9c650ef..809d35f86 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -256,6 +256,8 @@ export type AggregatedLedgerEntry = { toAccountPartyId?: Maybe; /** Account type, if query was grouped by receiver account type - else null */ toAccountType?: Maybe; + /** Transfer ID associated with this aggregated ledger entry */ + transferId: Scalars['ID']; /** Type of the transfer for this ledger entry */ transferType?: Maybe; /** RFC3339Nano time from at which this ledger entries records were relevant */