Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7404157ec6 | ||
|
|
a90c5c3b0c | ||
|
|
9e2e6b7636 | ||
|
|
ab06c95468 | ||
|
|
7b4c5c0fab |
@@ -4,5 +4,6 @@ tmp/*
|
||||
.dockerignore
|
||||
dockerfiles
|
||||
node_modules
|
||||
.git
|
||||
.github
|
||||
.vscode
|
||||
|
||||
@@ -10,7 +10,7 @@ on:
|
||||
inputs:
|
||||
console-test-branch:
|
||||
type: choice
|
||||
description: 'main: v0.74.10, develop: v0.75.5'
|
||||
description: 'main: v0.73.13, develop: v0.74.0'
|
||||
options:
|
||||
- main
|
||||
- develop
|
||||
@@ -57,14 +57,15 @@ jobs:
|
||||
#----------------------------------------------
|
||||
- name: Build trading app
|
||||
run: |
|
||||
ENV_NAME="${{ needs.console-test-branch.outputs.console-branch == 'main' && 'mainnet' || 'stagnet1' }}"
|
||||
yarn env-cmd -f ./apps/trading/.env.$ENV_NAME yarn nx export trading
|
||||
yarn env-cmd -f ./apps/trading/.env.stagnet1 yarn nx export trading
|
||||
DIST_LOCATION=dist/apps/trading/exported
|
||||
mv $DIST_LOCATION dist-result
|
||||
tree dist-result
|
||||
|
||||
#----------------------------------------------
|
||||
# export trading app docker image
|
||||
#----------------------------------------------
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -77,7 +78,7 @@ jobs:
|
||||
load: true
|
||||
build-args: |
|
||||
APP=trading
|
||||
ENV_NAME=${{ needs.console-test-branch.outputs.console-branch == 'main' && 'mainnet' || 'stagnet1' }}
|
||||
ENV_NAME=stagnet1
|
||||
tags: ci/trading:local
|
||||
outputs: type=docker,dest=/tmp/console-image.tar
|
||||
|
||||
@@ -181,22 +182,12 @@ jobs:
|
||||
virtualenvs-create: true
|
||||
virtualenvs-in-project: true
|
||||
virtualenvs-path: .venv
|
||||
#----------------------------------------------
|
||||
# Set up pyproject.toml based on branch
|
||||
#----------------------------------------------
|
||||
- name: Create pyproject.toml based on branch
|
||||
run: |
|
||||
if [ "${{ needs.console-test-branch.outputs.console-branch }}" = "main" ]; then
|
||||
mv pyproject.main.toml pyproject.toml
|
||||
elif [ "${{ needs.console-test-branch.outputs.console-branch }}" = "develop" ]; then
|
||||
mv pyproject.develop.toml pyproject.toml
|
||||
fi
|
||||
working-directory: apps/trading/e2e
|
||||
|
||||
#----------------------------------------------
|
||||
# install python dependencies
|
||||
#----------------------------------------------
|
||||
- name: Install dependencies
|
||||
run: poetry lock && poetry install --no-interaction --no-root
|
||||
run: poetry install --no-interaction --no-root
|
||||
working-directory: apps/trading/e2e
|
||||
#----------------------------------------------
|
||||
# install vega binaries
|
||||
|
||||
@@ -58,6 +58,5 @@ __pycache__/
|
||||
apps/trading/e2e/logs/
|
||||
apps/trading/e2e/.pytest_cache/
|
||||
apps/trading/e2e/traces/
|
||||
apps/trading/e2e/pyproject.toml
|
||||
|
||||
.nx/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
||||
NX_VEGA_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
||||
|
||||
@@ -8,14 +8,12 @@ import EpochMissingOverview from './epoch-missing';
|
||||
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import type { IconProps } from '@vegaprotocol/ui-toolkit';
|
||||
import isPast from 'date-fns/isPast';
|
||||
import { EpochSymbol } from '../links/block-link/block-link';
|
||||
|
||||
const borderClass =
|
||||
'border-solid border-2 border-vega-dark-200 border-collapse';
|
||||
|
||||
export type EpochOverviewProps = {
|
||||
id?: string;
|
||||
icon?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -26,7 +24,7 @@ export type EpochOverviewProps = {
|
||||
*
|
||||
* The details are hidden in a tooltip, behind the epoch number
|
||||
*/
|
||||
const EpochOverview = ({ id, icon = true }: EpochOverviewProps) => {
|
||||
const EpochOverview = ({ id }: EpochOverviewProps) => {
|
||||
const { data, error, loading } = useExplorerEpochQuery({
|
||||
variables: { id: id || '' },
|
||||
});
|
||||
@@ -40,12 +38,7 @@ const EpochOverview = ({ id, icon = true }: EpochOverviewProps) => {
|
||||
}
|
||||
|
||||
if (!ti || loading || error) {
|
||||
return (
|
||||
<span>
|
||||
<EpochSymbol />
|
||||
{id}
|
||||
</span>
|
||||
);
|
||||
return <span>{id}</span>;
|
||||
}
|
||||
|
||||
const description = (
|
||||
@@ -97,11 +90,7 @@ const EpochOverview = ({ id, icon = true }: EpochOverviewProps) => {
|
||||
return (
|
||||
<Tooltip description={description}>
|
||||
<p>
|
||||
{icon ? (
|
||||
<IconForEpoch start={ti.start} end={ti.end} />
|
||||
) : (
|
||||
<EpochSymbol />
|
||||
)}
|
||||
<IconForEpoch start={ti.start} end={ti.end} />
|
||||
{id}
|
||||
</p>
|
||||
</Tooltip>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
query ExplorerEpochForBlock($block: String!) {
|
||||
epoch(block: $block) {
|
||||
id
|
||||
timestamps {
|
||||
start
|
||||
end
|
||||
lastBlock
|
||||
}
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type ExplorerEpochForBlockQueryVariables = Types.Exact<{
|
||||
block: Types.Scalars['String'];
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerEpochForBlockQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: any | null, end?: any | null, lastBlock?: string | null } } };
|
||||
|
||||
|
||||
export const ExplorerEpochForBlockDocument = gql`
|
||||
query ExplorerEpochForBlock($block: String!) {
|
||||
epoch(block: $block) {
|
||||
id
|
||||
timestamps {
|
||||
start
|
||||
end
|
||||
lastBlock
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useExplorerEpochForBlockQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useExplorerEpochForBlockQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useExplorerEpochForBlockQuery` 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 } = useExplorerEpochForBlockQuery({
|
||||
* variables: {
|
||||
* block: // value for 'block'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useExplorerEpochForBlockQuery(baseOptions: Apollo.QueryHookOptions<ExplorerEpochForBlockQuery, ExplorerEpochForBlockQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<ExplorerEpochForBlockQuery, ExplorerEpochForBlockQueryVariables>(ExplorerEpochForBlockDocument, options);
|
||||
}
|
||||
export function useExplorerEpochForBlockLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerEpochForBlockQuery, ExplorerEpochForBlockQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<ExplorerEpochForBlockQuery, ExplorerEpochForBlockQueryVariables>(ExplorerEpochForBlockDocument, options);
|
||||
}
|
||||
export type ExplorerEpochForBlockQueryHookResult = ReturnType<typeof useExplorerEpochForBlockQuery>;
|
||||
export type ExplorerEpochForBlockLazyQueryHookResult = ReturnType<typeof useExplorerEpochForBlockLazyQuery>;
|
||||
export type ExplorerEpochForBlockQueryResult = Apollo.QueryResult<ExplorerEpochForBlockQuery, ExplorerEpochForBlockQueryVariables>;
|
||||
@@ -4,56 +4,17 @@ import { Link } from 'react-router-dom';
|
||||
|
||||
import type { ComponentProps } from 'react';
|
||||
import Hash from '../hash';
|
||||
import { useExplorerEpochForBlockQuery } from './__generated__/EpochByBlock';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
|
||||
export type BlockLinkProps = Partial<ComponentProps<typeof Link>> & {
|
||||
height: string;
|
||||
showEpoch?: boolean;
|
||||
};
|
||||
|
||||
const BlockLink = ({ height, showEpoch = false, ...props }: BlockLinkProps) => {
|
||||
const BlockLink = ({ height, ...props }: BlockLinkProps) => {
|
||||
return (
|
||||
<>
|
||||
<Link className="underline" {...props} to={`/${Routes.BLOCKS}/${height}`}>
|
||||
<Hash text={height} />
|
||||
</Link>
|
||||
{showEpoch && <EpochForBlock block={height} />}
|
||||
</>
|
||||
<Link className="underline" {...props} to={`/${Routes.BLOCKS}/${height}`}>
|
||||
<Hash text={height} />
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
export function EpochForBlock(props: { block: string }) {
|
||||
const { error, data, loading } = useExplorerEpochForBlockQuery({
|
||||
errorPolicy: 'ignore',
|
||||
variables: { block: props.block },
|
||||
});
|
||||
|
||||
// NOTE: 0.73.x & <0.74.2 can error showing epoch, so for now we hide loading
|
||||
// or error states and only display if we get usable data
|
||||
if (error || loading || !data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="ml-2" title={t('Epoch')}>
|
||||
<EpochSymbol />
|
||||
{data.epoch.id}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export const EPOCH_SYMBOL = 'ⓔ';
|
||||
|
||||
export function EpochSymbol() {
|
||||
return (
|
||||
<em
|
||||
title={t('Epoch')}
|
||||
className="mr-1 cursor-default text-xl leading-none align-text-bottom not-italic"
|
||||
>
|
||||
{EPOCH_SYMBOL}
|
||||
</em>
|
||||
);
|
||||
}
|
||||
|
||||
export default BlockLink;
|
||||
|
||||
+2
-5
@@ -1,8 +1,5 @@
|
||||
import type { ChainIdMapping } from '@vegaprotocol/environment';
|
||||
import {
|
||||
SUPPORTED_CHAIN_IDS,
|
||||
SUPPORTED_CHAIN_LABELS,
|
||||
} from '@vegaprotocol/environment';
|
||||
import type { ChainIdMapping } from './external-chain';
|
||||
import { SUPPORTED_CHAIN_IDS, SUPPORTED_CHAIN_LABELS } from './external-chain';
|
||||
|
||||
export const SUPPORTED_CHAIN_ICON_URLS: ChainIdMapping = {
|
||||
'1': '/assets/chain-eth-logo.svg',
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ export const SUPPORTED_CHAIN_LABELS: ChainIdMapping = {
|
||||
'11155111': 'Sepolia',
|
||||
};
|
||||
|
||||
export function getExternalExplorerLink(chainId: string) {
|
||||
export function getExternalExplorerLink(chainId: string, type: string) {
|
||||
if (SUPPORTED_CHAIN_IDS.includes(chainId)) {
|
||||
switch (chainId) {
|
||||
case '1':
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import Hash from '../hash';
|
||||
import { getExternalExplorerLink } from '@vegaprotocol/environment';
|
||||
import { getExternalExplorerLink } from './external-chain';
|
||||
import { ExternalChainIcon } from './external-chain-icon';
|
||||
|
||||
export enum EthExplorerLinkTypes {
|
||||
@@ -23,7 +23,7 @@ export const ExternalExplorerLink = ({
|
||||
code = false,
|
||||
...props
|
||||
}: ExternalExplorerLinkProps) => {
|
||||
const link = `${getExternalExplorerLink(chain)}/${type}/${id}${
|
||||
const link = `${getExternalExplorerLink(chain, type)}/${type}/${id}${
|
||||
code ? '#code' : ''
|
||||
}`;
|
||||
return (
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import GovernanceLink from './governance-link';
|
||||
|
||||
describe('GovernanceLink', () => {
|
||||
it('renders the link with the correct text', () => {
|
||||
render(<GovernanceLink text="Governance internet website" />);
|
||||
const linkElement = screen.getByText('Governance internet website');
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the link with the correct href and sensible default text', () => {
|
||||
render(<GovernanceLink />);
|
||||
const linkElement = screen.getByText('Governance');
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -1,18 +0,0 @@
|
||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||
import { ENV } from '../../../config/env';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
|
||||
export type GovernanceLinkProps = {
|
||||
text?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Just a link to the governance page, with optional text
|
||||
*/
|
||||
const GovernanceLink = ({ text = t('Governance') }: GovernanceLinkProps) => {
|
||||
const base = ENV.dataSources.governanceUrl;
|
||||
|
||||
return <ExternalLink href={base}>{text}</ExternalLink>;
|
||||
};
|
||||
|
||||
export default GovernanceLink;
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
LiquiditySLAParametersInfoPanel,
|
||||
MarginScalingFactorsPanel,
|
||||
PriceMonitoringBoundsInfoPanel,
|
||||
PriceMonitoringSettingsInfoPanel,
|
||||
SuccessionLineInfoPanel,
|
||||
getDataSourceSpecForSettlementData,
|
||||
getDataSourceSpecForTradingTermination,
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
RiskModelInfoPanel,
|
||||
SettlementAssetInfoPanel,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { MarketInfoTable } from '@vegaprotocol/markets';
|
||||
import type { DataSourceFragment } from '@vegaprotocol/markets';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
@@ -74,14 +74,27 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
||||
<MarginScalingFactorsPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Risk factors')}</h2>
|
||||
<RiskFactorsInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Price monitoring bounds')}</h2>
|
||||
<div className="mt-3">
|
||||
<PriceMonitoringBoundsInfoPanel market={market} />
|
||||
</div>
|
||||
<h2 className={headerClassName}>{t('Price monitoring settings')}</h2>
|
||||
<div className="mt-3">
|
||||
<PriceMonitoringSettingsInfoPanel market={market} />
|
||||
</div>
|
||||
{(market.data?.priceMonitoringBounds || []).map((trigger, i) => (
|
||||
<>
|
||||
<h2 className={headerClassName}>
|
||||
{t('Price monitoring bounds %s', [(i + 1).toString()])}
|
||||
</h2>
|
||||
<PriceMonitoringBoundsInfoPanel
|
||||
market={market}
|
||||
triggerIndex={i + 1}
|
||||
/>
|
||||
</>
|
||||
))}
|
||||
{(market.priceMonitoringSettings?.parameters?.triggers || []).map(
|
||||
(trigger, i) => (
|
||||
<>
|
||||
<h2 className={headerClassName}>
|
||||
{t('Price monitoring settings %s', [(i + 1).toString()])}
|
||||
</h2>
|
||||
<MarketInfoTable data={trigger} key={i} />
|
||||
</>
|
||||
)
|
||||
)}
|
||||
<h2 className={headerClassName}>{t('Liquidation strategy')}</h2>
|
||||
<LiquidationStrategyInfoPanel market={market} />
|
||||
<h2 className={headerClassName}>{t('Liquidity monitoring')}</h2>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { getAsset, type MarketMaybeWithData } from '@vegaprotocol/markets';
|
||||
import { getAsset, type MarketFieldsFragment } from '@vegaprotocol/markets';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||
import { type AgGridReact } from 'ag-grid-react';
|
||||
@@ -17,7 +17,7 @@ import { type RowClickedEvent } from 'ag-grid-community';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
|
||||
type MarketsTableProps = {
|
||||
data: MarketMaybeWithData[] | null;
|
||||
data: MarketFieldsFragment[] | null;
|
||||
};
|
||||
export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
const openAssetDetailsDialog = useAssetDetailsDialogStore(
|
||||
@@ -56,10 +56,10 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
headerName: t('Status'),
|
||||
field: 'state',
|
||||
hide: window.innerWidth <= BREAKPOINT_MD,
|
||||
valueGetter: ({ data }: VegaValueGetterParams<MarketMaybeWithData>) => {
|
||||
return data?.data?.marketState
|
||||
? MarketStateMapping[data?.data.marketState]
|
||||
: '-';
|
||||
valueGetter: ({
|
||||
data,
|
||||
}: VegaValueGetterParams<MarketFieldsFragment>) => {
|
||||
return data?.state ? MarketStateMapping[data?.state] : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -70,7 +70,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
cellRenderer: ({
|
||||
data,
|
||||
}: VegaICellRendererParams<
|
||||
MarketMaybeWithData,
|
||||
MarketFieldsFragment,
|
||||
'tradableInstrument.instrument.product.settlementAsset.symbol'
|
||||
>) => {
|
||||
const value = data && getAsset(data);
|
||||
@@ -99,7 +99,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
field: 'id',
|
||||
cellRenderer: ({
|
||||
value,
|
||||
}: VegaICellRendererParams<MarketMaybeWithData, 'id'>) =>
|
||||
}: VegaICellRendererParams<MarketFieldsFragment, 'id'>) =>
|
||||
value ? (
|
||||
<Link className="underline" to={value}>
|
||||
{t('View details')}
|
||||
@@ -116,7 +116,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||
<AgGrid
|
||||
ref={gridRef}
|
||||
rowData={data}
|
||||
getRowId={({ data }: { data: MarketMaybeWithData }) => data.id}
|
||||
getRowId={({ data }: { data: MarketFieldsFragment }) => data.id}
|
||||
overlayNoRowsTemplate={t('This chain has no markets')}
|
||||
domLayout="autoHeight"
|
||||
defaultColDef={{
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
import compact from 'lodash/compact';
|
||||
import { MarketLink } from '../links';
|
||||
import { type MarketState, MarketStateMapping } from '@vegaprotocol/types';
|
||||
import OracleLink from '../links/oracle-link/oracle-link';
|
||||
import type {
|
||||
ExplorerOracleForMarketQuery,
|
||||
ExplorerOracleFormMarketsQuery,
|
||||
} from '../../routes/oracles/__generated__/OraclesForMarkets';
|
||||
import { useState } from 'react';
|
||||
|
||||
export type OraclesTableProps = {
|
||||
data?: ExplorerOracleFormMarketsQuery | ExplorerOracleForMarketQuery;
|
||||
};
|
||||
|
||||
const cellSpacing = 'px-3';
|
||||
|
||||
export function OraclesTable({ data }: OraclesTableProps) {
|
||||
const [hoveredOracle, setHoveredOracle] = useState('');
|
||||
|
||||
return (
|
||||
<table className="text-left">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className={cellSpacing}>Market</th>
|
||||
<th className={cellSpacing}>Type</th>
|
||||
<th className={cellSpacing}>State</th>
|
||||
<th className={cellSpacing}>Settlement</th>
|
||||
<th className={cellSpacing}>Termination</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data?.marketsConnection?.edges
|
||||
? data.marketsConnection.edges.map((o) => {
|
||||
let hasSeenOracleReports = false;
|
||||
let settlementOracle = '-';
|
||||
let settlementOracleStatus = '-';
|
||||
let terminationOracle = '-';
|
||||
let terminationOracleStatus = '-';
|
||||
|
||||
const id = o?.node.id;
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
o.node.tradableInstrument.instrument.product.__typename ===
|
||||
'Future'
|
||||
) {
|
||||
settlementOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.id;
|
||||
terminationOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.id;
|
||||
settlementOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.status;
|
||||
terminationOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.status;
|
||||
} else if (
|
||||
o.node.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual'
|
||||
) {
|
||||
settlementOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.id;
|
||||
terminationOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementSchedule.id;
|
||||
settlementOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.status;
|
||||
terminationOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementSchedule.status;
|
||||
}
|
||||
const oracleInformationUnfiltered =
|
||||
data?.oracleSpecsConnection?.edges?.map((e) =>
|
||||
e && e.node ? e.node : undefined
|
||||
) || [];
|
||||
|
||||
const oracleInformation = compact(oracleInformationUnfiltered)
|
||||
.filter(
|
||||
(o) =>
|
||||
o.dataConnection.edges &&
|
||||
o.dataConnection.edges.length > 0 &&
|
||||
(o.dataSourceSpec.spec.id === settlementOracle ||
|
||||
o.dataSourceSpec.spec.id === terminationOracle)
|
||||
)
|
||||
.at(0);
|
||||
if (oracleInformation) {
|
||||
hasSeenOracleReports = true;
|
||||
}
|
||||
|
||||
const oracleList = `${settlementOracle} ${terminationOracle}`;
|
||||
|
||||
return (
|
||||
<tr
|
||||
id={id}
|
||||
key={id}
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
oracleList.indexOf(hoveredOracle) > -1
|
||||
? 'bg-gray-100 dark:bg-gray-800'
|
||||
: ''
|
||||
}
|
||||
data-testid="oracle-details"
|
||||
data-oracles={oracleList}
|
||||
>
|
||||
<td className={cellSpacing}>
|
||||
<MarketLink id={id} />
|
||||
</td>
|
||||
<td className={cellSpacing}>
|
||||
{o.node.tradableInstrument.instrument.product.__typename}
|
||||
</td>
|
||||
<td className={cellSpacing}>
|
||||
{MarketStateMapping[o.node.state as MarketState]}
|
||||
</td>
|
||||
<td
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
hoveredOracle === settlementOracle
|
||||
? `indent-1 ${cellSpacing}`
|
||||
: cellSpacing
|
||||
}
|
||||
>
|
||||
<OracleLink
|
||||
id={settlementOracle}
|
||||
status={settlementOracleStatus}
|
||||
hasSeenOracleReports={hasSeenOracleReports}
|
||||
onMouseOver={() => setHoveredOracle(settlementOracle)}
|
||||
onMouseOut={() => setHoveredOracle('')}
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
hoveredOracle === terminationOracle
|
||||
? `indent-1 ${cellSpacing}`
|
||||
: cellSpacing
|
||||
}
|
||||
>
|
||||
<OracleLink
|
||||
id={terminationOracle}
|
||||
status={terminationOracleStatus}
|
||||
hasSeenOracleReports={hasSeenOracleReports}
|
||||
onMouseOver={() => setHoveredOracle(terminationOracle)}
|
||||
onMouseOut={() => setHoveredOracle('')}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
: null}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
}
|
||||
@@ -33,10 +33,10 @@ const SizeInAsset = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
<p>
|
||||
<span>{label}</span>
|
||||
<AssetLink assetId={assetId} showAssetSymbol={true} asDialog={true} />
|
||||
</span>
|
||||
</p>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||
import { getExternalChainLabel } from '@vegaprotocol/environment';
|
||||
import { getExternalChainLabel } from '../../../links/external-explorer-link/external-chain';
|
||||
import type { components } from '../../../../../types/explorer';
|
||||
import { defaultAbiCoder, base64 } from 'ethers/lib/utils';
|
||||
import { BigNumber } from 'ethers';
|
||||
|
||||
@@ -10,8 +10,6 @@ import { ChainResponseCode } from '../chain-response-code/chain-reponse.code';
|
||||
import { TxDataView } from '../../tx-data-view';
|
||||
import Hash from '../../../links/hash';
|
||||
import { Signature } from '../../../signature/signature';
|
||||
import { useExplorerEpochForBlockQuery } from '../../../links/block-link/__generated__/EpochByBlock';
|
||||
import EpochOverview from '../../../epoch-overview/epoch';
|
||||
|
||||
interface TxDetailsSharedProps {
|
||||
txData: BlockExplorerTransactionResult | undefined;
|
||||
@@ -46,11 +44,6 @@ export const TxDetailsShared = ({
|
||||
blockData,
|
||||
hideTypeRow = false,
|
||||
}: TxDetailsSharedProps) => {
|
||||
const { data } = useExplorerEpochForBlockQuery({
|
||||
errorPolicy: 'ignore',
|
||||
variables: { block: txData?.block?.toString() || '' },
|
||||
});
|
||||
|
||||
if (!txData) {
|
||||
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
||||
}
|
||||
@@ -81,7 +74,7 @@ export const TxDetailsShared = ({
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell {...sharedHeaderProps}>{t('Block')}</TableCell>
|
||||
<TableCell>
|
||||
<BlockLink height={height} showEpoch={false} />
|
||||
<BlockLink height={height} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow modifier="bordered">
|
||||
@@ -90,7 +83,6 @@ export const TxDetailsShared = ({
|
||||
<Signature signature={txData.signature} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell {...sharedHeaderProps}>{t('Time')}</TableCell>
|
||||
<TableCell>
|
||||
@@ -108,14 +100,6 @@ export const TxDetailsShared = ({
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{data && data.epoch && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell scope="row">{t('Epoch')}</TableCell>
|
||||
<TableCell modifier="bordered">
|
||||
<EpochOverview id={data.epoch.id} icon={false} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell {...sharedHeaderProps}>{t('Response code')}</TableCell>
|
||||
<TableCell>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
query ExplorerTransferStatus($id: ID!) {
|
||||
transfer(id: $id) {
|
||||
fees {
|
||||
amount
|
||||
epoch
|
||||
}
|
||||
transfer {
|
||||
reference
|
||||
timestamp
|
||||
|
||||
+1
-5
@@ -8,16 +8,12 @@ export type ExplorerTransferStatusQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerTransferStatusQuery = { __typename?: 'Query', transfer?: { __typename?: 'TransferNode', fees?: Array<{ __typename?: 'TransferFee', amount: string, epoch: number } | null> | null, 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 ExplorerTransferStatusDocument = gql`
|
||||
query ExplorerTransferStatus($id: ID!) {
|
||||
transfer(id: $id) {
|
||||
fees {
|
||||
amount
|
||||
epoch
|
||||
}
|
||||
transfer {
|
||||
reference
|
||||
timestamp
|
||||
|
||||
+4
-45
@@ -44,14 +44,8 @@ const AccountType: Record<AccountTypes, string> = {
|
||||
ACCOUNT_TYPE_ORDER_MARGIN: 'Order Margin',
|
||||
};
|
||||
|
||||
export type TransferFee = {
|
||||
amount?: string;
|
||||
epoch?: number;
|
||||
};
|
||||
|
||||
interface TransferParticipantsProps {
|
||||
transfer: Transfer;
|
||||
fees?: TransferFee[] | null;
|
||||
from: string;
|
||||
}
|
||||
|
||||
@@ -66,7 +60,6 @@ interface TransferParticipantsProps {
|
||||
export function TransferParticipants({
|
||||
transfer,
|
||||
from,
|
||||
fees,
|
||||
}: TransferParticipantsProps) {
|
||||
// This mapping is required as the global account types require a type to be set, while
|
||||
// the underlying protobufs allow for every field to be undefined.
|
||||
@@ -111,9 +104,6 @@ export function TransferParticipants({
|
||||
{transfer.asset ? (
|
||||
<SizeInAsset assetId={transfer.asset} size={transfer.amount} />
|
||||
) : null}
|
||||
{transfer.asset && fees && (
|
||||
<TransferFees assetId={transfer.asset} fees={fees} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Empty divs for the top arrow and the bottom arrow of the transfer inset */}
|
||||
@@ -135,6 +125,10 @@ export function TransferParticipants({
|
||||
<path d="M0,0L8,9l8,-9Z" />
|
||||
</svg>
|
||||
</div>
|
||||
{/*
|
||||
<div className="z-10 absolute top-0 left-1/2 transform -translate-x-1/2 -translate-y-1/2 rotate-45 w-4 h-4 dark:border-vega-dark-200 border-vega-light-200 bg-white dark:bg-black border-r border-b"></div>
|
||||
<div className="z-10 absolute bottom-0 left-1/2 transform -translate-x-1/2 translate-y-1/2 rotate-45 w-4 h-4 border-vega-light-200 dark:border-vega-dark-200 bg-vega-light-200 dark:bg-vega-dark-200 border-r border-b"></div>
|
||||
*/}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -175,38 +169,3 @@ export function TransferRecurringRecipient({
|
||||
// Fallback should not happen
|
||||
return null;
|
||||
}
|
||||
|
||||
export function TransferFees({
|
||||
assetId,
|
||||
fees,
|
||||
}: {
|
||||
assetId: string;
|
||||
fees: TransferFee[];
|
||||
}) {
|
||||
// A recurring transfer that is rejected or cancelled will have an array of fees of 0 length
|
||||
if (assetId && fees && fees.length > 0) {
|
||||
if (fees.length === 1) {
|
||||
return (
|
||||
<p className="mt-2">
|
||||
Fee: <SizeInAsset assetId={assetId} size={fees[0].amount} />
|
||||
</p>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<details className="cursor-pointer mt-2">
|
||||
<summary>{t('Fees')}</summary>
|
||||
<ul>
|
||||
{fees.map((fee) => (
|
||||
<li className="text-nowrap leading-normal">
|
||||
<SizeInAsset assetId={assetId} size={fee.amount} />{' '}
|
||||
{t('in epoch')} {fee.epoch}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,16 +41,9 @@ export function TransferDetails({ transfer, from, id }: TransferDetailsProps) {
|
||||
? TransferStatus.STATUS_REJECTED
|
||||
: data?.transfer?.transfer.status;
|
||||
|
||||
const fees = data?.transfer?.fees?.map((fee) => {
|
||||
return {
|
||||
amount: fee?.amount ? fee.amount : '0',
|
||||
epoch: fee?.epoch ? fee.epoch : 0,
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap">
|
||||
<TransferParticipants from={from} transfer={transfer} fees={fees} />
|
||||
<TransferParticipants from={from} transfer={transfer} />
|
||||
{recurring ? <TransferRepeat recurring={transfer.recurring} /> : null}
|
||||
<TransferStatusView status={status} error={error} loading={loading} />
|
||||
{recurring && recurring.dispatchStrategy ? (
|
||||
|
||||
@@ -113,16 +113,13 @@ export const TxDetailsTransfer = ({
|
||||
|
||||
/**
|
||||
* Gets a string description of this transfer
|
||||
* @param tx A full transfer
|
||||
* @param txData A full transfer
|
||||
* @returns string Transfer label
|
||||
*/
|
||||
export function getTypeLabelForTransfer(tx: Transfer) {
|
||||
if (tx.to === SPECIAL_CASE_NETWORK || tx.to === SPECIAL_CASE_NETWORK_ID) {
|
||||
if (tx.toAccountType === 'ACCOUNT_TYPE_NETWORK_TREASURY') {
|
||||
return 'Treasury transfer';
|
||||
}
|
||||
if (tx.recurring && tx.recurring.dispatchStrategy) {
|
||||
return 'Reward transfer';
|
||||
return 'Reward top up transfer';
|
||||
}
|
||||
// Else: we don't know that it's a reward transfer, so let's not guess
|
||||
} else if (tx.recurring) {
|
||||
|
||||
@@ -16,12 +16,12 @@ import { FilterLabel } from './tx-filter-label';
|
||||
|
||||
// All possible transaction types. Should be generated.
|
||||
export type FilterOption =
|
||||
| 'Amend Liquidity Provision Order'
|
||||
| 'Amend LiquidityProvision Order'
|
||||
| 'Amend Order'
|
||||
| 'Apply Referral Code'
|
||||
| 'Batch Market Instructions'
|
||||
| 'Batch Proposal'
|
||||
| 'Cancel Liquidity Provision Order'
|
||||
| 'Cancel LiquidityProvision Order'
|
||||
| 'Cancel Order'
|
||||
| 'Cancel Transfer Funds'
|
||||
| 'Chain Event'
|
||||
@@ -53,10 +53,10 @@ export type FilterOption =
|
||||
|
||||
export const filterOptions: Record<string, FilterOption[]> = {
|
||||
'Market Instructions': [
|
||||
'Amend Liquidity Provision Order',
|
||||
'Amend LiquidityProvision Order',
|
||||
'Amend Order',
|
||||
'Batch Market Instructions',
|
||||
'Cancel Liquidity Provision Order',
|
||||
'Cancel LiquidityProvision Order',
|
||||
'Cancel Order',
|
||||
'Liquidity Provision Order',
|
||||
'Stop Orders Submission',
|
||||
|
||||
@@ -2,7 +2,6 @@ import { t } from '@vegaprotocol/i18n';
|
||||
import type { components } from '../../../types/explorer';
|
||||
import { VoteIcon } from '../vote-icon/vote-icon';
|
||||
import { ExternalChainIcon } from '../links/external-explorer-link/external-chain-icon';
|
||||
import { getTypeLabelForTransfer } from './details/tx-transfer';
|
||||
|
||||
interface TxOrderTypeProps {
|
||||
orderType: string;
|
||||
@@ -96,7 +95,7 @@ export function getLabelForOrderType(
|
||||
|
||||
/**
|
||||
* Given a proposal, will return a specific label
|
||||
* @param proposal
|
||||
* @param chainEvent
|
||||
* @returns
|
||||
*/
|
||||
export function getLabelForProposal(
|
||||
@@ -143,36 +142,6 @@ export function getLabelForProposal(
|
||||
}
|
||||
}
|
||||
|
||||
type label = {
|
||||
type: string;
|
||||
colours: string;
|
||||
};
|
||||
|
||||
export function getLabelForTransfer(
|
||||
transfer: components['schemas']['commandsv1Transfer']
|
||||
): label {
|
||||
const type = getTypeLabelForTransfer(transfer);
|
||||
|
||||
if (transfer.toAccountType === 'ACCOUNT_TYPE_NETWORK_TREASURY') {
|
||||
return {
|
||||
type,
|
||||
colours:
|
||||
'text-vega-green dark:text-green bg-vega-dark-150 dark:bg-vega-dark-250',
|
||||
};
|
||||
} else if (transfer.recurring) {
|
||||
return {
|
||||
type,
|
||||
colours:
|
||||
'text-vega-yellow dark:text-yellow bg-vega-dark-150 dark:bg-vega-dark-250',
|
||||
};
|
||||
}
|
||||
return {
|
||||
type,
|
||||
colours:
|
||||
'text-white dark:text-white bg-vega-dark-150 dark:bg-vega-dark-250',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a chain event, will try to provide a more useful label
|
||||
* @param chainEvent
|
||||
@@ -256,10 +225,9 @@ export const TxOrderType = ({ orderType, command }: TxOrderTypeProps) => {
|
||||
if (type === 'Chain Event' && !!command?.chainEvent) {
|
||||
type = getLabelForChainEvent(command.chainEvent);
|
||||
colours = 'text-white dark-text-white bg-vega-pink dark:bg-vega-pink';
|
||||
} else if (type === 'Transfer Funds' && command?.transfer) {
|
||||
const res = getLabelForTransfer(command.transfer);
|
||||
type = res.type;
|
||||
colours = res.colours;
|
||||
} else if (type === 'Validator Heartbeat') {
|
||||
colours =
|
||||
'text-white dark-text-white bg-vega-light-200 dark:bg-vega-dark-100';
|
||||
} else if (type === 'Proposal' || type === 'Governance Proposal') {
|
||||
if (command && !!command.proposalSubmission) {
|
||||
type = getLabelForProposal(command.proposalSubmission);
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('TX: Transfer: getLabelForTransfer', () => {
|
||||
},
|
||||
};
|
||||
|
||||
expect(getTypeLabelForTransfer(mock)).toEqual('Reward transfer');
|
||||
expect(getTypeLabelForTransfer(mock)).toEqual('Reward top up transfer');
|
||||
});
|
||||
|
||||
it('renders reward top up label if the TO party is network', () => {
|
||||
@@ -32,7 +32,7 @@ describe('TX: Transfer: getLabelForTransfer', () => {
|
||||
},
|
||||
};
|
||||
|
||||
expect(getTypeLabelForTransfer(mock)).toEqual('Reward transfer');
|
||||
expect(getTypeLabelForTransfer(mock)).toEqual('Reward top up transfer');
|
||||
});
|
||||
|
||||
it('renders recurring label if the tx has a recurring property', () => {
|
||||
@@ -81,7 +81,6 @@ describe('TxDetailsTransfer', () => {
|
||||
hash: 'test',
|
||||
submitter:
|
||||
'e1943eea46fed576cf2be42972f3c5515ad3d0ac7ac013f56677c12a53a1b3ed',
|
||||
block: '100',
|
||||
command: {
|
||||
nonce: '5188810881378065222',
|
||||
blockHeight: '14951513',
|
||||
|
||||
@@ -16,8 +16,6 @@ import { useBlockInfo } from '@vegaprotocol/tendermint';
|
||||
import { NodeLink } from '../../../components/links';
|
||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||
import EmptyList from '../../../components/empty-list/empty-list';
|
||||
import { useExplorerEpochForBlockQuery } from '../../../components/links/block-link/__generated__/EpochByBlock';
|
||||
import EpochOverview from '../../../components/epoch-overview/epoch';
|
||||
|
||||
type Params = { block: string };
|
||||
|
||||
@@ -28,11 +26,6 @@ const Block = () => {
|
||||
state: { data: blockData, loading, error },
|
||||
} = useBlockInfo(Number(block));
|
||||
|
||||
const { data } = useExplorerEpochForBlockQuery({
|
||||
errorPolicy: 'ignore',
|
||||
variables: { block: block?.toString() || '' },
|
||||
});
|
||||
|
||||
return (
|
||||
<section>
|
||||
<RouteTitle data-testid="block-header">{t(`BLOCK ${block}`)}</RouteTitle>
|
||||
@@ -82,7 +75,6 @@ const Block = () => {
|
||||
<code>{blockData.result.block.header.consensus_hash}</code>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row">Mined by</TableHeader>
|
||||
<TableCell modifier="bordered">
|
||||
@@ -105,14 +97,6 @@ const Block = () => {
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{data && data.epoch && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableCell scope="row">{t('Epoch')}</TableCell>
|
||||
<TableCell modifier="bordered">
|
||||
<EpochOverview id={data.epoch.id} icon={false} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row">Transactions</TableHeader>
|
||||
<TableCell modifier="bordered">
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useScrollToLocation } from '../../hooks/scroll-to-location';
|
||||
import { useDocumentTitle } from '../../hooks/use-document-title';
|
||||
import { PageTitle } from '../../components/page-helpers/page-title';
|
||||
import { useExplorerOracleForMarketQuery } from '../oracles/__generated__/OraclesForMarkets';
|
||||
import { OraclesTable } from '../../components/oracle-table';
|
||||
|
||||
type Params = { marketId: string };
|
||||
|
||||
export const MarketOraclesPage = () => {
|
||||
useScrollToLocation();
|
||||
|
||||
const { marketId } = useParams<Params>();
|
||||
const { data, error, loading } = useExplorerOracleForMarketQuery({
|
||||
errorPolicy: 'ignore',
|
||||
variables: {
|
||||
id: marketId || '1',
|
||||
},
|
||||
});
|
||||
|
||||
useDocumentTitle([marketId ? marketId : 'market', 'Oracles for Market']);
|
||||
|
||||
return (
|
||||
<section className="relative">
|
||||
<PageTitle
|
||||
data-testid="markets-heading"
|
||||
title={t('Oracles for market')}
|
||||
/>
|
||||
<AsyncRenderer
|
||||
noDataMessage={t('This chain has no markets')}
|
||||
errorMessage={t('Could not fetch market') + ' ' + marketId}
|
||||
data={data}
|
||||
loading={loading}
|
||||
error={error}
|
||||
>
|
||||
<OraclesTable data={data} />
|
||||
</AsyncRenderer>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useScrollToLocation } from '../../hooks/scroll-to-location';
|
||||
import { useDocumentTitle } from '../../hooks/use-document-title';
|
||||
import { marketsWithDataProvider } from '@vegaprotocol/markets';
|
||||
import { marketsProvider } from '@vegaprotocol/markets';
|
||||
import { RouteTitle } from '../../components/route-title';
|
||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
@@ -12,7 +12,7 @@ export const MarketsPage = () => {
|
||||
useScrollToLocation();
|
||||
|
||||
const { data, loading, error } = useDataProvider({
|
||||
dataProvider: marketsWithDataProvider,
|
||||
dataProvider: marketsProvider,
|
||||
variables: undefined,
|
||||
skipUpdates: true,
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
addDecimalsFormatNumber,
|
||||
formatNumber,
|
||||
removePaginationWrapper,
|
||||
suitableForSyntaxHighlighter,
|
||||
validForSyntaxHighlighter,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { RouteTitle } from '../../components/route-title';
|
||||
@@ -134,7 +134,7 @@ export const NetworkParameterRow = ({
|
||||
}: {
|
||||
row: { key: string; value: string };
|
||||
}) => {
|
||||
const isSyntaxRow = suitableForSyntaxHighlighter(value);
|
||||
const isSyntaxRow = validForSyntaxHighlighter(value);
|
||||
useDocumentTitle(['Network Parameters']);
|
||||
|
||||
return (
|
||||
|
||||
@@ -89,40 +89,7 @@ fragment ExplorerOracleDataSourceSpec on ExternalDataSourceSpec {
|
||||
}
|
||||
|
||||
query ExplorerOracleFormMarkets {
|
||||
marketsConnection(includeSettled: false, pagination: { first: 20 }) {
|
||||
edges {
|
||||
node {
|
||||
...ExplorerOracleForMarketsMarket
|
||||
}
|
||||
}
|
||||
}
|
||||
oracleSpecsConnection {
|
||||
edges {
|
||||
node {
|
||||
dataSourceSpec {
|
||||
...ExplorerOracleDataSourceSpec
|
||||
}
|
||||
dataConnection(pagination: { first: 1 }) {
|
||||
edges {
|
||||
node {
|
||||
externalData {
|
||||
data {
|
||||
data {
|
||||
name
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query ExplorerOracleForMarket($id: ID!) {
|
||||
marketsConnection(id: $id) {
|
||||
marketsConnection {
|
||||
edges {
|
||||
node {
|
||||
...ExplorerOracleForMarketsMarket
|
||||
|
||||
@@ -16,13 +16,6 @@ export type ExplorerOracleFormMarketsQueryVariables = Types.Exact<{ [key: string
|
||||
|
||||
export type ExplorerOracleFormMarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Spot' } } } } }> } | null, oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string, sourceChainId: number } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
|
||||
export type ExplorerOracleForMarketQueryVariables = Types.Exact<{
|
||||
id: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type ExplorerOracleForMarketQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Perpetual', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus } } | { __typename?: 'Spot' } } } } }> } | null, oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } | { __typename?: 'EthCallSpec', address: string, sourceChainId: number } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null>, triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null> } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null };
|
||||
|
||||
export const ExplorerOracleFutureFragmentDoc = gql`
|
||||
fragment ExplorerOracleFuture on Future {
|
||||
dataSourceSpecForSettlementData {
|
||||
@@ -120,7 +113,7 @@ export const ExplorerOracleDataSourceSpecFragmentDoc = gql`
|
||||
`;
|
||||
export const ExplorerOracleFormMarketsDocument = gql`
|
||||
query ExplorerOracleFormMarkets {
|
||||
marketsConnection(includeSettled: false, pagination: {first: 20}) {
|
||||
marketsConnection {
|
||||
edges {
|
||||
node {
|
||||
...ExplorerOracleForMarketsMarket
|
||||
@@ -133,7 +126,7 @@ export const ExplorerOracleFormMarketsDocument = gql`
|
||||
dataSourceSpec {
|
||||
...ExplorerOracleDataSourceSpec
|
||||
}
|
||||
dataConnection(pagination: {first: 1}) {
|
||||
dataConnection(pagination: {last: 1}) {
|
||||
edges {
|
||||
node {
|
||||
externalData {
|
||||
@@ -179,67 +172,4 @@ export function useExplorerOracleFormMarketsLazyQuery(baseOptions?: Apollo.LazyQ
|
||||
}
|
||||
export type ExplorerOracleFormMarketsQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsQuery>;
|
||||
export type ExplorerOracleFormMarketsLazyQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsLazyQuery>;
|
||||
export type ExplorerOracleFormMarketsQueryResult = Apollo.QueryResult<ExplorerOracleFormMarketsQuery, ExplorerOracleFormMarketsQueryVariables>;
|
||||
export const ExplorerOracleForMarketDocument = gql`
|
||||
query ExplorerOracleForMarket($id: ID!) {
|
||||
marketsConnection(id: $id) {
|
||||
edges {
|
||||
node {
|
||||
...ExplorerOracleForMarketsMarket
|
||||
}
|
||||
}
|
||||
}
|
||||
oracleSpecsConnection {
|
||||
edges {
|
||||
node {
|
||||
dataSourceSpec {
|
||||
...ExplorerOracleDataSourceSpec
|
||||
}
|
||||
dataConnection(pagination: {last: 1}) {
|
||||
edges {
|
||||
node {
|
||||
externalData {
|
||||
data {
|
||||
data {
|
||||
name
|
||||
value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${ExplorerOracleForMarketsMarketFragmentDoc}
|
||||
${ExplorerOracleDataSourceSpecFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useExplorerOracleForMarketQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useExplorerOracleForMarketQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useExplorerOracleForMarketQuery` 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 } = useExplorerOracleForMarketQuery({
|
||||
* variables: {
|
||||
* id: // value for 'id'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useExplorerOracleForMarketQuery(baseOptions: Apollo.QueryHookOptions<ExplorerOracleForMarketQuery, ExplorerOracleForMarketQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<ExplorerOracleForMarketQuery, ExplorerOracleForMarketQueryVariables>(ExplorerOracleForMarketDocument, options);
|
||||
}
|
||||
export function useExplorerOracleForMarketLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerOracleForMarketQuery, ExplorerOracleForMarketQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<ExplorerOracleForMarketQuery, ExplorerOracleForMarketQueryVariables>(ExplorerOracleForMarketDocument, options);
|
||||
}
|
||||
export type ExplorerOracleForMarketQueryHookResult = ReturnType<typeof useExplorerOracleForMarketQuery>;
|
||||
export type ExplorerOracleForMarketLazyQueryHookResult = ReturnType<typeof useExplorerOracleForMarketLazyQuery>;
|
||||
export type ExplorerOracleForMarketQueryResult = Apollo.QueryResult<ExplorerOracleForMarketQuery, ExplorerOracleForMarketQueryVariables>;
|
||||
export type ExplorerOracleFormMarketsQueryResult = Apollo.QueryResult<ExplorerOracleFormMarketsQuery, ExplorerOracleFormMarketsQueryVariables>;
|
||||
@@ -4,13 +4,8 @@ import {
|
||||
ExternalExplorerLink,
|
||||
EthExplorerLinkTypes,
|
||||
} from '../../../components/links/external-explorer-link/external-explorer-link';
|
||||
import { getExternalChainLabel } from '@vegaprotocol/environment';
|
||||
import { getExternalChainLabel } from '../../../components/links/external-explorer-link/external-chain';
|
||||
import { t } from 'i18next';
|
||||
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
|
||||
import isArray from 'lodash/isArray';
|
||||
import type { components } from '../../../../types/explorer';
|
||||
|
||||
type Normalisers = components['schemas']['vegaNormaliser'][];
|
||||
|
||||
interface OracleDetailsEthSourceProps {
|
||||
sourceType: SourceType;
|
||||
@@ -39,117 +34,21 @@ export function OracleEthSource({
|
||||
|
||||
const chainLabel = getExternalChainLabel(chain);
|
||||
|
||||
const abi = prepareOracleSpecField(sourceType?.sourceType?.abi);
|
||||
const args = prepareOracleSpecField(sourceType?.sourceType?.args);
|
||||
const normalisers = serialiseNormalisers(sourceType.sourceType.normalisers);
|
||||
|
||||
return (
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row" className="pt-1 align-text-top">
|
||||
<TableHeader scope="row">
|
||||
{chainLabel} {t('Contract')}
|
||||
</TableHeader>
|
||||
<TableCell modifier="bordered">
|
||||
<details>
|
||||
<summary className="cursor-pointer">
|
||||
<ExternalExplorerLink
|
||||
chain={chain}
|
||||
id={address}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
code={true}
|
||||
/>
|
||||
<span className="mx-3">⇒</span>
|
||||
<code>{sourceType.sourceType.method}</code>
|
||||
</summary>
|
||||
|
||||
{args && (
|
||||
<>
|
||||
<h2 className={'mt-5 mb-1 text-xl'}>{t('Arguments')}</h2>
|
||||
<div className="max-w-3">
|
||||
<SyntaxHighlighter
|
||||
data={JSON.parse(
|
||||
sourceType.sourceType.args as unknown as string
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{abi && (
|
||||
<>
|
||||
<h2 className={'mt-5 mb-1 text-xl'}>{t('ABI')}</h2>
|
||||
<div className="max-w-3">
|
||||
<SyntaxHighlighter data={abi} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{normalisers && (
|
||||
<>
|
||||
<h2 className={'mt-5 mb-1 text-xl'}>{t('Normalisers')}</h2>
|
||||
<div className="max-w-3 mb-3">
|
||||
<SyntaxHighlighter data={normalisers} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</details>
|
||||
<ExternalExplorerLink
|
||||
chain={chain}
|
||||
id={address}
|
||||
type={EthExplorerLinkTypes.address}
|
||||
code={true}
|
||||
/>
|
||||
<span className="mx-3">⇒</span>
|
||||
<code>{sourceType.sourceType.method}</code>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
}
|
||||
|
||||
// Constant to define the absence of a valid string from the Oracle Spec fields
|
||||
const NO_DATA = false;
|
||||
|
||||
/**
|
||||
* The ABI and args are stored as either a (JSON escaped, probably) string
|
||||
* or array of strings. Given that OracleEthSource is simply throwing the
|
||||
* data in to a SyntaxHighlighter, we don't really care about the format,
|
||||
* so this function will just try to parse the data and return it as a string.
|
||||
*
|
||||
* @param abi
|
||||
* @returns
|
||||
*/
|
||||
export function prepareOracleSpecField(
|
||||
specField?: string[] | null
|
||||
): string | false {
|
||||
if (!specField) {
|
||||
return NO_DATA;
|
||||
}
|
||||
|
||||
try {
|
||||
if (isArray(specField)) {
|
||||
return JSON.parse(specField.join(''));
|
||||
} else {
|
||||
return JSON.parse(specField);
|
||||
}
|
||||
} catch (e) {
|
||||
return NO_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to prepareOracleSpecField above, but processes an array of normaliser objects
|
||||
* removing the __typename and returning a serialised array of normalisers for
|
||||
* SyntaxHighlighter
|
||||
*
|
||||
* @param normalisers
|
||||
* @returns
|
||||
*/
|
||||
export function serialiseNormalisers(
|
||||
normalisers?: Normalisers | null
|
||||
): Normalisers | false {
|
||||
if (!normalisers) {
|
||||
return NO_DATA;
|
||||
}
|
||||
|
||||
try {
|
||||
return normalisers.map((normaliser) => {
|
||||
return {
|
||||
name: normaliser.name,
|
||||
expression: normaliser.expression,
|
||||
};
|
||||
});
|
||||
} catch (e) {
|
||||
return NO_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { OracleFilter } from './oracle-filter';
|
||||
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
||||
import { ConditionOperator, DataSourceSpecStatus } from '@vegaprotocol/types';
|
||||
import {
|
||||
ConditionOperator,
|
||||
DataSourceSpecStatus,
|
||||
PropertyKeyType,
|
||||
} from '@vegaprotocol/types';
|
||||
import type { Condition } from '@vegaprotocol/types';
|
||||
|
||||
type Spec =
|
||||
ExplorerOracleDataSourceFragment['dataSourceSpec']['spec']['data']['sourceType'];
|
||||
|
||||
const mockExternalSpec: Spec = {
|
||||
sourceType: {
|
||||
__typename: 'DataSourceSpecConfiguration',
|
||||
filters: [
|
||||
{
|
||||
__typename: 'Filter',
|
||||
key: {
|
||||
type: PropertyKeyType.TYPE_INTEGER,
|
||||
name: 'testKey',
|
||||
},
|
||||
conditions: [
|
||||
{
|
||||
__typename: 'Condition',
|
||||
value: 'testValue',
|
||||
operator: ConditionOperator.OPERATOR_EQUALS,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
function renderComponent(data: ExplorerOracleDataSourceFragment) {
|
||||
return <OracleFilter data={data} />;
|
||||
}
|
||||
@@ -21,6 +50,31 @@ describe('Oracle Filter view', () => {
|
||||
expect(res.container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
it('Renders filters if type is DataSourceSpecConfiguration', () => {
|
||||
const res = render(
|
||||
renderComponent({
|
||||
dataSourceSpec: {
|
||||
spec: {
|
||||
id: 'irrelevant-test-data',
|
||||
createdAt: 'irrelevant-test-data',
|
||||
status: DataSourceSpecStatus.STATUS_ACTIVE,
|
||||
data: {
|
||||
sourceType: mockExternalSpec,
|
||||
},
|
||||
},
|
||||
},
|
||||
dataConnection: {
|
||||
edges: [],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Renders a comprehensible summary of key = value
|
||||
expect(res.getByText('testKey')).toBeInTheDocument();
|
||||
expect(res.getByText('=')).toBeInTheDocument();
|
||||
expect(res.getByText('testValue')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Renders conditions if type is DataSourceSpecConfigurationTime', () => {
|
||||
const res = render(
|
||||
renderComponent({
|
||||
@@ -82,7 +136,7 @@ describe('Oracle Filter view', () => {
|
||||
})
|
||||
);
|
||||
|
||||
// This should never happen, but for coverage we test that it does this
|
||||
// This should never happen, but for coverage sake we test that it does this
|
||||
const ul = res.getByRole('list');
|
||||
expect(ul).toBeInTheDocument();
|
||||
expect(ul).toBeEmptyDOMElement();
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
||||
import {
|
||||
OracleSpecInternalTimeTrigger,
|
||||
TimeTrigger,
|
||||
} from './oracle-spec/internal-time-trigger';
|
||||
import { OracleSpecInternalTimeTrigger } from './oracle-spec/internal-time-trigger';
|
||||
import { OracleSpecCondition } from './oracle-spec/condition';
|
||||
import { getCharacterForOperator } from './oracle-spec/operator';
|
||||
|
||||
@@ -14,7 +11,7 @@ interface OracleFilterProps {
|
||||
* Shows the conditions that this oracle is using to filter
|
||||
* data sources, as a list.
|
||||
*
|
||||
* Renders nothing if there is no data (which will frequently
|
||||
* Renders nothing if there is no data (which will frequently)
|
||||
* be the case) and if there is data, currently renders a simple
|
||||
* JSON view.
|
||||
*/
|
||||
@@ -24,7 +21,6 @@ export function OracleFilter({ data }: OracleFilterProps) {
|
||||
}
|
||||
|
||||
const s = data.dataSourceSpec.spec.data.sourceType.sourceType;
|
||||
|
||||
if (s.__typename === 'DataSourceSpecConfigurationTime' && s.conditions) {
|
||||
return (
|
||||
<ul>
|
||||
@@ -45,30 +41,30 @@ export function OracleFilter({ data }: OracleFilterProps) {
|
||||
s.triggers
|
||||
) {
|
||||
return <OracleSpecInternalTimeTrigger data={s} />;
|
||||
} else if (s.__typename === 'EthCallSpec') {
|
||||
} else if (
|
||||
s.__typename === 'EthCallSpec' ||
|
||||
s.__typename === 'DataSourceSpecConfiguration'
|
||||
) {
|
||||
if (s.filters !== null && s.filters && 'filters' in s) {
|
||||
return (
|
||||
<div>
|
||||
<ul>
|
||||
{s.filters.map((f) => {
|
||||
const prop = <code title={f.key.type}>{f.key.name}</code>;
|
||||
<ul>
|
||||
{s.filters.map((f) => {
|
||||
const prop = <code title={f.key.type}>{f.key.name}</code>;
|
||||
|
||||
if (!f.conditions || f.conditions.length === 0) {
|
||||
return prop;
|
||||
} else {
|
||||
return f.conditions.map((c) => {
|
||||
return (
|
||||
<li key={`${prop}${c.value}`}>
|
||||
{prop} {getCharacterForOperator(c.operator)}{' '}
|
||||
<code>{c.value ? c.value : '-'}</code>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
}
|
||||
})}
|
||||
</ul>
|
||||
{s.trigger && <TimeTrigger data={s.trigger.trigger} />}
|
||||
</div>
|
||||
if (!f.conditions || f.conditions.length === 0) {
|
||||
return prop;
|
||||
} else {
|
||||
return f.conditions.map((c) => {
|
||||
return (
|
||||
<li key={`${prop}${c.value}`}>
|
||||
{prop} {getCharacterForOperator(c.operator)}{' '}
|
||||
<code>{c.value ? c.value : '-'}</code>
|
||||
</li>
|
||||
);
|
||||
});
|
||||
}
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+27
-60
@@ -1,10 +1,5 @@
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import type {
|
||||
DataSourceSpecConfigurationTimeTrigger,
|
||||
EthTimeTrigger,
|
||||
InternalTimeTrigger,
|
||||
Maybe,
|
||||
} from '@vegaprotocol/types';
|
||||
import type { DataSourceSpecConfigurationTimeTrigger } from '@vegaprotocol/types';
|
||||
import secondsToMinutes from 'date-fns/secondsToMinutes';
|
||||
import fromUnixTime from 'date-fns/fromUnixTime';
|
||||
|
||||
@@ -18,60 +13,32 @@ export function OracleSpecInternalTimeTrigger({
|
||||
return (
|
||||
<div>
|
||||
<span>{t('Time')}</span>,
|
||||
{data.triggers.map((tr) => (
|
||||
<TimeTrigger data={tr} />
|
||||
))}
|
||||
{data.triggers.map((tr) => {
|
||||
return (
|
||||
<span>
|
||||
{tr?.initial ? (
|
||||
<span title={`${tr.initial}`}>
|
||||
<strong>{t('starting at')}</strong>{' '}
|
||||
<em className="not-italic underline decoration-dotted">
|
||||
{fromUnixTime(tr.initial).toLocaleString()}
|
||||
</em>
|
||||
</span>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{tr?.every ? (
|
||||
<span title={`${tr.every} ${t('seconds')}`}>
|
||||
, <strong>{t('every')}</strong>{' '}
|
||||
<em className="not-italic underline decoration-dotted">
|
||||
{secondsToMinutes(tr.every)} {t('minutes')}
|
||||
</em>{' '}
|
||||
</span>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export interface TimeTriggerProps {
|
||||
data: Maybe<InternalTimeTrigger> | Maybe<EthTimeTrigger>;
|
||||
}
|
||||
|
||||
export function TimeTrigger({ data }: TimeTriggerProps) {
|
||||
const d = parseDate(data?.initial);
|
||||
|
||||
return (
|
||||
<span key={JSON.stringify(data)}>
|
||||
{data?.initial ? (
|
||||
<span title={`${data.initial}`}>
|
||||
<strong>{t('starting at')}</strong>{' '}
|
||||
<em className="not-italic underline decoration-dotted">{d}</em>
|
||||
</span>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{data?.every ? (
|
||||
<span title={`${data.every} ${t('seconds')}`}>
|
||||
, <strong>{t('every')}</strong>{' '}
|
||||
<em className="not-italic underline decor</em>ation-dotted">
|
||||
{secondsToMinutes(data.every)} {t('minutes')}
|
||||
</em>{' '}
|
||||
</span>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dates in oracle triggers can be (or maybe were previously) Unix Time or timestamps
|
||||
* depending on type. This function handles both cases and returns a nicely formatted date.
|
||||
*
|
||||
* @param date
|
||||
* @returns string Localestring for date
|
||||
*/
|
||||
export function parseDate(date?: string | number): string {
|
||||
if (!date) {
|
||||
return 'Invalid date';
|
||||
}
|
||||
const d = fromUnixTime(+date).toLocaleString();
|
||||
|
||||
if (d === 'Invalid Date') {
|
||||
return new Date(date).toLocaleString();
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,6 @@ export const OracleDetails = ({
|
||||
? dataSource.dataSourceSpec.spec.data.sourceType.sourceType.sourceChainId.toString()
|
||||
: undefined;
|
||||
|
||||
const requiredConfirmations =
|
||||
(sourceType.sourceType.__typename === 'EthCallSpec' &&
|
||||
sourceType.sourceType.requiredConfirmations) ||
|
||||
'';
|
||||
|
||||
return (
|
||||
<div>
|
||||
<TableWithTbody className="mb-2">
|
||||
@@ -69,23 +64,15 @@ export const OracleDetails = ({
|
||||
{getStatusString(dataSource.dataSourceSpec.spec.status)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<OracleMarkets id={id} />
|
||||
<OracleSigners sourceType={sourceType} />
|
||||
<OracleEthSource sourceType={sourceType} chain={chain} />
|
||||
<OracleMarkets id={id} />
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row" className="pt-1 align-text-top">
|
||||
{t('Filter')}
|
||||
</TableHeader>
|
||||
<TableHeader scope="row">{t('Filter')}</TableHeader>
|
||||
<TableCell modifier="bordered">
|
||||
<OracleFilter data={dataSource} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{requiredConfirmations && requiredConfirmations > 0 && (
|
||||
<TableRow modifier="bordered">
|
||||
<TableHeader scope="row">{t('Required Confirmations')}</TableHeader>
|
||||
<TableCell modifier="bordered">{requiredConfirmations}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableWithTbody>
|
||||
{dataConnection ? <OracleData data={dataConnection} /> : null}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import compact from 'lodash/compact';
|
||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { RouteTitle } from '../../../components/route-title';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||
import { useScrollToLocation } from '../../../hooks/scroll-to-location';
|
||||
import { useExplorerOracleFormMarketsQuery } from '../__generated__/OraclesForMarkets';
|
||||
import { OraclesTable } from '../../../components/oracle-table';
|
||||
import { MarketLink } from '../../../components/links';
|
||||
import { OracleLink } from '../../../components/links/oracle-link/oracle-link';
|
||||
import { useState } from 'react';
|
||||
import { MarketStateMapping } from '@vegaprotocol/types';
|
||||
import type { MarketState } from '@vegaprotocol/types';
|
||||
|
||||
const cellSpacing = 'px-3';
|
||||
|
||||
const Oracles = () => {
|
||||
const { data, loading, error } = useExplorerOracleFormMarketsQuery({
|
||||
@@ -14,6 +21,8 @@ const Oracles = () => {
|
||||
useDocumentTitle(['Oracles']);
|
||||
useScrollToLocation();
|
||||
|
||||
const [hoveredOracle, setHoveredOracle] = useState('');
|
||||
|
||||
return (
|
||||
<section>
|
||||
<RouteTitle data-testid="oracle-specs-heading">{t('Oracles')}</RouteTitle>
|
||||
@@ -29,7 +38,148 @@ const Oracles = () => {
|
||||
data.oracleSpecsConnection.edges?.length === 0
|
||||
}
|
||||
>
|
||||
<OraclesTable data={data} />
|
||||
<table className="text-left">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className={cellSpacing}>Market</th>
|
||||
<th className={cellSpacing}>Type</th>
|
||||
<th className={cellSpacing}>State</th>
|
||||
<th className={cellSpacing}>Settlement</th>
|
||||
<th className={cellSpacing}>Termination</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data?.marketsConnection?.edges
|
||||
? data.marketsConnection.edges.map((o) => {
|
||||
let hasSeenOracleReports = false;
|
||||
let settlementOracle = '-';
|
||||
let settlementOracleStatus = '-';
|
||||
let terminationOracle = '-';
|
||||
let terminationOracleStatus = '-';
|
||||
|
||||
const id = o?.node.id;
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
o.node.tradableInstrument.instrument.product.__typename ===
|
||||
'Future'
|
||||
) {
|
||||
settlementOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.id;
|
||||
terminationOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.id;
|
||||
settlementOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.status;
|
||||
terminationOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForTradingTermination.status;
|
||||
} else if (
|
||||
o.node.tradableInstrument.instrument.product.__typename ===
|
||||
'Perpetual'
|
||||
) {
|
||||
settlementOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.id;
|
||||
terminationOracle =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementSchedule.id;
|
||||
settlementOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementData.status;
|
||||
terminationOracleStatus =
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.dataSourceSpecForSettlementSchedule.status;
|
||||
}
|
||||
const oracleInformationUnfiltered =
|
||||
data?.oracleSpecsConnection?.edges?.map((e) =>
|
||||
e && e.node ? e.node : undefined
|
||||
) || [];
|
||||
|
||||
const oracleInformation = compact(oracleInformationUnfiltered)
|
||||
.filter(
|
||||
(o) =>
|
||||
o.dataConnection.edges &&
|
||||
o.dataConnection.edges.length > 0 &&
|
||||
(o.dataSourceSpec.spec.id === settlementOracle ||
|
||||
o.dataSourceSpec.spec.id === terminationOracle)
|
||||
)
|
||||
.at(0);
|
||||
if (oracleInformation) {
|
||||
hasSeenOracleReports = true;
|
||||
}
|
||||
|
||||
const oracleList = `${settlementOracle} ${terminationOracle}`;
|
||||
|
||||
return (
|
||||
<tr
|
||||
id={id}
|
||||
key={id}
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
oracleList.indexOf(hoveredOracle) > -1
|
||||
? 'bg-gray-100 dark:bg-gray-800'
|
||||
: ''
|
||||
}
|
||||
data-testid="oracle-details"
|
||||
data-oracles={oracleList}
|
||||
>
|
||||
<td className={cellSpacing}>
|
||||
<MarketLink id={id} />
|
||||
</td>
|
||||
<td className={cellSpacing}>
|
||||
{
|
||||
o.node.tradableInstrument.instrument.product
|
||||
.__typename
|
||||
}
|
||||
</td>
|
||||
<td className={cellSpacing}>
|
||||
{MarketStateMapping[o.node.state as MarketState]}
|
||||
</td>
|
||||
<td
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
hoveredOracle === settlementOracle
|
||||
? `indent-1 ${cellSpacing}`
|
||||
: cellSpacing
|
||||
}
|
||||
>
|
||||
<OracleLink
|
||||
id={settlementOracle}
|
||||
status={settlementOracleStatus}
|
||||
hasSeenOracleReports={hasSeenOracleReports}
|
||||
onMouseOver={() => setHoveredOracle(settlementOracle)}
|
||||
onMouseOut={() => setHoveredOracle('')}
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className={
|
||||
hoveredOracle.length > 0 &&
|
||||
hoveredOracle === terminationOracle
|
||||
? `indent-1 ${cellSpacing}`
|
||||
: cellSpacing
|
||||
}
|
||||
>
|
||||
<OracleLink
|
||||
id={terminationOracle}
|
||||
status={terminationOracleStatus}
|
||||
hasSeenOracleReports={hasSeenOracleReports}
|
||||
onMouseOver={() =>
|
||||
setHoveredOracle(terminationOracle)
|
||||
}
|
||||
onMouseOut={() => setHoveredOracle('')}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
: null}
|
||||
</tbody>
|
||||
</table>
|
||||
</AsyncRenderer>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useMemo, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { SubHeading } from '../../../components/sub-heading';
|
||||
import { toNonHex } from '../../../components/search/detect-search';
|
||||
import { getInitialFilters, useTxsData } from '../../../hooks/use-txs-data';
|
||||
import { useTxsData } from '../../../hooks/use-txs-data';
|
||||
import { TxsInfiniteList } from '../../../components/txs';
|
||||
import { PageHeader } from '../../../components/page-header';
|
||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||
@@ -15,18 +15,16 @@ import { PartyBlockAccounts } from './components/party-block-accounts';
|
||||
import { isValidPartyId } from './components/party-id-error';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import { TxsListNavigation } from '../../../components/txs/tx-list-navigation';
|
||||
import {
|
||||
TxsFilter,
|
||||
type FilterOption,
|
||||
} from '../../../components/txs/tx-filter';
|
||||
import type { FilterOption } from '../../../components/txs/tx-filter';
|
||||
import { AllFilterOptions, TxsFilter } from '../../../components/txs/tx-filter';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
type Params = { party: string };
|
||||
|
||||
const Party = () => {
|
||||
const [params] = useSearchParams();
|
||||
const [filters, setFilters] = useState(getInitialFilters(params));
|
||||
|
||||
const [filters, setFilters] = useState(new Set(AllFilterOptions));
|
||||
const { party } = useParams<Params>();
|
||||
|
||||
useDocumentTitle(['Public keys', party || '-']);
|
||||
|
||||
@@ -5,8 +5,9 @@ import Home from './home';
|
||||
import OraclePage from './oracles';
|
||||
import Oracles from './oracles/home';
|
||||
import { Oracle } from './oracles/id';
|
||||
import Party from './parties';
|
||||
import { Parties } from './parties/home';
|
||||
import { Party } from './parties/id';
|
||||
import { Party as PartySingle } from './parties/id';
|
||||
import { ValidatorsPage } from './validators';
|
||||
import Genesis from './genesis';
|
||||
import { Block } from './blocks/id';
|
||||
@@ -16,7 +17,6 @@ import { TxsList } from './txs/home';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { Routes } from './route-names';
|
||||
import { NetworkParameters } from './network-parameters';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import type { Params, RouteObject } from 'react-router-dom';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { MarketPage, MarketsPage } from './markets';
|
||||
@@ -31,7 +31,6 @@ import { Disclaimer } from './pages/disclaimer';
|
||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
||||
import RestrictedPage from './restricted';
|
||||
import { NetworkTreasury } from './treasury';
|
||||
import { MarketOraclesPage } from './markets/market-oracles-page';
|
||||
|
||||
export type Navigable = {
|
||||
path: string;
|
||||
@@ -68,7 +67,7 @@ export const useRouterConfig = () => {
|
||||
? [
|
||||
{
|
||||
path: Routes.PARTIES,
|
||||
element: <Outlet />,
|
||||
element: <Party />,
|
||||
handle: {
|
||||
name: t('Parties'),
|
||||
text: t('Parties'),
|
||||
@@ -81,12 +80,12 @@ export const useRouterConfig = () => {
|
||||
},
|
||||
{
|
||||
path: ':party',
|
||||
element: <Outlet />,
|
||||
element: <Party />,
|
||||
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
element: <Party />,
|
||||
element: <PartySingle />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => (
|
||||
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
||||
@@ -97,7 +96,7 @@ export const useRouterConfig = () => {
|
||||
},
|
||||
{
|
||||
path: 'assets',
|
||||
element: <Outlet />,
|
||||
element: <Party />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => (
|
||||
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
||||
@@ -200,36 +199,12 @@ export const useRouterConfig = () => {
|
||||
},
|
||||
{
|
||||
path: ':marketId',
|
||||
element: <Outlet />,
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
element: <MarketPage />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => (
|
||||
<MarketLink id={params.marketId as string} />
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'oracles',
|
||||
element: <Outlet />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => (
|
||||
<MarketLink id={params.marketId as string} />
|
||||
),
|
||||
},
|
||||
children: [
|
||||
{
|
||||
index: true,
|
||||
element: <MarketOraclesPage />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => t('Oracles'),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
element: <MarketPage />,
|
||||
handle: {
|
||||
breadcrumb: (params: Params<string>) => (
|
||||
<MarketLink id={params.marketId as string} />
|
||||
),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -33,10 +33,7 @@ export const NetworkAccountsTable = () => {
|
||||
return (
|
||||
<section className="md:flex md:flex-row flex-wrap">
|
||||
{c.map((a) => (
|
||||
<div
|
||||
className="basis-1/2 md:basis-1/4"
|
||||
key={`${a.assetId}-${a.balance}`}
|
||||
>
|
||||
<div className="basis-1/2 md:basis-1/4">
|
||||
<div className="bg-white rounded overflow-hidden shadow-lg dark:bg-black dark:border-slate-500 dark:border">
|
||||
<div className="text-center p-6 bg-gray-100 dark:bg-slate-900 border-b dark:border-slate-500">
|
||||
<p className="flex justify-center">
|
||||
|
||||
@@ -16,21 +16,19 @@ import type { DeepPartial } from '@apollo/client/utilities';
|
||||
|
||||
describe('typeLabel', () => {
|
||||
it('should return "Transfer" for "OneOffTransfer" kind', () => {
|
||||
expect(typeLabel('OneOffTransfer')).toBe('Transfer - one time');
|
||||
expect(typeLabel('OneOffTransfer')).toBe('Transfer');
|
||||
});
|
||||
|
||||
it('should return "Transfer" for "RecurringTransfer" kind', () => {
|
||||
expect(typeLabel('RecurringTransfer')).toBe('Transfer - repeating');
|
||||
expect(typeLabel('RecurringTransfer')).toBe('Transfer');
|
||||
});
|
||||
|
||||
it('should return "Governance" for "OneOffGovernanceTransfer" kind', () => {
|
||||
expect(typeLabel('OneOffGovernanceTransfer')).toBe('Governance - one time');
|
||||
expect(typeLabel('OneOffGovernanceTransfer')).toBe('Governance');
|
||||
});
|
||||
|
||||
it('should return "Governance" for "RecurringGovernanceTransfer" kind', () => {
|
||||
expect(typeLabel('RecurringGovernanceTransfer')).toBe(
|
||||
'Governance - repeating'
|
||||
);
|
||||
expect(typeLabel('RecurringGovernanceTransfer')).toBe('Governance');
|
||||
});
|
||||
|
||||
it('should return "Unknown" for unknown kind', () => {
|
||||
@@ -258,7 +256,7 @@ describe('NetworkTransfersTable', () => {
|
||||
expect(screen.getByTestId('from-account').textContent).toEqual('Treasury');
|
||||
expect(screen.getByTestId('to-account').textContent).toEqual('7100…97a0');
|
||||
expect(screen.getByTestId('transfer-kind').textContent).toEqual(
|
||||
'Governance - one time'
|
||||
'Governance'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ import { t } from '@vegaprotocol/i18n';
|
||||
import { IconNames } from '@blueprintjs/icons';
|
||||
import { useMemo } from 'react';
|
||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||
import ProposalLink from '../../../components/links/proposal-link/proposal-link';
|
||||
|
||||
export const colours = {
|
||||
INCOMING: '!fill-vega-green-600 text-vega-green-600 mr-2',
|
||||
@@ -51,24 +50,14 @@ export function getToAccountTypeLabel(type?: AccountType): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function isGovernanceTransfer(kind?: string): boolean {
|
||||
if (kind && kind.includes('Governance')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function typeLabel(kind?: string): string {
|
||||
switch (kind) {
|
||||
case 'OneOffTransfer':
|
||||
return t('Transfer - one time');
|
||||
case 'RecurringTransfer':
|
||||
return t('Transfer - repeating');
|
||||
return t('Transfer');
|
||||
case 'OneOffGovernanceTransfer':
|
||||
return t('Governance - one time');
|
||||
case 'RecurringGovernanceTransfer':
|
||||
return t('Governance - repeating');
|
||||
return t('Governance');
|
||||
default:
|
||||
return t('Unknown');
|
||||
}
|
||||
@@ -250,11 +239,6 @@ export const NetworkTransfersTable = () => {
|
||||
>
|
||||
{a && typeLabel(a.kind.__typename)}
|
||||
</span>
|
||||
{isGovernanceTransfer(a?.kind.__typename) && a?.id && (
|
||||
<span className="ml-4">
|
||||
<ProposalLink id={a?.id} text="View" />
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { t } from '@vegaprotocol/i18n';
|
||||
import { RouteTitle } from '../../components/route-title';
|
||||
import { NetworkAccountsTable } from './components/network-accounts-table';
|
||||
import { NetworkTransfersTable } from './components/network-transfers-table';
|
||||
import GovernanceLink from '../../components/links/governance-link/governance-link';
|
||||
|
||||
export type NonZeroAccount = {
|
||||
assetId: string;
|
||||
@@ -17,33 +16,7 @@ export const NetworkTreasury = () => {
|
||||
return (
|
||||
<section>
|
||||
<RouteTitle data-testid="block-header">{t(`Treasury`)}</RouteTitle>
|
||||
<details className="w-full md:w-3/5 cursor-pointer shadow-lg p-5 dark:border-l-2 dark:border-vega-green">
|
||||
<summary>{t('About the Network Treasury')}</summary>
|
||||
<section className="mt-4 b-1 border-grey">
|
||||
<p className="mb-2">
|
||||
The network treasury can hold funds from any active settlement asset
|
||||
on the network. It is funded periodically by transfers from Gobalsky
|
||||
as part of the Community Adoption Fund (CAF), but in future may
|
||||
receive funds from any sources.
|
||||
</p>
|
||||
<p className="mb-2">
|
||||
Funds in the network treasury can be used by creating governance
|
||||
initiated transfers via{' '}
|
||||
<GovernanceLink text={t('community governance')} />. These transfers
|
||||
can be initiated by anyone and be used to fund reward pools, or can
|
||||
be used to fund other activities the{' '}
|
||||
<abbr className="decoration-dotted" title="Community Adoption Fund">
|
||||
CAF
|
||||
</abbr>{' '}
|
||||
is exploring.
|
||||
</p>
|
||||
<p>
|
||||
This page shows details of the balances in the treasury, pending
|
||||
transfers, and historic transfer movements to and from the treasury.
|
||||
</p>
|
||||
</section>
|
||||
</details>
|
||||
<div className="mt-6">
|
||||
<div>
|
||||
<NetworkAccountsTable />
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
||||
NX_VEGA_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
||||
|
||||
@@ -47,7 +47,7 @@ export const SubHeading = ({
|
||||
|
||||
return (
|
||||
<h2
|
||||
className={classNames('text-2xl font-alpha calt break-words', {
|
||||
className={classNames('text-2xl font-alpha calt uppercase break-words', {
|
||||
'mx-auto': centerContent,
|
||||
'mb-0': !marginBottom,
|
||||
'mb-4': marginBottom,
|
||||
|
||||
@@ -41,7 +41,7 @@ export const ContractAddresses: {
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||
lockedAddress: '0x0', // TODO not deployed to this env
|
||||
},
|
||||
VALIDATORS_TESTNET: {
|
||||
VALIDATOR_TESTNET: {
|
||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||
lockedAddress: '0x0', // TODO not deployed to this env
|
||||
// This is a fallback contract address for the validator testnet network which does not
|
||||
|
||||
@@ -6,11 +6,10 @@ import {
|
||||
ViewPartyConnector,
|
||||
createConfig,
|
||||
fairground,
|
||||
validatorsTestnet,
|
||||
stagnet,
|
||||
mainnet,
|
||||
} from '@vegaprotocol/wallet';
|
||||
import { CHAIN_IDS, useEnvironment } from '@vegaprotocol/environment';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
|
||||
export const useVegaWalletConfig = () => {
|
||||
const { VEGA_ENV, VEGA_URL, VEGA_WALLET_URL } = useEnvironment();
|
||||
@@ -32,8 +31,8 @@ export const useVegaWalletConfig = () => {
|
||||
const viewParty = new ViewPartyConnector();
|
||||
|
||||
const config = createConfig({
|
||||
chains: [mainnet, fairground, validatorsTestnet, stagnet],
|
||||
defaultChainId: CHAIN_IDS[VEGA_ENV],
|
||||
chains: [mainnet, fairground, stagnet],
|
||||
defaultChainId: fairground.id,
|
||||
connectors: [injected, snap, jsonRpc, viewParty],
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ i18n
|
||||
load: 'languageOnly',
|
||||
debug: isInDev,
|
||||
// have a common namespace used around the full app
|
||||
ns: ['governance', 'wallet', 'wallet-react', 'assets', 'utils'],
|
||||
ns: ['governance', 'wallet', 'wallet-react'],
|
||||
defaultNS: 'governance',
|
||||
keySeparator: false, // we use content as keys
|
||||
nsSeparator: false,
|
||||
|
||||
+1
-4
@@ -38,7 +38,6 @@ import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||
import { MarketName } from '../proposal/market-name';
|
||||
import { Indicator } from '../proposal/indicator';
|
||||
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||
|
||||
const ProposalTypeTags = ({
|
||||
proposal,
|
||||
@@ -541,12 +540,10 @@ const BatchProposalStateText = ({
|
||||
|
||||
export const ProposalHeader = ({
|
||||
proposal,
|
||||
restData,
|
||||
isListItem = true,
|
||||
voteState,
|
||||
}: {
|
||||
proposal: Proposal | BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
isListItem?: boolean;
|
||||
voteState?: VoteState | null;
|
||||
}) => {
|
||||
@@ -598,7 +595,7 @@ export const ProposalHeader = ({
|
||||
)}
|
||||
</div>
|
||||
<ProposalDetails proposal={proposal} />
|
||||
<VoteBreakdown proposal={proposal} restData={restData} />
|
||||
<VoteBreakdown proposal={proposal} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
+46
-33
@@ -19,7 +19,6 @@ import {
|
||||
getSigners,
|
||||
MarginScalingFactorsPanel,
|
||||
marketInfoProvider,
|
||||
PriceMonitoringSettingsInfoPanel,
|
||||
} from '@vegaprotocol/markets';
|
||||
import {
|
||||
Button,
|
||||
@@ -50,7 +49,7 @@ export const useMarketDataDialogStore = create<MarketDataDialogState>(
|
||||
const marketDataHeaderStyles =
|
||||
'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2';
|
||||
|
||||
export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
||||
const { t } = useTranslation();
|
||||
const { isOpen, open, close } = useMarketDataDialogStore();
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
@@ -59,7 +58,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
dataProvider: marketInfoProvider,
|
||||
skipUpdates: true,
|
||||
variables: {
|
||||
marketId: marketId,
|
||||
marketId: proposalId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -72,7 +71,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
},
|
||||
});
|
||||
|
||||
if (!marketData) {
|
||||
if (!marketData || !parentMarketData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -134,13 +133,13 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
<h2 className={marketDataHeaderStyles}>{t('Key details')}</h2>
|
||||
<KeyDetailsInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData ? parentMarketData : undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>{t('Instrument')}</h2>
|
||||
<InstrumentInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData ? parentMarketData : undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
{settlementData &&
|
||||
@@ -156,7 +155,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
isParentSettlementDataEqual ||
|
||||
isParentSettlementScheduleDataEqual
|
||||
? undefined
|
||||
: parentMarketData || undefined
|
||||
: parentMarketData
|
||||
}
|
||||
/>
|
||||
</>
|
||||
@@ -169,9 +168,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
market={marketData}
|
||||
type="settlementData"
|
||||
parentMarket={
|
||||
isParentSettlementDataEqual
|
||||
? undefined
|
||||
: parentMarketData || undefined
|
||||
isParentSettlementDataEqual ? undefined : parentMarketData
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -187,7 +184,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
parentMarket={
|
||||
isParentTerminationDataEqual
|
||||
? undefined
|
||||
: parentMarketData || undefined
|
||||
: parentMarketData
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
@@ -205,7 +202,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
parentMarket={
|
||||
isParentSettlementScheduleDataEqual
|
||||
? undefined
|
||||
: parentMarketData || undefined
|
||||
: parentMarketData
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
@@ -219,19 +216,19 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
<h2 className={marketDataHeaderStyles}>{t('Settlement assets')}</h2>
|
||||
<SettlementAssetInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>{t('Metadata')}</h2>
|
||||
<MetadataInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>{t('Risk model')}</h2>
|
||||
<RiskModelInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
@@ -239,45 +236,61 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
</h2>
|
||||
<MarginScalingFactorsPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>{t('Risk factors')}</h2>
|
||||
<RiskFactorsInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
{showParentPriceMonitoringBounds && (
|
||||
// shows bounds for parent market
|
||||
{showParentPriceMonitoringBounds &&
|
||||
(
|
||||
parentMarketData?.priceMonitoringSettings?.parameters
|
||||
?.triggers || []
|
||||
).map((_, triggerIndex) => (
|
||||
<>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t(`Parent price monitoring bounds ${triggerIndex + 1}`)}
|
||||
</h2>
|
||||
|
||||
<div className="text-vega-dark-300 line-through">
|
||||
<PriceMonitoringBoundsInfoPanel
|
||||
market={parentMarketData}
|
||||
triggerIndex={triggerIndex}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
))}
|
||||
|
||||
{(
|
||||
marketData.priceMonitoringSettings?.parameters?.triggers || []
|
||||
).map((_, triggerIndex) => (
|
||||
<>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Parent price monitoring bounds')}
|
||||
{t(`Price monitoring bounds ${triggerIndex + 1}`)}
|
||||
</h2>
|
||||
<div className="text-vega-dark-300 line-through">
|
||||
<PriceMonitoringBoundsInfoPanel market={parentMarketData} />
|
||||
</div>
|
||||
|
||||
<PriceMonitoringBoundsInfoPanel
|
||||
market={marketData}
|
||||
triggerIndex={triggerIndex}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Price monitoring settings')}
|
||||
</h2>
|
||||
<PriceMonitoringSettingsInfoPanel market={marketData} />
|
||||
|
||||
))}
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Liquidity monitoring parameters')}
|
||||
</h2>
|
||||
<LiquidityMonitoringParametersInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
{t('Liquidity price range')}
|
||||
</h2>
|
||||
<LiquidityPriceRangeInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
|
||||
<h2 className={marketDataHeaderStyles}>
|
||||
@@ -285,7 +298,7 @@ export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||
</h2>
|
||||
<LiquiditySLAParametersInfoPanel
|
||||
market={marketData}
|
||||
parentMarket={parentMarketData || undefined}
|
||||
parentMarket={parentMarketData}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
+2
-16
@@ -17,20 +17,17 @@ import { type ProposalNode } from './proposal-utils';
|
||||
import { Lozenge } from '@vegaprotocol/ui-toolkit';
|
||||
import { Indicator } from './indicator';
|
||||
import { SubHeading } from '../../../../components/heading';
|
||||
import { determineId } from '@vegaprotocol/wallet';
|
||||
|
||||
export const ProposalChangeDetails = ({
|
||||
proposal,
|
||||
terms,
|
||||
restData,
|
||||
indicator,
|
||||
termsCount = 0,
|
||||
}: {
|
||||
proposal: Proposal | BatchProposal;
|
||||
terms: ProposalTermsFieldsFragment;
|
||||
restData: ProposalNode | null;
|
||||
indicator?: number;
|
||||
termsCount?: number;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
let details = null;
|
||||
@@ -64,18 +61,7 @@ export const ProposalChangeDetails = ({
|
||||
}
|
||||
case 'NewMarket': {
|
||||
if (proposal.id) {
|
||||
let marketId = proposal.id;
|
||||
|
||||
// TODO: when https://github.com/vegaprotocol/vega/issues/11005 gets merged
|
||||
// this will need to be updated to loop forward from 0. Right now subProposals
|
||||
// are returned (when using GQL) in the reverse order
|
||||
if (proposal.__typename === 'BatchProposal') {
|
||||
for (let i = termsCount - 1; i >= 0; i--) {
|
||||
marketId = determineId(marketId);
|
||||
}
|
||||
}
|
||||
|
||||
details = <ProposalMarketData marketId={marketId} />;
|
||||
details = <ProposalMarketData proposalId={proposal.id} />;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -83,7 +69,7 @@ export const ProposalChangeDetails = ({
|
||||
if (proposal.id) {
|
||||
details = (
|
||||
<div className="flex flex-col gap-4">
|
||||
<ProposalMarketData marketId={proposal.id} />
|
||||
<ProposalMarketData proposalId={proposal.id} />
|
||||
<ProposalMarketChanges
|
||||
indicator={indicator}
|
||||
marketId={terms.change.marketId}
|
||||
|
||||
@@ -91,28 +91,6 @@ export type ProposalNode = {
|
||||
proposal: ProposalData;
|
||||
proposalType: ProposalNodeType;
|
||||
proposals: SubProposalData[];
|
||||
yes?: [
|
||||
{
|
||||
partyId: string;
|
||||
elsPerMarket?: [
|
||||
{
|
||||
marketId: string;
|
||||
els: string;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
no?: [
|
||||
{
|
||||
partyId: string;
|
||||
elsPerMarket?: [
|
||||
{
|
||||
marketId: string;
|
||||
els: string;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
type SingleProposalNode = ProposalNode & {
|
||||
|
||||
@@ -48,7 +48,6 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
||||
|
||||
<ProposalHeader
|
||||
proposal={proposal}
|
||||
restData={restData}
|
||||
isListItem={false}
|
||||
voteState={voteState}
|
||||
/>
|
||||
@@ -78,7 +77,6 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
||||
proposal={proposal}
|
||||
terms={p.terms}
|
||||
restData={restData}
|
||||
termsCount={proposal.subProposals?.length}
|
||||
/>
|
||||
);
|
||||
})
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
import { useBatchVoteInformation } from '../../hooks/use-vote-information';
|
||||
import { MarketName } from '../proposal/market-name';
|
||||
import { Indicator } from '../proposal/indicator';
|
||||
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||
|
||||
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
||||
<CompactNumber
|
||||
@@ -111,64 +110,24 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
||||
|
||||
export const VoteBreakdown = ({
|
||||
proposal,
|
||||
restData,
|
||||
}: {
|
||||
proposal: Proposal | BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
}) => {
|
||||
if (proposal.__typename === 'Proposal') {
|
||||
return <VoteBreakdownNormal proposal={proposal} />;
|
||||
}
|
||||
|
||||
if (proposal.__typename === 'BatchProposal') {
|
||||
return <VoteBreakdownBatch proposal={proposal} restData={restData} />;
|
||||
return <VoteBreakdownBatch proposal={proposal} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const VoteBreakdownBatch = ({
|
||||
proposal,
|
||||
restData,
|
||||
}: {
|
||||
proposal: BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
}) => {
|
||||
const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
||||
const [fullBreakdown, setFullBreakdown] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const yesELS =
|
||||
restData?.yes?.reduce((all, y) => {
|
||||
if (y.elsPerMarket) {
|
||||
y.elsPerMarket.forEach((item) => {
|
||||
const share = Number(item.els);
|
||||
if (all[item.marketId]) {
|
||||
all[item.marketId].push(share);
|
||||
} else {
|
||||
all[item.marketId] = [share];
|
||||
}
|
||||
return all;
|
||||
});
|
||||
}
|
||||
return all;
|
||||
}, {} as Record<string, number[]>) || {};
|
||||
|
||||
const noELS =
|
||||
restData?.no?.reduce((all, y) => {
|
||||
if (y.elsPerMarket) {
|
||||
y.elsPerMarket.forEach((item) => {
|
||||
const share = Number(item.els);
|
||||
if (all[item.marketId]) {
|
||||
all[item.marketId].push(share);
|
||||
} else {
|
||||
all[item.marketId] = [share];
|
||||
}
|
||||
return all;
|
||||
});
|
||||
}
|
||||
return all;
|
||||
}, {} as Record<string, number[]>) || {};
|
||||
|
||||
const voteInfo = useBatchVoteInformation({
|
||||
terms: compact(
|
||||
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
|
||||
@@ -235,8 +194,6 @@ const VoteBreakdownBatch = ({
|
||||
proposal={proposal}
|
||||
votes={proposal.votes}
|
||||
terms={p.terms}
|
||||
yesELS={yesELS}
|
||||
noELS={noELS}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -297,8 +254,6 @@ const VoteBreakdownBatch = ({
|
||||
proposal={proposal}
|
||||
votes={proposal.votes}
|
||||
terms={p.terms}
|
||||
yesELS={yesELS}
|
||||
noELS={noELS}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -316,17 +271,17 @@ const VoteBreakdownBatchSubProposal = ({
|
||||
votes,
|
||||
terms,
|
||||
indicator,
|
||||
yesELS,
|
||||
noELS,
|
||||
}: {
|
||||
proposal: BatchProposal;
|
||||
votes: VoteFieldsFragment;
|
||||
terms: ProposalTermsFieldsFragment;
|
||||
indicator?: number;
|
||||
yesELS: Record<string, number[]>;
|
||||
noELS: Record<string, number[]>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const voteInfo = useVoteInformation({
|
||||
votes,
|
||||
terms,
|
||||
});
|
||||
|
||||
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
||||
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
|
||||
@@ -339,15 +294,6 @@ const VoteBreakdownBatchSubProposal = ({
|
||||
marketId = terms.change.market.id;
|
||||
}
|
||||
|
||||
const voteInfo = useVoteInformation({
|
||||
votes,
|
||||
terms,
|
||||
// yes votes ELS for this specific proposal (market)
|
||||
yesELS: marketId ? yesELS[marketId] : undefined,
|
||||
// no votes ELS for this specific proposal (market)
|
||||
noELS: marketId ? noELS[marketId] : undefined,
|
||||
});
|
||||
|
||||
const marketName = marketId ? (
|
||||
<>
|
||||
: <MarketName marketId={marketId} />
|
||||
|
||||
@@ -8,18 +8,13 @@ import {
|
||||
type VoteFieldsFragment,
|
||||
} from '../__generated__/Proposals';
|
||||
import { type ProposalChangeType } from '../types';
|
||||
import sum from 'lodash/sum';
|
||||
|
||||
export const useVoteInformation = ({
|
||||
votes,
|
||||
terms,
|
||||
yesELS,
|
||||
noELS,
|
||||
}: {
|
||||
votes: VoteFieldsFragment;
|
||||
terms: ProposalTermsFieldsFragment;
|
||||
yesELS?: number[];
|
||||
noELS?: number[];
|
||||
}) => {
|
||||
const {
|
||||
appState: { totalSupply, decimals },
|
||||
@@ -36,9 +31,7 @@ export const useVoteInformation = ({
|
||||
paramsForChange,
|
||||
votes,
|
||||
totalSupply,
|
||||
decimals,
|
||||
yesELS,
|
||||
noELS
|
||||
decimals
|
||||
);
|
||||
};
|
||||
|
||||
@@ -79,11 +72,7 @@ const getVoteData = (
|
||||
},
|
||||
votes: ProposalFieldsFragment['votes'],
|
||||
totalSupply: BigNumber,
|
||||
decimals: number,
|
||||
/** A list of ELS yes votes */
|
||||
yesELS?: number[],
|
||||
/** A list if ELS no votes */
|
||||
noELS?: number[]
|
||||
decimals: number
|
||||
) => {
|
||||
const requiredMajorityPercentage = params.requiredMajority
|
||||
? new BigNumber(params.requiredMajority).times(100)
|
||||
@@ -97,31 +86,17 @@ const getVoteData = (
|
||||
addDecimal(votes.no.totalTokens ?? 0, decimals)
|
||||
);
|
||||
|
||||
let noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||
const noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||
? new BigNumber(0)
|
||||
: new BigNumber(votes.no.totalEquityLikeShareWeight).times(100);
|
||||
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
|
||||
// it has to be deduced from `elsPerMarket` of `no` votes of given proposal
|
||||
// data. (by REST DATA)
|
||||
if (noELS != null) {
|
||||
const noTotalELS = sum(noELS);
|
||||
noEquityLikeShareWeight = new BigNumber(noTotalELS).times(100);
|
||||
}
|
||||
|
||||
const yesTokens = new BigNumber(
|
||||
addDecimal(votes.yes.totalTokens ?? 0, decimals)
|
||||
);
|
||||
|
||||
let yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||
const yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||
? new BigNumber(0)
|
||||
: new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100);
|
||||
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
|
||||
// it has to be deduced from `elsPerMarket` of `yes` votes of given proposal
|
||||
// data. (by REST DATA)
|
||||
if (noELS != null) {
|
||||
const yesTotalELS = sum(yesELS);
|
||||
yesEquityLikeShareWeight = new BigNumber(yesTotalELS).times(100);
|
||||
}
|
||||
|
||||
const totalTokensVoted = yesTokens.plus(noTokens);
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { suitableForSyntaxHighlighter } from '@vegaprotocol/utils';
|
||||
import { validForSyntaxHighlighter } from '@vegaprotocol/utils';
|
||||
import { useNetworkParams } from '@vegaprotocol/network-parameters';
|
||||
import {
|
||||
getClosingTimestamp,
|
||||
@@ -46,7 +46,7 @@ const SelectedNetworkParamCurrentValue = ({
|
||||
<div className="mb-4">
|
||||
<p className="text-sm text-white">{t('CurrentValue')}</p>
|
||||
|
||||
{suitableForSyntaxHighlighter(value) ? (
|
||||
{validForSyntaxHighlighter(value) ? (
|
||||
<SyntaxHighlighter data={JSON.parse(value)} />
|
||||
) : (
|
||||
<Input
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
doesValueEquateToParam,
|
||||
} from '@vegaprotocol/proposals';
|
||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||
import { useValidateJson } from '@vegaprotocol/utils';
|
||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
doesValueEquateToParam,
|
||||
} from '@vegaprotocol/proposals';
|
||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||
import { useValidateJson } from '@vegaprotocol/utils';
|
||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
RoundedWrapper,
|
||||
TextArea,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { useValidateJson } from '@vegaprotocol/utils';
|
||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
doesValueEquateToParam,
|
||||
} from '@vegaprotocol/proposals';
|
||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||
import { useValidateJson } from '@vegaprotocol/utils';
|
||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
||||
useProposalSubmit,
|
||||
} from '@vegaprotocol/proposals';
|
||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||
import { useValidateJson } from '@vegaprotocol/utils';
|
||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
NetworkParams,
|
||||
useNetworkParams,
|
||||
|
||||
-1
@@ -61,7 +61,6 @@ const mockConsensusValidators: NodesFragmentFragment[] = [
|
||||
];
|
||||
|
||||
jest.mock('@vegaprotocol/environment', () => ({
|
||||
...jest.requireActual('@vegaprotocol/environment'),
|
||||
useVegaRelease: jest.fn(),
|
||||
useVegaReleases: jest.fn(),
|
||||
}));
|
||||
|
||||
@@ -3,6 +3,8 @@ export const VALIDATOR_LOGO_MAP: { [key: string]: string } = {
|
||||
'https://pbs.twimg.com/profile_images/1586047492629712897/ZVMWBE94_400x400.jpg',
|
||||
efbdf943443bd7595e83b0d7e88f37b7932d487d1b94aab3d004997273bb43fc:
|
||||
'https://pbs.twimg.com/profile_images/1026823609979949057/3e-LCHHm_400x400.jpg',
|
||||
'126751c5830b50d39eb85412fb2964f46338cce6946ff455b73f1b1be3f5e8cc':
|
||||
'https://pbs.twimg.com/profile_images/1228627868542029824/9aoaLiIx_400x400.jpg',
|
||||
'43697a3e911d8b70c0ce672adde17a5c38ca8f6a0486bf85ed0546e1b9a82887':
|
||||
'https://pbs.twimg.com/profile_images/1352167987478843392/XzX82gIb_400x400.jpg',
|
||||
ac735acc9ab11cf1d8c59c2df2107e00092b4ac96451cb137a1629af5b66242a:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
|
||||
h1 {
|
||||
@apply text-2xl text-white mb-4;
|
||||
@apply text-2xl text-white uppercase mb-4;
|
||||
}
|
||||
h2 {
|
||||
@apply text-xl text-white mb-4;
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.tom
|
||||
NX_VEGA_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||
NX_VEGA_NETWORKS={'{"TESTNET":"https://multisig-signer.fairground.wtf","MAINNET":"https://multisig-signer.vega.xyz"}'
|
||||
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
||||
|
||||
@@ -21,7 +21,6 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||
NX_ISOLATED_MARGIN=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
@@ -21,8 +21,6 @@ NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supp
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=false
|
||||
NX_STOP_ORDERS=false
|
||||
NX_TAKE_PROFIT_STOP_LOSS=false
|
||||
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||
NX_ISOLATED_MARGIN=true
|
||||
# NX_ICEBERG_ORDERS
|
||||
# NX_PRODUCT_PERPETUALS
|
||||
|
||||
@@ -21,7 +21,6 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_TAKE_PROFIT_STOP_LOSS=false
|
||||
NX_ISOLATED_MARGIN=false
|
||||
NX_ICEBERG_ORDERS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
@@ -21,7 +21,6 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||
NX_ISOLATED_MARGIN=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
# NX_PRODUCT_PERPETUALS
|
||||
|
||||
@@ -22,7 +22,6 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||
NX_ISOLATED_MARGIN=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
@@ -4,7 +4,7 @@ NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
|
||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
||||
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks
|
||||
NX_VEGA_NETWORKS={\"MAINNET\":\"https://console.vega.xyz\",\"STAGNET1\":\"https://trading.stagnet1.vega.rocks\",\"TESTNET\":\"https://console.fairground.wtf\"}
|
||||
NX_VEGA_TOKEN_URL=https://governance.validators-testnet.vega.rocks
|
||||
@@ -22,7 +22,6 @@ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/m
|
||||
# Cosmic elevator flags
|
||||
NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||
NX_ISOLATED_MARGIN=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
# NX_PRODUCT_PERPETUALS
|
||||
|
||||
@@ -9,10 +9,6 @@ import {
|
||||
Button,
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
Tooltip,
|
||||
TradingAnchorButton,
|
||||
Intent,
|
||||
CopyWithTooltip,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { TransferStatus, type Asset } from '@vegaprotocol/types';
|
||||
import classNames from 'classnames';
|
||||
@@ -21,7 +17,7 @@ import { Table } from '../../components/table';
|
||||
import {
|
||||
addDecimalsFormatNumberQuantum,
|
||||
formatNumber,
|
||||
removePaginationWrapper,
|
||||
getDateTimeFormat,
|
||||
} from '@vegaprotocol/utils';
|
||||
import {
|
||||
useTeam,
|
||||
@@ -45,6 +41,10 @@ import {
|
||||
} from '../../lib/hooks/use-games';
|
||||
import { useEpochInfoQuery } from '../../lib/hooks/__generated__/Epoch';
|
||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import {
|
||||
ActiveRewardCard,
|
||||
DispatchMetricInfo,
|
||||
} from '../../components/rewards-container/active-rewards';
|
||||
import { type MarketMap, useMarketsMapProvider } from '@vegaprotocol/markets';
|
||||
import format from 'date-fns/format';
|
||||
import {
|
||||
@@ -52,13 +52,6 @@ import {
|
||||
isScopedToTeams,
|
||||
useRewards,
|
||||
} from '../../lib/hooks/use-rewards';
|
||||
import {
|
||||
ActiveRewardCard,
|
||||
DispatchMetricInfo,
|
||||
} from '../../components/rewards-container/reward-card';
|
||||
import { usePartyProfilesQuery } from '../../components/vega-wallet-connect-button/__generated__/PartyProfiles';
|
||||
|
||||
const formatDate = (date: Date) => format(date, 'yyyy/MM/dd hh:mm:ss');
|
||||
|
||||
export const CompetitionsTeam = () => {
|
||||
const t = useT();
|
||||
@@ -147,25 +140,11 @@ const TeamPage = ({
|
||||
const t = useT();
|
||||
const [showGames, setShowGames] = useState(true);
|
||||
|
||||
const createdAt = new Date(team.createdAt);
|
||||
|
||||
const closedIndicator = team.closed ? (
|
||||
<div className="border rounded border-vega-clight-300 dark:border-vega-cdark-300 px-1 pt-[1px] flex items-baseline gap-1">
|
||||
<VegaIcon name={VegaIconNames.LOCK} size={10} />
|
||||
<span>{t('Private')}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="border rounded border-vega-clight-300 dark:border-vega-cdark-300 px-1 pt-[1px] flex items-baseline gap-1">
|
||||
<VegaIcon name={VegaIconNames.GLOBE} size={10} />
|
||||
<span>{t('Public')}</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<LayoutWithGradient>
|
||||
<header className="flex gap-3 lg:gap-4 pt-5 lg:pt-10">
|
||||
<TeamAvatar teamId={team.teamId} imgUrl={team.avatarUrl} />
|
||||
<div className="flex flex-col items-start gap-1 lg:gap-2">
|
||||
<div className="flex flex-col items-start gap-1 lg:gap-3">
|
||||
<h1
|
||||
className="calt text-2xl lg:text-3xl xl:text-5xl"
|
||||
data-testid="team-name"
|
||||
@@ -175,38 +154,6 @@ const TeamPage = ({
|
||||
<div className="flex gap-2">
|
||||
<JoinTeam team={team} partyTeam={partyTeam} refetch={refetch} />
|
||||
<UpdateTeamButton team={team} />
|
||||
{team.teamUrl && team.teamUrl.length > 0 && (
|
||||
<Tooltip description={t("Visit the team's page.")}>
|
||||
<span>
|
||||
<TradingAnchorButton
|
||||
intent={Intent.Info}
|
||||
target="_blank"
|
||||
referrerPolicy="no-referrer"
|
||||
href={team.teamUrl}
|
||||
>
|
||||
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={16} />
|
||||
</TradingAnchorButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
<CopyWithTooltip
|
||||
description={t('Copy this page url.')}
|
||||
text={globalThis.location.href}
|
||||
>
|
||||
<button className="h-10 w-7">
|
||||
<VegaIcon name={VegaIconNames.COPY} size={16} />
|
||||
</button>
|
||||
</CopyWithTooltip>
|
||||
</div>
|
||||
<div className="flex gap-2 items-baseline text-xs text-muted font-alpha calt">
|
||||
{closedIndicator}
|
||||
<div className="">
|
||||
{t('Created at')}:{' '}
|
||||
<span className="text-vega-cdark-600 dark:text-vega-clight-600 ">
|
||||
{formatDate(createdAt)}
|
||||
</span>{' '}
|
||||
({t('epoch')}: {team.createdAtEpoch})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -283,138 +230,118 @@ const Games = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<Table
|
||||
columns={[
|
||||
{
|
||||
name: 'epoch',
|
||||
displayName: t('Epoch'),
|
||||
},
|
||||
{
|
||||
name: 'endtime',
|
||||
displayName: t('End time'),
|
||||
},
|
||||
{ name: 'type', displayName: t('Type') },
|
||||
{
|
||||
name: 'asset',
|
||||
displayName: t('Reward asset'),
|
||||
},
|
||||
{ name: 'daily', displayName: t('Daily reward amount') },
|
||||
{ name: 'rank', displayName: t('Rank') },
|
||||
{ name: 'amount', displayName: t('Amount earned this epoch') },
|
||||
{ name: 'total', displayName: t('Cumulative amount earned') },
|
||||
{
|
||||
name: 'participatingTeams',
|
||||
displayName: t('No. of participating teams'),
|
||||
},
|
||||
{
|
||||
name: 'participatingMembers',
|
||||
displayName: t('No. of participating members'),
|
||||
},
|
||||
].map((c) => ({ ...c, headerClassName: 'text-left' }))}
|
||||
data={games.map((game) => {
|
||||
let transfer = transfers?.find((t) => {
|
||||
if (!isScopedToTeams(t)) return false;
|
||||
<Table
|
||||
columns={[
|
||||
{
|
||||
name: 'epoch',
|
||||
displayName: t('Epoch'),
|
||||
},
|
||||
{
|
||||
name: 'endtime',
|
||||
displayName: t('End time'),
|
||||
},
|
||||
{ name: 'type', displayName: t('Type') },
|
||||
{
|
||||
name: 'asset',
|
||||
displayName: t('Reward asset'),
|
||||
},
|
||||
{ name: 'daily', displayName: t('Daily reward amount') },
|
||||
{ name: 'rank', displayName: t('Rank') },
|
||||
{ name: 'amount', displayName: t('Amount earned this epoch') },
|
||||
{ name: 'total', displayName: t('Cumulative amount earned') },
|
||||
{
|
||||
name: 'participatingTeams',
|
||||
displayName: t('No. of participating teams'),
|
||||
},
|
||||
{
|
||||
name: 'participatingMembers',
|
||||
displayName: t('No. of participating members'),
|
||||
},
|
||||
].map((c) => ({ ...c, headerClassName: 'text-left' }))}
|
||||
data={games.map((game) => {
|
||||
let transfer = transfers?.find((t) => {
|
||||
if (!isScopedToTeams(t)) return false;
|
||||
|
||||
const idMatch = t.transfer.gameId === game.id;
|
||||
const metricMatch =
|
||||
t.transfer.kind.dispatchStrategy?.dispatchMetric ===
|
||||
game.team.rewardMetric;
|
||||
const idMatch = t.transfer.gameId === game.id;
|
||||
const metricMatch =
|
||||
t.transfer.kind.dispatchStrategy?.dispatchMetric ===
|
||||
game.team.rewardMetric;
|
||||
|
||||
const start = t.transfer.kind.startEpoch <= game.epoch;
|
||||
const end = t.transfer.kind.endEpoch
|
||||
? t.transfer.kind.endEpoch >= game.epoch
|
||||
: true;
|
||||
const start = t.transfer.kind.startEpoch <= game.epoch;
|
||||
const end = t.transfer.kind.endEpoch
|
||||
? t.transfer.kind.endEpoch >= game.epoch
|
||||
: true;
|
||||
|
||||
const rejected =
|
||||
t.transfer.status === TransferStatus.STATUS_REJECTED;
|
||||
const rejected = t.transfer.status === TransferStatus.STATUS_REJECTED;
|
||||
|
||||
return idMatch && metricMatch && start && end && !rejected;
|
||||
});
|
||||
if (!transfer || !isScopedToTeams(transfer)) transfer = undefined;
|
||||
const asset = transfer?.transfer.asset;
|
||||
return idMatch && metricMatch && start && end && !rejected;
|
||||
});
|
||||
if (!transfer || !isScopedToTeams(transfer)) transfer = undefined;
|
||||
const asset = transfer?.transfer.asset;
|
||||
|
||||
const dailyAmount =
|
||||
asset && transfer
|
||||
? addDecimalsFormatNumberQuantum(
|
||||
transfer.transfer.amount,
|
||||
asset.decimals,
|
||||
asset.quantum
|
||||
)
|
||||
: '-';
|
||||
|
||||
const earnedAmount = asset
|
||||
const dailyAmount =
|
||||
asset && transfer
|
||||
? addDecimalsFormatNumberQuantum(
|
||||
game.team.rewardEarned,
|
||||
transfer.transfer.amount,
|
||||
asset.decimals,
|
||||
asset.quantum
|
||||
)
|
||||
: '-';
|
||||
|
||||
const totalAmount = asset
|
||||
? addDecimalsFormatNumberQuantum(
|
||||
game.team.totalRewardsEarned,
|
||||
asset.decimals,
|
||||
asset.quantum
|
||||
)
|
||||
: '-';
|
||||
const earnedAmount = asset
|
||||
? addDecimalsFormatNumberQuantum(
|
||||
game.team.rewardEarned,
|
||||
asset.decimals,
|
||||
asset.quantum
|
||||
)
|
||||
: '-';
|
||||
|
||||
const assetSymbol = asset ? <RewardAssetCell asset={asset} /> : '-';
|
||||
const totalAmount = asset
|
||||
? addDecimalsFormatNumberQuantum(
|
||||
game.team.totalRewardsEarned,
|
||||
asset.decimals,
|
||||
asset.quantum
|
||||
)
|
||||
: '-';
|
||||
|
||||
return {
|
||||
id: game.id,
|
||||
amount: dependable(earnedAmount),
|
||||
asset: dependable(assetSymbol),
|
||||
daily: dependable(dailyAmount),
|
||||
endtime: <EndTimeCell epoch={game.epoch} />,
|
||||
epoch: game.epoch,
|
||||
participatingMembers: game.numberOfParticipants,
|
||||
participatingTeams: game.entities.length,
|
||||
rank: game.team.rank,
|
||||
total: totalAmount,
|
||||
// type: DispatchMetricLabels[game.team.rewardMetric as DispatchMetric],
|
||||
type: dependable(
|
||||
<GameTypeCell transfer={transfer} allMarkets={allMarkets} />
|
||||
),
|
||||
};
|
||||
})}
|
||||
noCollapse={false}
|
||||
/>
|
||||
</div>
|
||||
const assetSymbol = asset ? <RewardAssetCell asset={asset} /> : '-';
|
||||
|
||||
return {
|
||||
id: game.id,
|
||||
amount: dependable(earnedAmount),
|
||||
asset: dependable(assetSymbol),
|
||||
daily: dependable(dailyAmount),
|
||||
endtime: <EndTimeCell epoch={game.epoch} />,
|
||||
epoch: game.epoch,
|
||||
participatingMembers: game.numberOfParticipants,
|
||||
participatingTeams: game.entities.length,
|
||||
rank: game.team.rank,
|
||||
total: totalAmount,
|
||||
// type: DispatchMetricLabels[game.team.rewardMetric as DispatchMetric],
|
||||
type: dependable(
|
||||
<GameTypeCell transfer={transfer} allMarkets={allMarkets} />
|
||||
),
|
||||
};
|
||||
})}
|
||||
noCollapse={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const Members = ({ members }: { members?: Member[] }) => {
|
||||
const t = useT();
|
||||
|
||||
const partyIds = members?.map((m) => m.referee) || [];
|
||||
const { data: profilesData } = usePartyProfilesQuery({
|
||||
variables: {
|
||||
partyIds,
|
||||
},
|
||||
skip: partyIds.length === 0,
|
||||
});
|
||||
const profiles = removePaginationWrapper(
|
||||
profilesData?.partiesProfilesConnection?.edges
|
||||
);
|
||||
|
||||
if (!members?.length) {
|
||||
return <p>{t('No members')}</p>;
|
||||
}
|
||||
|
||||
const data = orderBy(
|
||||
members.map((m) => ({
|
||||
referee: (
|
||||
<RefereeLink
|
||||
pubkey={m.referee}
|
||||
isCreator={m.isCreator}
|
||||
profiles={profiles}
|
||||
/>
|
||||
),
|
||||
referee: <RefereeLink pubkey={m.referee} isCreator={m.isCreator} />,
|
||||
rewards: formatNumber(m.totalQuantumRewards),
|
||||
volume: formatNumber(m.totalQuantumVolume),
|
||||
gamesPlayed: formatNumber(m.totalGamesPlayed),
|
||||
joinedAt: formatDate(new Date(m.joinedAt)),
|
||||
joinedAt: getDateTimeFormat().format(new Date(m.joinedAt)),
|
||||
joinedAtEpoch: Number(m.joinedAtEpoch),
|
||||
})),
|
||||
'joinedAtEpoch',
|
||||
@@ -422,69 +349,45 @@ const Members = ({ members }: { members?: Member[] }) => {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<Table
|
||||
columns={[
|
||||
{ name: 'referee', displayName: t('Member') },
|
||||
{ name: 'rewards', displayName: t('Rewards earned') },
|
||||
{ name: 'volume', displayName: t('Total volume') },
|
||||
{ name: 'gamesPlayed', displayName: t('Games played') },
|
||||
{
|
||||
name: 'joinedAt',
|
||||
displayName: t('Joined at'),
|
||||
},
|
||||
{
|
||||
name: 'joinedAtEpoch',
|
||||
displayName: t('Joined epoch'),
|
||||
},
|
||||
]}
|
||||
data={data}
|
||||
noCollapse={true}
|
||||
/>
|
||||
</div>
|
||||
<Table
|
||||
columns={[
|
||||
{ name: 'referee', displayName: t('Member ID') },
|
||||
{ name: 'rewards', displayName: t('Rewards earned') },
|
||||
{ name: 'volume', displayName: t('Total volume') },
|
||||
{ name: 'gamesPlayed', displayName: t('Games played') },
|
||||
{
|
||||
name: 'joinedAt',
|
||||
displayName: t('Joined at'),
|
||||
},
|
||||
{
|
||||
name: 'joinedAtEpoch',
|
||||
displayName: t('Joined epoch'),
|
||||
},
|
||||
]}
|
||||
data={data}
|
||||
noCollapse={true}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const RefereeLink = ({
|
||||
pubkey,
|
||||
isCreator,
|
||||
profiles,
|
||||
}: {
|
||||
pubkey: string;
|
||||
isCreator: boolean;
|
||||
profiles?: { partyId: string; alias: string }[];
|
||||
}) => {
|
||||
const t = useT();
|
||||
const linkCreator = useLinks(DApp.Explorer);
|
||||
const link = linkCreator(EXPLORER_PARTIES.replace(':id', pubkey));
|
||||
|
||||
const alias = profiles?.find((p) => p.partyId === pubkey)?.alias;
|
||||
|
||||
return (
|
||||
<div className="flex items-baseline gap-2">
|
||||
<>
|
||||
<Link to={link} target="_blank" className="underline underline-offset-4">
|
||||
{alias || truncateMiddle(pubkey)}
|
||||
</Link>
|
||||
{!alias && (
|
||||
<Tooltip
|
||||
description={t(
|
||||
'You can set your pubkey alias by using the key selector in the top right corner.'
|
||||
)}
|
||||
>
|
||||
<button className="text-muted text-xs">
|
||||
<VegaIcon name={VegaIconNames.QUESTION_MARK} size={14} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{alias && (
|
||||
<span className="text-muted text-xs">{truncateMiddle(pubkey)}</span>
|
||||
)}
|
||||
{isCreator && (
|
||||
<span className="text-muted text-xs border border-vega-clight-300 dark:border-vega-cdark-300 rounded px-1 py-[1px]">
|
||||
{t('Owner')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{truncateMiddle(pubkey)}
|
||||
</Link>{' '}
|
||||
<span className="text-muted text-xs">{isCreator ? t('Owner') : ''}</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -508,12 +411,15 @@ const EndTimeCell = ({ epoch }: { epoch?: number }) => {
|
||||
variables: {
|
||||
epochId: epoch ? epoch.toString() : undefined,
|
||||
},
|
||||
fetchPolicy: 'cache-first',
|
||||
fetchPolicy: 'cache-and-network',
|
||||
});
|
||||
|
||||
if (loading) return <Loader size="small" />;
|
||||
if (data) {
|
||||
return formatDate(new Date(data.epoch.timestamps.expiry));
|
||||
return format(
|
||||
new Date(data.epoch.timestamps.expiry),
|
||||
'yyyy/MM/dd hh:mm:ss'
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -70,12 +70,6 @@ export const JoinButton = ({
|
||||
}) => {
|
||||
const t = useT();
|
||||
|
||||
/**
|
||||
* A team cannot be joined (closed) when set as such
|
||||
* and the currently connected pubkey is not whitelisted.
|
||||
*/
|
||||
const isTeamClosed = team.closed && !team.allowList.includes(pubKey || '');
|
||||
|
||||
if (!pubKey || isReadOnly) {
|
||||
return (
|
||||
<Tooltip description={t('Connect your wallet to join the team')}>
|
||||
@@ -85,9 +79,8 @@ export const JoinButton = ({
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
// Party is the creator of a team
|
||||
if (partyTeam && partyTeam.referrer === pubKey) {
|
||||
else if (partyTeam && partyTeam.referrer === pubKey) {
|
||||
// Party is the creator of THIS team
|
||||
if (partyTeam.teamId === team.teamId) {
|
||||
return (
|
||||
@@ -112,24 +105,8 @@ export const JoinButton = ({
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Party is in a team, but not this one
|
||||
if (partyTeam && partyTeam.teamId !== team.teamId) {
|
||||
// This team is closed.
|
||||
if (isTeamClosed) {
|
||||
return (
|
||||
<Tooltip description={t('You cannot join a private team')}>
|
||||
<Button
|
||||
intent={Intent.Primary}
|
||||
data-testid="switch-team-button"
|
||||
disabled={true}
|
||||
>
|
||||
{t('Switch team')}{' '}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
// This team is open.
|
||||
else if (partyTeam && partyTeam.teamId !== team.teamId) {
|
||||
return (
|
||||
<Button
|
||||
onClick={() => onJoin('switch')}
|
||||
@@ -140,9 +117,8 @@ export const JoinButton = ({
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
// Joined. Current party is already in this team
|
||||
if (partyTeam && partyTeam.teamId === team.teamId) {
|
||||
else if (partyTeam && partyTeam.teamId === team.teamId) {
|
||||
return (
|
||||
<Button intent={Intent.None} disabled={true}>
|
||||
<span className="flex items-center gap-2">
|
||||
@@ -155,17 +131,6 @@ export const JoinButton = ({
|
||||
);
|
||||
}
|
||||
|
||||
// This team is closed.
|
||||
if (isTeamClosed) {
|
||||
return (
|
||||
<Tooltip description={t('You cannot join a closed team')}>
|
||||
<Button intent={Intent.Primary} disabled={true}>
|
||||
{t('Join team')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
// This team is open.
|
||||
return (
|
||||
<Button onClick={() => onJoin('join')} intent={Intent.Primary}>
|
||||
{t('Join team')}
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { URL_REGEX, isValidVegaPublicKey } from '@vegaprotocol/utils';
|
||||
import { URL_REGEX, validVegaPublicKey } from '@vegaprotocol/utils';
|
||||
|
||||
import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||
import { useT } from '../../lib/use-t';
|
||||
@@ -217,9 +217,7 @@ export const TeamForm = ({
|
||||
validate: {
|
||||
allowList: (value) => {
|
||||
const publicKeys = parseAllowListText(value);
|
||||
if (
|
||||
publicKeys.every((pk) => isValidVegaPublicKey(pk))
|
||||
) {
|
||||
if (publicKeys.every((pk) => validVegaPublicKey(pk))) {
|
||||
return true;
|
||||
}
|
||||
return t('Invalid public key found in allow list');
|
||||
|
||||
@@ -2,12 +2,11 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import { DocsLinks, useEnvironment } from '@vegaprotocol/environment';
|
||||
import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit';
|
||||
import type { Market } from '@vegaprotocol/markets';
|
||||
import { addDecimalsFormatNumber, fromNanoSeconds } from '@vegaprotocol/utils';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
fromNanoSeconds,
|
||||
useMarketExpiryDate,
|
||||
getMarketExpiryDate,
|
||||
useExpiryDate,
|
||||
} from '@vegaprotocol/utils';
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
Last24hPriceChange,
|
||||
Last24hVolume,
|
||||
@@ -20,7 +19,6 @@ import {
|
||||
useMarketTradingMode,
|
||||
useExternalTwap,
|
||||
getQuoteName,
|
||||
useMarketState,
|
||||
} from '@vegaprotocol/markets';
|
||||
import { MarketState as State } from '@vegaprotocol/types';
|
||||
import { HeaderStat } from '../../components/header';
|
||||
@@ -45,12 +43,6 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
const asset = getAsset(market);
|
||||
const quoteUnit = getQuoteName(market);
|
||||
|
||||
const dataSourceSpec = market.markPriceConfiguration?.dataSourcesSpec?.[1];
|
||||
const sourceType =
|
||||
dataSourceSpec?.sourceType.__typename === 'DataSourceDefinitionExternal' &&
|
||||
dataSourceSpec?.sourceType.sourceType.__typename === 'EthCallSpec' &&
|
||||
dataSourceSpec?.sourceType.sourceType;
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
||||
@@ -68,13 +60,16 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
<HeaderStat heading={t('Volume (24h)')} testId="market-volume">
|
||||
<Last24hVolume
|
||||
marketId={market.id}
|
||||
marketDecimals={market.decimalPlaces}
|
||||
positionDecimalPlaces={market.positionDecimalPlaces}
|
||||
marketDecimals={market.decimalPlaces}
|
||||
quoteUnit={quoteUnit}
|
||||
/>
|
||||
</HeaderStat>
|
||||
<HeaderStatMarketTradingMode marketId={market.id} />
|
||||
<MarketState marketId={market.id} />
|
||||
<HeaderStatMarketTradingMode
|
||||
marketId={market.id}
|
||||
initialTradingMode={market.tradingMode}
|
||||
/>
|
||||
<MarketState market={market} />
|
||||
{asset ? (
|
||||
<HeaderStat
|
||||
heading={t('Settlement asset')}
|
||||
@@ -131,25 +126,14 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
{t(
|
||||
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
||||
)}
|
||||
<div className="flex flex-col gap-1">
|
||||
{DocsLinks && (
|
||||
<ExternalLink
|
||||
href={DocsLinks.ETH_DATA_SOURCES}
|
||||
className="mt-2"
|
||||
>
|
||||
{t('Find out more')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
{sourceType && (
|
||||
<ExternalLink
|
||||
data-testid="oracle-spec-links"
|
||||
href={`${VEGA_EXPLORER_URL}/markets/${market.id}/oracles#${sourceType.address}`}
|
||||
className="text-xs my-1"
|
||||
>
|
||||
{t('Oracle specification')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
</div>
|
||||
{DocsLinks && (
|
||||
<ExternalLink
|
||||
href={DocsLinks.ETH_DATA_SOURCES}
|
||||
className="mt-2"
|
||||
>
|
||||
{t('Find out more')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
testId="index-price"
|
||||
@@ -279,13 +263,14 @@ export const FundingCountdown = ({ marketId }: { marketId: string }) => {
|
||||
};
|
||||
|
||||
const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
|
||||
const { data: marketState } = useMarketState(market.id);
|
||||
const content =
|
||||
useExpiryDate(
|
||||
market.tradableInstrument.instrument.metadata.tags,
|
||||
market.marketTimestamps.close,
|
||||
marketState
|
||||
) || '-';
|
||||
const expiryDate = useMarketExpiryDate(
|
||||
market.tradableInstrument.instrument.metadata.tags,
|
||||
market.marketTimestamps.close,
|
||||
market.state
|
||||
);
|
||||
const content = market.tradableInstrument.instrument.metadata.tags
|
||||
? expiryDate
|
||||
: '-';
|
||||
return <div data-testid="trading-expiry">{content}</div>;
|
||||
};
|
||||
|
||||
@@ -298,7 +283,6 @@ const ExpiryTooltipContent = ({
|
||||
market,
|
||||
explorerUrl,
|
||||
}: ExpiryTooltipContentProps) => {
|
||||
const { data: state } = useMarketState(market.id);
|
||||
const t = useT();
|
||||
if (market.marketTimestamps.close === null) {
|
||||
const oracleId =
|
||||
@@ -314,8 +298,8 @@ const ExpiryTooltipContent = ({
|
||||
const isExpired =
|
||||
metadataExpiryDate &&
|
||||
Date.now() - metadataExpiryDate.valueOf() > 0 &&
|
||||
(state === State.STATE_TRADING_TERMINATED ||
|
||||
state === State.STATE_SETTLED);
|
||||
(market.state === State.STATE_TRADING_TERMINATED ||
|
||||
market.state === State.STATE_SETTLED);
|
||||
|
||||
return (
|
||||
<section data-testid="expiry-tooltip">
|
||||
|
||||
@@ -40,6 +40,7 @@ describe('Closed', () => {
|
||||
|
||||
const market = createMarketFragment({
|
||||
id: marketId,
|
||||
state: MarketState.STATE_SETTLED,
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
metadata: {
|
||||
@@ -95,7 +96,6 @@ describe('Closed', () => {
|
||||
|
||||
const marketsData = createMarketsDataFragment({
|
||||
__typename: 'MarketData',
|
||||
marketState: MarketState.STATE_SETTLED,
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: marketId,
|
||||
@@ -199,16 +199,13 @@ describe('Closed', () => {
|
||||
|
||||
it('renders correctly formatted and filtered rows', async () => {
|
||||
await renderComponent([marketsMock, marketsDataMock, oracleDataMock]);
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByRole('gridcell').length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
const assetSymbol = getAsset(market).symbol;
|
||||
|
||||
const cells = screen.getAllByRole('gridcell');
|
||||
const expectedValues = [
|
||||
market.tradableInstrument.instrument.code,
|
||||
MarketStateMapping[marketsData.marketState],
|
||||
MarketStateMapping[market.state],
|
||||
'3 days ago',
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
addDecimalsFormatNumber(marketsData.bestBidPrice, market.decimalPlaces),
|
||||
@@ -227,6 +224,87 @@ describe('Closed', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('only renders settled and terminated markets', async () => {
|
||||
const mixedMarkets = [
|
||||
{
|
||||
// include as settled
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: 'include-0',
|
||||
state: MarketState.STATE_SETTLED,
|
||||
}),
|
||||
},
|
||||
{
|
||||
// omit this market
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: 'discard-0',
|
||||
state: MarketState.STATE_SUSPENDED,
|
||||
}),
|
||||
},
|
||||
{
|
||||
// include as terminated
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: 'include-1',
|
||||
state: MarketState.STATE_TRADING_TERMINATED,
|
||||
}),
|
||||
},
|
||||
{
|
||||
// omit this market
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: 'discard-1',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
}),
|
||||
},
|
||||
];
|
||||
const mixedMarketsMock: MockedResponse<MarketsQuery> = {
|
||||
request: {
|
||||
query: MarketsDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
marketsConnection: {
|
||||
__typename: 'MarketConnection',
|
||||
edges: mixedMarkets,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await renderComponent([mixedMarketsMock, marketsDataMock, oracleDataMock]);
|
||||
|
||||
// check that the number of rows in datagrid is 2
|
||||
const container = within(
|
||||
document.querySelector('.ag-center-cols-container') as HTMLElement
|
||||
);
|
||||
const expectedRows = mixedMarkets.filter((m) => {
|
||||
return [
|
||||
MarketState.STATE_SETTLED,
|
||||
MarketState.STATE_TRADING_TERMINATED,
|
||||
].includes(m.node.state);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
// check rows length is correct
|
||||
const rows = container.getAllByRole('row');
|
||||
expect(rows).toHaveLength(expectedRows.length);
|
||||
});
|
||||
|
||||
// check that only included ids are shown
|
||||
const cells = screen
|
||||
.getAllByRole('gridcell')
|
||||
.filter((cell) => cell.getAttribute('col-id') === 'code')
|
||||
.map((cell) => {
|
||||
const marketCode = within(cell).getByTestId('stack-cell-primary');
|
||||
return marketCode.textContent;
|
||||
});
|
||||
expect(cells).toEqual(
|
||||
expectedRows.map((m) => m.node.tradableInstrument.instrument.code)
|
||||
);
|
||||
});
|
||||
|
||||
it('display market actions', async () => {
|
||||
// Use market with a successor Id as the actions dropdown will optionally
|
||||
// show a link to the successor market
|
||||
@@ -234,7 +312,8 @@ describe('Closed', () => {
|
||||
{
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: marketId,
|
||||
id: 'include-0',
|
||||
state: MarketState.STATE_SETTLED,
|
||||
successorMarketID: 'successor',
|
||||
parentMarketID: 'parent',
|
||||
}),
|
||||
@@ -259,33 +338,31 @@ describe('Closed', () => {
|
||||
oracleDataMock,
|
||||
]);
|
||||
|
||||
await waitFor(async () => {
|
||||
const actionCell = screen
|
||||
.getAllByRole('gridcell')
|
||||
.find((el) => el.getAttribute('col-id') === 'market-actions');
|
||||
const actionCell = screen
|
||||
.getAllByRole('gridcell')
|
||||
.find((el) => el.getAttribute('col-id') === 'market-actions');
|
||||
|
||||
await userEvent.click(
|
||||
within(actionCell as HTMLElement).getByTestId('dropdown-menu')
|
||||
);
|
||||
await userEvent.click(
|
||||
within(actionCell as HTMLElement).getByTestId('dropdown-menu')
|
||||
);
|
||||
|
||||
expect(screen.getByRole('menu')).toBeInTheDocument();
|
||||
expect(screen.getByRole('menu')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'Copy Market ID' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View on Explorer' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View settlement asset details' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View parent market' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View successor market' })
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'Copy Market ID' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View on Explorer' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View settlement asset details' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View parent market' })
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('menuitem', { name: 'View successor market' })
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('successor market should be visible', async () => {
|
||||
@@ -293,7 +370,8 @@ describe('Closed', () => {
|
||||
{
|
||||
__typename: 'MarketEdge' as const,
|
||||
node: createMarketFragment({
|
||||
id: marketId,
|
||||
id: 'include-0',
|
||||
state: MarketState.STATE_SETTLED,
|
||||
successorMarketID: 'successor',
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -11,11 +11,9 @@ import { useMemo } from 'react';
|
||||
import type { Asset } from '@vegaprotocol/types';
|
||||
import type { ProductType } from '@vegaprotocol/types';
|
||||
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
getMarketExpiryDate,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { closedMarketsProvider, getAsset } from '@vegaprotocol/markets';
|
||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers';
|
||||
import { closedMarketsWithDataProvider, getAsset } from '@vegaprotocol/markets';
|
||||
import type { DataSourceFilterFragment } from '@vegaprotocol/markets';
|
||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
|
||||
@@ -35,7 +33,7 @@ interface Row {
|
||||
code: string;
|
||||
name: string;
|
||||
decimalPlaces: number;
|
||||
state?: MarketState;
|
||||
state: MarketState;
|
||||
metadata: string[];
|
||||
closeTimestamp: string | null;
|
||||
bestBidPrice: string | undefined;
|
||||
@@ -53,7 +51,7 @@ interface Row {
|
||||
|
||||
export const Closed = () => {
|
||||
const { data: marketData, error } = useDataProvider({
|
||||
dataProvider: closedMarketsProvider,
|
||||
dataProvider: closedMarketsWithDataProvider,
|
||||
variables: undefined,
|
||||
});
|
||||
|
||||
@@ -87,7 +85,7 @@ export const Closed = () => {
|
||||
code: instrument.code,
|
||||
name: instrument.name,
|
||||
decimalPlaces: market.decimalPlaces,
|
||||
state: market.data?.marketState,
|
||||
state: market.state,
|
||||
metadata: instrument.metadata.tags ?? [],
|
||||
closeTimestamp: market.marketTimestamps.close,
|
||||
bestBidPrice: market.data?.bestBidPrice,
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { ProposalsList } from './proposals-list';
|
||||
@@ -1,37 +0,0 @@
|
||||
import type { FC } from 'react';
|
||||
import { AgGrid } from '@vegaprotocol/datagrid';
|
||||
import { useProposedMarketsList } from '@vegaprotocol/markets';
|
||||
import { type ProposalListFieldsFragment } from '@vegaprotocol/proposals';
|
||||
import { useColumnDefs } from './use-column-defs';
|
||||
import { useT } from '../../../lib/use-t';
|
||||
|
||||
const defaultColDef = {
|
||||
sortable: true,
|
||||
filter: true,
|
||||
resizable: true,
|
||||
filterParams: { buttons: ['reset'] },
|
||||
};
|
||||
|
||||
interface ProposalListProps {
|
||||
cellRenderers: {
|
||||
[name: string]: FC<{ value: string; data: ProposalListFieldsFragment }>;
|
||||
};
|
||||
}
|
||||
|
||||
export const ProposalsList = ({ cellRenderers }: ProposalListProps) => {
|
||||
const t = useT();
|
||||
const { data } = useProposedMarketsList();
|
||||
const columnDefs = useColumnDefs();
|
||||
|
||||
return (
|
||||
<AgGrid
|
||||
columnDefs={columnDefs}
|
||||
rowData={data}
|
||||
defaultColDef={defaultColDef}
|
||||
getRowId={({ data }) => data.id}
|
||||
overlayNoRowsTemplate={t('No proposed markets')}
|
||||
components={cellRenderers}
|
||||
rowHeight={45}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ProposalsList } from './proposals-list';
|
||||
import { ProposalsList } from '@vegaprotocol/proposals';
|
||||
import { ParentMarketCell } from './parent-market-cell';
|
||||
|
||||
const cellRenderers = {
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface SettlementDataCellProps {
|
||||
oracleSpecId: string;
|
||||
metaDate: Date | null;
|
||||
closeTimestamp: string | null;
|
||||
marketState?: MarketState;
|
||||
marketState: MarketState;
|
||||
}
|
||||
|
||||
export const SettlementDateCell = ({
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
import { ButtonLink, Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import type {
|
||||
MarketFieldsFragment,
|
||||
MarketMaybeWithData,
|
||||
MarketMaybeWithDataAndCandles,
|
||||
} from '@vegaprotocol/markets';
|
||||
@@ -125,9 +126,7 @@ export const useMarketsColumnDefs = () => {
|
||||
valueFormatter: ({
|
||||
data,
|
||||
}: VegaValueFormatterParams<MarketMaybeWithData, 'state'>) => {
|
||||
return data?.data?.marketState
|
||||
? Schema.MarketStateMapping[data?.data?.marketState]
|
||||
: '-';
|
||||
return data?.state ? Schema.MarketStateMapping[data.state] : '-';
|
||||
},
|
||||
filter: SetFilter,
|
||||
filterParams: {
|
||||
@@ -167,10 +166,9 @@ export const useMarketsColumnDefs = () => {
|
||||
valueFormatter: ({
|
||||
data,
|
||||
}: ValueFormatterParams<MarketMaybeWithDataAndCandles, 'candles'>) => {
|
||||
if (!data) return '-';
|
||||
const candles = data.candles;
|
||||
const candles = data?.candles;
|
||||
const vol = candles ? calcCandleVolume(candles) : '0';
|
||||
const quoteName = getQuoteName(data);
|
||||
const quoteName = getQuoteName(data as MarketFieldsFragment);
|
||||
const volPrice =
|
||||
candles &&
|
||||
calcCandleVolumePrice(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { InMemoryCacheConfig } from '@apollo/client';
|
||||
import {
|
||||
AppLoader,
|
||||
NetworkLoader,
|
||||
useEnvironment,
|
||||
useNodeSwitcherStore,
|
||||
@@ -85,6 +86,10 @@ export const Bootstrapper = ({ children }: { children: ReactNode }) => {
|
||||
}));
|
||||
const config = useVegaWalletConfig();
|
||||
|
||||
if (!config) {
|
||||
return <AppLoader />;
|
||||
}
|
||||
|
||||
const ERR_DATA_LOADER = (
|
||||
<Trans
|
||||
i18nKey="It appears that the connection to the node <0>{{VEGA_URL}}</0> does not return necessary data, try switching to another node."
|
||||
@@ -113,11 +118,7 @@ export const Bootstrapper = ({ children }: { children: ReactNode }) => {
|
||||
skeleton={<Loading />}
|
||||
failure={<Failure reason={t('Could not configure web3 provider')} />}
|
||||
>
|
||||
{config ? (
|
||||
<WalletProvider config={config}>{children}</WalletProvider>
|
||||
) : (
|
||||
<Failure reason={t('Could not configure the wallet provider')} />
|
||||
)}
|
||||
<WalletProvider config={config}>{children}</WalletProvider>
|
||||
</Web3Provider>
|
||||
</DataLoader>
|
||||
</NetworkLoader>
|
||||
@@ -144,30 +145,6 @@ const cacheConfig: InMemoryCacheConfig = {
|
||||
Product: {
|
||||
keyFields: ['settlementAsset', ['id']],
|
||||
},
|
||||
Market: {
|
||||
fields: {
|
||||
/**
|
||||
* Intercept cache field for tickSize because mainnet specific queries have been
|
||||
* set up, marking this field as client only. The following can be removed when mainnet
|
||||
* supports ticksize:
|
||||
*
|
||||
* 1. The typePolicy for tickSize below
|
||||
* 2. The MarketInfoMainnet query in libs/markets/src/lib/components/market-info/MarketInfo.graphql
|
||||
* 3. The ternary to switch queries in libs/markets/src/lib/components/market-info/market-info-data-provider.ts
|
||||
* 4. The MarketsMainnet query in libs/markets/src/lib/markets.graphql
|
||||
* 5. The ternary to switch queries in libs/markets/src/lib/markets-provider.ts
|
||||
*/
|
||||
tickSize: {
|
||||
read(value) {
|
||||
// value is not present, we have probably marked tickSize as a client only field
|
||||
if (!value) return '1';
|
||||
|
||||
// Use fetch response value
|
||||
return value;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
MarketData: {
|
||||
keyFields: ['market', ['id']],
|
||||
},
|
||||
|
||||
@@ -44,7 +44,6 @@ export const CompetitionsLeaderboard = ({
|
||||
|
||||
const avatar = (
|
||||
<TeamAvatar
|
||||
key={td.teamId}
|
||||
teamId={td.teamId}
|
||||
imgUrl={td.avatarUrl}
|
||||
alt={td.name}
|
||||
@@ -68,7 +67,7 @@ export const CompetitionsLeaderboard = ({
|
||||
),
|
||||
earned: num(td.totalQuantumRewards),
|
||||
games: num(td.totalGamesPlayed),
|
||||
status: td.closed ? t('Private') : t('Public'),
|
||||
status: td.closed ? t('Closed') : t('Open'),
|
||||
volume: num(td.totalQuantumVolume),
|
||||
};
|
||||
})}
|
||||
|
||||
@@ -1,81 +1,6 @@
|
||||
import { ActiveRewardCard } from '../rewards-container/active-rewards';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { type EnrichedRewardTransfer } from '../../lib/hooks/use-rewards';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet-react';
|
||||
import { useStakeAvailable } from '../../lib/hooks/use-stake-available';
|
||||
import { useMyTeam } from '../../lib/hooks/use-my-team';
|
||||
import {
|
||||
ActiveRewardCard,
|
||||
areAllMarketsSettled,
|
||||
} from '../rewards-container/reward-card';
|
||||
import {
|
||||
VegaIcon,
|
||||
VegaIconNames,
|
||||
TradingInput,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { useState } from 'react';
|
||||
import { type AssetFieldsFragment } from '@vegaprotocol/assets';
|
||||
import { type MarketFieldsFragment } from '@vegaprotocol/markets';
|
||||
import {
|
||||
type TransferNode,
|
||||
DispatchMetricLabels,
|
||||
EntityScopeLabelMapping,
|
||||
AccountType,
|
||||
} from '@vegaprotocol/types';
|
||||
|
||||
export type Filter = {
|
||||
searchTerm: string;
|
||||
};
|
||||
|
||||
export const applyFilter = (
|
||||
node: TransferNode & {
|
||||
asset?: AssetFieldsFragment | null;
|
||||
markets?: (MarketFieldsFragment | null)[];
|
||||
},
|
||||
filter: Filter
|
||||
) => {
|
||||
const { transfer } = node;
|
||||
|
||||
// if the transfer is a staking reward then it should be displayed
|
||||
if (transfer.toAccountType === AccountType.ACCOUNT_TYPE_GLOBAL_REWARD) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
transfer.kind.__typename !== 'RecurringTransfer' &&
|
||||
transfer.kind.__typename !== 'RecurringGovernanceTransfer'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
(transfer.kind.dispatchStrategy?.dispatchMetric &&
|
||||
DispatchMetricLabels[transfer.kind.dispatchStrategy.dispatchMetric]
|
||||
.toLowerCase()
|
||||
.includes(filter.searchTerm.toLowerCase())) ||
|
||||
transfer.asset?.symbol
|
||||
.toLowerCase()
|
||||
.includes(filter.searchTerm.toLowerCase()) ||
|
||||
(
|
||||
(transfer.kind.dispatchStrategy &&
|
||||
EntityScopeLabelMapping[transfer.kind.dispatchStrategy.entityScope]) ||
|
||||
'Unspecified'
|
||||
)
|
||||
.toLowerCase()
|
||||
.includes(filter.searchTerm.toLowerCase()) ||
|
||||
node.asset?.name
|
||||
.toLocaleLowerCase()
|
||||
.includes(filter.searchTerm.toLowerCase()) ||
|
||||
node.markets?.some((m) =>
|
||||
m?.tradableInstrument?.instrument?.name
|
||||
.toLocaleLowerCase()
|
||||
.includes(filter.searchTerm.toLowerCase())
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const GamesContainer = ({
|
||||
data,
|
||||
@@ -85,23 +10,6 @@ export const GamesContainer = ({
|
||||
currentEpoch: number;
|
||||
}) => {
|
||||
const t = useT();
|
||||
const { pubKey } = useVegaWallet();
|
||||
const { team } = useMyTeam();
|
||||
const { stakeAvailable, isEligible, requiredStake } = useStakeAvailable();
|
||||
|
||||
const requirements = pubKey
|
||||
? {
|
||||
isEligible,
|
||||
stakeAvailable,
|
||||
requiredStake,
|
||||
team,
|
||||
pubKey,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const [filter, setFilter] = useState<Filter>({
|
||||
searchTerm: '',
|
||||
});
|
||||
|
||||
if (!data || data.length === 0) {
|
||||
return (
|
||||
@@ -112,46 +20,24 @@ export const GamesContainer = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/** CARDS FILTER */}
|
||||
{data.length > 1 && (
|
||||
<TradingInput
|
||||
onChange={(e) =>
|
||||
setFilter((curr) => ({ ...curr, searchTerm: e.target.value }))
|
||||
}
|
||||
value={filter.searchTerm}
|
||||
type="text"
|
||||
placeholder={t(
|
||||
'Search by reward dispatch metric, entity scope or asset name'
|
||||
)}
|
||||
data-testid="search-term"
|
||||
className="mb-4 w-20 mr-2 max-w-xl"
|
||||
prependElement={<VegaIcon name={VegaIconNames.SEARCH} />}
|
||||
/>
|
||||
)}
|
||||
{/** CARDS */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{data
|
||||
.filter((n) => applyFilter(n, filter))
|
||||
// filter out the cards (rewards) for which all of the markets
|
||||
// are settled
|
||||
.filter((n) => !areAllMarketsSettled(n))
|
||||
.map((game, i) => {
|
||||
// TODO: Remove `kind` prop from ActiveRewardCard
|
||||
const { transfer } = game;
|
||||
if (!transfer.kind.dispatchStrategy?.dispatchMetric) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ActiveRewardCard
|
||||
key={i}
|
||||
transferNode={game}
|
||||
currentEpoch={currentEpoch}
|
||||
requirements={requirements}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{data.map((game, i) => {
|
||||
// TODO: Remove `kind` prop from ActiveRewardCard
|
||||
const { transfer } = game;
|
||||
if (
|
||||
transfer.kind.__typename !== 'RecurringTransfer' ||
|
||||
!transfer.kind.dispatchStrategy?.dispatchMetric
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<ActiveRewardCard
|
||||
key={i}
|
||||
transferNode={game}
|
||||
currentEpoch={currentEpoch}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { isValidUrl } from '@vegaprotocol/utils';
|
||||
import classNames from 'classnames';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const NUM_AVATARS = 20;
|
||||
const AVATAR_PATHNAME_PATTERN = '/team-avatars/{id}.png';
|
||||
@@ -11,6 +13,26 @@ export const getFallbackAvatar = (teamId: string) => {
|
||||
return AVATAR_PATHNAME_PATTERN.replace('{id}', avatarId);
|
||||
};
|
||||
|
||||
const useAvatar = (teamId: string, url: string) => {
|
||||
const fallback = getFallbackAvatar(teamId);
|
||||
const [avatar, setAvatar] = useState<string>(fallback);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isValidUrl(url)) return;
|
||||
fetch(url, { cache: 'force-cache' })
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
setAvatar(url);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
/** noop */
|
||||
});
|
||||
});
|
||||
|
||||
return avatar;
|
||||
};
|
||||
|
||||
export const TeamAvatar = ({
|
||||
teamId,
|
||||
imgUrl,
|
||||
@@ -22,11 +44,11 @@ export const TeamAvatar = ({
|
||||
alt?: string;
|
||||
size?: 'large' | 'small';
|
||||
}) => {
|
||||
// const img = useAvatar(teamId, imgUrl);
|
||||
const img = useAvatar(teamId, imgUrl);
|
||||
return (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={imgUrl}
|
||||
src={img}
|
||||
alt={alt || 'Team avatar'}
|
||||
className={classNames(
|
||||
'rounded-full bg-vega-clight-700 dark:bg-vega-cdark-700 shrink-0',
|
||||
@@ -36,9 +58,6 @@ export const TeamAvatar = ({
|
||||
}
|
||||
)}
|
||||
referrerPolicy="no-referrer"
|
||||
onError={(e) => {
|
||||
e.currentTarget.src = getFallbackAvatar(teamId);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -115,7 +115,6 @@ describe('MarketSettledBanner', () => {
|
||||
open: '100',
|
||||
close: '100',
|
||||
volume: '100',
|
||||
notional: '10000',
|
||||
periodStart: subHours(new Date(now), 1).toISOString(),
|
||||
},
|
||||
},
|
||||
@@ -126,7 +125,6 @@ describe('MarketSettledBanner', () => {
|
||||
open: '100',
|
||||
close: '200',
|
||||
volume: '100',
|
||||
notional: '10000',
|
||||
periodStart: subHours(new Date(now), 2).toISOString(),
|
||||
},
|
||||
},
|
||||
@@ -163,7 +161,6 @@ describe('MarketSettledBanner', () => {
|
||||
open: '100',
|
||||
close: '100',
|
||||
volume: '100',
|
||||
notional: '10000',
|
||||
periodStart: '2020-01-01T00:00:00',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,11 +7,8 @@ import {
|
||||
useSuccessorMarket,
|
||||
type Market,
|
||||
} from '@vegaprotocol/markets';
|
||||
import {
|
||||
addDecimalsFormatNumber,
|
||||
getMarketExpiryDate,
|
||||
isNumeric,
|
||||
} from '@vegaprotocol/utils';
|
||||
import { addDecimalsFormatNumber, isNumeric } from '@vegaprotocol/utils';
|
||||
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers';
|
||||
import { useT, ns } from '../../lib/use-t';
|
||||
import { Links } from '../../lib/links';
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ describe('MarketSelectorItem', () => {
|
||||
high: '5',
|
||||
low: '5',
|
||||
volume: '50',
|
||||
notional: '10000',
|
||||
periodStart: yesterday.toISOString(),
|
||||
},
|
||||
{
|
||||
@@ -88,7 +87,6 @@ describe('MarketSelectorItem', () => {
|
||||
high: '10',
|
||||
low: '10',
|
||||
volume: '50',
|
||||
notional: '10000',
|
||||
periodStart: yesterday.toISOString(),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -72,17 +72,17 @@ const MarketData = ({
|
||||
|
||||
const marketTradingMode = marketData
|
||||
? marketData.marketTradingMode
|
||||
: market.data?.marketTradingMode;
|
||||
: market.data
|
||||
? market.data.marketTradingMode
|
||||
: market.tradingMode;
|
||||
|
||||
const mode =
|
||||
marketTradingMode &&
|
||||
[
|
||||
MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
|
||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||
MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
|
||||
].includes(marketTradingMode)
|
||||
? MarketTradingModeMapping[marketTradingMode]
|
||||
: '';
|
||||
const mode = [
|
||||
MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
|
||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||
MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
|
||||
].includes(marketTradingMode)
|
||||
? MarketTradingModeMapping[marketTradingMode]
|
||||
: '';
|
||||
|
||||
const { oneDayCandles } = useCandles({ marketId: market.id });
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ export const MarketSelector = ({
|
||||
<div data-testid="market-selector-list">
|
||||
<MarketList
|
||||
data={markets}
|
||||
loading={loading && !data}
|
||||
loading={loading}
|
||||
error={error}
|
||||
searchTerm={filter.searchTerm}
|
||||
currentMarketId={currentMarketId}
|
||||
|
||||
@@ -409,6 +409,7 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-1',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
// @ts-ignore data not on fragment
|
||||
data: createMarketsDataFragment({
|
||||
marketState: MarketState.STATE_ACTIVE,
|
||||
@@ -423,6 +424,7 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-2',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
// @ts-ignore data not on fragment
|
||||
data: createMarketsDataFragment({
|
||||
marketState: MarketState.STATE_ACTIVE,
|
||||
@@ -437,6 +439,7 @@ describe('useMarketSelectorList', () => {
|
||||
}),
|
||||
createMarketFragment({
|
||||
id: 'market-3',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
// @ts-ignore data not on fragment
|
||||
data: createMarketsDataFragment({
|
||||
marketState: MarketState.STATE_ACTIVE,
|
||||
|
||||
@@ -63,11 +63,7 @@ export const useMarketSelectorList = ({
|
||||
[
|
||||
(m) => {
|
||||
if (!m.candles?.length) return 0;
|
||||
return Number(
|
||||
priceChangePercentage(
|
||||
m.candles.filter((c) => c.close !== '').map((c) => c.close)
|
||||
)
|
||||
);
|
||||
return Number(priceChangePercentage(m.candles.map((c) => c.close)));
|
||||
},
|
||||
],
|
||||
[dir]
|
||||
|
||||
@@ -1,18 +1,48 @@
|
||||
import { useMarketState } from '@vegaprotocol/markets';
|
||||
import throttle from 'lodash/throttle';
|
||||
import type { MarketData, Market } from '@vegaprotocol/markets';
|
||||
import { marketDataProvider } from '@vegaprotocol/markets';
|
||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
import { HeaderStat } from '../header';
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import * as constants from '../constants';
|
||||
import { DocsLinks } from '@vegaprotocol/environment';
|
||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||
import { useT } from '../../lib/use-t';
|
||||
|
||||
export const MarketState = ({ marketId }: { marketId?: string }) => {
|
||||
export const MarketState = ({ market }: { market: Market | null }) => {
|
||||
const t = useT();
|
||||
const { data: marketState } = useMarketState(marketId);
|
||||
const [marketState, setMarketState] = useState<Schema.MarketState | null>(
|
||||
null
|
||||
);
|
||||
|
||||
const throttledSetMarketState = useRef(
|
||||
throttle((state: Schema.MarketState) => {
|
||||
setMarketState(state);
|
||||
}, constants.THROTTLE_UPDATE_TIME)
|
||||
).current;
|
||||
|
||||
const update = useCallback(
|
||||
({ data: marketData }: { data: MarketData | null }) => {
|
||||
if (marketData) {
|
||||
throttledSetMarketState(marketData.marketState);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[throttledSetMarketState]
|
||||
);
|
||||
|
||||
useDataProvider({
|
||||
dataProvider: marketDataProvider,
|
||||
update,
|
||||
variables: { marketId: market?.id || '' },
|
||||
skip: !market?.id,
|
||||
});
|
||||
|
||||
return (
|
||||
<HeaderStat
|
||||
heading={t('Status')}
|
||||
description={useGetMarketStateTooltip(marketState ?? undefined)}
|
||||
description={useGetMarketStateTooltip(marketState)}
|
||||
testId="market-state"
|
||||
>
|
||||
{marketState ? Schema.MarketStateMapping[marketState] : '-'}
|
||||
@@ -20,7 +50,7 @@ export const MarketState = ({ marketId }: { marketId?: string }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const useGetMarketStateTooltip = (state?: Schema.MarketState) => {
|
||||
const useGetMarketStateTooltip = (state: Schema.MarketState | null) => {
|
||||
const t = useT();
|
||||
if (state === Schema.MarketState.STATE_ACTIVE) {
|
||||
return t('Enactment date reached and usual auction exit checks pass');
|
||||
|
||||
@@ -26,15 +26,20 @@ const getTradingModeLabel = (
|
||||
interface HeaderStatMarketTradingModeProps {
|
||||
marketId?: string;
|
||||
onSelect?: (marketId: string, metaKey?: boolean) => void;
|
||||
initialTradingMode?: Schema.MarketTradingMode;
|
||||
initialTrigger?: Schema.AuctionTrigger;
|
||||
}
|
||||
|
||||
export const HeaderStatMarketTradingMode = ({
|
||||
marketId,
|
||||
onSelect,
|
||||
initialTradingMode,
|
||||
initialTrigger,
|
||||
}: HeaderStatMarketTradingModeProps) => {
|
||||
const t = useT();
|
||||
const { data } = useStaticMarketData(marketId);
|
||||
const { marketTradingMode, trigger } = data || {};
|
||||
const marketTradingMode = data?.marketTradingMode ?? initialTradingMode;
|
||||
const trigger = data?.trigger ?? initialTrigger;
|
||||
|
||||
return (
|
||||
<HeaderStat
|
||||
@@ -51,6 +56,8 @@ export const HeaderStatMarketTradingMode = ({
|
||||
|
||||
export const MarketTradingMode = ({
|
||||
marketId,
|
||||
initialTradingMode,
|
||||
initialTrigger,
|
||||
inViewRoot,
|
||||
}: Omit<HeaderStatMarketTradingModeProps, 'onUpdate'> & {
|
||||
inViewRoot?: RefObject<Element>;
|
||||
@@ -65,7 +72,10 @@ export const MarketTradingMode = ({
|
||||
}
|
||||
>
|
||||
<span ref={ref}>
|
||||
{getTradingModeLabel(data?.marketTradingMode, data?.trigger)}
|
||||
{getTradingModeLabel(
|
||||
data?.marketTradingMode ?? initialTradingMode,
|
||||
data?.trigger ?? initialTrigger
|
||||
)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { NodeHealthContainer, NodeUrl } from './node-health';
|
||||
import { MockedProvider, type MockedResponse } from '@apollo/client/testing';
|
||||
import {
|
||||
NodeCheckDocument,
|
||||
type NodeCheckQuery,
|
||||
} from '@vegaprotocol/environment';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
|
||||
const mockSetNodeSwitcher = jest.fn();
|
||||
|
||||
@@ -19,50 +15,20 @@ jest.mock('@vegaprotocol/environment', () => ({
|
||||
}));
|
||||
|
||||
describe('NodeHealthContainer', () => {
|
||||
const blockHeight = '1';
|
||||
const nodeCheckMock: MockedResponse<NodeCheckQuery, never> = {
|
||||
request: {
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
statistics: {
|
||||
chainId: 'chain-id',
|
||||
blockHeight: blockHeight,
|
||||
vegaTime: '12345',
|
||||
},
|
||||
networkParametersConnection: {
|
||||
edges: [
|
||||
{
|
||||
node: {
|
||||
key: 'a',
|
||||
value: '1',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const renderComponent = (mocks: MockedResponse[] = []) => {
|
||||
return render(
|
||||
<MockedProvider mocks={mocks}>
|
||||
<NodeHealthContainer />
|
||||
</MockedProvider>
|
||||
);
|
||||
};
|
||||
|
||||
it('controls the node switcher dialog', async () => {
|
||||
renderComponent([nodeCheckMock]);
|
||||
expect(await screen.findByRole('button')).toBeInTheDocument();
|
||||
render(<NodeHealthContainer />, { wrapper: MockedProvider });
|
||||
await waitFor(() => {
|
||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
||||
});
|
||||
await userEvent.click(screen.getByRole('button'));
|
||||
expect(mockSetNodeSwitcher).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('Shows node health data on hover', async () => {
|
||||
renderComponent([nodeCheckMock]);
|
||||
expect(await screen.findByRole('button')).toBeInTheDocument();
|
||||
render(<NodeHealthContainer />, { wrapper: MockedProvider });
|
||||
await waitFor(() => {
|
||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
||||
});
|
||||
await userEvent.hover(screen.getByRole('button'));
|
||||
await waitFor(() => {
|
||||
const portal = within(
|
||||
@@ -70,13 +36,12 @@ describe('NodeHealthContainer', () => {
|
||||
'[data-radix-popper-content-wrapper]'
|
||||
) as HTMLElement
|
||||
);
|
||||
|
||||
// two tooltips get rendered, I believe for animation purposes
|
||||
const tooltip = within(portal.getAllByTestId('tooltip-content')[0]);
|
||||
expect(
|
||||
tooltip.getByRole('link', { name: /^Mainnet status & incidents/ })
|
||||
).toBeInTheDocument();
|
||||
expect(tooltip.getByText('Operational')).toBeInTheDocument();
|
||||
expect(tooltip.getByText('Non operational')).toBeInTheDocument();
|
||||
expect(tooltip.getByTitle('Connected node')).toHaveTextContent(
|
||||
'vega-url.wtf'
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { OrderbookManager } from '@vegaprotocol/market-depth';
|
||||
import { ViewType, useSidebar } from '../sidebar';
|
||||
import { useDealTicketFormValues } from '@vegaprotocol/react-helpers';
|
||||
import { useDealTicketFormValues } from '@vegaprotocol/deal-ticket';
|
||||
import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id';
|
||||
|
||||
export const OrderbookContainer = ({ marketId }: { marketId: string }) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { useProfileDialogStore } from '../../stores/profile-dialog-store';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useT } from '../../lib/use-t';
|
||||
import { useRequired } from '@vegaprotocol/utils';
|
||||
import { useRequired } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
useSimpleTransaction,
|
||||
type Status,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user