chore(2161): migrate queries (#2162)
* chore: migrate home page * chore: migrate vote buttons * chore: migrate stake linkings * chore: add missing GQL files and run generate * chore: fix broken typings * chore: migrate proposal market update query * test: fix tests * fix: remove dead type and replace with new one
This commit is contained in:
parent
7d2a3af358
commit
1abd1d0ebf
@ -1,39 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: VoteButtonsQuery
|
||||
// ====================================================
|
||||
|
||||
export interface VoteButtonsQuery_party_stakingSummary {
|
||||
__typename: "StakingSummary";
|
||||
/**
|
||||
* The stake currently available for the party
|
||||
*/
|
||||
currentStakeAvailable: string;
|
||||
}
|
||||
|
||||
export interface VoteButtonsQuery_party {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The staking information for this Party
|
||||
*/
|
||||
stakingSummary: VoteButtonsQuery_party_stakingSummary;
|
||||
}
|
||||
|
||||
export interface VoteButtonsQuery {
|
||||
/**
|
||||
* An entity that is trading on the Vega network
|
||||
*/
|
||||
party: VoteButtonsQuery_party | null;
|
||||
}
|
||||
|
||||
export interface VoteButtonsQueryVariables {
|
||||
partyId: string;
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import { format } from 'date-fns';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -16,10 +15,7 @@ import { DATE_FORMAT_LONG } from '../../../../lib/date-formats';
|
||||
import { VoteState } from './use-user-vote';
|
||||
import { ProposalMinRequirements, ProposalUserAction } from '../shared';
|
||||
import { VoteTransactionDialog } from './vote-transaction-dialog';
|
||||
import type {
|
||||
VoteButtonsQuery as VoteButtonsQueryResult,
|
||||
VoteButtonsQueryVariables,
|
||||
} from './__generated__/VoteButtonsQuery';
|
||||
import { useVoteButtonsQuery } from './__generated___/Stake';
|
||||
|
||||
interface VoteButtonsContainerProps {
|
||||
voteState: VoteState | null;
|
||||
@ -31,26 +27,12 @@ interface VoteButtonsContainerProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const VOTE_BUTTONS_QUERY = gql`
|
||||
query VoteButtonsQuery($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
stakingSummary {
|
||||
currentStakeAvailable
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
|
||||
const { pubKey } = useVegaWallet();
|
||||
const {
|
||||
appState: { decimals },
|
||||
} = useAppState();
|
||||
const { data, loading, error } = useQuery<
|
||||
VoteButtonsQueryResult,
|
||||
VoteButtonsQueryVariables
|
||||
>(VOTE_BUTTONS_QUERY, {
|
||||
const { data, loading, error } = useVoteButtonsQuery({
|
||||
variables: { partyId: pubKey || '' },
|
||||
skip: !pubKey,
|
||||
});
|
||||
|
319
apps/token/src/routes/governance/proposal/Proposal.graphql
Normal file
319
apps/token/src/routes/governance/proposal/Proposal.graphql
Normal file
@ -0,0 +1,319 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
106
apps/token/src/routes/governance/proposals/Proposals.graphql
Normal file
106
apps/token/src/routes/governance/proposals/Proposals.graphql
Normal file
@ -0,0 +1,106 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query Proposals {
|
||||
proposalsConnection {
|
||||
edges {
|
||||
node {
|
||||
...ProposalFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
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: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | 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: string, 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: string, 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: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | 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: string, 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: string, 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>;
|
@ -0,0 +1,15 @@
|
||||
query ProposalMarketsQuery {
|
||||
marketsConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: ProposalMarketsQuery
|
||||
// ====================================================
|
||||
|
||||
export interface ProposalMarketsQuery_marketsConnection_edges_node_tradableInstrument_instrument {
|
||||
__typename: "Instrument";
|
||||
/**
|
||||
* 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) (string)
|
||||
*/
|
||||
code: string;
|
||||
}
|
||||
|
||||
export interface ProposalMarketsQuery_marketsConnection_edges_node_tradableInstrument {
|
||||
__typename: "TradableInstrument";
|
||||
/**
|
||||
* An instance of, or reference to, a fully specified instrument.
|
||||
*/
|
||||
instrument: ProposalMarketsQuery_marketsConnection_edges_node_tradableInstrument_instrument;
|
||||
}
|
||||
|
||||
export interface ProposalMarketsQuery_marketsConnection_edges_node {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* An instance of, or reference to, a tradable instrument.
|
||||
*/
|
||||
tradableInstrument: ProposalMarketsQuery_marketsConnection_edges_node_tradableInstrument;
|
||||
}
|
||||
|
||||
export interface ProposalMarketsQuery_marketsConnection_edges {
|
||||
__typename: "MarketEdge";
|
||||
/**
|
||||
* The market
|
||||
*/
|
||||
node: ProposalMarketsQuery_marketsConnection_edges_node;
|
||||
}
|
||||
|
||||
export interface ProposalMarketsQuery_marketsConnection {
|
||||
__typename: "MarketConnection";
|
||||
/**
|
||||
* The markets in this connection
|
||||
*/
|
||||
edges: ProposalMarketsQuery_marketsConnection_edges[];
|
||||
}
|
||||
|
||||
export interface ProposalMarketsQuery {
|
||||
/**
|
||||
* One or more instruments that are trading on the Vega network
|
||||
*/
|
||||
marketsConnection: ProposalMarketsQuery_marketsConnection | null;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
import { Schema 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>;
|
@ -7,9 +7,9 @@ import { AppStateProvider } from '../../../../contexts/app-state/app-state-provi
|
||||
import { mockWalletContext } from '../../test-helpers/mocks';
|
||||
import { ProposeUpdateMarket } from './propose-update-market';
|
||||
import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers';
|
||||
import { MARKETS_QUERY } from './propose-update-market';
|
||||
import type { ProposalMarketsQuery } from './__generated__/ProposalMarketsQuery';
|
||||
import { NetworkParamsDocument } from '@vegaprotocol/react-helpers';
|
||||
import type { ProposalMarketsQueryQuery } from './__generated___/UpdateMarket';
|
||||
import { ProposalMarketsQueryDocument } from './__generated___/UpdateMarket';
|
||||
|
||||
const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
|
||||
request: {
|
||||
@ -67,9 +67,9 @@ const updateMarketNetworkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
|
||||
},
|
||||
};
|
||||
|
||||
const marketQueryMock: MockedResponse<ProposalMarketsQuery> = {
|
||||
const marketQueryMock: MockedResponse<ProposalMarketsQueryQuery> = {
|
||||
request: {
|
||||
query: MARKETS_QUERY,
|
||||
query: ProposalMarketsQueryDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@ -36,26 +35,8 @@ import {
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { Heading } from '../../../../components/heading';
|
||||
import { VegaWalletContainer } from '../../../../components/vega-wallet-container';
|
||||
import type { ProposalMarketsQuery } from './__generated__/ProposalMarketsQuery';
|
||||
import { ProposalUserAction } from '../../components/shared';
|
||||
|
||||
export const MARKETS_QUERY = gql`
|
||||
query ProposalMarketsQuery {
|
||||
marketsConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { useProposalMarketsQueryQuery } from './__generated___/UpdateMarket';
|
||||
|
||||
export interface UpdateMarketProposalFormFields {
|
||||
proposalVoteDeadline: string;
|
||||
@ -87,7 +68,7 @@ export const ProposeUpdateMarket = () => {
|
||||
data: marketsData,
|
||||
loading: marketsLoading,
|
||||
error: marketsError,
|
||||
} = useQuery<ProposalMarketsQuery>(MARKETS_QUERY);
|
||||
} = useProposalMarketsQueryQuery();
|
||||
const sortedMarkets = useMemo(() => {
|
||||
if (!marketsData?.marketsConnection?.edges.length) {
|
||||
return [];
|
||||
|
27
apps/token/src/routes/home/__generated__/NodeData.ts
generated
27
apps/token/src/routes/home/__generated__/NodeData.ts
generated
@ -1,27 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: NodeData
|
||||
// ====================================================
|
||||
|
||||
export interface NodeData_nodeData {
|
||||
__typename: "NodeData";
|
||||
/**
|
||||
* Total staked amount across all nodes
|
||||
*/
|
||||
stakedTotal: string;
|
||||
/**
|
||||
* The total staked field formatted by the client
|
||||
*/
|
||||
stakedTotalFormatted: string;
|
||||
}
|
||||
|
||||
export interface NodeData {
|
||||
/**
|
||||
* Returns information about nodes
|
||||
*/
|
||||
nodeData: NodeData_nodeData | null;
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import React from 'react';
|
||||
import { Trans, useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
@ -10,24 +9,15 @@ import { useDocumentTitle } from '../../hooks/use-document-title';
|
||||
import { BigNumber } from '../../lib/bignumber';
|
||||
import type { RouteChildProps } from '..';
|
||||
import Routes from '../routes';
|
||||
import type { NodeData } from './__generated__/NodeData';
|
||||
import { TokenDetails } from './token-details';
|
||||
import { Button } from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
export const TOTAL_ASSOCIATED_QUERY = gql`
|
||||
query NodeData {
|
||||
nodeData {
|
||||
stakedTotal
|
||||
stakedTotalFormatted @client
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { useNodeDataQuery } from './__generated___/NodeData';
|
||||
|
||||
const Home = ({ name }: RouteChildProps) => {
|
||||
useDocumentTitle(name);
|
||||
const { t } = useTranslation();
|
||||
const { appState } = useAppState();
|
||||
const { data } = useQuery<NodeData>(TOTAL_ASSOCIATED_QUERY);
|
||||
const { data } = useNodeDataQuery();
|
||||
const totalAssociated = React.useMemo(() => {
|
||||
return new BigNumber(data?.nodeData?.stakedTotalFormatted || '0');
|
||||
}, [data]);
|
||||
|
@ -1,3 +1,9 @@
|
||||
fragment LinkingsFields on StakeLinking {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
}
|
||||
|
||||
query PartyStakeLinkings($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
@ -5,9 +11,7 @@ query PartyStakeLinkings($partyId: ID!) {
|
||||
linkings {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
...LinkingsFields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { StakeLinkingStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: PartyStakeLinkings
|
||||
// ====================================================
|
||||
|
||||
export interface PartyStakeLinkings_party_stakingSummary_linkings_edges_node {
|
||||
__typename: "StakeLinking";
|
||||
id: string;
|
||||
/**
|
||||
* The transaction hash (ethereum) which initiated the link/unlink
|
||||
*/
|
||||
txHash: string;
|
||||
/**
|
||||
* The status of the linking
|
||||
*/
|
||||
status: StakeLinkingStatus;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkings_party_stakingSummary_linkings_edges {
|
||||
__typename: "StakeLinkingEdge";
|
||||
/**
|
||||
* The stake linking
|
||||
*/
|
||||
node: PartyStakeLinkings_party_stakingSummary_linkings_edges_node;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkings_party_stakingSummary_linkings {
|
||||
__typename: "StakesConnection";
|
||||
/**
|
||||
* List of stake links available for the connection
|
||||
*/
|
||||
edges: (PartyStakeLinkings_party_stakingSummary_linkings_edges | null)[] | null;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkings_party_stakingSummary {
|
||||
__typename: "StakingSummary";
|
||||
/**
|
||||
* The list of all stake link/unlink for the party
|
||||
*/
|
||||
linkings: PartyStakeLinkings_party_stakingSummary_linkings;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkings_party {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The staking information for this Party
|
||||
*/
|
||||
stakingSummary: PartyStakeLinkings_party_stakingSummary;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkings {
|
||||
/**
|
||||
* An entity that is trading on the Vega network
|
||||
*/
|
||||
party: PartyStakeLinkings_party | null;
|
||||
}
|
||||
|
||||
export interface PartyStakeLinkingsVariables {
|
||||
partyId: string;
|
||||
}
|
@ -3,6 +3,8 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type LinkingsFieldsFragment = { __typename?: 'StakeLinking', id: string, txHash: string, status: Types.StakeLinkingStatus };
|
||||
|
||||
export type PartyStakeLinkingsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
@ -10,7 +12,13 @@ export type PartyStakeLinkingsQueryVariables = Types.Exact<{
|
||||
|
||||
export type PartyStakeLinkingsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', linkings: { __typename?: 'StakesConnection', edges?: Array<{ __typename?: 'StakeLinkingEdge', node: { __typename?: 'StakeLinking', id: string, txHash: string, status: Types.StakeLinkingStatus } } | null> | null } } } | null };
|
||||
|
||||
|
||||
export const LinkingsFieldsFragmentDoc = gql`
|
||||
fragment LinkingsFields on StakeLinking {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
}
|
||||
`;
|
||||
export const PartyStakeLinkingsDocument = gql`
|
||||
query PartyStakeLinkings($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
@ -19,16 +27,14 @@ export const PartyStakeLinkingsDocument = gql`
|
||||
linkings {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
...LinkingsFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
${LinkingsFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __usePartyStakeLinkingsQuery__
|
||||
|
@ -14,8 +14,8 @@ import {
|
||||
TxState,
|
||||
} from '../../../hooks/transaction-reducer';
|
||||
import Routes from '../../routes';
|
||||
import type { PartyStakeLinkings_party_stakingSummary_linkings_edges_node } from './__generated__/PartyStakeLinkings';
|
||||
import { truncateMiddle } from '../../../lib/truncate-middle';
|
||||
import type { LinkingsFieldsFragment } from './__generated___/PartyStakeLinkings';
|
||||
|
||||
export const AssociateTransaction = ({
|
||||
amount,
|
||||
@ -30,7 +30,7 @@ export const AssociateTransaction = ({
|
||||
state: TransactionState;
|
||||
dispatch: React.Dispatch<TransactionAction>;
|
||||
requiredConfirmations: number;
|
||||
linking: PartyStakeLinkings_party_stakingSummary_linkings_edges_node | null;
|
||||
linking: LinkingsFieldsFragment | null;
|
||||
}) => {
|
||||
const { ETHERSCAN_URL } = useEnvironment();
|
||||
const { t } = useTranslation();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { gql, useApolloClient } from '@apollo/client';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import React from 'react';
|
||||
|
||||
@ -8,15 +8,16 @@ import { TxState } from '../../../hooks/transaction-reducer';
|
||||
import { useGetAssociationBreakdown } from '../../../hooks/use-get-association-breakdown';
|
||||
import { useRefreshBalances } from '../../../hooks/use-refresh-balances';
|
||||
import { useTransaction } from '../../../hooks/use-transaction';
|
||||
import type {
|
||||
PartyStakeLinkings,
|
||||
PartyStakeLinkingsVariables,
|
||||
PartyStakeLinkings_party_stakingSummary_linkings_edges_node,
|
||||
} from './__generated__/PartyStakeLinkings';
|
||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
||||
import { removeDecimal } from '@vegaprotocol/react-helpers';
|
||||
import { StakeLinkingStatus } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import compact from 'lodash/compact';
|
||||
import type {
|
||||
LinkingsFieldsFragment,
|
||||
PartyStakeLinkingsQuery,
|
||||
PartyStakeLinkingsQueryVariables,
|
||||
} from './__generated___/PartyStakeLinkings';
|
||||
import { PartyStakeLinkingsDocument } from './__generated___/PartyStakeLinkings';
|
||||
|
||||
export const useAddStake = (
|
||||
address: string,
|
||||
@ -68,34 +69,14 @@ export const useAddStake = (
|
||||
}, [contractAdd, stakingMethod, walletAdd]);
|
||||
};
|
||||
|
||||
const PARTY_STAKE_LINKINGS = gql`
|
||||
query PartyStakeLinkings($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
stakingSummary {
|
||||
linkings {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const usePollForStakeLinking = (
|
||||
partyId: string,
|
||||
txHash: string | null
|
||||
) => {
|
||||
const client = useApolloClient();
|
||||
const [linking, setLinking] =
|
||||
React.useState<PartyStakeLinkings_party_stakingSummary_linkings_edges_node | null>(
|
||||
null
|
||||
);
|
||||
const [linking, setLinking] = React.useState<LinkingsFieldsFragment | null>(
|
||||
null
|
||||
);
|
||||
|
||||
// Query for linkings under current connected party (vega key)
|
||||
React.useEffect(() => {
|
||||
@ -103,8 +84,8 @@ export const usePollForStakeLinking = (
|
||||
if (!txHash || !partyId) return;
|
||||
|
||||
client
|
||||
.query<PartyStakeLinkings, PartyStakeLinkingsVariables>({
|
||||
query: PARTY_STAKE_LINKINGS,
|
||||
.query<PartyStakeLinkingsQuery, PartyStakeLinkingsQueryVariables>({
|
||||
query: PartyStakeLinkingsDocument,
|
||||
variables: { partyId },
|
||||
// 'network-only' doesn't work here. no-cache just means its network only plus
|
||||
// the result is not stored in the cache
|
||||
@ -123,7 +104,7 @@ export const usePollForStakeLinking = (
|
||||
const matchingLinking = linkings?.find((l) => {
|
||||
return (
|
||||
l.txHash === txHash &&
|
||||
l.status === StakeLinkingStatus.STATUS_ACCEPTED
|
||||
l.status === Schema.StakeLinkingStatus.STATUS_ACCEPTED
|
||||
);
|
||||
});
|
||||
|
||||
|
9
libs/types/src/__generated__/globalTypes.ts
generated
9
libs/types/src/__generated__/globalTypes.ts
generated
@ -93,15 +93,6 @@ export enum ProposalState {
|
||||
STATE_WAITING_FOR_NODE_VOTE = "STATE_WAITING_FOR_NODE_VOTE",
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of the stake linking
|
||||
*/
|
||||
export enum StakeLinkingStatus {
|
||||
STATUS_ACCEPTED = "STATUS_ACCEPTED",
|
||||
STATUS_PENDING = "STATUS_PENDING",
|
||||
STATUS_REJECTED = "STATUS_REJECTED",
|
||||
}
|
||||
|
||||
export enum VoteValue {
|
||||
VALUE_NO = "VALUE_NO",
|
||||
VALUE_YES = "VALUE_YES",
|
||||
|
Loading…
Reference in New Issue
Block a user