Chore/1877 deprecated apis stake (#1914)

* chore: generate types

* chore: remove type policy as it is bad

* chore: migrate all usages of depreacted stake field

* chore: fix build
This commit is contained in:
Dexter Edwards 2022-11-01 09:38:02 +00:00 committed by GitHub
parent fc309e7409
commit 92be8dfabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 129 additions and 130 deletions

View File

@ -48,7 +48,7 @@ query ProposalsQuery {
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }
@ -62,7 +62,7 @@ query ProposalsQuery {
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }

View File

@ -6,7 +6,7 @@ const defaultOptions = {} as const;
export type ProposalsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>; export type ProposalsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ProposalsQueryQuery = { __typename?: 'Query', proposals?: Array<{ __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', symbol: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } }> | null }; export type ProposalsQueryQuery = { __typename?: 'Query', proposals?: Array<{ __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', symbol: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: 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, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } }> | null } } }> | null };
export const ProposalsQueryDocument = gql` export const ProposalsQueryDocument = gql`
@ -60,7 +60,7 @@ export const ProposalsQueryDocument = gql`
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }
@ -74,7 +74,7 @@ export const ProposalsQueryDocument = gql`
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }

View File

@ -9,7 +9,7 @@ query PartyAssetsQuery($partyId: ID!) {
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
accounts { accounts {

View File

@ -8,7 +8,7 @@ export type PartyAssetsQueryQueryVariables = Types.Exact<{
}>; }>;
export type PartyAssetsQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string }, accounts?: Array<{ __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 }; export type PartyAssetsQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, accounts?: Array<{ __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 };
export const PartyAssetsQueryDocument = gql` export const PartyAssetsQueryDocument = gql`
@ -23,7 +23,7 @@ export const PartyAssetsQueryDocument = gql`
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
accounts { accounts {

View File

@ -34,8 +34,8 @@ export interface PartyAssetsQuery_party_delegations {
epoch: number; epoch: number;
} }
export interface PartyAssetsQuery_party_stake { export interface PartyAssetsQuery_party_stakingSummary {
__typename: "PartyStake"; __typename: "StakingSummary";
/** /**
* The stake currently available for the party * The stake currently available for the party
*/ */
@ -106,7 +106,7 @@ export interface PartyAssetsQuery_party {
/** /**
* The staking information for this Party * The staking information for this Party
*/ */
stake: PartyAssetsQuery_party_stake; stakingSummary: PartyAssetsQuery_party_stakingSummary;
/** /**
* Collateral accounts relating to a party * Collateral accounts relating to a party
*/ */

View File

@ -40,7 +40,7 @@ const PARTY_ASSETS_QUERY = gql`
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
accounts { accounts {
@ -142,10 +142,10 @@ const Party = () => {
const staking = ( const staking = (
<section> <section>
{data?.party?.stake?.currentStakeAvailable ? ( {data?.party?.stakingSummary?.currentStakeAvailable ? (
<InfoPanel <InfoPanel
title={t('Current Stake Available')} title={t('Current Stake Available')}
id={data?.party?.stake?.currentStakeAvailable} id={data?.party?.stakingSummary?.currentStakeAvailable}
copy={false} copy={false}
/> />
) : ( ) : (

View File

@ -3,11 +3,6 @@ extend type Delegation {
amountFormatted: String! amountFormatted: String!
} }
extend type PartyStake {
"The currently available stake formatted by the client"
currentStakeAvailableFormatted: String!
}
extend type NodeData { extend type NodeData {
"The total staked field formatted by the client" "The total staked field formatted by the client"
stakedTotalFormatted: String! stakedTotalFormatted: String!

View File

@ -13,9 +13,8 @@ query Delegations($partyId: ID!) {
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
accounts { accounts {
asset { asset {

View File

@ -46,16 +46,12 @@ export interface Delegations_party_delegations {
epoch: number; epoch: number;
} }
export interface Delegations_party_stake { export interface Delegations_party_stakingSummary {
__typename: "PartyStake"; __typename: "StakingSummary";
/** /**
* The stake currently available for the party * The stake currently available for the party
*/ */
currentStakeAvailable: string; currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
} }
export interface Delegations_party_accounts_asset_source_BuiltinAsset { export interface Delegations_party_accounts_asset_source_BuiltinAsset {
@ -122,7 +118,7 @@ export interface Delegations_party {
/** /**
* The staking information for this Party * The staking information for this Party
*/ */
stake: Delegations_party_stake; stakingSummary: Delegations_party_stakingSummary;
/** /**
* Collateral accounts relating to a party * Collateral accounts relating to a party
*/ */

View File

@ -8,7 +8,7 @@ export type DelegationsQueryVariables = Types.Exact<{
}>; }>;
export type DelegationsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amountFormatted: string, amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string, currentStakeAvailableFormatted: string }, accounts?: Array<{ __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 }; export type DelegationsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amountFormatted: string, amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, accounts?: Array<{ __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 };
export const DelegationsDocument = gql` export const DelegationsDocument = gql`
@ -27,9 +27,8 @@ export const DelegationsDocument = gql`
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
accounts { accounts {
asset { asset {

View File

@ -19,6 +19,8 @@ import { useContracts } from '../../contexts/contracts/contracts-context';
import type { ERC20Asset } from '@vegaprotocol/assets'; import type { ERC20Asset } from '@vegaprotocol/assets';
import { isAssetTypeERC20 } from '@vegaprotocol/assets'; import { isAssetTypeERC20 } from '@vegaprotocol/assets';
import { AccountType } from '@vegaprotocol/types'; import { AccountType } from '@vegaprotocol/types';
import { toBigNum } from '@vegaprotocol/react-helpers';
import { useAppState } from '../../contexts/app-state/app-state-context';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal } from '@vegaprotocol/react-helpers';
const DELEGATIONS_QUERY = gql` const DELEGATIONS_QUERY = gql`
@ -37,9 +39,8 @@ const DELEGATIONS_QUERY = gql`
} }
epoch epoch
} }
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
accounts { accounts {
asset { asset {
@ -63,6 +64,10 @@ const DELEGATIONS_QUERY = gql`
export const usePollForDelegations = () => { export const usePollForDelegations = () => {
const { token: vegaToken } = useContracts(); const { token: vegaToken } = useContracts();
const {
appState: { decimals },
} = useAppState();
const { t } = useTranslation(); const { t } = useTranslation();
const { pubKey } = useVegaWallet(); const { pubKey } = useVegaWallet();
const client = useApolloClient(); const client = useApolloClient();
@ -109,8 +114,9 @@ export const usePollForDelegations = () => {
}); });
setDelegations(sortedDelegations); setDelegations(sortedDelegations);
setCurrentStakeAvailable( setCurrentStakeAvailable(
new BigNumber( toBigNum(
res.data.party?.stake.currentStakeAvailableFormatted || 0 res.data.party?.stakingSummary.currentStakeAvailable || 0,
decimals
) )
); );
const accounts = res.data.party?.accounts || []; const accounts = res.data.party?.accounts || [];
@ -231,7 +237,7 @@ export const usePollForDelegations = () => {
clearInterval(interval); clearInterval(interval);
mounted = false; mounted = false;
}; };
}, [client, pubKey, t, vegaToken.address]); }, [client, decimals, pubKey, t, vegaToken.address]);
return { delegations, currentStakeAvailable, delegatedNodes, accounts }; return { delegations, currentStakeAvailable, delegatedNodes, accounts };
}; };

View File

@ -112,29 +112,6 @@ export function createClient(base?: string) {
...createReadField('stakedTotal'), ...createReadField('stakedTotal'),
}, },
}, },
Party: {
fields: {
stake: {
merge(existing, incoming) {
return {
...existing,
...incoming,
};
},
read(stake) {
if (stake) {
return {
...stake,
currentStakeAvailableFormatted: formatUintToNumber(
stake.currentStakeAvailable
),
};
}
return stake;
},
},
},
},
Withdrawal: { Withdrawal: {
fields: { fields: {
pendingOnForeignChain: { pendingOnForeignChain: {

View File

@ -20,10 +20,6 @@ extend type NodeData {
stakedTotalFormatted: String! stakedTotalFormatted: String!
} }
extend type PartyStake {
currentStakeAvailableFormatted: String!
}
extend type Reward { extend type Reward {
amountFormatted: String! amountFormatted: String!
} }

View File

@ -69,7 +69,7 @@ fragment ProposalFields on Proposal {
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }
@ -84,7 +84,7 @@ fragment ProposalFields on Proposal {
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }

View File

@ -3,19 +3,19 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; 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, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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, stake: { __typename?: 'PartyStake', 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, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } }; export type ProposalFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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 ProposalQueryVariables = Types.Exact<{ export type ProposalQueryVariables = Types.Exact<{
proposalId: Types.Scalars['ID']; proposalId: Types.Scalars['ID'];
}>; }>;
export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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, stake: { __typename?: 'PartyStake', 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, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } } | null }; export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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 };
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>; export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type ProposalsQuery = { __typename?: 'Query', proposals?: Array<{ __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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, stake: { __typename?: 'PartyStake', 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, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } }> | null }; export type ProposalsQuery = { __typename?: 'Query', proposals?: Array<{ __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, 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', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset', quantum: 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 };
export const ProposalFieldsFragmentDoc = gql` export const ProposalFieldsFragmentDoc = gql`
fragment ProposalFields on Proposal { fragment ProposalFields on Proposal {
@ -89,7 +89,7 @@ export const ProposalFieldsFragmentDoc = gql`
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }
@ -104,7 +104,7 @@ export const ProposalFieldsFragmentDoc = gql`
value value
party { party {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
} }
} }

View File

@ -1,9 +1,8 @@
query VoteButtons($partyId: ID!) { query VoteButtons($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
} }
} }

View File

@ -7,16 +7,12 @@
// GraphQL query operation: VoteButtonsQuery // GraphQL query operation: VoteButtonsQuery
// ==================================================== // ====================================================
export interface VoteButtonsQuery_party_stake { export interface VoteButtonsQuery_party_stakingSummary {
__typename: "PartyStake"; __typename: "StakingSummary";
/** /**
* The stake currently available for the party * The stake currently available for the party
*/ */
currentStakeAvailable: string; currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
} }
export interface VoteButtonsQuery_party { export interface VoteButtonsQuery_party {
@ -28,7 +24,7 @@ export interface VoteButtonsQuery_party {
/** /**
* The staking information for this Party * The staking information for this Party
*/ */
stake: VoteButtonsQuery_party_stake; stakingSummary: VoteButtonsQuery_party_stakingSummary;
} }
export interface VoteButtonsQuery { export interface VoteButtonsQuery {

View File

@ -8,16 +8,15 @@ export type VoteButtonsQueryVariables = Types.Exact<{
}>; }>;
export type VoteButtonsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string, currentStakeAvailableFormatted: string } } | null }; export type VoteButtonsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string } } | null };
export const VoteButtonsDocument = gql` export const VoteButtonsDocument = gql`
query VoteButtons($partyId: ID!) { query VoteButtons($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
} }
} }

View File

@ -19,7 +19,7 @@ import { ProposalState, VoteValue } from '@vegaprotocol/types';
import { ProposalUserAction } from '../shared'; import { ProposalUserAction } from '../shared';
import { AsyncRenderer, Button, ButtonLink } from '@vegaprotocol/ui-toolkit'; import { AsyncRenderer, Button, ButtonLink } from '@vegaprotocol/ui-toolkit';
import { ProposalMinRequirements } from '../shared'; import { ProposalMinRequirements } from '../shared';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal, toBigNum } from '@vegaprotocol/react-helpers';
interface VoteButtonsContainerProps { interface VoteButtonsContainerProps {
voteState: VoteState | null; voteState: VoteState | null;
@ -35,9 +35,8 @@ export const VOTE_BUTTONS_QUERY = gql`
query VoteButtonsQuery($partyId: ID!) { query VoteButtonsQuery($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
} }
} }
@ -45,6 +44,9 @@ export const VOTE_BUTTONS_QUERY = gql`
export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => { export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
const { pubKey } = useVegaWallet(); const { pubKey } = useVegaWallet();
const {
appState: { decimals },
} = useAppState();
const { data, loading, error } = useQuery< const { data, loading, error } = useQuery<
VoteButtonsQueryResult, VoteButtonsQueryResult,
VoteButtonsQueryVariables VoteButtonsQueryVariables
@ -57,9 +59,10 @@ export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
<AsyncRenderer loading={loading} error={error} data={data}> <AsyncRenderer loading={loading} error={error} data={data}>
<VoteButtons <VoteButtons
{...props} {...props}
currentStakeAvailable={ currentStakeAvailable={toBigNum(
new BigNumber(data?.party?.stake.currentStakeAvailableFormatted || 0) data?.party?.stakingSummary.currentStakeAvailable || 0,
} decimals
)}
/> />
</AsyncRenderer> </AsyncRenderer>
); );

View File

@ -1,11 +1,15 @@
query PartyStakeLinkings($partyId: ID!) { query PartyStakeLinkings($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
linkings { linkings {
id edges {
txHash node {
status id
txHash
status
}
}
} }
} }
} }

View File

@ -9,7 +9,7 @@ import { StakeLinkingStatus } from "@vegaprotocol/types";
// GraphQL query operation: PartyStakeLinkings // GraphQL query operation: PartyStakeLinkings
// ==================================================== // ====================================================
export interface PartyStakeLinkings_party_stake_linkings { export interface PartyStakeLinkings_party_stakingSummary_linkings_edges_node {
__typename: "StakeLinking"; __typename: "StakeLinking";
id: string; id: string;
/** /**
@ -22,12 +22,28 @@ export interface PartyStakeLinkings_party_stake_linkings {
status: StakeLinkingStatus; status: StakeLinkingStatus;
} }
export interface PartyStakeLinkings_party_stake { export interface PartyStakeLinkings_party_stakingSummary_linkings_edges {
__typename: "PartyStake"; __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 * The list of all stake link/unlink for the party
*/ */
linkings: PartyStakeLinkings_party_stake_linkings[] | null; linkings: PartyStakeLinkings_party_stakingSummary_linkings;
} }
export interface PartyStakeLinkings_party { export interface PartyStakeLinkings_party {
@ -39,7 +55,7 @@ export interface PartyStakeLinkings_party {
/** /**
* The staking information for this Party * The staking information for this Party
*/ */
stake: PartyStakeLinkings_party_stake; stakingSummary: PartyStakeLinkings_party_stakingSummary;
} }
export interface PartyStakeLinkings { export interface PartyStakeLinkings {

View File

@ -8,18 +8,22 @@ export type PartyStakeLinkingsQueryVariables = Types.Exact<{
}>; }>;
export type PartyStakeLinkingsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', linkings?: Array<{ __typename?: 'StakeLinking', id: string, txHash: string, status: Types.StakeLinkingStatus }> | null } } | null }; 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 PartyStakeLinkingsDocument = gql` export const PartyStakeLinkingsDocument = gql`
query PartyStakeLinkings($partyId: ID!) { query PartyStakeLinkings($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
linkings { linkings {
id edges {
txHash node {
status id
txHash
status
}
}
} }
} }
} }

View File

@ -14,7 +14,7 @@ import {
TxState, TxState,
} from '../../../hooks/transaction-reducer'; } from '../../../hooks/transaction-reducer';
import Routes from '../../routes'; import Routes from '../../routes';
import type { PartyStakeLinkings_party_stake_linkings } from './__generated__/PartyStakeLinkings'; import type { PartyStakeLinkings_party_stakingSummary_linkings_edges_node } from './__generated__/PartyStakeLinkings';
import { truncateMiddle } from '../../../lib/truncate-middle'; import { truncateMiddle } from '../../../lib/truncate-middle';
export const AssociateTransaction = ({ export const AssociateTransaction = ({
@ -30,7 +30,7 @@ export const AssociateTransaction = ({
state: TransactionState; state: TransactionState;
dispatch: React.Dispatch<TransactionAction>; dispatch: React.Dispatch<TransactionAction>;
requiredConfirmations: number; requiredConfirmations: number;
linking: PartyStakeLinkings_party_stake_linkings | null; linking: PartyStakeLinkings_party_stakingSummary_linkings_edges_node | null;
}) => { }) => {
const { ETHERSCAN_URL } = useEnvironment(); const { ETHERSCAN_URL } = useEnvironment();
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -10,12 +10,13 @@ import { useRefreshBalances } from '../../../hooks/use-refresh-balances';
import { useTransaction } from '../../../hooks/use-transaction'; import { useTransaction } from '../../../hooks/use-transaction';
import type { import type {
PartyStakeLinkings, PartyStakeLinkings,
PartyStakeLinkings_party_stake_linkings,
PartyStakeLinkingsVariables, PartyStakeLinkingsVariables,
PartyStakeLinkings_party_stakingSummary_linkings_edges_node,
} from './__generated__/PartyStakeLinkings'; } from './__generated__/PartyStakeLinkings';
import { useAppState } from '../../../contexts/app-state/app-state-context'; import { useAppState } from '../../../contexts/app-state/app-state-context';
import { removeDecimal } from '@vegaprotocol/react-helpers'; import { removeDecimal } from '@vegaprotocol/react-helpers';
import { StakeLinkingStatus } from '@vegaprotocol/types'; import { StakeLinkingStatus } from '@vegaprotocol/types';
import compact from 'lodash/compact';
export const useAddStake = ( export const useAddStake = (
address: string, address: string,
@ -71,11 +72,15 @@ const PARTY_STAKE_LINKINGS = gql`
query PartyStakeLinkings($partyId: ID!) { query PartyStakeLinkings($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
linkings { linkings {
id edges {
txHash node {
status id
txHash
status
}
}
} }
} }
} }
@ -88,7 +93,9 @@ export const usePollForStakeLinking = (
) => { ) => {
const client = useApolloClient(); const client = useApolloClient();
const [linking, setLinking] = const [linking, setLinking] =
React.useState<PartyStakeLinkings_party_stake_linkings | null>(null); React.useState<PartyStakeLinkings_party_stakingSummary_linkings_edges_node | null>(
null
);
// Query for linkings under current connected party (vega key) // Query for linkings under current connected party (vega key)
React.useEffect(() => { React.useEffect(() => {
@ -104,7 +111,12 @@ export const usePollForStakeLinking = (
fetchPolicy: 'no-cache', fetchPolicy: 'no-cache',
}) })
.then((res) => { .then((res) => {
const linkings = res.data?.party?.stake.linkings; const linkings =
compact(
res.data?.party?.stakingSummary.linkings.edges?.map(
(e) => e?.node
)
) || [];
if (!linkings?.length) return; if (!linkings?.length) return;

View File

@ -1,9 +1,8 @@
query Staking($partyId: ID!) { query Staking($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
delegations { delegations {
amount amount

View File

@ -9,16 +9,12 @@ import { NodeStatus } from "@vegaprotocol/types";
// GraphQL query operation: Staking // GraphQL query operation: Staking
// ==================================================== // ====================================================
export interface Staking_party_stake { export interface Staking_party_stakingSummary {
__typename: "PartyStake"; __typename: "StakingSummary";
/** /**
* The stake currently available for the party * The stake currently available for the party
*/ */
currentStakeAvailable: string; currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
} }
export interface Staking_party_delegations_node { export interface Staking_party_delegations_node {
@ -58,7 +54,7 @@ export interface Staking_party {
/** /**
* The staking information for this Party * The staking information for this Party
*/ */
stake: Staking_party_stake; stakingSummary: Staking_party_stakingSummary;
delegations: Staking_party_delegations[] | null; delegations: Staking_party_delegations[] | null;
} }

View File

@ -8,16 +8,15 @@ export type StakingQueryVariables = Types.Exact<{
}>; }>;
export type StakingQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string, currentStakeAvailableFormatted: string }, delegations?: Array<{ __typename?: 'Delegation', amount: string, amountFormatted: string, epoch: number, node: { __typename?: 'Node', id: string } }> | null } | null, epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: string | null, end?: string | null, expiry?: string | null } }, nodes?: Array<{ __typename?: 'Node', id: string, name: string, pubkey: string, infoUrl: string, location: string, ethereumAddress: string, stakedByOperator: string, stakedByDelegates: string, stakedTotal: string, pendingStake: string, stakedByOperatorFormatted: string, stakedByDelegatesFormatted: string, stakedTotalFormatted: string, pendingStakeFormatted: string, status: Types.NodeStatus, epochData?: { __typename?: 'EpochData', total: number, offline: number, online: number } | null, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string } }> | null, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string, totalNodes: number, inactiveNodes: number, validatingNodes: number, uptime: number } | null }; export type StakingQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, stakingSummary: { __typename?: 'StakingSummary', currentStakeAvailable: string }, delegations?: Array<{ __typename?: 'Delegation', amount: string, amountFormatted: string, epoch: number, node: { __typename?: 'Node', id: string } }> | null } | null, epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: string | null, end?: string | null, expiry?: string | null } }, nodes?: Array<{ __typename?: 'Node', id: string, name: string, pubkey: string, infoUrl: string, location: string, ethereumAddress: string, stakedByOperator: string, stakedByDelegates: string, stakedTotal: string, pendingStake: string, stakedByOperatorFormatted: string, stakedByDelegatesFormatted: string, stakedTotalFormatted: string, pendingStakeFormatted: string, status: Types.NodeStatus, epochData?: { __typename?: 'EpochData', total: number, offline: number, online: number } | null, rankingScore: { __typename?: 'RankingScore', rankingScore: string, stakeScore: string, performanceScore: string, votingPower: string } }> | null, nodeData?: { __typename?: 'NodeData', stakedTotal: string, stakedTotalFormatted: string, totalNodes: number, inactiveNodes: number, validatingNodes: number, uptime: number } | null };
export const StakingDocument = gql` export const StakingDocument = gql`
query Staking($partyId: ID!) { query Staking($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
delegations { delegations {
amount amount

View File

@ -11,6 +11,8 @@ import { ValidatorTable } from './validator-table';
import { YourStake } from './your-stake'; import { YourStake } from './your-stake';
import NodeContainer from './nodes-container'; import NodeContainer from './nodes-container';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
import { useAppState } from '../../../contexts/app-state/app-state-context';
import { toBigNum } from '@vegaprotocol/react-helpers';
interface StakingNodeProps { interface StakingNodeProps {
data?: StakingQueryResult; data?: StakingQueryResult;
@ -18,6 +20,9 @@ interface StakingNodeProps {
export const StakingNode = ({ data }: StakingNodeProps) => { export const StakingNode = ({ data }: StakingNodeProps) => {
const { pubKey: vegaKey } = useVegaWallet(); const { pubKey: vegaKey } = useVegaWallet();
const {
appState: { decimals },
} = useAppState();
const { node } = useParams<{ node: string }>(); const { node } = useParams<{ node: string }>();
const { t } = useTranslation(); const { t } = useTranslation();
const nodeInfo = React.useMemo(() => { const nodeInfo = React.useMemo(() => {
@ -59,13 +64,15 @@ export const StakingNode = ({ data }: StakingNodeProps) => {
}, [currentEpoch, data?.party?.delegations]); }, [currentEpoch, data?.party?.delegations]);
const unstaked = React.useMemo(() => { const unstaked = React.useMemo(() => {
const value = new BigNumber( const value = toBigNum(
data?.party?.stake.currentStakeAvailableFormatted || 0 data?.party?.stakingSummary.currentStakeAvailable || 0,
decimals
).minus(currentDelegationAmount); ).minus(currentDelegationAmount);
return value.isLessThan(0) ? new BigNumber(0) : value; return value.isLessThan(0) ? new BigNumber(0) : value;
}, [ }, [
currentDelegationAmount, currentDelegationAmount,
data?.party?.stake.currentStakeAvailableFormatted, data?.party?.stakingSummary.currentStakeAvailable,
decimals,
]); ]);
if (!nodeInfo) { if (!nodeInfo) {

View File

@ -12,9 +12,8 @@ export const STAKING_QUERY = gql`
query Staking($partyId: ID!) { query Staking($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
stake { stakingSummary {
currentStakeAvailable currentStakeAvailable
currentStakeAvailableFormatted @client
} }
delegations { delegations {
amount amount

View File

@ -2752,8 +2752,6 @@ export type PartyStake = {
__typename?: 'PartyStake'; __typename?: 'PartyStake';
/** The stake currently available for the party */ /** The stake currently available for the party */
currentStakeAvailable: Scalars['String']; currentStakeAvailable: Scalars['String'];
/** The currently available stake formatted by the client */
currentStakeAvailableFormatted: Scalars['String'];
/** The list of all stake link/unlink for the party */ /** The list of all stake link/unlink for the party */
linkings?: Maybe<Array<StakeLinking>>; linkings?: Maybe<Array<StakeLinking>>;
}; };