chore: migrate governance types (#1834)
* chore: migrate governance types * fix: format * fix: import
This commit is contained in:
parent
da726ea439
commit
26d277d775
@ -3,11 +3,11 @@ import {
|
||||
getProposalDialogIntent,
|
||||
getProposalDialogTitle,
|
||||
} from '@vegaprotocol/governance';
|
||||
import type { ProposalEvent_busEvents_event_Proposal } from '@vegaprotocol/governance';
|
||||
import type { ProposalEventFieldsFragment } from '@vegaprotocol/governance';
|
||||
import type { DialogProps } from '@vegaprotocol/wallet';
|
||||
|
||||
interface ProposalFormTransactionDialogProps {
|
||||
finalizedProposal: ProposalEvent_busEvents_event_Proposal | null;
|
||||
finalizedProposal: ProposalEventFieldsFragment | null;
|
||||
TransactionDialog: (props: DialogProps) => JSX.Element;
|
||||
}
|
||||
|
||||
|
@ -11,14 +11,14 @@ import {
|
||||
ProposalState,
|
||||
} from '@vegaprotocol/types';
|
||||
import { ProposeRaw } from './propose-raw';
|
||||
import { PROPOSAL_EVENT_SUB } from '@vegaprotocol/governance';
|
||||
import type { ProposalEvent } from '@vegaprotocol/governance';
|
||||
import { ProposalEventDocument } from '@vegaprotocol/governance';
|
||||
import type { ProposalEventSubscription } from '@vegaprotocol/governance';
|
||||
|
||||
describe('Raw proposal form', () => {
|
||||
const pubKey = '0x123';
|
||||
const mockProposalEvent: MockedResponse<ProposalEvent> = {
|
||||
const mockProposalEvent: MockedResponse<ProposalEventSubscription> = {
|
||||
request: {
|
||||
query: PROPOSAL_EVENT_SUB,
|
||||
query: ProposalEventDocument,
|
||||
variables: {
|
||||
partyId: pubKey,
|
||||
},
|
||||
|
@ -1,13 +1,17 @@
|
||||
fragment ProposalEventFields on Proposal {
|
||||
id
|
||||
reference
|
||||
state
|
||||
rejectionReason
|
||||
errorDetails
|
||||
}
|
||||
|
||||
subscription ProposalEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Proposal]) {
|
||||
type
|
||||
event {
|
||||
... on Proposal {
|
||||
id
|
||||
reference
|
||||
state
|
||||
rejectionReason
|
||||
errorDetails
|
||||
...ProposalEventFields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ProposalEventFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null };
|
||||
|
||||
export type ProposalEventSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
@ -10,23 +12,27 @@ export type ProposalEventSubscriptionVariables = Types.Exact<{
|
||||
|
||||
export type ProposalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'Account' } | { __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 const ProposalEventFieldsFragmentDoc = gql`
|
||||
fragment ProposalEventFields on Proposal {
|
||||
id
|
||||
reference
|
||||
state
|
||||
rejectionReason
|
||||
errorDetails
|
||||
}
|
||||
`;
|
||||
export const ProposalEventDocument = gql`
|
||||
subscription ProposalEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Proposal]) {
|
||||
type
|
||||
event {
|
||||
... on Proposal {
|
||||
id
|
||||
reference
|
||||
state
|
||||
rejectionReason
|
||||
errorDetails
|
||||
...ProposalEventFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
${ProposalEventFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useProposalEventSubscription__
|
@ -1,63 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { BusEventType, ProposalState, ProposalRejectionReason } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: ProposalEvent
|
||||
// ====================================================
|
||||
|
||||
export interface ProposalEvent_busEvents_event_TimeUpdate {
|
||||
__typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "Account" | "Party" | "MarginLevels" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Deposit" | "Withdrawal" | "OracleSpec" | "LiquidityProvision" | "TransactionResult";
|
||||
}
|
||||
|
||||
export interface ProposalEvent_busEvents_event_Proposal {
|
||||
__typename: "Proposal";
|
||||
/**
|
||||
* Proposal ID that is filled by Vega once proposal reaches the network
|
||||
*/
|
||||
id: string | null;
|
||||
/**
|
||||
* A UUID reference to aid tracking proposals on Vega
|
||||
*/
|
||||
reference: string;
|
||||
/**
|
||||
* State of the proposal
|
||||
*/
|
||||
state: ProposalState;
|
||||
/**
|
||||
* Why the proposal was rejected by the core
|
||||
*/
|
||||
rejectionReason: ProposalRejectionReason | null;
|
||||
/**
|
||||
* Error details of the rejectionReason
|
||||
*/
|
||||
errorDetails: string | null;
|
||||
}
|
||||
|
||||
export type ProposalEvent_busEvents_event = ProposalEvent_busEvents_event_TimeUpdate | ProposalEvent_busEvents_event_Proposal;
|
||||
|
||||
export interface ProposalEvent_busEvents {
|
||||
__typename: "BusEvent";
|
||||
/**
|
||||
* The type of event
|
||||
*/
|
||||
type: BusEventType;
|
||||
/**
|
||||
* The payload - the wrapped event
|
||||
*/
|
||||
event: ProposalEvent_busEvents_event;
|
||||
}
|
||||
|
||||
export interface ProposalEvent {
|
||||
/**
|
||||
* Subscribe to event data from the event bus
|
||||
*/
|
||||
busEvents: ProposalEvent_busEvents[] | null;
|
||||
}
|
||||
|
||||
export interface ProposalEventVariables {
|
||||
partyId: string;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
export * from './__generated__/ProposalEvent';
|
||||
export * from './__generated__/Proposal';
|
||||
export * from './use-proposal-event';
|
||||
export * from './use-proposal-submit';
|
||||
|
@ -1,30 +1,14 @@
|
||||
import { useApolloClient, gql } from '@apollo/client';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
import { ProposalEventDocument } from './__generated__/Proposal';
|
||||
import type {
|
||||
ProposalEvent,
|
||||
ProposalEventVariables,
|
||||
ProposalEvent_busEvents_event_Proposal,
|
||||
} from './__generated__/ProposalEvent';
|
||||
ProposalEventSubscriptionVariables,
|
||||
ProposalEventSubscription,
|
||||
ProposalEventFieldsFragment,
|
||||
} from './__generated__/Proposal';
|
||||
import type { Subscription } from 'zen-observable-ts';
|
||||
import type { VegaTxState } from '@vegaprotocol/wallet';
|
||||
|
||||
export const PROPOSAL_EVENT_SUB = gql`
|
||||
subscription ProposalEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Proposal]) {
|
||||
type
|
||||
event {
|
||||
... on Proposal {
|
||||
id
|
||||
reference
|
||||
state
|
||||
rejectionReason
|
||||
errorDetails
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const useProposalEvent = (transaction: VegaTxState) => {
|
||||
const client = useApolloClient();
|
||||
const subRef = useRef<Subscription | null>(null);
|
||||
@ -33,11 +17,14 @@ export const useProposalEvent = (transaction: VegaTxState) => {
|
||||
(
|
||||
id: string,
|
||||
partyId: string,
|
||||
callback: (proposal: ProposalEvent_busEvents_event_Proposal) => void
|
||||
callback: (proposal: ProposalEventFieldsFragment) => void
|
||||
) => {
|
||||
subRef.current = client
|
||||
.subscribe<ProposalEvent, ProposalEventVariables>({
|
||||
query: PROPOSAL_EVENT_SUB,
|
||||
.subscribe<
|
||||
ProposalEventSubscription,
|
||||
ProposalEventSubscriptionVariables
|
||||
>({
|
||||
query: ProposalEventDocument,
|
||||
variables: { partyId },
|
||||
})
|
||||
.subscribe(({ data }) => {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
} from '@vegaprotocol/wallet';
|
||||
import { useProposalEvent } from './use-proposal-event';
|
||||
import type { ProposalSubmission } from '@vegaprotocol/wallet';
|
||||
import type { ProposalEvent_busEvents_event_Proposal } from './__generated__/ProposalEvent';
|
||||
import type { ProposalEventFieldsFragment } from './__generated__/Proposal';
|
||||
|
||||
export const useProposalSubmit = () => {
|
||||
const { pubKey } = useVegaWallet();
|
||||
@ -16,7 +16,7 @@ export const useProposalSubmit = () => {
|
||||
const waitForProposalEvent = useProposalEvent(transaction);
|
||||
|
||||
const [finalizedProposal, setFinalizedProposal] =
|
||||
useState<ProposalEvent_busEvents_event_Proposal | null>(null);
|
||||
useState<ProposalEventFieldsFragment | null>(null);
|
||||
|
||||
const submit = useCallback(
|
||||
async (proposal: ProposalSubmission) => {
|
||||
|
@ -2,12 +2,12 @@ import compact from 'lodash/compact';
|
||||
import filter from 'lodash/filter';
|
||||
import flow from 'lodash/flow';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import { ProposalState } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
|
||||
type Proposal = {
|
||||
__typename: 'Proposal';
|
||||
id: string | null;
|
||||
state: ProposalState;
|
||||
state: Schema.ProposalState;
|
||||
terms: {
|
||||
enactmentDatetime: string | null;
|
||||
closingDatetime: string;
|
||||
@ -46,7 +46,7 @@ export const getNotRejectedProposals = (data?: ProposalsConnection) => {
|
||||
return flow([
|
||||
compact,
|
||||
(arr: Proposal[]) =>
|
||||
filter(arr, ({ state }) => state !== ProposalState.STATE_REJECTED),
|
||||
filter(arr, ({ state }) => state !== Schema.ProposalState.STATE_REJECTED),
|
||||
orderByDate,
|
||||
])(proposals);
|
||||
};
|
||||
@ -56,7 +56,7 @@ export const getRejectedProposals = (data?: ProposalsConnection) => {
|
||||
return flow([
|
||||
compact,
|
||||
(arr: Proposal[]) =>
|
||||
filter(arr, ({ state }) => state === ProposalState.STATE_REJECTED),
|
||||
filter(arr, ({ state }) => state === Schema.ProposalState.STATE_REJECTED),
|
||||
orderByDate,
|
||||
])(proposals);
|
||||
};
|
||||
|
@ -21,6 +21,7 @@ module.exports = {
|
||||
'../../libs/deposits/**',
|
||||
'../../libs/environment/**',
|
||||
'../../libs/fills/**',
|
||||
'../../libs/governance/**',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user