diff --git a/apps/token/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx b/apps/token/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx index d587d56c2..d6a32f2df 100644 --- a/apps/token/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx +++ b/apps/token/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx @@ -15,7 +15,7 @@ export const ProposalFormTransactionDialog = ({ finalizedProposal, TransactionDialog, }: ProposalFormTransactionDialogProps) => { - // Render a custom complete UI if the proposal was rejected other wise + // Render a custom complete UI if the proposal was rejected otherwise // pass undefined so that the default vega transaction dialog UI gets used const completeContent = finalizedProposal?.rejectionReason ? (

{finalizedProposal.rejectionReason}

diff --git a/apps/token/src/routes/proposals/propose/raw/proposal-raw.spec.tsx b/apps/token/src/routes/proposals/propose/raw/proposal-raw.spec.tsx index fff9f21fa..240065317 100644 --- a/apps/token/src/routes/proposals/propose/raw/proposal-raw.spec.tsx +++ b/apps/token/src/routes/proposals/propose/raw/proposal-raw.spec.tsx @@ -90,22 +90,15 @@ describe('Raw proposal form', () => { }, result: { data: { - busEvents: [ - { - __typename: 'BusEvent', - type: Schema.BusEventType.Proposal, - event: { - __typename: 'Proposal', - id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50', - reference: 'proposal-reference', - state: Schema.ProposalState.STATE_OPEN, - rejectionReason: - Schema.ProposalRejectionReason - .PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE, - errorDetails: 'error-details', - }, - }, - ], + proposals: { + __typename: 'Proposal', + id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50', + reference: 'proposal-reference', + state: Schema.ProposalState.STATE_OPEN, + rejectionReason: + Schema.ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE, + errorDetails: 'error-details', + }, }, }, delay: 300, diff --git a/libs/governance/src/lib/proposals-hooks/Proposal.graphql b/libs/governance/src/lib/proposals-hooks/Proposal.graphql index d61caa3f3..8285a3f24 100644 --- a/libs/governance/src/lib/proposals-hooks/Proposal.graphql +++ b/libs/governance/src/lib/proposals-hooks/Proposal.graphql @@ -7,13 +7,8 @@ fragment ProposalEventFields on Proposal { } subscription ProposalEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Proposal]) { - type - event { - ... on Proposal { - ...ProposalEventFields - } - } + proposals(partyId: $partyId) { + ...ProposalEventFields } } diff --git a/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts b/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts index 1b6c17953..bde52882a 100644 --- a/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts +++ b/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts @@ -10,7 +10,7 @@ export type ProposalEventSubscriptionVariables = Types.Exact<{ }>; -export type ProposalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; +export type ProposalEventSubscription = { __typename?: 'Subscription', proposals: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null } }; export type UpdateNetworkParameterFieldsFragment = { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, datetime: any, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null, change: { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } } }; @@ -55,13 +55,8 @@ export const UpdateNetworkParameterFieldsFragmentDoc = gql` `; export const ProposalEventDocument = gql` subscription ProposalEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Proposal]) { - type - event { - ... on Proposal { - ...ProposalEventFields - } - } + proposals(partyId: $partyId) { + ...ProposalEventFields } } ${ProposalEventFieldsFragmentDoc}`; diff --git a/libs/governance/src/lib/proposals-hooks/use-proposal-event.ts b/libs/governance/src/lib/proposals-hooks/use-proposal-event.ts index 4c2f5051f..2c33f32a7 100644 --- a/libs/governance/src/lib/proposals-hooks/use-proposal-event.ts +++ b/libs/governance/src/lib/proposals-hooks/use-proposal-event.ts @@ -28,24 +28,15 @@ export const useProposalEvent = (transaction: VegaTxState) => { variables: { partyId }, }) .subscribe(({ data }) => { - if (!data?.busEvents?.length) { + if (!data?.proposals) { return; } - // No types available for the subscription result - const matchingProposalEvent = data.busEvents.find((e) => { - if (e.event.__typename !== 'Proposal') { - return false; - } + // typo in 'proposals' - this should be singular + const proposal = data.proposals; - return e.event.id === id; - }); - - if ( - matchingProposalEvent && - matchingProposalEvent.event.__typename === 'Proposal' - ) { - callback(matchingProposalEvent.event); + if (proposal.id === id) { + callback(proposal); subRef.current?.unsubscribe(); } }); diff --git a/libs/governance/src/lib/voting-hooks/VoteSubsciption.graphql b/libs/governance/src/lib/voting-hooks/VoteSubsciption.graphql index 0556f2314..d09b34822 100644 --- a/libs/governance/src/lib/voting-hooks/VoteSubsciption.graphql +++ b/libs/governance/src/lib/voting-hooks/VoteSubsciption.graphql @@ -1,18 +1,13 @@ -fragment VoteEventFields on Vote { +fragment VoteEventFields on ProposalVote { proposalId - value - datetime + vote { + value + datetime + } } subscription VoteEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Vote]) { - type - event { - ... on Vote { - proposalId - value - datetime - } - } + votes(partyId: $partyId) { + ...VoteEventFields } } diff --git a/libs/governance/src/lib/voting-hooks/__generated__/VoteSubsciption.ts b/libs/governance/src/lib/voting-hooks/__generated__/VoteSubsciption.ts index 725d2e16a..aea13f5f4 100644 --- a/libs/governance/src/lib/voting-hooks/__generated__/VoteSubsciption.ts +++ b/libs/governance/src/lib/voting-hooks/__generated__/VoteSubsciption.ts @@ -3,36 +3,31 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type VoteEventFieldsFragment = { __typename?: 'Vote', proposalId: string, value: Types.VoteValue, datetime: any }; +export type VoteEventFieldsFragment = { __typename?: 'ProposalVote', proposalId: string, vote: { __typename?: 'Vote', value: Types.VoteValue, datetime: any } }; export type VoteEventSubscriptionVariables = Types.Exact<{ partyId: Types.Scalars['ID']; }>; -export type VoteEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote', proposalId: string, value: Types.VoteValue, datetime: any } | { __typename?: 'Withdrawal' } }> | null }; +export type VoteEventSubscription = { __typename?: 'Subscription', votes: { __typename?: 'ProposalVote', proposalId: string, vote: { __typename?: 'Vote', value: Types.VoteValue, datetime: any } } }; export const VoteEventFieldsFragmentDoc = gql` - fragment VoteEventFields on Vote { + fragment VoteEventFields on ProposalVote { proposalId - value - datetime + vote { + value + datetime + } } `; export const VoteEventDocument = gql` subscription VoteEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Vote]) { - type - event { - ... on Vote { - proposalId - value - datetime - } - } + votes(partyId: $partyId) { + ...VoteEventFields } } - `; + ${VoteEventFieldsFragmentDoc}`; /** * __useVoteEventSubscription__ diff --git a/libs/governance/src/lib/voting-hooks/use-vote-event.ts b/libs/governance/src/lib/voting-hooks/use-vote-event.ts index 63bc970c9..591d2ddc6 100644 --- a/libs/governance/src/lib/voting-hooks/use-vote-event.ts +++ b/libs/governance/src/lib/voting-hooks/use-vote-event.ts @@ -25,23 +25,14 @@ export const useVoteEvent = (transaction: VegaTxState) => { variables: { partyId }, }) .subscribe(({ data }) => { - if (!data?.busEvents?.length) { + if (!data?.votes) { return; } - const matchingVoteEvent = data.busEvents.find((e) => { - if (e.event.__typename !== 'Vote') { - return false; - } + const vote = data.votes; - return e.event.proposalId === proposalId; - }); - - if ( - matchingVoteEvent && - matchingVoteEvent.event.__typename === 'Vote' - ) { - callback(matchingVoteEvent.event); + if (vote.proposalId === proposalId) { + callback(vote); subRef.current?.unsubscribe(); } });