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
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}
@ -62,7 +62,7 @@ query ProposalsQuery {
value
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}

View File

@ -6,7 +6,7 @@ const defaultOptions = {} as const;
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`
@ -60,7 +60,7 @@ export const ProposalsQueryDocument = gql`
value
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}
@ -74,7 +74,7 @@ export const ProposalsQueryDocument = gql`
value
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}

View File

@ -9,7 +9,7 @@ query PartyAssetsQuery($partyId: ID!) {
}
epoch
}
stake {
stakingSummary {
currentStakeAvailable
}
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`
@ -23,7 +23,7 @@ export const PartyAssetsQueryDocument = gql`
}
epoch
}
stake {
stakingSummary {
currentStakeAvailable
}
accounts {

View File

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

View File

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

View File

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

View File

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

View File

@ -46,16 +46,12 @@ export interface Delegations_party_delegations {
epoch: number;
}
export interface Delegations_party_stake {
__typename: "PartyStake";
export interface Delegations_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
}
export interface Delegations_party_accounts_asset_source_BuiltinAsset {
@ -122,7 +118,7 @@ export interface Delegations_party {
/**
* The staking information for this Party
*/
stake: Delegations_party_stake;
stakingSummary: Delegations_party_stakingSummary;
/**
* 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`
@ -27,9 +27,8 @@ export const DelegationsDocument = gql`
}
epoch
}
stake {
stakingSummary {
currentStakeAvailable
currentStakeAvailableFormatted @client
}
accounts {
asset {

View File

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

View File

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

View File

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

View File

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

View File

@ -3,19 +3,19 @@ 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, 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<{
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 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`
fragment ProposalFields on Proposal {
@ -89,7 +89,7 @@ export const ProposalFieldsFragmentDoc = gql`
value
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}
@ -104,7 +104,7 @@ export const ProposalFieldsFragmentDoc = gql`
value
party {
id
stake {
stakingSummary {
currentStakeAvailable
}
}

View File

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

View File

@ -7,16 +7,12 @@
// GraphQL query operation: VoteButtonsQuery
// ====================================================
export interface VoteButtonsQuery_party_stake {
__typename: "PartyStake";
export interface VoteButtonsQuery_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
}
export interface VoteButtonsQuery_party {
@ -28,7 +24,7 @@ export interface VoteButtonsQuery_party {
/**
* The staking information for this Party
*/
stake: VoteButtonsQuery_party_stake;
stakingSummary: VoteButtonsQuery_party_stakingSummary;
}
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`
query VoteButtons($partyId: ID!) {
party(id: $partyId) {
id
stake {
stakingSummary {
currentStakeAvailable
currentStakeAvailableFormatted @client
}
}
}

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import { StakeLinkingStatus } from "@vegaprotocol/types";
// GraphQL query operation: PartyStakeLinkings
// ====================================================
export interface PartyStakeLinkings_party_stake_linkings {
export interface PartyStakeLinkings_party_stakingSummary_linkings_edges_node {
__typename: "StakeLinking";
id: string;
/**
@ -22,12 +22,28 @@ export interface PartyStakeLinkings_party_stake_linkings {
status: StakeLinkingStatus;
}
export interface PartyStakeLinkings_party_stake {
__typename: "PartyStake";
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_stake_linkings[] | null;
linkings: PartyStakeLinkings_party_stakingSummary_linkings;
}
export interface PartyStakeLinkings_party {
@ -39,7 +55,7 @@ export interface PartyStakeLinkings_party {
/**
* The staking information for this Party
*/
stake: PartyStakeLinkings_party_stake;
stakingSummary: PartyStakeLinkings_party_stakingSummary;
}
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`
query PartyStakeLinkings($partyId: ID!) {
party(id: $partyId) {
id
stake {
stakingSummary {
linkings {
id
txHash
status
edges {
node {
id
txHash
status
}
}
}
}
}

View File

@ -14,7 +14,7 @@ import {
TxState,
} from '../../../hooks/transaction-reducer';
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';
export const AssociateTransaction = ({
@ -30,7 +30,7 @@ export const AssociateTransaction = ({
state: TransactionState;
dispatch: React.Dispatch<TransactionAction>;
requiredConfirmations: number;
linking: PartyStakeLinkings_party_stake_linkings | null;
linking: PartyStakeLinkings_party_stakingSummary_linkings_edges_node | null;
}) => {
const { ETHERSCAN_URL } = useEnvironment();
const { t } = useTranslation();

View File

@ -10,12 +10,13 @@ import { useRefreshBalances } from '../../../hooks/use-refresh-balances';
import { useTransaction } from '../../../hooks/use-transaction';
import type {
PartyStakeLinkings,
PartyStakeLinkings_party_stake_linkings,
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 compact from 'lodash/compact';
export const useAddStake = (
address: string,
@ -71,11 +72,15 @@ const PARTY_STAKE_LINKINGS = gql`
query PartyStakeLinkings($partyId: ID!) {
party(id: $partyId) {
id
stake {
stakingSummary {
linkings {
id
txHash
status
edges {
node {
id
txHash
status
}
}
}
}
}
@ -88,7 +93,9 @@ export const usePollForStakeLinking = (
) => {
const client = useApolloClient();
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)
React.useEffect(() => {
@ -104,7 +111,12 @@ export const usePollForStakeLinking = (
fetchPolicy: 'no-cache',
})
.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;

View File

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

View File

@ -9,16 +9,12 @@ import { NodeStatus } from "@vegaprotocol/types";
// GraphQL query operation: Staking
// ====================================================
export interface Staking_party_stake {
__typename: "PartyStake";
export interface Staking_party_stakingSummary {
__typename: "StakingSummary";
/**
* The stake currently available for the party
*/
currentStakeAvailable: string;
/**
* The currently available stake formatted by the client
*/
currentStakeAvailableFormatted: string;
}
export interface Staking_party_delegations_node {
@ -58,7 +54,7 @@ export interface Staking_party {
/**
* The staking information for this Party
*/
stake: Staking_party_stake;
stakingSummary: Staking_party_stakingSummary;
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`
query Staking($partyId: ID!) {
party(id: $partyId) {
id
stake {
stakingSummary {
currentStakeAvailable
currentStakeAvailableFormatted @client
}
delegations {
amount

View File

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

View File

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

View File

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