From b01c67ced536914690d6d77425206b2a2114b8af Mon Sep 17 00:00:00 2001 From: Edd Date: Thu, 8 Feb 2024 10:54:00 +0000 Subject: [PATCH] chore(explorer): update transfer status query to match latest preview --- .../txs/details/transfer/Transfer.graphql | 26 +++---- .../transfer/__generated__/Transfer.ts | 54 +++++++------- .../transfer/blocks/transfer-rewards.tsx | 72 +++++++++++++------ .../transfer/blocks/transfer-status.tsx | 2 +- .../txs/details/transfer/transfer-details.tsx | 6 +- libs/types/src/__generated__/types.ts | 64 +++++++++++++++-- 6 files changed, 154 insertions(+), 70 deletions(-) diff --git a/apps/explorer/src/app/components/txs/details/transfer/Transfer.graphql b/apps/explorer/src/app/components/txs/details/transfer/Transfer.graphql index 7dee705e7..0bab974b6 100644 --- a/apps/explorer/src/app/components/txs/details/transfer/Transfer.graphql +++ b/apps/explorer/src/app/components/txs/details/transfer/Transfer.graphql @@ -1,16 +1,18 @@ -query ExplorerTransferVote($id: ID!) { +query ExplorerTransferStatus($id: ID!) { transfer(id: $id) { - reference - timestamp - status - reason - fromAccountType - from - to - toAccountType - asset { - id + transfer { + reference + timestamp + status + reason + fromAccountType + from + to + toAccountType + asset { + id + } + amount } - amount } } diff --git a/apps/explorer/src/app/components/txs/details/transfer/__generated__/Transfer.ts b/apps/explorer/src/app/components/txs/details/transfer/__generated__/Transfer.ts index ae8a2c1a5..cd29ad55a 100644 --- a/apps/explorer/src/app/components/txs/details/transfer/__generated__/Transfer.ts +++ b/apps/explorer/src/app/components/txs/details/transfer/__generated__/Transfer.ts @@ -3,57 +3,59 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type ExplorerTransferVoteQueryVariables = Types.Exact<{ +export type ExplorerTransferStatusQueryVariables = Types.Exact<{ id: Types.Scalars['ID']; }>; -export type ExplorerTransferVoteQuery = { __typename?: 'Query', transfer?: { __typename?: 'Transfer', reference?: string | null, timestamp: any, status: Types.TransferStatus, reason?: string | null, fromAccountType: Types.AccountType, from: string, to: string, toAccountType: Types.AccountType, amount: string, asset?: { __typename?: 'Asset', id: string } | null } | null }; +export type ExplorerTransferStatusQuery = { __typename?: 'Query', transfer?: { __typename?: 'TransferNode', transfer: { __typename?: 'Transfer', reference?: string | null, timestamp: any, status: Types.TransferStatus, reason?: string | null, fromAccountType: Types.AccountType, from: string, to: string, toAccountType: Types.AccountType, amount: string, asset?: { __typename?: 'Asset', id: string } | null } } | null }; -export const ExplorerTransferVoteDocument = gql` - query ExplorerTransferVote($id: ID!) { +export const ExplorerTransferStatusDocument = gql` + query ExplorerTransferStatus($id: ID!) { transfer(id: $id) { - reference - timestamp - status - reason - fromAccountType - from - to - toAccountType - asset { - id + transfer { + reference + timestamp + status + reason + fromAccountType + from + to + toAccountType + asset { + id + } + amount } - amount } } `; /** - * __useExplorerTransferVoteQuery__ + * __useExplorerTransferStatusQuery__ * - * To run a query within a React component, call `useExplorerTransferVoteQuery` and pass it any options that fit your needs. - * When your component renders, `useExplorerTransferVoteQuery` returns an object from Apollo Client that contains loading, error, and data properties + * To run a query within a React component, call `useExplorerTransferStatusQuery` and pass it any options that fit your needs. + * When your component renders, `useExplorerTransferStatusQuery` 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 } = useExplorerTransferVoteQuery({ + * const { data, loading, error } = useExplorerTransferStatusQuery({ * variables: { * id: // value for 'id' * }, * }); */ -export function useExplorerTransferVoteQuery(baseOptions: Apollo.QueryHookOptions) { +export function useExplorerTransferStatusQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ExplorerTransferVoteDocument, options); + return Apollo.useQuery(ExplorerTransferStatusDocument, options); } -export function useExplorerTransferVoteLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { +export function useExplorerTransferStatusLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ExplorerTransferVoteDocument, options); + return Apollo.useLazyQuery(ExplorerTransferStatusDocument, options); } -export type ExplorerTransferVoteQueryHookResult = ReturnType; -export type ExplorerTransferVoteLazyQueryHookResult = ReturnType; -export type ExplorerTransferVoteQueryResult = Apollo.QueryResult; \ No newline at end of file +export type ExplorerTransferStatusQueryHookResult = ReturnType; +export type ExplorerTransferStatusLazyQueryHookResult = ReturnType; +export type ExplorerTransferStatusQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-rewards.tsx b/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-rewards.tsx index 3db0a6dfe..5ed6bd5f6 100644 --- a/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-rewards.tsx +++ b/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-rewards.tsx @@ -7,7 +7,7 @@ import { DistributionStrategy, } from '@vegaprotocol/types'; import { VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; - +import { formatNumber } from '@vegaprotocol/utils'; export type Metric = components['schemas']['vegaDispatchMetric']; export type Strategy = components['schemas']['vegaDispatchStrategy']; @@ -72,37 +72,44 @@ export function TransferRewards({ recurring }: TransferRewardsProps) {

{getRewardTitle(entityScope)}

    + {entityScope && entityScopeIcons[entityScope] ? ( +
  • + {t('Scope')}:{' '} + +   + {individualScope ? individualScopeLabels[individualScope] : null} + {getScopeLabel(entityScope, teamScope)} +
  • + ) : null} + {metric && ( +
  • + {t('Metric')}: {metricLabels[metric]} +
  • + )} + {assetForMetric ? (
  • {t('Asset')}:{' '}
  • ) : null} -
  • - {t('Metric')}: {metricLabels[metric]} -
  • - {entityScope && entityScopeIcons[entityScope] ? ( -
  • - {t('Scope')}:{' '} - - {individualScope ? individualScopeLabels[individualScope] : null} -
  • - ) : null} - {teamScope} - - {lockPeriod && lockPeriod !== '0' ? ( + {lockPeriod ? (
  • - {t('Lock')}: {lockPeriod} + {t('Reward lock')}:  + {recurring.dispatchStrategy.lockPeriod}{' '} + {recurring.dispatchStrategy.lockPeriod === '1' + ? t('epoch') + : t('epochs')}
  • ) : null} {markets && markets.length > 0 ? (
  • {t('Markets in scope')}: -
      +
        {markets.map((m) => ( -
      • +
      • ))} @@ -119,7 +126,10 @@ export function TransferRewards({ recurring }: TransferRewardsProps) { {windowLength && windowLength !== '0' ? (
      • {t('Window length')}:{' '} - {recurring.dispatchStrategy.windowLength} + {recurring.dispatchStrategy.windowLength}{' '} + {recurring.dispatchStrategy.windowLength === '1' + ? t('epoch') + : t('epochs')}
      • ) : null} @@ -133,9 +143,11 @@ export function TransferRewards({ recurring }: TransferRewardsProps) { {nTopPerformers && (
      • - {t('Top performers')}: {nTopPerformers} + {t('Elligible team members:')} top{' '} + {`${formatNumber(Number(nTopPerformers) * 100, 0)}%`}
      • )} + {distributionStrategy && distributionStrategy !== 'DISTRIBUTION_STRATEGY_UNSPECIFIED' && (
      • @@ -146,13 +158,13 @@ export function TransferRewards({ recurring }: TransferRewardsProps) {
      {rankTable && rankTable.length > 0 ? ( - +
      - - @@ -178,6 +190,22 @@ export function TransferRewards({ recurring }: TransferRewardsProps) { ); } +export function getScopeLabel( + scope: components['schemas']['vegaEntityScope'] | undefined, + teamScope: readonly string[] | undefined +): string { + if (scope === 'ENTITY_SCOPE_TEAMS') { + if (teamScope && teamScope.length !== 0) { + return ` ${teamScope.length} teams`; + } else { + return t('All teams'); + } + } else if (scope === 'ENTITY_SCOPE_INDIVIDUALS') { + return t('Individuals'); + } else { + return ''; + } +} export function getRewardTitle( scope?: components['schemas']['vegaEntityScope'] ) { diff --git a/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-status.tsx b/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-status.tsx index faa6be065..959e2126b 100644 --- a/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-status.tsx +++ b/apps/explorer/src/app/components/txs/details/transfer/blocks/transfer-status.tsx @@ -25,7 +25,7 @@ export function TransferStatusView({ status, loading }: TransferStatusProps) { return (
      -

      {t('Transfer Status')}

      +

      {t('Status')}

      {loading ? (
      diff --git a/apps/explorer/src/app/components/txs/details/transfer/transfer-details.tsx b/apps/explorer/src/app/components/txs/details/transfer/transfer-details.tsx index 56140318c..3755be0b6 100644 --- a/apps/explorer/src/app/components/txs/details/transfer/transfer-details.tsx +++ b/apps/explorer/src/app/components/txs/details/transfer/transfer-details.tsx @@ -2,7 +2,7 @@ import type { components } from '../../../../../types/explorer'; import { TransferRepeat } from './blocks/transfer-repeat'; import { TransferRewards } from './blocks/transfer-rewards'; import { TransferParticipants } from './blocks/transfer-participants'; -import { useExplorerTransferVoteQuery } from './__generated__/Transfer'; +import { useExplorerTransferStatusQuery } from './__generated__/Transfer'; import { TransferStatusView } from './blocks/transfer-status'; import { TransferStatus } from '@vegaprotocol/types'; @@ -33,13 +33,13 @@ export function TransferDetails({ transfer, from, id }: TransferDetailsProps) { // Currently all this is passed in to TransferStatus, but the extra details // may be useful in the future. - const { data, error, loading } = useExplorerTransferVoteQuery({ + const { data, error, loading } = useExplorerTransferStatusQuery({ variables: { id }, }); const status = error ? TransferStatus.STATUS_REJECTED - : data?.transfer?.status; + : data?.transfer?.transfer.status; return (
      diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index 5b147778c..cd5ee37a2 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -14,6 +14,32 @@ export type Scalars = { Timestamp: any; }; +/** Margins for a hypothetical position not related to any existing party */ +export type AbstractMarginLevels = { + __typename?: 'AbstractMarginLevels'; + /** Asset for the current margins */ + asset: Asset; + /** + * If the margin of the party is greater than this level, then collateral will be released from the margin account into + * the general account of the party for the given asset. + */ + collateralReleaseLevel: Scalars['String']; + /** This is the minimum margin required for a party to place a new order on the network, expressed as unsigned integer */ + initialLevel: Scalars['String']; + /** Minimal margin for the position to be maintained in the network (unsigned integer) */ + maintenanceLevel: Scalars['String']; + /** Margin factor, only relevant for isolated margin mode, else 0 */ + marginFactor: Scalars['String']; + /** Margin mode of the party, cross margin or isolated margin */ + marginMode: MarginMode; + /** Market in which the margin is required for this party */ + market: Market; + /** When in isolated margin, the required order margin level, otherwise, 0 */ + orderMarginLevel: Scalars['String']; + /** If the margin is between maintenance and search, the network will initiate a collateral search, expressed as unsigned integer */ + searchLevel: Scalars['String']; +}; + /** An account record */ export type AccountBalance = { __typename?: 'AccountBalance'; @@ -359,6 +385,8 @@ export enum AuctionTrigger { export type BatchProposal = { __typename?: 'BatchProposal'; + /** Terms of all the proposals in the batch */ + batchTerms?: Maybe; /** RFC3339Nano time and date when the proposal reached the network */ datetime: Scalars['Timestamp']; /** Details of the rejection reason */ @@ -389,10 +417,10 @@ export type BatchProposal = { votes: ProposalVotes; }; -/** The rationale for the proposal */ +/** The terms for the batch proposal */ export type BatchProposalTerms = { __typename?: 'BatchProposalTerms'; - /** Actual changes being introduced by the proposal - actions the proposal triggers if passed and enacted. */ + /** Actual changes being introduced by the batch proposal - actions the proposal triggers if passed and enacted. */ changes: Array>; /** * RFC3339Nano time and date when voting closes for this proposal. @@ -531,6 +559,22 @@ export type CompositePriceConfiguration = { decayWeight: Scalars['String']; }; +export type CompositePriceSource = { + __typename?: 'CompositePriceSource'; + /** The source of the price */ + PriceSource: Scalars['String']; + /** The last time the price source was updated in RFC3339Nano */ + lastUpdated: Scalars['Timestamp']; + /** The current value of the composite source price */ + price: Scalars['String']; +}; + +export type CompositePriceState = { + __typename?: 'CompositePriceState'; + /** Underlying state of the composite price */ + priceSources?: Maybe>; +}; + export enum CompositePriceType { /** Composite price is set to the last trade (legacy) */ COMPOSITE_PRICE_TYPE_LAST_TRADE = 'COMPOSITE_PRICE_TYPE_LAST_TRADE', @@ -2165,9 +2209,9 @@ export type MarginEdge = { export type MarginEstimate = { __typename?: 'MarginEstimate'; /** Margin level estimate assuming no slippage */ - bestCase: MarginLevels; + bestCase: AbstractMarginLevels; /** Margin level estimate assuming slippage cap is applied */ - worstCase: MarginLevels; + worstCase: AbstractMarginLevels; }; /** Margins for a given a party */ @@ -2439,6 +2483,8 @@ export type MarketData = { liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; + /** State of the underlying internal composite price */ + markPriceState?: Maybe; /** The methodology used for the calculation of the mark price */ markPriceType: CompositePriceType; /** Market of the associated mark price */ @@ -3053,6 +3099,8 @@ export type ObservableMarketData = { liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; + /** State of the underlying internal composite price */ + markPriceState?: Maybe; /** The methodology used to calculated mark price */ markPriceType: CompositePriceType; /** The market growth factor for the last market time window */ @@ -4021,6 +4069,8 @@ export type PerpetualData = { fundingRate?: Maybe; /** Internal composite price used as input to the internal VWAP */ internalCompositePrice: Scalars['String']; + /** The internal state of the underlying internal composite price */ + internalCompositePriceState?: Maybe; /** The methodology used to calculated internal composite price for perpetual markets */ internalCompositePriceType: CompositePriceType; /** Time-weighted average price calculated from data points for this period from the internal data source. */ @@ -4031,6 +4081,8 @@ export type PerpetualData = { seqNum: Scalars['Int']; /** Time at which the funding period started */ startTime: Scalars['Timestamp']; + /** The last value from the external oracle */ + underlyingIndexPrice: Scalars['String']; }; export type PerpetualProduct = { @@ -4328,7 +4380,7 @@ export type ProposalDetail = { __typename?: 'ProposalDetail'; /** Batch proposal ID that is provided by Vega once proposal reaches the network */ batchId?: Maybe; - /** Terms of the proposal for a batch proposal */ + /** Terms of all the proposals in the batch */ batchTerms?: Maybe; /** RFC3339Nano time and date when the proposal reached the Vega network */ datetime: Scalars['Timestamp']; @@ -4354,7 +4406,7 @@ export type ProposalDetail = { requiredParticipation: Scalars['String']; /** State of the proposal */ state: ProposalState; - /** Terms of the proposal for proposal */ + /** Terms of the proposal */ terms?: Maybe; };
      + {t('Start rank')} + {t('Share of reward pool')}