chore: cleanup type gen (#2362)

* chore: remove apollo type gen and clean up types lib

* fix: format

* fix: tests

* fix: format

* fix: hammer token types til sh*t turns green

* fix: format

* fix: apparently format again

* fix: lint

* fix: build-specs

* fix: format

* chore: regen types

* chore: regenerate types again

* fix: format
This commit is contained in:
botond 2022-12-08 22:13:30 +01:00 committed by GitHub
parent e5fe6a3106
commit 2211abbd72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
307 changed files with 2334 additions and 3760 deletions

View File

@ -1,5 +1,5 @@
import type { Market } from '@vegaprotocol/market-list';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { SingleMarketFieldsFragment } from '@vegaprotocol/market-list';
export const protoCandles = [

View File

@ -1,6 +1,6 @@
import merge from 'lodash/merge';
import type { AccountsQuery } from '@vegaprotocol/accounts';
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest';
export const generateAccounts = (

View File

@ -1,6 +1,6 @@
import merge from 'lodash/merge';
import type { AssetsQuery } from '@vegaprotocol/assets';
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import type { PartialDeep } from 'type-fest';
export const generateAssets = (override?: PartialDeep<AssetsQuery>) => {

View File

@ -1,5 +1,5 @@
import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';

View File

@ -1,7 +1,7 @@
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
import type { MarketDepthQuery } from '../../../../../libs/market-depth/src/lib/__generated___/MarketDepth';
import type { MarketDepthQuery } from '../../../../../libs/market-depth/src/lib/__generated__/MarketDepth';
export const generateMarketDepth = (
override?: PartialDeep<MarketDepthQuery>

View File

@ -1,5 +1,5 @@
import type { MarketPositionsQuery } from '@vegaprotocol/deal-ticket';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
export const generateMarketPositions = (): MarketPositionsQuery => {
return {

View File

@ -1,5 +1,5 @@
import merge from 'lodash/merge';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type {
MarketsQuery,
Market,

View File

@ -1,7 +1,7 @@
import merge from 'lodash/merge';
import type { PartialDeep } from 'type-fest';
import type { OrdersQuery, OrderFieldsFragment } from '@vegaprotocol/orders';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
export const generateOrders = (
override?: PartialDeep<OrdersQuery>

View File

@ -1,7 +1,7 @@
import merge from 'lodash/merge';
import type { PartyBalanceQuery } from '@vegaprotocol/deal-ticket';
import type { PartialDeep } from 'type-fest';
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
export const generatePartyBalance = (
override?: PartialDeep<PartyBalanceQuery>

View File

@ -1,5 +1,5 @@
import type { PartyMarketDataQuery } from '@vegaprotocol/deal-ticket';
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
export const generatePartyMarketData = (): PartyMarketDataQuery => {
return {

View File

@ -1,51 +1,54 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import * as Types from '@vegaprotocol/types';
// ====================================================
// GraphQL query operation: MarketTags
// ====================================================
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type MarketTagsQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
}>;
export interface MarketTags_market_tradableInstrument_instrument_metadata {
__typename: "InstrumentMetadata";
/**
* An arbitrary list of tags to associated to associate to the Instrument (string list)
export type MarketTagsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null } } } } | null };
export const MarketTagsDocument = gql`
query MarketTags($marketId: ID!) {
market(id: $marketId) {
tradableInstrument {
instrument {
metadata {
tags
}
}
}
}
}
`;
/**
* __useMarketTagsQuery__
*
* To run a query within a React component, call `useMarketTagsQuery` and pass it any options that fit your needs.
* When your component renders, `useMarketTagsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useMarketTagsQuery({
* variables: {
* marketId: // value for 'marketId'
* },
* });
*/
tags: string[] | null;
}
export interface MarketTags_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Metadata for this instrument
*/
metadata: MarketTags_market_tradableInstrument_instrument_metadata;
}
export interface MarketTags_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: MarketTags_market_tradableInstrument_instrument;
}
export interface MarketTags_market {
__typename: "Market";
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: MarketTags_market_tradableInstrument;
}
export interface MarketTags {
/**
* An instrument that is trading on the Vega network
*/
market: MarketTags_market | null;
}
export interface MarketTagsVariables {
marketId: string;
}
export function useMarketTagsQuery(baseOptions: Apollo.QueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
}
export function useMarketTagsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
}
export type MarketTagsQueryHookResult = ReturnType<typeof useMarketTagsQuery>;
export type MarketTagsLazyQueryHookResult = ReturnType<typeof useMarketTagsLazyQuery>;
export type MarketTagsQueryResult = Apollo.QueryResult<MarketTagsQuery, MarketTagsQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,54 +0,0 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type MarketTagsQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
}>;
export type MarketTagsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null } } } } | null };
export const MarketTagsDocument = gql`
query MarketTags($marketId: ID!) {
market(id: $marketId) {
tradableInstrument {
instrument {
metadata {
tags
}
}
}
}
}
`;
/**
* __useMarketTagsQuery__
*
* To run a query within a React component, call `useMarketTagsQuery` and pass it any options that fit your needs.
* When your component renders, `useMarketTagsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useMarketTagsQuery({
* variables: {
* marketId: // value for 'marketId'
* },
* });
*/
export function useMarketTagsQuery(baseOptions: Apollo.QueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
}
export function useMarketTagsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketTagsQuery, MarketTagsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<MarketTagsQuery, MarketTagsQueryVariables>(MarketTagsDocument, options);
}
export type MarketTagsQueryHookResult = ReturnType<typeof useMarketTagsQuery>;
export type MarketTagsLazyQueryHookResult = ReturnType<typeof useMarketTagsLazyQuery>;
export type MarketTagsQueryResult = Apollo.QueryResult<MarketTagsQuery, MarketTagsQueryVariables>;

View File

@ -2,7 +2,7 @@ import React from 'react';
import { render } from '@testing-library/react';
import type { AccountFragment } from '@vegaprotocol/deal-ticket';
import { DealTicketBalance } from './deal-ticket-balance';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { MarketDealTicketAsset } from '@vegaprotocol/market-list';
const tDAI: MarketDealTicketAsset = {

View File

@ -1,6 +1,6 @@
import classNames from 'classnames';
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { AccountFragment } from '@vegaprotocol/deal-ticket';
import type { MarketDealTicket } from '@vegaprotocol/market-list';
import { useSettlementAccount } from '@vegaprotocol/deal-ticket';

View File

@ -37,7 +37,7 @@ import { DealTicketSize } from './deal-ticket-size';
import MarketNameRenderer from '../simple-market-list/simple-market-renderer';
import SideSelector, { SIDE_NAMES } from './side-selector';
import ReviewTrade from './review-trade';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { DealTicketSlippage } from './deal-ticket-slippage';
import { useOrderValidation } from './use-order-validation';
import type { MarketDealTicket } from '@vegaprotocol/market-list';

View File

@ -8,28 +8,10 @@ import classNames from 'classnames';
import { DealTicketEstimates } from '@vegaprotocol/deal-ticket';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { SIDE_NAMES } from './side-selector';
import { gql, useQuery } from '@apollo/client';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { MarketExpires } from '@vegaprotocol/market-info';
import type { MarketDealTicket } from '@vegaprotocol/market-list';
import type {
MarketTags,
MarketTagsVariables,
} from './__generated__/MarketTags';
export const MARKET_TAGS_QUERY = gql`
query MarketTags($marketId: ID!) {
market(id: $marketId) {
tradableInstrument {
instrument {
metadata {
tags
}
}
}
}
}
`;
import { useMarketTagsQuery } from './__generated__/MarketTags';
interface Props {
market: MarketDealTicket;
@ -57,12 +39,9 @@ export default ({
notionalSize,
slippage,
}: Props) => {
const { data: tagsData } = useQuery<MarketTags, MarketTagsVariables>(
MARKET_TAGS_QUERY,
{
const { data: tagsData } = useMarketTagsQuery({
variables: { marketId: market.id },
}
);
});
return (
<div className="mb-8 text-black dark:text-white" data-testid="review-trade">

View File

@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import { FormGroup } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/react-helpers';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
interface SideSelectorProps {
value: Schema.Side;

View File

@ -3,11 +3,7 @@ import { renderHook } from '@testing-library/react';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { MockedProvider } from '@apollo/client/testing';
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
import {
MarketStateMapping,
Schema as Types,
Schema,
} from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { ValidationProps } from './use-order-validation';
import { marketTranslations, useOrderValidation } from './use-order-validation';
import type { MarketDealTicket } from '@vegaprotocol/market-list';
@ -78,7 +74,7 @@ const market: MarketDealTicket = {
bestBidPrice: '1605489971',
bestOfferPrice: '1606823730',
markPrice: '1606823730',
trigger: Types.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
trigger: Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
staticMidPrice: '1606156850',
marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
marketState: Schema.MarketState.STATE_ACTIVE,
@ -245,7 +241,7 @@ describe('useOrderValidation', () => {
});
expect(result.current).toStrictEqual({
isDisabled: false,
message: `This market is ${MarketStateMapping[
message: `This market is ${Schema.MarketStateMapping[
state as Schema.MarketState
].toLowerCase()} and only accepting liquidity commitment orders`,
section: 'sec-summary',

View File

@ -3,7 +3,7 @@ import type { FieldErrors } from 'react-hook-form';
import { useMemo } from 'react';
import { t, toDecimal } from '@vegaprotocol/react-helpers';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { MarketStateMapping, Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { OrderSubmissionBody } from '@vegaprotocol/wallet';
import { Tooltip } from '@vegaprotocol/ui-toolkit';
import {
@ -39,7 +39,7 @@ export const marketTranslations = (marketState: Schema.MarketState) => {
case Schema.MarketState.STATE_TRADING_TERMINATED:
return t('terminated');
default:
return t(MarketStateMapping[marketState]).toLowerCase();
return t(Schema.MarketStateMapping[marketState]).toLowerCase();
}
};

View File

@ -12,7 +12,7 @@ import {
t,
} from '@vegaprotocol/react-helpers';
import BigNumber from 'bignumber.js';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
interface Props {
partyId: string;

View File

@ -14,20 +14,14 @@ import {
import type { OrderFieldsFragment, Order } from '@vegaprotocol/orders';
import type { OrderCancellationBody } from '@vegaprotocol/wallet';
import { isOrderActive } from '@vegaprotocol/orders';
import {
OrderRejectionReasonMapping,
OrderStatusMapping,
OrderTypeMapping,
Schema,
OrderTimeInForceMapping,
} from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import BigNumber from 'bignumber.js';
import { Button } from '@vegaprotocol/ui-toolkit';
type StatusKey = keyof typeof OrderStatusMapping;
type RejectReasonKey = keyof typeof OrderRejectionReasonMapping;
type OrderTimeKey = keyof typeof OrderTimeInForceMapping;
type StatusKey = keyof typeof Schema.OrderStatusMapping;
type RejectReasonKey = keyof typeof Schema.OrderRejectionReasonMapping;
type OrderTimeKey = keyof typeof Schema.OrderTimeInForceMapping;
interface Props {
setEditOrder: (order: Order) => void;
orderCancel: {
@ -81,7 +75,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => {
value,
}: ValueFormatterParams & {
value?: OrderFieldsFragment['type'];
}) => OrderTypeMapping[value as Schema.OrderType],
}) => Schema.OrderTypeMapping[value as Schema.OrderType],
},
{
colId: 'status',
@ -95,14 +89,14 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => {
}) => {
if (value && data && data.market) {
if (value === Schema.OrderStatus.STATUS_REJECTED) {
return `${OrderStatusMapping[value as StatusKey]}: ${
return `${Schema.OrderStatusMapping[value as StatusKey]}: ${
data.rejectionReason &&
OrderRejectionReasonMapping[
Schema.OrderRejectionReasonMapping[
data.rejectionReason as RejectReasonKey
]
}`;
}
return OrderStatusMapping[value as StatusKey] as string;
return Schema.OrderStatusMapping[value as StatusKey] as string;
}
return '-';
},
@ -176,11 +170,11 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => {
new Date(data.expiresAt)
);
return `${
OrderTimeInForceMapping[value as OrderTimeKey]
Schema.OrderTimeInForceMapping[value as OrderTimeKey]
}: ${expiry}`;
}
return OrderTimeInForceMapping[value as OrderTimeKey];
return Schema.OrderTimeInForceMapping[value as OrderTimeKey];
}
return '-';
},

View File

@ -16,7 +16,7 @@ import type {
GroupCellRendererParams,
ColDef,
} from 'ag-grid-community';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit';
import { Intent, ProgressBarCell } from '@vegaprotocol/ui-toolkit';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,6 +1,6 @@
import { t } from '@vegaprotocol/react-helpers';
import { themelite as theme } from '@vegaprotocol/tailwindcss-config';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import colors from 'tailwindcss/colors';
import type { Market } from '@vegaprotocol/market-list';
import { IS_MARKET_TRADABLE } from '../../constants';

View File

@ -9,7 +9,7 @@ import {
} from '@testing-library/react';
import { MockedProvider } from '@apollo/client/testing';
import { BrowserRouter } from 'react-router-dom';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list';
import SimpleMarketList from './simple-market-list';

View File

@ -13,7 +13,7 @@ import SimpleMarketToolbar from './simple-market-toolbar';
import { IS_MARKET_TRADABLE } from '../../constants';
import { ConsoleLiteGrid } from '../console-lite-grid';
import type { Market } from '@vegaprotocol/market-list';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { marketsWithCandlesProvider } from '@vegaprotocol/market-list';
export type MarketWithPercentChange = Market & {

View File

@ -4,7 +4,7 @@ import { InView } from 'react-intersection-observer';
import { useDataProvider, useYesterday } from '@vegaprotocol/react-helpers';
import type { Candle } from '@vegaprotocol/market-list';
import { marketCandlesProvider } from '@vegaprotocol/market-list';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
interface Props {
candles: (Candle | null)[] | null;

View File

@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import MarketNameRenderer from './simple-market-renderer';
import type { Market } from '@vegaprotocol/market-list';

View File

@ -14,7 +14,7 @@ import {
getAllByText,
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list';
import SimpleMarketToolbar from './simple-market-toolbar';
import { markets as filterData } from './mocks/market-filters.json';

View File

@ -13,7 +13,7 @@ import {
DropdownMenuItemIndicator,
Icon,
} from '@vegaprotocol/ui-toolkit';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { Market } from '@vegaprotocol/market-list';
import { HorizontalMenu } from '../horizontal-menu';
import type { HorizontalMenuItem } from '../horizontal-menu';

View File

@ -1,5 +1,5 @@
import { useMemo } from 'react';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { MarketWithCandles } from '@vegaprotocol/market-list';
import type { RouterParams } from './simple-market-list';

View File

@ -1,4 +1,4 @@
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { t } from '@vegaprotocol/react-helpers';
import type { Market } from '@vegaprotocol/market-list';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -5,7 +5,7 @@ import { MemoryRouter } from 'react-router-dom';
import AmendOrderDetails from './amend-order-details';
import { ExplorerDeterministicOrderDocument } from './__generated__/Order';
import { render } from '@testing-library/react';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { ExplorerMarketDocument } from '../links/market-link/__generated__/Market';
type Amend = components['schemas']['v1OrderAmendment'];

View File

@ -1,5 +1,5 @@
import { t } from '@vegaprotocol/react-helpers';
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
export interface DeterministicOrderDetailsProps {
id: string;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -0,0 +1,75 @@
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ExplorerNodeVoteQueryVariables = Types.Exact<{
id: Types.Scalars['ID'];
}>;
export type ExplorerNodeVoteQuery = { __typename?: 'Query', withdrawal?: { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, createdTimestamp: any, withdrawnTimestamp?: any | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, name: string, decimals: number }, party: { __typename?: 'Party', id: string } } | null, deposit?: { __typename?: 'Deposit', id: string, status: Types.DepositStatus, createdTimestamp: any, creditedTimestamp?: any | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, name: string, decimals: number }, party: { __typename?: 'Party', id: string } } | null };
export const ExplorerNodeVoteDocument = gql`
query ExplorerNodeVote($id: ID!) {
withdrawal(id: $id) {
id
status
createdTimestamp
withdrawnTimestamp
txHash
asset {
id
name
decimals
}
party {
id
}
}
deposit(id: $id) {
id
status
createdTimestamp
creditedTimestamp
txHash
asset {
id
name
decimals
}
party {
id
}
}
}
`;
/**
* __useExplorerNodeVoteQuery__
*
* To run a query within a React component, call `useExplorerNodeVoteQuery` and pass it any options that fit your needs.
* When your component renders, `useExplorerNodeVoteQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useExplorerNodeVoteQuery({
* variables: {
* id: // value for 'id'
* },
* });
*/
export function useExplorerNodeVoteQuery(baseOptions: Apollo.QueryHookOptions<ExplorerNodeVoteQuery, ExplorerNodeVoteQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExplorerNodeVoteQuery, ExplorerNodeVoteQueryVariables>(ExplorerNodeVoteDocument, options);
}
export function useExplorerNodeVoteLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerNodeVoteQuery, ExplorerNodeVoteQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExplorerNodeVoteQuery, ExplorerNodeVoteQueryVariables>(ExplorerNodeVoteDocument, options);
}
export type ExplorerNodeVoteQueryHookResult = ReturnType<typeof useExplorerNodeVoteQuery>;
export type ExplorerNodeVoteLazyQueryHookResult = ReturnType<typeof useExplorerNodeVoteLazyQuery>;
export type ExplorerNodeVoteQueryResult = Apollo.QueryResult<ExplorerNodeVoteQuery, ExplorerNodeVoteQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -13,7 +13,7 @@ import { useTxsData } from '../../../hooks/use-txs-data';
import { TxsInfiniteList } from '../../../components/txs';
import { PageHeader } from '../../../components/page-header';
import { useExplorerPartyAssetsQuery } from './__generated__/party-assets';
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
import get from 'lodash/get';
const accountTypeString: Record<Schema.AccountType, string> = {

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -11,7 +11,7 @@ import {
t,
toBigNum,
} from '@vegaprotocol/react-helpers';
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
import {
AsyncRenderer,
Icon,

View File

@ -5,7 +5,7 @@ import {
useDataProvider,
addDecimalsFormatNumber,
} from '@vegaprotocol/react-helpers';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import {
calcDayVolume,
getChange,

View File

@ -3,7 +3,7 @@ import { t } from '@vegaprotocol/react-helpers';
import { Icon } from '@vegaprotocol/ui-toolkit';
import { formatWithAsset } from '@vegaprotocol/liquidity';
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
import { HealthBar } from '../../health-bar';
import { HealthDialog } from '../../health-dialog';
import { Last24hVolume } from '../last-24h-volume';

View File

@ -1,5 +1,5 @@
import classNames from 'classnames';
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
import { t, addDecimalsFormatNumber } from '@vegaprotocol/react-helpers';
import { BigNumber } from 'bignumber.js';
import type { ReactNode } from 'react';

View File

@ -1,6 +1,6 @@
import { t } from '@vegaprotocol/react-helpers';
import { Dialog } from '@vegaprotocol/ui-toolkit';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import classNames from 'classnames';
import { HealthBar } from '../health-bar';

View File

@ -1,4 +1,4 @@
import type { Schema } from '@vegaprotocol/types';
import type * as Schema from '@vegaprotocol/types';
import { getColorForStatus } from '../../lib/utils';

View File

@ -1,11 +1,7 @@
import { Lozenge, Tooltip } from '@vegaprotocol/ui-toolkit';
import classNames from 'classnames';
import {
MarketTradingModeMapping,
AuctionTriggerMapping,
Schema,
} from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { t } from '@vegaprotocol/react-helpers';
import { Indicator } from '../indicator';
@ -28,10 +24,10 @@ export const Status = ({
trigger &&
trigger !== Schema.AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED
) {
return `${MarketTradingModeMapping[tradingMode]} - ${AuctionTriggerMapping[trigger]}`;
return `${Schema.MarketTradingModeMapping[tradingMode]} - ${Schema.AuctionTriggerMapping[trigger]}`;
}
}
return MarketTradingModeMapping[tradingMode];
return Schema.MarketTradingModeMapping[tradingMode];
};
const status = getStatus();
@ -59,15 +55,15 @@ export const Status = ({
const getTooltipDescription = (status: string) => {
let tooltipDescription = '';
switch (status) {
case MarketTradingModeMapping.TRADING_MODE_CONTINUOUS:
case Schema.MarketTradingModeMapping.TRADING_MODE_CONTINUOUS:
tooltipDescription =
'This is the standard trading mode where trades are executed whenever orders are received';
break;
case `${MarketTradingModeMapping.TRADING_MODE_MONITORING_AUCTION} - ${AuctionTriggerMapping.AUCTION_TRIGGER_LIQUIDITY}`:
case `${Schema.MarketTradingModeMapping.TRADING_MODE_MONITORING_AUCTION} - ${Schema.AuctionTriggerMapping.AUCTION_TRIGGER_LIQUIDITY}`:
tooltipDescription =
'This market is in auction until it reaches sufficient liquidity';
break;
case MarketTradingModeMapping.TRADING_MODE_OPENING_AUCTION:
case Schema.MarketTradingModeMapping.TRADING_MODE_OPENING_AUCTION:
tooltipDescription =
'This is a new market in an opening auction to determine a fair mid-price before starting continuous trading.';
break;

View File

@ -1,4 +1,4 @@
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
const marketTradingModeStyle = {
[Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS]: '#00D46E',

View File

@ -0,0 +1,92 @@
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type WalletDelegationFieldsFragment = { __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } };
export type DelegationsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID'];
}>;
export type DelegationsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, party?: { __typename?: 'Party', id: string, delegationsConnection?: { __typename?: 'DelegationsConnection', edges?: Array<{ __typename?: 'DelegationEdge', node: { __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } } } | null> | null } | null, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } } } } | null> | null } | null } | null };
export const WalletDelegationFieldsFragmentDoc = gql`
fragment WalletDelegationFields on Delegation {
amount
node {
id
name
}
epoch
}
`;
export const DelegationsDocument = gql`
query Delegations($partyId: ID!) {
epoch {
id
}
party(id: $partyId) {
id
delegationsConnection {
edges {
node {
...WalletDelegationFields
}
}
}
stakingSummary {
currentStakeAvailable
}
accountsConnection {
edges {
node {
asset {
name
id
decimals
symbol
source {
__typename
... on ERC20 {
contractAddress
}
}
}
type
balance
}
}
}
}
}
${WalletDelegationFieldsFragmentDoc}`;
/**
* __useDelegationsQuery__
*
* To run a query within a React component, call `useDelegationsQuery` and pass it any options that fit your needs.
* When your component renders, `useDelegationsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useDelegationsQuery({
* variables: {
* partyId: // value for 'partyId'
* },
* });
*/
export function useDelegationsQuery(baseOptions: Apollo.QueryHookOptions<DelegationsQuery, DelegationsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<DelegationsQuery, DelegationsQueryVariables>(DelegationsDocument, options);
}
export function useDelegationsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DelegationsQuery, DelegationsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<DelegationsQuery, DelegationsQueryVariables>(DelegationsDocument, options);
}
export type DelegationsQueryHookResult = ReturnType<typeof useDelegationsQuery>;
export type DelegationsLazyQueryHookResult = ReturnType<typeof useDelegationsLazyQuery>;
export type DelegationsQueryResult = Apollo.QueryResult<DelegationsQuery, DelegationsQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -13,7 +13,7 @@ import { useVegaWallet } from '@vegaprotocol/wallet';
import { useContracts } from '../../contexts/contracts/contracts-context';
import type { ERC20Asset } from '@vegaprotocol/assets';
import { isAssetTypeERC20 } from '@vegaprotocol/assets';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { removePaginationWrapper, toBigNum } from '@vegaprotocol/react-helpers';
import { useAppState } from '../../contexts/app-state/app-state-context';
import { addDecimal } from '@vegaprotocol/react-helpers';

View File

@ -1,25 +1,25 @@
import { ProposalState } from '@vegaprotocol/types';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import * as Schema from '@vegaprotocol/types';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
export const CurrentProposalState = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const { state } = proposal;
let className = 'text-white';
if (
state === ProposalState.STATE_DECLINED ||
state === ProposalState.STATE_FAILED ||
state === ProposalState.STATE_REJECTED
proposal?.state === Schema.ProposalState.STATE_DECLINED ||
proposal?.state === Schema.ProposalState.STATE_FAILED ||
proposal?.state === Schema.ProposalState.STATE_REJECTED
) {
className = 'text-danger';
} else if (
state === ProposalState.STATE_ENACTED ||
state === ProposalState.STATE_PASSED
proposal?.state === Schema.ProposalState.STATE_ENACTED ||
proposal?.state === Schema.ProposalState.STATE_PASSED
) {
className = 'text-white';
}
return <span className={className}>{state}</span>;
return <span className={className}>{proposal?.state}</span>;
};

View File

@ -7,7 +7,7 @@ import { NetworkParamsDocument } from '@vegaprotocol/react-helpers';
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
import { generateProposal } from '../../test-helpers/generate-proposals';
import { CurrentProposalStatus } from './current-proposal-status';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const networkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
request: {
@ -37,7 +37,11 @@ const networkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
},
};
const renderComponent = ({ proposal }: { proposal: Proposal_proposal }) => {
const renderComponent = ({
proposal,
}: {
proposal: ProposalQuery['proposal'];
}) => {
render(
<AppStateProvider>
<MockedProvider mocks={[networkParamsQueryMock]}>
@ -57,9 +61,7 @@ afterEach(() => {
});
it('Proposal open - renders will fail state if the proposal will fail', async () => {
const proposal = generateProposal();
const failedProposal: Proposal_proposal = {
...proposal,
const failedProposal = generateProposal({
votes: {
__typename: 'ProposalVotes',
yes: {
@ -77,7 +79,7 @@ it('Proposal open - renders will fail state if the proposal will fail', async ()
totalEquityLikeShareWeight: '0',
},
},
};
});
renderComponent({ proposal: failedProposal });
expect(await screen.findByText('Currently expected to')).toBeInTheDocument();
expect(await screen.findByText('fail.')).toBeInTheDocument();
@ -92,43 +94,33 @@ it('Proposal open - renders will pass state if the proposal will pass', async ()
});
it('Proposal enacted - renders vote passed and time since enactment', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_ENACTED,
terms: {
...proposal.terms,
enactmentDatetime: new Date(0).toISOString(),
},
},
});
renderComponent({ proposal });
expect(await screen.findByText('Vote passed.')).toBeInTheDocument();
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
});
it('Proposal passed - renders vote passed and time since vote closed', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_PASSED,
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
},
});
renderComponent({ proposal });
expect(await screen.findByText('Vote passed.')).toBeInTheDocument();
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
});
it('Proposal waiting for node vote - will pass - renders if the vote will pass and status', async () => {
const proposal = generateProposal();
const failedProposal: Proposal_proposal = {
...proposal,
const failedProposal = generateProposal({
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
votes: {
__typename: 'ProposalVotes',
@ -147,7 +139,7 @@ it('Proposal waiting for node vote - will pass - renders if the vote will pass
totalEquityLikeShareWeight: '0',
},
},
};
});
renderComponent({ proposal: failedProposal });
expect(
await screen.findByText('Waiting for nodes to validate asset.')
@ -157,14 +149,11 @@ it('Proposal waiting for node vote - will pass - renders if the vote will pass
});
it('Proposal waiting for node vote - will fail - renders if the vote will pass and status', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Waiting for nodes to validate asset.')
).toBeInTheDocument();
@ -173,19 +162,15 @@ it('Proposal waiting for node vote - will fail - renders if the vote will pass a
});
it('Proposal failed - renders vote failed reason and vote closed ago', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_FAILED,
errorDetails: 'foo',
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Vote closed. Failed due to:')
).toBeInTheDocument();
@ -194,20 +179,15 @@ it('Proposal failed - renders vote failed reason and vote closed ago', async ()
});
it('Proposal failed - renders rejection reason there are no error details', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_FAILED,
rejectionReason:
ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE,
rejectionReason: ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE,
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Vote closed. Failed due to:')
).toBeInTheDocument();
@ -218,18 +198,14 @@ it('Proposal failed - renders rejection reason there are no error details', asyn
});
it('Proposal failed - renders unknown reason if there are no error details or rejection reason', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_FAILED,
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Vote closed. Failed due to:')
).toBeInTheDocument();
@ -238,14 +214,9 @@ it('Proposal failed - renders unknown reason if there are no error details or re
});
it('Proposal failed - renders participation not met if participation is not met', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_FAILED,
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
votes: {
@ -265,8 +236,9 @@ it('Proposal failed - renders participation not met if participation is not met'
totalEquityLikeShareWeight: '0',
},
},
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Vote closed. Failed due to:')
).toBeInTheDocument();
@ -275,14 +247,9 @@ it('Proposal failed - renders participation not met if participation is not met'
});
it('Proposal failed - renders majority not met if majority is not met', async () => {
const proposal = generateProposal();
renderComponent({
proposal: {
...proposal,
const proposal = generateProposal({
state: ProposalState.STATE_FAILED,
terms: {
...proposal.terms,
closingDatetime: new Date(0).toISOString(),
},
votes: {
@ -302,8 +269,9 @@ it('Proposal failed - renders majority not met if majority is not met', async ()
totalEquityLikeShareWeight: '0',
},
},
},
});
renderComponent({ proposal });
expect(
await screen.findByText('Vote closed. Failed due to:')
).toBeInTheDocument();

View File

@ -4,7 +4,8 @@ import { useTranslation } from 'react-i18next';
import { ProposalState } from '@vegaprotocol/types';
import { useVoteInformation } from '../../hooks';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
export const StatusPass = ({ children }: { children: ReactNode }) => (
<span className="text-vega-green">{children}</span>
@ -44,7 +45,7 @@ const WillPass = ({
export const CurrentProposalStatus = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const { willPassByTokenVote, majorityMet, participationMet } =
useVoteInformation({
@ -53,26 +54,26 @@ export const CurrentProposalStatus = ({
const { t } = useTranslation();
const daysClosedAgo = formatDistanceToNow(
new Date(proposal.terms.closingDatetime),
new Date(proposal?.terms.closingDatetime),
{ addSuffix: true }
);
const daysEnactedAgo =
proposal.terms.enactmentDatetime &&
proposal?.terms.enactmentDatetime &&
formatDistanceToNow(new Date(proposal.terms.enactmentDatetime), {
addSuffix: true,
});
if (proposal.state === ProposalState.STATE_OPEN) {
if (proposal?.state === ProposalState.STATE_OPEN) {
return (
<WillPass willPass={willPassByTokenVote}>{t('currentlySetTo')}</WillPass>
);
}
if (
proposal.state === ProposalState.STATE_FAILED ||
proposal.state === ProposalState.STATE_DECLINED ||
proposal.state === ProposalState.STATE_REJECTED
proposal?.state === ProposalState.STATE_FAILED ||
proposal?.state === ProposalState.STATE_DECLINED ||
proposal?.state === ProposalState.STATE_REJECTED
) {
if (!participationMet) {
return (
@ -98,8 +99,8 @@ export const CurrentProposalStatus = ({
<>
<span>{t('voteFailedReason')}</span>
<StatusFail>
{proposal.errorDetails ||
proposal.rejectionReason ||
{proposal?.errorDetails ||
proposal?.rejectionReason ||
t('unknownReason')}
</StatusFail>
<span>&nbsp;{daysClosedAgo}</span>
@ -107,21 +108,21 @@ export const CurrentProposalStatus = ({
);
}
if (
proposal.state === ProposalState.STATE_ENACTED ||
proposal.state === ProposalState.STATE_PASSED
proposal?.state === ProposalState.STATE_ENACTED ||
proposal?.state === ProposalState.STATE_PASSED
) {
return (
<>
<span>{t('votePassed')}</span>
<StatusPass>
&nbsp;
{proposal.state === ProposalState.STATE_ENACTED
{proposal?.state === ProposalState.STATE_ENACTED
? t('Enacted')
: t('Passed')}
</StatusPass>
<span>
&nbsp;
{proposal.state === ProposalState.STATE_ENACTED
{proposal?.state === ProposalState.STATE_ENACTED
? daysEnactedAgo
: daysClosedAgo}
</span>
@ -129,7 +130,7 @@ export const CurrentProposalStatus = ({
);
}
if (proposal.state === ProposalState.STATE_WAITING_FOR_NODE_VOTE) {
if (proposal?.state === ProposalState.STATE_WAITING_FOR_NODE_VOTE) {
return (
<WillPass willPass={willPassByTokenVote}>
<span>{t('WaitingForNodeVote')}</span>{' '}

View File

@ -0,0 +1,98 @@
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ProposalAssetQueryVariables = Types.Exact<{
assetId: Types.Scalars['ID'];
}>;
export type ProposalAssetQuery = { __typename?: 'Query', asset?: { __typename?: 'Asset', status: Types.AssetStatus, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } | null };
export type AssetListBundleQueryVariables = Types.Exact<{
assetId: Types.Scalars['ID'];
}>;
export type AssetListBundleQuery = { __typename?: 'Query', erc20ListAssetBundle?: { __typename?: 'Erc20ListAssetBundle', assetSource: string, vegaAssetId: string, nonce: string, signatures: string } | null };
export const ProposalAssetDocument = gql`
query ProposalAsset($assetId: ID!) {
asset(id: $assetId) {
status
source {
... on ERC20 {
contractAddress
}
}
}
}
`;
/**
* __useProposalAssetQuery__
*
* To run a query within a React component, call `useProposalAssetQuery` and pass it any options that fit your needs.
* When your component renders, `useProposalAssetQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useProposalAssetQuery({
* variables: {
* assetId: // value for 'assetId'
* },
* });
*/
export function useProposalAssetQuery(baseOptions: Apollo.QueryHookOptions<ProposalAssetQuery, ProposalAssetQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ProposalAssetQuery, ProposalAssetQueryVariables>(ProposalAssetDocument, options);
}
export function useProposalAssetLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProposalAssetQuery, ProposalAssetQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ProposalAssetQuery, ProposalAssetQueryVariables>(ProposalAssetDocument, options);
}
export type ProposalAssetQueryHookResult = ReturnType<typeof useProposalAssetQuery>;
export type ProposalAssetLazyQueryHookResult = ReturnType<typeof useProposalAssetLazyQuery>;
export type ProposalAssetQueryResult = Apollo.QueryResult<ProposalAssetQuery, ProposalAssetQueryVariables>;
export const AssetListBundleDocument = gql`
query AssetListBundle($assetId: ID!) {
erc20ListAssetBundle(assetId: $assetId) {
assetSource
vegaAssetId
nonce
signatures
}
}
`;
/**
* __useAssetListBundleQuery__
*
* To run a query within a React component, call `useAssetListBundleQuery` and pass it any options that fit your needs.
* When your component renders, `useAssetListBundleQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAssetListBundleQuery({
* variables: {
* assetId: // value for 'assetId'
* },
* });
*/
export function useAssetListBundleQuery(baseOptions: Apollo.QueryHookOptions<AssetListBundleQuery, AssetListBundleQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<AssetListBundleQuery, AssetListBundleQueryVariables>(AssetListBundleDocument, options);
}
export function useAssetListBundleLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AssetListBundleQuery, AssetListBundleQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<AssetListBundleQuery, AssetListBundleQueryVariables>(AssetListBundleDocument, options);
}
export type AssetListBundleQueryHookResult = ReturnType<typeof useAssetListBundleQuery>;
export type AssetListBundleLazyQueryHookResult = ReturnType<typeof useAssetListBundleLazyQuery>;
export type AssetListBundleQueryResult = Apollo.QueryResult<AssetListBundleQuery, AssetListBundleQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -8,7 +8,7 @@ import type {
} from './__generated___/Asset';
import { AssetListBundleDocument } from './__generated___/Asset';
import { ProposalAssetDocument } from './__generated___/Asset';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import type { useWeb3React } from '@web3-react/core';
import BigNumber from 'bignumber.js';
import type { AppState } from '../../../../contexts/app-state/app-state-context';

View File

@ -1,5 +1,5 @@
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
import { Schema } from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { Button } from '@vegaprotocol/ui-toolkit';
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
import { useTranslation } from 'react-i18next';

View File

@ -16,7 +16,7 @@ it('Renders all data for table', () => {
const proposal = generateProposal();
render(<ProposalChangeTable proposal={proposal} />);
expect(screen.getByText('ID')).toBeInTheDocument();
expect(screen.getByText(proposal.id as string)).toBeInTheDocument();
expect(screen.getByText(proposal?.id as string)).toBeInTheDocument();
expect(screen.getByText('State')).toBeInTheDocument();
expect(screen.getByText('STATE_OPEN')).toBeInTheDocument();
@ -24,7 +24,7 @@ it('Renders all data for table', () => {
expect(screen.getByText('Closes on')).toBeInTheDocument();
expect(
screen.getByText(
format(new Date(proposal.terms.closingDatetime), DATE_FORMAT_DETAILED)
format(new Date(proposal?.terms.closingDatetime), DATE_FORMAT_DETAILED)
)
).toBeInTheDocument();
@ -32,23 +32,23 @@ it('Renders all data for table', () => {
expect(
screen.getByText(
format(
new Date(proposal.terms.enactmentDatetime || 0),
new Date(proposal?.terms.enactmentDatetime || 0),
DATE_FORMAT_DETAILED
)
)
).toBeInTheDocument();
expect(screen.getByText('Proposed by')).toBeInTheDocument();
expect(screen.getByText(proposal.party.id)).toBeInTheDocument();
expect(screen.getByText(proposal?.party.id ?? '')).toBeInTheDocument();
expect(screen.getByText('Proposed on')).toBeInTheDocument();
expect(
screen.getByText(format(new Date(proposal.datetime), DATE_FORMAT_DETAILED))
screen.getByText(format(new Date(proposal?.datetime), DATE_FORMAT_DETAILED))
).toBeInTheDocument();
expect(screen.getByText('Type')).toBeInTheDocument();
expect(
screen.getByText(proposal.terms.change.__typename)
screen.getByText(proposal?.terms.change.__typename ?? '')
).toBeInTheDocument();
});
@ -64,7 +64,7 @@ it('Changes data based on if data is in future or past', () => {
expect(screen.getByText('Closed on')).toBeInTheDocument();
expect(
screen.getByText(
format(new Date(proposal.terms.closingDatetime), DATE_FORMAT_DETAILED)
format(new Date(proposal?.terms.closingDatetime), DATE_FORMAT_DETAILED)
)
).toBeInTheDocument();
@ -72,7 +72,7 @@ it('Changes data based on if data is in future or past', () => {
expect(
screen.getByText(
format(
new Date(proposal.terms.enactmentDatetime || 0),
new Date(proposal?.terms.enactmentDatetime || 0),
DATE_FORMAT_DETAILED
)
)
@ -94,7 +94,7 @@ it('Does not render enactment time for freeform proposal', () => {
expect(
screen.queryByText(
format(
new Date(proposal.terms.enactmentDatetime || 0),
new Date(proposal?.terms.enactmentDatetime || 0),
DATE_FORMAT_DETAILED
)
)

View File

@ -4,56 +4,60 @@ import { useTranslation } from 'react-i18next';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
import { CurrentProposalState } from '../current-proposal-state';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
interface ProposalChangeTableProps {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}
export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
const { t } = useTranslation();
const terms = proposal.terms;
const terms = proposal?.terms;
return (
<KeyValueTable data-testid="proposal-change-table">
<KeyValueTableRow>
{t('id')}
{proposal.id}
{proposal?.id}
</KeyValueTableRow>
<KeyValueTableRow>
{t('state')}
<CurrentProposalState proposal={proposal} />
</KeyValueTableRow>
<KeyValueTableRow>
{isFuture(new Date(terms.closingDatetime))
{isFuture(new Date(terms?.closingDatetime))
? t('closesOn')
: t('closedOn')}
{format(new Date(terms.closingDatetime), DATE_FORMAT_DETAILED)}
{format(new Date(terms?.closingDatetime), DATE_FORMAT_DETAILED)}
</KeyValueTableRow>
{terms.change.__typename !== 'NewFreeform' ? (
{terms?.change.__typename !== 'NewFreeform' ? (
<KeyValueTableRow>
{isFuture(new Date(terms.enactmentDatetime || 0))
{isFuture(new Date(terms?.enactmentDatetime || 0))
? t('proposedEnactment')
: t('enactedOn')}
{format(new Date(terms.enactmentDatetime || 0), DATE_FORMAT_DETAILED)}
{format(
new Date(terms?.enactmentDatetime || 0),
DATE_FORMAT_DETAILED
)}
</KeyValueTableRow>
) : null}
<KeyValueTableRow>
{t('proposedBy')}
<span style={{ wordBreak: 'break-word' }}>{proposal.party.id}</span>
<span style={{ wordBreak: 'break-word' }}>{proposal?.party.id}</span>
</KeyValueTableRow>
<KeyValueTableRow>
{t('proposedOn')}
{format(new Date(proposal.datetime), DATE_FORMAT_DETAILED)}
{format(new Date(proposal?.datetime), DATE_FORMAT_DETAILED)}
</KeyValueTableRow>
{proposal.rejectionReason ? (
{proposal?.rejectionReason ? (
<KeyValueTableRow>
{t('rejectionReason')}
{proposal.rejectionReason}
</KeyValueTableRow>
) : null}
{proposal.errorDetails ? (
{proposal?.errorDetails ? (
<KeyValueTableRow>
{t('errorDetails')}
{proposal.errorDetails}
@ -61,7 +65,7 @@ export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
) : null}
<KeyValueTableRow>
{t('type')}
{proposal.terms.change.__typename}
{proposal?.terms.change.__typename}
</KeyValueTableRow>
</KeyValueTable>
);

View File

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { generateProposal } from '../../test-helpers/generate-proposals';
import { ProposalHeader } from './proposal-header';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const renderComponent = (proposal: Proposal_proposal) => (
const renderComponent = (proposal: ProposalQuery['proposal']) => (
<ProposalHeader proposal={proposal} />
);

View File

@ -2,28 +2,29 @@ import { useTranslation } from 'react-i18next';
import { Lozenge } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react';
import { shorten } from '@vegaprotocol/react-helpers';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
export const ProposalHeader = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const { t } = useTranslation();
const { change } = proposal.terms;
const change = proposal?.terms.change;
let details: ReactNode;
let title = proposal.rationale.title.trim();
let description = proposal.rationale.description.trim();
if (title.length === 0 && description.length > 0) {
let title = proposal?.rationale.title.trim();
let description = proposal?.rationale.description.trim();
if (title?.length === 0 && description && description.length > 0) {
title = description;
description = '';
}
const titleContent = shorten(title, 100);
const titleContent = shorten(title ?? '', 100);
switch (change.__typename) {
switch (change?.__typename) {
case 'NewMarket': {
details = (
<>
@ -51,9 +52,10 @@ export const ProposalHeader = ({
<>
{t('Symbol')}: {change.symbol}.{' '}
<Lozenge>
{change.source.__typename === 'ERC20'
? `ERC20 ${change.source.contractAddress}`
: `${t('Max faucet amount mint')}: ${
{change.source.__typename === 'ERC20' &&
`ERC20 ${change.source.contractAddress}`}
{change.source.__typename === 'BuiltinAsset' &&
`${t('Max faucet amount mint')}: ${
change.source.maxFaucetAmountMint
}`}
</Lozenge>
@ -77,7 +79,7 @@ export const ProposalHeader = ({
break;
}
case 'NewFreeform': {
details = `${t('FreeformProposal')}: ${proposal.id}`;
details = `${t('FreeformProposal')}: ${proposal?.id}`;
break;
}
case 'UpdateAsset': {

View File

@ -1,11 +1,12 @@
import { useTranslation } from 'react-i18next';
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
import type { Proposal_proposal_terms } from '../../proposal/__generated__/Proposal';
import type { PartialDeep } from 'type-fest';
import type * as Schema from '@vegaprotocol/types';
export const ProposalTermsJson = ({
terms,
}: {
terms: Proposal_proposal_terms;
terms: PartialDeep<Schema.ProposalTerms>;
}) => {
const { t } = useTranslation();
return (

View File

@ -10,11 +10,12 @@ import {
} from '@vegaprotocol/react-helpers';
import { useVoteInformation } from '../../hooks';
import { useAppState } from '../../../../contexts/app-state/app-state-context';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
import { ProposalType } from '../proposal/proposal';
interface ProposalVotesTableProps {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
proposalType: ProposalType | null;
}

View File

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import { generateProposal } from '../../test-helpers/generate-proposals';
import { Proposal } from './proposal';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
jest.mock('@vegaprotocol/react-helpers', () => ({
...jest.requireActual('@vegaprotocol/react-helpers'),
@ -40,13 +40,13 @@ jest.mock('../list-asset', () => ({
it('Renders with data-testid', async () => {
const proposal = generateProposal();
render(<Proposal proposal={proposal as Proposal_proposal} />);
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
expect(await screen.findByTestId('proposal')).toBeInTheDocument();
});
it('renders each section', async () => {
const proposal = generateProposal();
render(<Proposal proposal={proposal as Proposal_proposal} />);
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
expect(await screen.findByTestId('proposal-header')).toBeInTheDocument();
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
expect(screen.getByTestId('proposal-terms-json')).toBeInTheDocument();
@ -72,6 +72,6 @@ it('renders whitelist section if proposal is new asset and source is erc20', asy
},
},
});
render(<Proposal proposal={proposal as Proposal_proposal} />);
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
expect(screen.getByTestId('proposal-list-asset')).toBeInTheDocument();
});

View File

@ -1,7 +1,8 @@
import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
import { ProposalChangeTable } from '../proposal-change-table';
import { ProposalTermsJson } from '../proposal-terms-json';
import { ProposalVotesTable } from '../proposal-votes-table';
@ -17,7 +18,7 @@ export enum ProposalType {
PROPOSAL_FREEFORM = 'PROPOSAL_FREEFORM',
}
interface ProposalProps {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}
export const Proposal = ({ proposal }: ProposalProps) => {

View File

@ -26,10 +26,10 @@ import {
lastWeek,
nextWeek,
} from '../../test-helpers/mocks';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const renderComponent = (
proposal: Proposal_proposal,
proposal: ProposalQuery['proposal'],
mock = networkParamsQueryMock
) =>
render(

View File

@ -15,7 +15,8 @@ import {
ProposalState,
} from '@vegaprotocol/types';
import Routes from '../../../routes';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const MajorityNotReached = () => {
const { t } = useTranslation();
@ -37,18 +38,18 @@ const ParticipationNotReached = () => {
export const ProposalsListItemDetails = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const { state } = proposal;
const state = proposal?.state;
const { willPassByTokenVote, majorityMet, participationMet } =
useVoteInformation({
proposal,
});
const { t } = useTranslation();
const { voteState } = useUserVote(
proposal.id,
proposal.votes.yes.votes,
proposal.votes.no.votes
proposal?.id ?? '',
proposal?.votes.yes.votes ?? null,
proposal?.votes.no.votes ?? null
);
let proposalStatus: ReactNode;
@ -62,10 +63,10 @@ export const ProposalsListItemDetails = ({
{t('voteState_Enacted')} <Icon name={'tick'} />
</>
);
voteDetails = proposal.terms.enactmentDatetime && (
voteDetails = proposal?.terms.enactmentDatetime && (
<>
{format(
new Date(proposal.terms.enactmentDatetime),
new Date(proposal?.terms.enactmentDatetime),
DATE_FORMAT_DETAILED
)}
</>
@ -78,10 +79,10 @@ export const ProposalsListItemDetails = ({
{t('voteState_Passed')} <Icon name={'tick'} />
</>
);
voteDetails = proposal.terms.change.__typename !== 'NewFreeform' && (
voteDetails = proposal?.terms.change.__typename !== 'NewFreeform' && (
<>
{t('toEnactOn')}{' '}
{proposal.terms.enactmentDatetime &&
{proposal?.terms.enactmentDatetime &&
format(
new Date(proposal.terms.enactmentDatetime),
DATE_FORMAT_DETAILED
@ -96,10 +97,10 @@ export const ProposalsListItemDetails = ({
{t('voteState_WaitingForNodeVote')} <Icon name={'time'} />
</>
);
voteDetails = proposal.terms.change.__typename !== 'NewFreeform' && (
voteDetails = proposal?.terms.change.__typename !== 'NewFreeform' && (
<>
{t('toEnactOn')}{' '}
{proposal.terms.enactmentDatetime &&
{proposal?.terms.enactmentDatetime &&
format(
new Date(proposal.terms.enactmentDatetime),
DATE_FORMAT_DETAILED
@ -126,7 +127,7 @@ export const ProposalsListItemDetails = ({
)) || (
<>
{formatDistanceToNowStrict(
new Date(proposal.terms.closingDatetime)
new Date(proposal?.terms.closingDatetime)
)}{' '}
{t('left to vote')}
</>
@ -163,7 +164,7 @@ export const ProposalsListItemDetails = ({
<Icon name={'warning-sign'} />
</>
);
voteStatus = proposal.rejectionReason && (
voteStatus = proposal?.rejectionReason && (
<>{t(ProposalRejectionReasonMapping[proposal.rejectionReason])}</>
);
break;
@ -194,7 +195,7 @@ export const ProposalsListItemDetails = ({
{voteStatus}
</div>
)}
{proposal.id && (
{proposal?.id && (
<div className="col-start-2 row-start-2 justify-self-end">
<Link to={`${Routes.PROPOSALS}/${proposal.id}`}>
<Button data-testid="view-proposal-btn" size="sm">

View File

@ -1,9 +1,10 @@
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
import { ProposalsListItemDetails } from './proposals-list-item-details';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
interface ProposalsListItemProps {
proposal: Proposal_proposal;
proposal?: ProposalFieldsFragment | ProposalQuery['proposal'] | null;
}
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {

View File

@ -14,7 +14,7 @@ import {
lastMonth,
nextMonth,
} from '../../test-helpers/mocks';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const openProposalClosesNextMonth = generateProposal({
id: 'proposal1',
@ -58,7 +58,7 @@ const failedProposalClosedLastMonth = generateProposal({
},
});
const renderComponent = (proposals: Proposal_proposal[]) => (
const renderComponent = (proposals: ProposalQuery['proposal'][]) => (
<Router>
<MockedProvider mocks={[networkParamsQueryMock]}>
<AppStateProvider>

View File

@ -7,17 +7,18 @@ import { ProposalsListFilter } from '../proposals-list-filter';
import Routes from '../../../routes';
import { Button } from '@vegaprotocol/ui-toolkit';
import { Link } from 'react-router-dom';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import { ExternalLinks } from '@vegaprotocol/react-helpers';
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
interface ProposalsListProps {
proposals: Proposal_proposal[];
proposals: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
}
interface SortedProposalsProps {
open: Proposal_proposal[];
closed: Proposal_proposal[];
open: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
closed: Array<ProposalFieldsFragment | ProposalQuery['proposal']>;
}
export const ProposalsList = ({ proposals }: ProposalsListProps) => {
@ -26,7 +27,7 @@ export const ProposalsList = ({ proposals }: ProposalsListProps) => {
const sortedProposals = proposals.reduce(
(acc: SortedProposalsProps, proposal) => {
if (isFuture(new Date(proposal.terms.closingDatetime))) {
if (isFuture(new Date(proposal?.terms.closingDatetime))) {
acc.open.push(proposal);
} else {
acc.closed.push(proposal);
@ -39,9 +40,11 @@ export const ProposalsList = ({ proposals }: ProposalsListProps) => {
}
);
const filterPredicate = (p: Proposal_proposal) =>
p.id?.includes(filterString) ||
p.party?.id?.toString().includes(filterString);
const filterPredicate = (
p: ProposalFieldsFragment | ProposalQuery['proposal']
) =>
p?.id?.includes(filterString) ||
p?.party?.id?.toString().includes(filterString);
return (
<>
@ -83,7 +86,7 @@ export const ProposalsList = ({ proposals }: ProposalsListProps) => {
{sortedProposals.open.length > 0 ? (
<ul data-testid="open-proposals">
{sortedProposals.open.filter(filterPredicate).map((proposal) => (
<ProposalsListItem key={proposal.id} proposal={proposal} />
<ProposalsListItem key={proposal?.id} proposal={proposal} />
))}
</ul>
) : (
@ -97,7 +100,7 @@ export const ProposalsList = ({ proposals }: ProposalsListProps) => {
{sortedProposals.closed.length > 0 ? (
<ul data-testid="closed-proposals">
{sortedProposals.closed.filter(filterPredicate).map((proposal) => (
<ProposalsListItem key={proposal.id} proposal={proposal} />
<ProposalsListItem key={proposal?.id} proposal={proposal} />
))}
</ul>
) : (

View File

@ -12,7 +12,7 @@ import {
nextWeek,
lastMonth,
} from '../../test-helpers/mocks';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
const rejectedProposalClosesNextWeek = generateProposal({
id: 'rejected1',
@ -35,7 +35,7 @@ const rejectedProposalClosedLastMonth = generateProposal({
},
});
const renderComponent = (proposals: Proposal_proposal[]) => (
const renderComponent = (proposals: ProposalQuery['proposal'][]) => (
<Router>
<MockedProvider mocks={[networkParamsQueryMock]}>
<AppStateProvider>

View File

@ -3,19 +3,22 @@ import { useTranslation } from 'react-i18next';
import { Heading } from '../../../../components/heading';
import { ProposalsListItem } from '../proposals-list-item';
import { ProposalsListFilter } from '../proposals-list-filter';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
interface ProposalsListProps {
proposals: Proposal_proposal[];
proposals: Array<ProposalQuery['proposal'] | ProposalFieldsFragment>;
}
export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
const { t } = useTranslation();
const [filterString, setFilterString] = useState('');
const filterPredicate = (p: Proposal_proposal) =>
p.id?.includes(filterString) ||
p.party?.id?.toString().includes(filterString);
const filterPredicate = (
p: ProposalFieldsFragment | ProposalQuery['proposal']
) =>
p?.id?.includes(filterString) ||
p?.party?.id?.toString().includes(filterString);
return (
<>
@ -25,7 +28,7 @@ export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
{proposals.length > 0 ? (
<ul data-testid="rejected-proposals">
{proposals.filter(filterPredicate).map((proposal) => (
<ProposalsListItem key={proposal.id} proposal={proposal} />
<ProposalsListItem key={proposal?.id} proposal={proposal} />
))}
</ul>
) : (

View File

@ -0,0 +1,51 @@
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type VoteButtonsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID'];
}>;
export type VoteButtonsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } | null };
export const VoteButtonsDocument = gql`
query VoteButtons($partyId: ID!) {
party(id: $partyId) {
id
stakingSummary {
currentStakeAvailable
}
}
}
`;
/**
* __useVoteButtonsQuery__
*
* To run a query within a React component, call `useVoteButtonsQuery` and pass it any options that fit your needs.
* When your component renders, `useVoteButtonsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useVoteButtonsQuery({
* variables: {
* partyId: // value for 'partyId'
* },
* });
*/
export function useVoteButtonsQuery(baseOptions: Apollo.QueryHookOptions<VoteButtonsQuery, VoteButtonsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<VoteButtonsQuery, VoteButtonsQueryVariables>(VoteButtonsDocument, options);
}
export function useVoteButtonsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<VoteButtonsQuery, VoteButtonsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<VoteButtonsQuery, VoteButtonsQueryVariables>(VoteButtonsDocument, options);
}
export type VoteButtonsQueryHookResult = ReturnType<typeof useVoteButtonsQuery>;
export type VoteButtonsLazyQueryHookResult = ReturnType<typeof useVoteButtonsLazyQuery>;
export type VoteButtonsQueryResult = Apollo.QueryResult<VoteButtonsQuery, VoteButtonsQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -10,10 +10,11 @@ import { useUserVote } from './use-user-vote';
import { CurrentProposalStatus } from '../current-proposal-status';
import { VoteButtonsContainer } from './vote-buttons';
import { ProposalType } from '../proposal/proposal';
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
interface VoteDetailsProps {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
minVoterBalance: string | null;
spamProtectionMinTokens: string | null;
proposalType: ProposalType | null;
@ -43,13 +44,13 @@ export const VoteDetails = ({
const { t } = useTranslation();
const { voteState, voteDatetime } = useUserVote(
proposal.id,
proposal.votes.yes.votes,
proposal.votes.no.votes
proposal?.id ?? '',
proposal?.votes.yes.votes ?? null,
proposal?.votes.no.votes ?? null
);
const defaultDecimals = 2;
const daysLeft = t('daysLeft', {
daysLeft: formatDistanceToNow(new Date(proposal.terms.closingDatetime)),
daysLeft: formatDistanceToNow(new Date(proposal?.terms.closingDatetime)),
});
return (
@ -62,7 +63,7 @@ export const VoteDetails = ({
<CurrentProposalStatus proposal={proposal} />
</span>
{'. '}
{proposal.state === ProposalState.STATE_OPEN ? daysLeft : null}
{proposal?.state === ProposalState.STATE_OPEN ? daysLeft : null}
</p>
<table className="w-full mb-8">
<thead>
@ -111,7 +112,7 @@ export const VoteDetails = ({
<CurrentProposalStatus proposal={proposal} />
</span>
{'. '}
{proposal.state === ProposalState.STATE_OPEN ? daysLeft : null}
{proposal?.state === ProposalState.STATE_OPEN ? daysLeft : null}
</p>
<table className="w-full mb-4">
<thead>
@ -181,15 +182,17 @@ export const VoteDetails = ({
{pubKey ? (
<>
<h3 className="text-xl mb-2">{t('yourVote')}</h3>
{proposal && (
<VoteButtonsContainer
voteState={voteState}
voteDatetime={voteDatetime}
proposalState={proposal.state}
proposalId={proposal.id}
proposalId={proposal.id ?? ''}
minVoterBalance={minVoterBalance}
spamProtectionMinTokens={spamProtectionMinTokens}
className="flex"
/>
)}
</>
) : (
<ConnectToVega />

View File

@ -1,11 +1,12 @@
import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers';
import { BigNumber } from '../../../lib/bignumber';
import type { Proposal_proposal } from '../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../proposal/__generated__/Proposal';
export const useProposalNetworkParams = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const { params } = useNetworkParams([
NetworkParams.governance_proposal_updateMarket_requiredMajority,
@ -33,7 +34,7 @@ export const useProposalNetworkParams = ({
};
}
switch (proposal.terms.change.__typename) {
switch (proposal?.terms.change.__typename) {
case 'UpdateMarket':
return {
requiredMajority:

View File

@ -2,13 +2,14 @@ import { useMemo } from 'react';
import { useAppState } from '../../../contexts/app-state/app-state-context';
import { BigNumber } from '../../../lib/bignumber';
import { useProposalNetworkParams } from './use-proposal-network-params';
import type { Proposal_proposal } from '../proposal/__generated__/Proposal';
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
import type { ProposalQuery } from '../proposal/__generated__/Proposal';
import { addDecimal } from '@vegaprotocol/react-helpers';
export const useVoteInformation = ({
proposal,
}: {
proposal: Proposal_proposal;
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
}) => {
const {
appState: { totalSupply, decimals },
@ -54,19 +55,19 @@ export const useVoteInformation = ({
: new BigNumber(100);
const noTokens = new BigNumber(
addDecimal(proposal.votes.no.totalTokens, decimals)
addDecimal(proposal?.votes.no.totalTokens ?? 0, decimals)
);
const noEquityLikeShareWeight = !proposal.votes.no
const noEquityLikeShareWeight = !proposal?.votes.no
.totalEquityLikeShareWeight
? new BigNumber(0)
: new BigNumber(proposal.votes.no.totalEquityLikeShareWeight);
const yesTokens = new BigNumber(
addDecimal(proposal.votes.yes.totalTokens, decimals)
addDecimal(proposal?.votes.yes.totalTokens ?? 0, decimals)
);
const yesEquityLikeShareWeight = !proposal.votes.yes
const yesEquityLikeShareWeight = !proposal?.votes.yes
.totalEquityLikeShareWeight
? new BigNumber(0)
: new BigNumber(proposal.votes.yes.totalEquityLikeShareWeight);
@ -159,10 +160,10 @@ export const useVoteInformation = ({
};
}, [
decimals,
proposal.votes.no.totalEquityLikeShareWeight,
proposal.votes.no.totalTokens,
proposal.votes.yes.totalEquityLikeShareWeight,
proposal.votes.yes.totalTokens,
proposal?.votes.no.totalEquityLikeShareWeight,
proposal?.votes.no.totalTokens,
proposal?.votes.yes.totalEquityLikeShareWeight,
proposal?.votes.yes.totalTokens,
requiredMajority,
requiredMajorityLP,
requiredParticipation,
@ -187,10 +188,10 @@ export const useVoteInformation = ({
noEquityLikeShareWeight,
yesTokens,
yesEquityLikeShareWeight,
yesVotes: new BigNumber(proposal.votes.yes.totalNumber),
noVotes: new BigNumber(proposal.votes.no.totalNumber),
totalVotes: new BigNumber(proposal.votes.yes.totalNumber).plus(
proposal.votes.no.totalNumber
yesVotes: new BigNumber(proposal?.votes.yes.totalNumber ?? 0),
noVotes: new BigNumber(proposal?.votes.no.totalNumber ?? 0),
totalVotes: new BigNumber(proposal?.votes.yes.totalNumber ?? 0).plus(
proposal?.votes.no.totalNumber ?? 0
),
requiredMajorityPercentage,
requiredMajorityLPPercentage,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,10 @@
import { render, screen, waitFor } from '@testing-library/react';
import { generateProposal } from '../test-helpers/generate-proposals';
import type { Proposal_proposal } from './__generated__/Proposal';
import { ProposalContainer, PROPOSAL_QUERY } from './proposal-container';
import type { ProposalQuery } from './__generated__/Proposal';
import { ProposalContainer } from './proposal-container';
import { MockedProvider } from '@apollo/client/testing';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { ProposalDocument } from './__generated__/Proposal';
jest.mock('../components/proposal', () => ({
Proposal: () => <div data-testid="proposal" />,
@ -13,14 +14,17 @@ jest.mock('../components/proposal-not-found', () => ({
ProposalNotFound: () => <div data-testid="proposal-not-found" />,
}));
const renderComponent = (proposal: Proposal_proposal | null, id: string) => {
const renderComponent = (
proposal: ProposalQuery['proposal'] | null,
id: string
) => {
return (
<MemoryRouter initialEntries={[`/governance/${id}`]}>
<MockedProvider
mocks={[
{
request: {
query: PROPOSAL_QUERY,
query: ProposalDocument,
variables: {
proposalId: id,
},
@ -50,7 +54,7 @@ describe('Proposal container', () => {
it('Renders proposal details if proposal is found', async () => {
const proposal = generateProposal({ id: 'foo' });
render(renderComponent(proposal as Proposal_proposal, 'foo'));
render(renderComponent(proposal as ProposalQuery['proposal'], 'foo'));
await waitFor(() => {
expect(screen.getByTestId('proposal')).toBeInTheDocument();
});

View File

@ -1,343 +1,14 @@
import { gql, useQuery } from '@apollo/client';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
import { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { Proposal } from '../components/proposal';
import { ProposalNotFound } from '../components/proposal-not-found';
import type {
Proposal as ProposalQueryResult,
ProposalVariables,
} from './__generated__/Proposal';
export const PROPOSAL_QUERY = gql`
query Proposal($proposalId: ID!) {
proposal(id: $proposalId) {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
errorDetails
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
decimalPlaces
metadata
instrument {
name
code
futureProduct {
settlementAsset {
id
name
symbol
decimals
quantum
}
quoteName
settlementDataDecimals
dataSourceSpecForSettlementData {
sourceType {
... on DataSourceDefinitionInternal {
sourceType {
... on DataSourceSpecConfigurationTime {
conditions {
operator
value
}
}
}
}
... on DataSourceDefinitionExternal {
sourceType {
... on DataSourceSpecConfiguration {
signers {
signer {
... on PubKey {
key
}
... on ETHAddress {
address
}
}
}
filters {
key {
name
type
}
conditions {
operator
value
}
}
}
}
}
}
}
dataSourceSpecForTradingTermination {
sourceType {
... on DataSourceDefinitionInternal {
sourceType {
... on DataSourceSpecConfigurationTime {
conditions {
operator
value
}
}
}
}
... on DataSourceDefinitionExternal {
sourceType {
... on DataSourceSpecConfiguration {
signers {
signer {
... on PubKey {
key
}
... on ETHAddress {
address
}
}
}
filters {
key {
name
type
}
conditions {
operator
value
}
}
}
}
}
}
}
dataSourceSpecBinding {
settlementDataProperty
tradingTerminationProperty
}
}
}
}
... on UpdateMarket {
marketId
updateMarketConfiguration {
instrument {
code
product {
quoteName
dataSourceSpecForSettlementData {
sourceType {
... on DataSourceDefinitionInternal {
sourceType {
... on DataSourceSpecConfigurationTime {
conditions {
operator
value
}
}
}
}
... on DataSourceDefinitionExternal {
sourceType {
... on DataSourceSpecConfiguration {
signers {
signer {
... on PubKey {
key
}
... on ETHAddress {
address
}
}
}
filters {
key {
name
type
}
conditions {
operator
value
}
}
}
}
}
}
}
dataSourceSpecForTradingTermination {
sourceType {
... on DataSourceDefinitionInternal {
sourceType {
... on DataSourceSpecConfigurationTime {
conditions {
operator
value
}
}
}
}
... on DataSourceDefinitionExternal {
sourceType {
... on DataSourceSpecConfiguration {
signers {
signer {
... on PubKey {
key
}
... on ETHAddress {
address
}
}
}
filters {
key {
name
type
}
conditions {
operator
value
}
}
}
}
}
}
}
dataSourceSpecBinding {
settlementDataProperty
tradingTerminationProperty
}
}
}
metadata
priceMonitoringParameters {
triggers {
horizonSecs
probability
auctionExtensionSecs
}
}
liquidityMonitoringParameters {
triggeringRatio
targetStakeParameters {
timeWindow
scalingFactor
}
}
riskParameters {
... on UpdateMarketSimpleRiskModel {
simple {
factorLong
factorShort
}
}
... on UpdateMarketLogNormalRiskModel {
logNormal {
riskAversionParameter
tau
params {
r
sigma
mu
}
}
}
}
}
}
... on NewAsset {
name
symbol
decimals
quantum
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
lifetimeLimit
withdrawThreshold
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
... on UpdateAsset {
quantum
assetId
source {
... on UpdateERC20 {
lifetimeLimit
withdrawThreshold
}
}
}
}
}
votes {
yes {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
}
`;
import { useProposalQuery } from './__generated__/Proposal';
export const ProposalContainer = () => {
const params = useParams<{ proposalId: string }>();
const { data, loading, error, refetch } = useQuery<
ProposalQueryResult,
ProposalVariables
>(PROPOSAL_QUERY, {
const { data, loading, error, refetch } = useProposalQuery({
fetchPolicy: 'network-only',
errorPolicy: 'ignore',
variables: { proposalId: params.proposalId || '' },

View File

@ -34,12 +34,16 @@ fragment ProposalFields on Proposal {
__typename
name
symbol
decimals
quantum
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
withdrawThreshold
lifetimeLimit
}
}
}

View File

@ -1,354 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { ProposalState, ProposalRejectionReason, VoteValue } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: ProposalFields
// ====================================================
export interface ProposalFields_rationale {
__typename: "ProposalRationale";
/**
* Title to be used to give a short description of the proposal in lists.
* This is to be between 0 and 100 unicode characters.
* This is mandatory for all proposals.
*/
title: string;
/**
* Description to show a short title / something in case the link goes offline.
* This is to be between 0 and 20k unicode characters.
* This is mandatory for all proposals.
*/
description: string;
}
export interface ProposalFields_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface ProposalFields_terms_change_NewFreeform {
__typename: "NewFreeform";
}
export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct_settlementAsset {
__typename: "Asset";
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
}
export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct {
__typename: "FutureProduct";
/**
* Product asset
*/
settlementAsset: ProposalFields_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
}
export interface ProposalFields_terms_change_NewMarket_instrument {
__typename: "InstrumentConfiguration";
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18)
*/
code: string;
/**
* Future product specification
*/
futureProduct: ProposalFields_terms_change_NewMarket_instrument_futureProduct | null;
}
export interface ProposalFields_terms_change_NewMarket {
__typename: "NewMarket";
/**
* New market instrument configuration
*/
instrument: ProposalFields_terms_change_NewMarket_instrument;
}
export interface ProposalFields_terms_change_UpdateMarket {
__typename: "UpdateMarket";
marketId: string;
}
export interface ProposalFields_terms_change_NewAsset_source_BuiltinAsset {
__typename: "BuiltinAsset";
/**
* Maximum amount that can be requested by a party through the built-in asset faucet at a time
*/
maxFaucetAmountMint: string;
}
export interface ProposalFields_terms_change_NewAsset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type ProposalFields_terms_change_NewAsset_source = ProposalFields_terms_change_NewAsset_source_BuiltinAsset | ProposalFields_terms_change_NewAsset_source_ERC20;
export interface ProposalFields_terms_change_NewAsset {
__typename: "NewAsset";
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The source of the new asset
*/
source: ProposalFields_terms_change_NewAsset_source;
}
export interface ProposalFields_terms_change_UpdateNetworkParameter_networkParameter {
__typename: "NetworkParameter";
/**
* The name of the network parameter
*/
key: string;
/**
* The value of the network parameter
*/
value: string;
}
export interface ProposalFields_terms_change_UpdateNetworkParameter {
__typename: "UpdateNetworkParameter";
networkParameter: ProposalFields_terms_change_UpdateNetworkParameter_networkParameter;
}
export interface ProposalFields_terms_change_UpdateAsset_source {
__typename: "UpdateERC20";
/**
* The lifetime limits deposit per address
* Note: this is a temporary measure that can be changed by governance
*/
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;
}
export interface ProposalFields_terms_change_UpdateAsset {
__typename: "UpdateAsset";
/**
* The minimum economically meaningful amount of this specific asset
*/
quantum: string;
/**
* The asset to update
*/
assetId: string;
/**
* The source of the updated asset
*/
source: ProposalFields_terms_change_UpdateAsset_source;
}
export type ProposalFields_terms_change = ProposalFields_terms_change_NewFreeform | ProposalFields_terms_change_NewMarket | ProposalFields_terms_change_UpdateMarket | ProposalFields_terms_change_NewAsset | ProposalFields_terms_change_UpdateNetworkParameter | ProposalFields_terms_change_UpdateAsset;
export interface ProposalFields_terms {
__typename: "ProposalTerms";
/**
* RFC3339Nano time and date when voting closes for this proposal.
* Constrained by "minClose" and "maxClose" network parameters.
*/
closingDatetime: any;
/**
* RFC3339Nano time and date when this proposal is executed (if passed). Note that it has to be after closing date time.
* Constrained by "minEnactInSeconds" and "maxEnactInSeconds" network parameters.
* Note: Optional as free form proposals do not require it.
*/
enactmentDatetime: any | null;
/**
* Actual change being introduced by the proposal - action the proposal triggers if passed and enacted.
*/
change: ProposalFields_terms_change;
}
export interface ProposalFields_votes_yes_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface ProposalFields_votes_yes_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: ProposalFields_votes_yes_votes_party_stakingSummary;
}
export interface ProposalFields_votes_yes_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: ProposalFields_votes_yes_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: any;
}
export interface ProposalFields_votes_yes {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* Total equity like share weight for this side (only for UpdateMarket Proposals)
*/
totalEquityLikeShareWeight: string;
/**
* All votes cast for this side
*/
votes: ProposalFields_votes_yes_votes[] | null;
}
export interface ProposalFields_votes_no_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface ProposalFields_votes_no_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: ProposalFields_votes_no_votes_party_stakingSummary;
}
export interface ProposalFields_votes_no_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: ProposalFields_votes_no_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: any;
}
export interface ProposalFields_votes_no {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* Total equity like share weight for this side (only for UpdateMarket Proposals)
*/
totalEquityLikeShareWeight: string;
/**
* All votes cast for this side
*/
votes: ProposalFields_votes_no_votes[] | null;
}
export interface ProposalFields_votes {
__typename: "ProposalVotes";
/**
* Yes votes cast for this proposal
*/
yes: ProposalFields_votes_yes;
/**
* No votes cast for this proposal
*/
no: ProposalFields_votes_no;
}
export interface ProposalFields {
__typename: "Proposal";
/**
* Proposal ID that is filled by Vega once proposal reaches the network
*/
id: string | null;
/**
* Rationale behind the proposal
*/
rationale: ProposalFields_rationale;
/**
* A UUID reference to aid tracking proposals on Vega
*/
reference: string;
/**
* State of the proposal
*/
state: ProposalState;
/**
* RFC3339Nano time and date when the proposal reached Vega network
*/
datetime: any;
/**
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**
* Party that prepared the proposal
*/
party: ProposalFields_party;
/**
* Error details of the rejectionReason
*/
errorDetails: string | null;
/**
* Terms of the proposal
*/
terms: ProposalFields_terms;
/**
* Votes cast for this proposal
*/
votes: ProposalFields_votes;
}

View File

@ -1,377 +1,152 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import * as Types from '@vegaprotocol/types';
import { ProposalState, ProposalRejectionReason, VoteValue } from "@vegaprotocol/types";
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
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: '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?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } };
// ====================================================
// GraphQL query operation: Proposals
// ====================================================
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export interface Proposals_proposalsConnection_edges_node_rationale {
__typename: "ProposalRationale";
/**
* Title to be used to give a short description of the proposal in lists.
* This is to be between 0 and 100 unicode characters.
* This is mandatory for all proposals.
*/
title: string;
/**
* Description to show a short title / something in case the link goes offline.
* This is to be between 0 and 20k unicode characters.
* This is mandatory for all proposals.
*/
description: string;
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: '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?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } } } | null> | null } | null };
export const ProposalFieldsFragmentDoc = gql`
fragment ProposalFields on Proposal {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
errorDetails
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
code
futureProduct {
settlementAsset {
symbol
}
}
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
name
symbol
decimals
quantum
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
withdrawThreshold
lifetimeLimit
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
... on UpdateAsset {
quantum
assetId
source {
... on UpdateERC20 {
lifetimeLimit
withdrawThreshold
}
}
}
}
}
votes {
yes {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
export interface Proposals_proposalsConnection_edges_node_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
`;
export const ProposalsDocument = gql`
query Proposals {
proposalsConnection {
edges {
node {
...ProposalFields
}
}
}
}
${ProposalFieldsFragmentDoc}`;
export interface Proposals_proposalsConnection_edges_node_terms_change_NewFreeform {
__typename: "NewFreeform";
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct_settlementAsset {
__typename: "Asset";
/**
* The symbol of the asset (e.g: GBP)
/**
* __useProposalsQuery__
*
* To run a query within a React component, call `useProposalsQuery` and pass it any options that fit your needs.
* When your component renders, `useProposalsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useProposalsQuery({
* variables: {
* },
* });
*/
symbol: string;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct {
__typename: "FutureProduct";
/**
* Product asset
*/
settlementAsset: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument {
__typename: "InstrumentConfiguration";
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18)
*/
code: string;
/**
* Future product specification
*/
futureProduct: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct | null;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket {
__typename: "NewMarket";
/**
* New market instrument configuration
*/
instrument: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateMarket {
__typename: "UpdateMarket";
marketId: string;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source_BuiltinAsset {
__typename: "BuiltinAsset";
/**
* Maximum amount that can be requested by a party through the built-in asset faucet at a time
*/
maxFaucetAmountMint: string;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source = Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source_BuiltinAsset | Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source_ERC20;
export interface Proposals_proposalsConnection_edges_node_terms_change_NewAsset {
__typename: "NewAsset";
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The source of the new asset
*/
source: Proposals_proposalsConnection_edges_node_terms_change_NewAsset_source;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter_networkParameter {
__typename: "NetworkParameter";
/**
* The name of the network parameter
*/
key: string;
/**
* The value of the network parameter
*/
value: string;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter {
__typename: "UpdateNetworkParameter";
networkParameter: Proposals_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter_networkParameter;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateAsset_source {
__typename: "UpdateERC20";
/**
* The lifetime limits deposit per address
* Note: this is a temporary measure that can be changed by governance
*/
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;
}
export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateAsset {
__typename: "UpdateAsset";
/**
* The minimum economically meaningful amount of this specific asset
*/
quantum: string;
/**
* The asset to update
*/
assetId: string;
/**
* The source of the updated asset
*/
source: Proposals_proposalsConnection_edges_node_terms_change_UpdateAsset_source;
}
export type Proposals_proposalsConnection_edges_node_terms_change = Proposals_proposalsConnection_edges_node_terms_change_NewFreeform | Proposals_proposalsConnection_edges_node_terms_change_NewMarket | Proposals_proposalsConnection_edges_node_terms_change_UpdateMarket | Proposals_proposalsConnection_edges_node_terms_change_NewAsset | Proposals_proposalsConnection_edges_node_terms_change_UpdateNetworkParameter | Proposals_proposalsConnection_edges_node_terms_change_UpdateAsset;
export interface Proposals_proposalsConnection_edges_node_terms {
__typename: "ProposalTerms";
/**
* RFC3339Nano time and date when voting closes for this proposal.
* Constrained by "minClose" and "maxClose" network parameters.
*/
closingDatetime: any;
/**
* RFC3339Nano time and date when this proposal is executed (if passed). Note that it has to be after closing date time.
* Constrained by "minEnactInSeconds" and "maxEnactInSeconds" network parameters.
* Note: Optional as free form proposals do not require it.
*/
enactmentDatetime: any | null;
/**
* Actual change being introduced by the proposal - action the proposal triggers if passed and enacted.
*/
change: Proposals_proposalsConnection_edges_node_terms_change;
}
export interface Proposals_proposalsConnection_edges_node_votes_yes_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface Proposals_proposalsConnection_edges_node_votes_yes_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: Proposals_proposalsConnection_edges_node_votes_yes_votes_party_stakingSummary;
}
export interface Proposals_proposalsConnection_edges_node_votes_yes_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: Proposals_proposalsConnection_edges_node_votes_yes_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: any;
}
export interface Proposals_proposalsConnection_edges_node_votes_yes {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* Total equity like share weight for this side (only for UpdateMarket Proposals)
*/
totalEquityLikeShareWeight: string;
/**
* All votes cast for this side
*/
votes: Proposals_proposalsConnection_edges_node_votes_yes_votes[] | null;
}
export interface Proposals_proposalsConnection_edges_node_votes_no_votes_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
}
export interface Proposals_proposalsConnection_edges_node_votes_no_votes_party {
__typename: "Party";
/**
* Party identifier
*/
id: string;
/**
* The staking information for this Party
*/
stakingSummary: Proposals_proposalsConnection_edges_node_votes_no_votes_party_stakingSummary;
}
export interface Proposals_proposalsConnection_edges_node_votes_no_votes {
__typename: "Vote";
/**
* The vote value cast
*/
value: VoteValue;
/**
* The party casting the vote
*/
party: Proposals_proposalsConnection_edges_node_votes_no_votes_party;
/**
* RFC3339Nano time and date when the vote reached Vega network
*/
datetime: any;
}
export interface Proposals_proposalsConnection_edges_node_votes_no {
__typename: "ProposalVoteSide";
/**
* Total number of governance tokens from the votes cast for this side
*/
totalTokens: string;
/**
* Total number of votes cast for this side
*/
totalNumber: string;
/**
* Total equity like share weight for this side (only for UpdateMarket Proposals)
*/
totalEquityLikeShareWeight: string;
/**
* All votes cast for this side
*/
votes: Proposals_proposalsConnection_edges_node_votes_no_votes[] | null;
}
export interface Proposals_proposalsConnection_edges_node_votes {
__typename: "ProposalVotes";
/**
* Yes votes cast for this proposal
*/
yes: Proposals_proposalsConnection_edges_node_votes_yes;
/**
* No votes cast for this proposal
*/
no: Proposals_proposalsConnection_edges_node_votes_no;
}
export interface Proposals_proposalsConnection_edges_node {
__typename: "Proposal";
/**
* Proposal ID that is filled by Vega once proposal reaches the network
*/
id: string | null;
/**
* Rationale behind the proposal
*/
rationale: Proposals_proposalsConnection_edges_node_rationale;
/**
* A UUID reference to aid tracking proposals on Vega
*/
reference: string;
/**
* State of the proposal
*/
state: ProposalState;
/**
* RFC3339Nano time and date when the proposal reached Vega network
*/
datetime: any;
/**
* Why the proposal was rejected by the core
*/
rejectionReason: ProposalRejectionReason | null;
/**
* Party that prepared the proposal
*/
party: Proposals_proposalsConnection_edges_node_party;
/**
* Error details of the rejectionReason
*/
errorDetails: string | null;
/**
* Terms of the proposal
*/
terms: Proposals_proposalsConnection_edges_node_terms;
/**
* Votes cast for this proposal
*/
votes: Proposals_proposalsConnection_edges_node_votes;
}
export interface Proposals_proposalsConnection_edges {
__typename: "ProposalEdge";
/**
* The proposal data
*/
node: Proposals_proposalsConnection_edges_node;
}
export interface Proposals_proposalsConnection {
__typename: "ProposalsConnection";
/**
* List of proposals available for the connection
*/
edges: (Proposals_proposalsConnection_edges | null)[] | null;
}
export interface Proposals {
/**
* All governance proposals in the Vega network
*/
proposalsConnection: Proposals_proposalsConnection | null;
}
export function useProposalsQuery(baseOptions?: Apollo.QueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
}
export function useProposalsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
}
export type ProposalsQueryHookResult = ReturnType<typeof useProposalsQuery>;
export type ProposalsLazyQueryHookResult = ReturnType<typeof useProposalsLazyQuery>;
export type ProposalsQueryResult = Apollo.QueryResult<ProposalsQuery, ProposalsQueryVariables>;

View File

@ -1,148 +0,0 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
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: 'NewAsset', name: string, symbol: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } };
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
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: 'NewAsset', name: string, symbol: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: any, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } } } | null> | null } | null };
export const ProposalFieldsFragmentDoc = gql`
fragment ProposalFields on Proposal {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
errorDetails
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
code
futureProduct {
settlementAsset {
symbol
}
}
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
name
symbol
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
... on UpdateAsset {
quantum
assetId
source {
... on UpdateERC20 {
lifetimeLimit
withdrawThreshold
}
}
}
}
}
votes {
yes {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
`;
export const ProposalsDocument = gql`
query Proposals {
proposalsConnection {
edges {
node {
...ProposalFields
}
}
}
}
${ProposalFieldsFragmentDoc}`;
/**
* __useProposalsQuery__
*
* To run a query within a React component, call `useProposalsQuery` and pass it any options that fit your needs.
* When your component renders, `useProposalsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useProposalsQuery({
* variables: {
* },
* });
*/
export function useProposalsQuery(baseOptions?: Apollo.QueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
}
export function useProposalsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
}
export type ProposalsQueryHookResult = ReturnType<typeof useProposalsQuery>;
export type ProposalsLazyQueryHookResult = ReturnType<typeof useProposalsLazyQuery>;
export type ProposalsQueryResult = Apollo.QueryResult<ProposalsQuery, ProposalsQueryVariables>;

View File

@ -1,5 +1,4 @@
export {
ProposalsContainer,
ProposalsContainer as default,
PROPOSALS_QUERY,
} from './proposals-container';

View File

@ -1,4 +1,3 @@
import { gql, useQuery } from '@apollo/client';
import { getNotRejectedProposals } from '@vegaprotocol/governance';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { useMemo } from 'react';
@ -6,129 +5,24 @@ import { useTranslation } from 'react-i18next';
import { SplashLoader } from '../../../components/splash-loader';
import { ProposalsList } from '../components/proposals-list';
import type { Proposals } from './__generated__/Proposals';
export const PROPOSAL_FRAGMENT = gql`
fragment ProposalFields on Proposal {
id
rationale {
title
description
}
reference
state
datetime
rejectionReason
party {
id
}
errorDetails
terms {
closingDatetime
enactmentDatetime
change {
... on NewMarket {
instrument {
name
code
futureProduct {
settlementAsset {
symbol
}
}
}
}
... on UpdateMarket {
marketId
}
... on NewAsset {
__typename
name
symbol
source {
... on BuiltinAsset {
maxFaucetAmountMint
}
... on ERC20 {
contractAddress
}
}
}
... on UpdateNetworkParameter {
networkParameter {
key
value
}
}
... on UpdateAsset {
quantum
assetId
source {
... on UpdateERC20 {
lifetimeLimit
withdrawThreshold
}
}
}
}
}
votes {
yes {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
no {
totalTokens
totalNumber
totalEquityLikeShareWeight
votes {
value
party {
id
stakingSummary {
currentStakeAvailable
}
}
datetime
}
}
}
}
`;
export const PROPOSALS_QUERY = gql`
${PROPOSAL_FRAGMENT}
query Proposals {
proposalsConnection {
edges {
node {
...ProposalFields
}
}
}
}
`;
import { useProposalsQuery } from './__generated__/Proposals';
import type { ProposalFieldsFragment } from './__generated__/Proposals';
export const ProposalsContainer = () => {
const { t } = useTranslation();
const { data, loading, error } = useQuery<Proposals>(PROPOSALS_QUERY, {
const { data, loading, error } = useProposalsQuery({
pollInterval: 5000,
fetchPolicy: 'network-only',
errorPolicy: 'ignore',
});
const proposals = useMemo(() => getNotRejectedProposals(data), [data]);
const proposals = useMemo(
() =>
getNotRejectedProposals<ProposalFieldsFragment>(
data?.proposalsConnection
),
[data]
);
if (error) {
return (

View File

@ -5,11 +5,7 @@ import { AppStateProvider } from '../../../../contexts/app-state/app-state-provi
import { MockedProvider } from '@apollo/client/testing';
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
import { VegaWalletContext } from '@vegaprotocol/wallet';
import {
Schema,
ProposalRejectionReason,
ProposalState,
} from '@vegaprotocol/types';
import * as Schema from '@vegaprotocol/types';
import { ProposeRaw } from './propose-raw';
import { ProposalEventDocument } from '@vegaprotocol/governance';
import type { ProposalEventSubscription } from '@vegaprotocol/governance';
@ -102,9 +98,10 @@ describe('Raw proposal form', () => {
__typename: 'Proposal',
id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50',
reference: 'proposal-reference',
state: ProposalState.STATE_OPEN,
state: Schema.ProposalState.STATE_OPEN,
rejectionReason:
ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE,
Schema.ProposalRejectionReason
.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE,
errorDetails: 'error-details',
},
},

View File

@ -0,0 +1,55 @@
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type ProposalMarketsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ProposalMarketsQueryQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string } } } }> } | null };
export const ProposalMarketsQueryDocument = gql`
query ProposalMarketsQuery {
marketsConnection {
edges {
node {
id
tradableInstrument {
instrument {
name
code
}
}
}
}
}
}
`;
/**
* __useProposalMarketsQueryQuery__
*
* To run a query within a React component, call `useProposalMarketsQueryQuery` and pass it any options that fit your needs.
* When your component renders, `useProposalMarketsQueryQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useProposalMarketsQueryQuery({
* variables: {
* },
* });
*/
export function useProposalMarketsQueryQuery(baseOptions?: Apollo.QueryHookOptions<ProposalMarketsQueryQuery, ProposalMarketsQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ProposalMarketsQueryQuery, ProposalMarketsQueryQueryVariables>(ProposalMarketsQueryDocument, options);
}
export function useProposalMarketsQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProposalMarketsQueryQuery, ProposalMarketsQueryQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ProposalMarketsQueryQuery, ProposalMarketsQueryQueryVariables>(ProposalMarketsQueryDocument, options);
}
export type ProposalMarketsQueryQueryHookResult = ReturnType<typeof useProposalMarketsQueryQuery>;
export type ProposalMarketsQueryLazyQueryHookResult = ReturnType<typeof useProposalMarketsQueryLazyQuery>;
export type ProposalMarketsQueryQueryResult = Apollo.QueryResult<ProposalMarketsQueryQuery, ProposalMarketsQueryQueryVariables>;

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types';
import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';

View File

@ -1,4 +1,3 @@
import { useQuery } from '@apollo/client';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@ -6,14 +5,18 @@ import { useTranslation } from 'react-i18next';
import { SplashLoader } from '../../../components/splash-loader';
import { RejectedProposalsList } from '../components/proposals-list';
import { getRejectedProposals } from '@vegaprotocol/governance';
import { PROPOSALS_QUERY } from '../proposals';
import type { Proposals } from '../proposals/__generated__/Proposals';
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
import { useProposalsQuery } from '../proposals/__generated__/Proposals';
export const RejectedProposalsContainer = () => {
const { t } = useTranslation();
const { data, loading, error } = useQuery<Proposals>(PROPOSALS_QUERY);
const { data, loading, error } = useProposalsQuery();
const proposals = useMemo(() => getRejectedProposals(data), [data]);
const proposals = useMemo(
() =>
getRejectedProposals<ProposalFieldsFragment>(data?.proposalsConnection),
[data]
);
if (error) {
return (

Some files were not shown because too many files have changed in this diff Show More