Compare commits
91
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73049215dd | ||
|
|
cc782b5eae | ||
|
|
703792fbda | ||
|
|
029357b5ab | ||
|
|
954b4b2755 | ||
|
|
d238662c9d | ||
|
|
88251fae4d | ||
|
|
17946ae149 | ||
|
|
ebb0db3b37 | ||
|
|
df21996707 | ||
|
|
bb2464ddc2 | ||
|
|
a77bb06b2f | ||
|
|
1e15032c06 | ||
|
|
e28cdb2463 | ||
|
|
840ca63464 | ||
|
|
64fc075f7a | ||
|
|
bfa6be4c1c | ||
|
|
5f8c725c5b | ||
|
|
6d4d0d548e | ||
|
|
cd4b0e508e | ||
|
|
ed9cd3e0dd | ||
|
|
91d00a0520 | ||
|
|
0ada3a2f8d | ||
|
|
2efe0a7aa1 | ||
|
|
678ba9c4f7 | ||
|
|
4d566f5a5f | ||
|
|
f13307aa77 | ||
|
|
aed45e419d | ||
|
|
01e87443ee | ||
|
|
891e0d3d2f | ||
|
|
dc81334aec | ||
|
|
0a70c0ea49 | ||
|
|
05debbd777 | ||
|
|
8c383d8756 | ||
|
|
3e61018d89 | ||
|
|
77b1306f25 | ||
|
|
ff3cddc21b | ||
|
|
1d2ca52a25 | ||
|
|
62ecaaa9ce | ||
|
|
204871b81c | ||
|
|
ecdd917977 | ||
|
|
c0396db2b1 | ||
|
|
1fd1013353 | ||
|
|
e389579537 | ||
|
|
74f0f7bb3d | ||
|
|
3e78d55c0e | ||
|
|
1df8ba0972 | ||
|
|
e515928d87 | ||
|
|
2928181884 | ||
|
|
f6f3fb43eb | ||
|
|
1511772849 | ||
|
|
ab6c67fd37 | ||
|
|
f4212724d0 | ||
|
|
7b162104b6 | ||
|
|
88f99031d1 | ||
|
|
72df08851c | ||
|
|
d9292b9be2 | ||
|
|
be8de04686 | ||
|
|
bd14c2a39a | ||
|
|
8e2ec8ab67 | ||
|
|
0636d19b0d | ||
|
|
0dd58b68cf | ||
|
|
49fdd0f68a | ||
|
|
3e2e3c3970 | ||
|
|
b89523efb2 | ||
|
|
be9a5a3437 | ||
|
|
475b52bcaf | ||
|
|
7620f0b67d | ||
|
|
0f5b712034 | ||
|
|
424061d64c | ||
|
|
a49f5f0dd1 | ||
|
|
bf094288fd | ||
|
|
bc8a427788 | ||
|
|
447dc254d7 | ||
|
|
cebbdb4ee7 | ||
|
|
fd69f6078c | ||
|
|
917bdde0bb | ||
|
|
2153367258 | ||
|
|
c0942d56a1 | ||
|
|
e57a6de765 | ||
|
|
9eee76e5a6 | ||
|
|
aa71e608f0 | ||
|
|
20ad18c8a0 | ||
|
|
457422b5ac | ||
|
|
990c894e2f | ||
|
|
2e28a175ce | ||
|
|
a77858c1c0 | ||
|
|
054c0377b4 | ||
|
|
29bcbd06fb | ||
|
|
05b39e2c08 | ||
|
|
654dd1e7b0 |
@@ -4,6 +4,5 @@ tmp/*
|
|||||||
.dockerignore
|
.dockerignore
|
||||||
dockerfiles
|
dockerfiles
|
||||||
node_modules
|
node_modules
|
||||||
.git
|
|
||||||
.github
|
.github
|
||||||
.vscode
|
.vscode
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
inputs:
|
inputs:
|
||||||
console-test-branch:
|
console-test-branch:
|
||||||
type: choice
|
type: choice
|
||||||
description: 'main: v0.73.13, develop: v0.74.0'
|
description: 'main: v0.74.10, develop: v0.75.5'
|
||||||
options:
|
options:
|
||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
@@ -57,15 +57,14 @@ jobs:
|
|||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Build trading app
|
- name: Build trading app
|
||||||
run: |
|
run: |
|
||||||
yarn env-cmd -f ./apps/trading/.env.stagnet1 yarn nx export trading
|
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
|
||||||
DIST_LOCATION=dist/apps/trading/exported
|
DIST_LOCATION=dist/apps/trading/exported
|
||||||
mv $DIST_LOCATION dist-result
|
mv $DIST_LOCATION dist-result
|
||||||
tree dist-result
|
tree dist-result
|
||||||
|
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# export trading app docker image
|
# export trading app docker image
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ jobs:
|
|||||||
load: true
|
load: true
|
||||||
build-args: |
|
build-args: |
|
||||||
APP=trading
|
APP=trading
|
||||||
ENV_NAME=stagnet1
|
ENV_NAME=${{ needs.console-test-branch.outputs.console-branch == 'main' && 'mainnet' || 'stagnet1' }}
|
||||||
tags: ci/trading:local
|
tags: ci/trading:local
|
||||||
outputs: type=docker,dest=/tmp/console-image.tar
|
outputs: type=docker,dest=/tmp/console-image.tar
|
||||||
|
|
||||||
@@ -182,12 +181,22 @@ jobs:
|
|||||||
virtualenvs-create: true
|
virtualenvs-create: true
|
||||||
virtualenvs-in-project: true
|
virtualenvs-in-project: true
|
||||||
virtualenvs-path: .venv
|
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
|
# install python dependencies
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: poetry install --no-interaction --no-root
|
run: poetry lock && poetry install --no-interaction --no-root
|
||||||
working-directory: apps/trading/e2e
|
working-directory: apps/trading/e2e
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# install vega binaries
|
# install vega binaries
|
||||||
|
|||||||
@@ -58,5 +58,6 @@ __pycache__/
|
|||||||
apps/trading/e2e/logs/
|
apps/trading/e2e/logs/
|
||||||
apps/trading/e2e/.pytest_cache/
|
apps/trading/e2e/.pytest_cache/
|
||||||
apps/trading/e2e/traces/
|
apps/trading/e2e/traces/
|
||||||
|
apps/trading/e2e/pyproject.toml
|
||||||
|
|
||||||
.nx/
|
.nx/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# App configuration variables
|
# App configuration variables
|
||||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
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_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||||
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ import EpochMissingOverview from './epoch-missing';
|
|||||||
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { IconProps } from '@vegaprotocol/ui-toolkit';
|
import type { IconProps } from '@vegaprotocol/ui-toolkit';
|
||||||
import isPast from 'date-fns/isPast';
|
import isPast from 'date-fns/isPast';
|
||||||
|
import { EpochSymbol } from '../links/block-link/block-link';
|
||||||
|
|
||||||
const borderClass =
|
const borderClass =
|
||||||
'border-solid border-2 border-vega-dark-200 border-collapse';
|
'border-solid border-2 border-vega-dark-200 border-collapse';
|
||||||
|
|
||||||
export type EpochOverviewProps = {
|
export type EpochOverviewProps = {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
icon?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +26,7 @@ export type EpochOverviewProps = {
|
|||||||
*
|
*
|
||||||
* The details are hidden in a tooltip, behind the epoch number
|
* The details are hidden in a tooltip, behind the epoch number
|
||||||
*/
|
*/
|
||||||
const EpochOverview = ({ id }: EpochOverviewProps) => {
|
const EpochOverview = ({ id, icon = true }: EpochOverviewProps) => {
|
||||||
const { data, error, loading } = useExplorerEpochQuery({
|
const { data, error, loading } = useExplorerEpochQuery({
|
||||||
variables: { id: id || '' },
|
variables: { id: id || '' },
|
||||||
});
|
});
|
||||||
@@ -38,7 +40,12 @@ const EpochOverview = ({ id }: EpochOverviewProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ti || loading || error) {
|
if (!ti || loading || error) {
|
||||||
return <span>{id}</span>;
|
return (
|
||||||
|
<span>
|
||||||
|
<EpochSymbol />
|
||||||
|
{id}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const description = (
|
const description = (
|
||||||
@@ -90,7 +97,11 @@ const EpochOverview = ({ id }: EpochOverviewProps) => {
|
|||||||
return (
|
return (
|
||||||
<Tooltip description={description}>
|
<Tooltip description={description}>
|
||||||
<p>
|
<p>
|
||||||
<IconForEpoch start={ti.start} end={ti.end} />
|
{icon ? (
|
||||||
|
<IconForEpoch start={ti.start} end={ti.end} />
|
||||||
|
) : (
|
||||||
|
<EpochSymbol />
|
||||||
|
)}
|
||||||
{id}
|
{id}
|
||||||
</p>
|
</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
query ExplorerEpochForBlock($block: String!) {
|
||||||
|
epoch(block: $block) {
|
||||||
|
id
|
||||||
|
timestamps {
|
||||||
|
start
|
||||||
|
end
|
||||||
|
lastBlock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
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,17 +4,56 @@ import { Link } from 'react-router-dom';
|
|||||||
|
|
||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from 'react';
|
||||||
import Hash from '../hash';
|
import Hash from '../hash';
|
||||||
|
import { useExplorerEpochForBlockQuery } from './__generated__/EpochByBlock';
|
||||||
|
import { t } from '@vegaprotocol/i18n';
|
||||||
|
|
||||||
export type BlockLinkProps = Partial<ComponentProps<typeof Link>> & {
|
export type BlockLinkProps = Partial<ComponentProps<typeof Link>> & {
|
||||||
height: string;
|
height: string;
|
||||||
|
showEpoch?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const BlockLink = ({ height, ...props }: BlockLinkProps) => {
|
const BlockLink = ({ height, showEpoch = false, ...props }: BlockLinkProps) => {
|
||||||
return (
|
return (
|
||||||
<Link className="underline" {...props} to={`/${Routes.BLOCKS}/${height}`}>
|
<>
|
||||||
<Hash text={height} />
|
<Link className="underline" {...props} to={`/${Routes.BLOCKS}/${height}`}>
|
||||||
</Link>
|
<Hash text={height} />
|
||||||
|
</Link>
|
||||||
|
{showEpoch && <EpochForBlock block={height} />}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
export default BlockLink;
|
||||||
|
|||||||
+5
-2
@@ -1,5 +1,8 @@
|
|||||||
import type { ChainIdMapping } from './external-chain';
|
import type { ChainIdMapping } from '@vegaprotocol/environment';
|
||||||
import { SUPPORTED_CHAIN_IDS, SUPPORTED_CHAIN_LABELS } from './external-chain';
|
import {
|
||||||
|
SUPPORTED_CHAIN_IDS,
|
||||||
|
SUPPORTED_CHAIN_LABELS,
|
||||||
|
} from '@vegaprotocol/environment';
|
||||||
|
|
||||||
export const SUPPORTED_CHAIN_ICON_URLS: ChainIdMapping = {
|
export const SUPPORTED_CHAIN_ICON_URLS: ChainIdMapping = {
|
||||||
'1': '/assets/chain-eth-logo.svg',
|
'1': '/assets/chain-eth-logo.svg',
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import Hash from '../hash';
|
import Hash from '../hash';
|
||||||
import { getExternalExplorerLink } from './external-chain';
|
import { getExternalExplorerLink } from '@vegaprotocol/environment';
|
||||||
import { ExternalChainIcon } from './external-chain-icon';
|
import { ExternalChainIcon } from './external-chain-icon';
|
||||||
|
|
||||||
export enum EthExplorerLinkTypes {
|
export enum EthExplorerLinkTypes {
|
||||||
@@ -23,7 +23,7 @@ export const ExternalExplorerLink = ({
|
|||||||
code = false,
|
code = false,
|
||||||
...props
|
...props
|
||||||
}: ExternalExplorerLinkProps) => {
|
}: ExternalExplorerLinkProps) => {
|
||||||
const link = `${getExternalExplorerLink(chain, type)}/${type}/${id}${
|
const link = `${getExternalExplorerLink(chain)}/${type}/${id}${
|
||||||
code ? '#code' : ''
|
code ? '#code' : ''
|
||||||
}`;
|
}`;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
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,6 +6,7 @@ import {
|
|||||||
LiquiditySLAParametersInfoPanel,
|
LiquiditySLAParametersInfoPanel,
|
||||||
MarginScalingFactorsPanel,
|
MarginScalingFactorsPanel,
|
||||||
PriceMonitoringBoundsInfoPanel,
|
PriceMonitoringBoundsInfoPanel,
|
||||||
|
PriceMonitoringSettingsInfoPanel,
|
||||||
SuccessionLineInfoPanel,
|
SuccessionLineInfoPanel,
|
||||||
getDataSourceSpecForSettlementData,
|
getDataSourceSpecForSettlementData,
|
||||||
getDataSourceSpecForTradingTermination,
|
getDataSourceSpecForTradingTermination,
|
||||||
@@ -21,7 +22,6 @@ import {
|
|||||||
RiskModelInfoPanel,
|
RiskModelInfoPanel,
|
||||||
SettlementAssetInfoPanel,
|
SettlementAssetInfoPanel,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
import { MarketInfoTable } from '@vegaprotocol/markets';
|
|
||||||
import type { DataSourceFragment } from '@vegaprotocol/markets';
|
import type { DataSourceFragment } from '@vegaprotocol/markets';
|
||||||
import isEqual from 'lodash/isEqual';
|
import isEqual from 'lodash/isEqual';
|
||||||
|
|
||||||
@@ -74,27 +74,14 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => {
|
|||||||
<MarginScalingFactorsPanel market={market} />
|
<MarginScalingFactorsPanel market={market} />
|
||||||
<h2 className={headerClassName}>{t('Risk factors')}</h2>
|
<h2 className={headerClassName}>{t('Risk factors')}</h2>
|
||||||
<RiskFactorsInfoPanel market={market} />
|
<RiskFactorsInfoPanel market={market} />
|
||||||
{(market.data?.priceMonitoringBounds || []).map((trigger, i) => (
|
<h2 className={headerClassName}>{t('Price monitoring bounds')}</h2>
|
||||||
<>
|
<div className="mt-3">
|
||||||
<h2 className={headerClassName}>
|
<PriceMonitoringBoundsInfoPanel market={market} />
|
||||||
{t('Price monitoring bounds %s', [(i + 1).toString()])}
|
</div>
|
||||||
</h2>
|
<h2 className={headerClassName}>{t('Price monitoring settings')}</h2>
|
||||||
<PriceMonitoringBoundsInfoPanel
|
<div className="mt-3">
|
||||||
market={market}
|
<PriceMonitoringSettingsInfoPanel market={market} />
|
||||||
triggerIndex={i + 1}
|
</div>
|
||||||
/>
|
|
||||||
</>
|
|
||||||
))}
|
|
||||||
{(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>
|
<h2 className={headerClassName}>{t('Liquidation strategy')}</h2>
|
||||||
<LiquidationStrategyInfoPanel market={market} />
|
<LiquidationStrategyInfoPanel market={market} />
|
||||||
<h2 className={headerClassName}>{t('Liquidity monitoring')}</h2>
|
<h2 className={headerClassName}>{t('Liquidity monitoring')}</h2>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { getAsset, type MarketFieldsFragment } from '@vegaprotocol/markets';
|
import { getAsset, type MarketMaybeWithData } from '@vegaprotocol/markets';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
import { ButtonLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import { type AgGridReact } from 'ag-grid-react';
|
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';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
type MarketsTableProps = {
|
type MarketsTableProps = {
|
||||||
data: MarketFieldsFragment[] | null;
|
data: MarketMaybeWithData[] | null;
|
||||||
};
|
};
|
||||||
export const MarketsTable = ({ data }: MarketsTableProps) => {
|
export const MarketsTable = ({ data }: MarketsTableProps) => {
|
||||||
const openAssetDetailsDialog = useAssetDetailsDialogStore(
|
const openAssetDetailsDialog = useAssetDetailsDialogStore(
|
||||||
@@ -56,10 +56,10 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
|||||||
headerName: t('Status'),
|
headerName: t('Status'),
|
||||||
field: 'state',
|
field: 'state',
|
||||||
hide: window.innerWidth <= BREAKPOINT_MD,
|
hide: window.innerWidth <= BREAKPOINT_MD,
|
||||||
valueGetter: ({
|
valueGetter: ({ data }: VegaValueGetterParams<MarketMaybeWithData>) => {
|
||||||
data,
|
return data?.data?.marketState
|
||||||
}: VegaValueGetterParams<MarketFieldsFragment>) => {
|
? MarketStateMapping[data?.data.marketState]
|
||||||
return data?.state ? MarketStateMapping[data?.state] : '-';
|
: '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -70,7 +70,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
|||||||
cellRenderer: ({
|
cellRenderer: ({
|
||||||
data,
|
data,
|
||||||
}: VegaICellRendererParams<
|
}: VegaICellRendererParams<
|
||||||
MarketFieldsFragment,
|
MarketMaybeWithData,
|
||||||
'tradableInstrument.instrument.product.settlementAsset.symbol'
|
'tradableInstrument.instrument.product.settlementAsset.symbol'
|
||||||
>) => {
|
>) => {
|
||||||
const value = data && getAsset(data);
|
const value = data && getAsset(data);
|
||||||
@@ -99,7 +99,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
|||||||
field: 'id',
|
field: 'id',
|
||||||
cellRenderer: ({
|
cellRenderer: ({
|
||||||
value,
|
value,
|
||||||
}: VegaICellRendererParams<MarketFieldsFragment, 'id'>) =>
|
}: VegaICellRendererParams<MarketMaybeWithData, 'id'>) =>
|
||||||
value ? (
|
value ? (
|
||||||
<Link className="underline" to={value}>
|
<Link className="underline" to={value}>
|
||||||
{t('View details')}
|
{t('View details')}
|
||||||
@@ -116,7 +116,7 @@ export const MarketsTable = ({ data }: MarketsTableProps) => {
|
|||||||
<AgGrid
|
<AgGrid
|
||||||
ref={gridRef}
|
ref={gridRef}
|
||||||
rowData={data}
|
rowData={data}
|
||||||
getRowId={({ data }: { data: MarketFieldsFragment }) => data.id}
|
getRowId={({ data }: { data: MarketMaybeWithData }) => data.id}
|
||||||
overlayNoRowsTemplate={t('This chain has no markets')}
|
overlayNoRowsTemplate={t('This chain has no markets')}
|
||||||
domLayout="autoHeight"
|
domLayout="autoHeight"
|
||||||
defaultColDef={{
|
defaultColDef={{
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
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 (
|
return (
|
||||||
<p>
|
<span>
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
<AssetLink assetId={assetId} showAssetSymbol={true} asDialog={true} />
|
<AssetLink assetId={assetId} showAssetSymbol={true} asDialog={true} />
|
||||||
</p>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
ExternalExplorerLink,
|
ExternalExplorerLink,
|
||||||
EthExplorerLinkTypes,
|
EthExplorerLinkTypes,
|
||||||
} from '../../../links/external-explorer-link/external-explorer-link';
|
} from '../../../links/external-explorer-link/external-explorer-link';
|
||||||
import { getExternalChainLabel } from '../../../links/external-explorer-link/external-chain';
|
import { getExternalChainLabel } from '@vegaprotocol/environment';
|
||||||
import type { components } from '../../../../../types/explorer';
|
import type { components } from '../../../../../types/explorer';
|
||||||
import { defaultAbiCoder, base64 } from 'ethers/lib/utils';
|
import { defaultAbiCoder, base64 } from 'ethers/lib/utils';
|
||||||
import { BigNumber } from 'ethers';
|
import { BigNumber } from 'ethers';
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { ChainResponseCode } from '../chain-response-code/chain-reponse.code';
|
|||||||
import { TxDataView } from '../../tx-data-view';
|
import { TxDataView } from '../../tx-data-view';
|
||||||
import Hash from '../../../links/hash';
|
import Hash from '../../../links/hash';
|
||||||
import { Signature } from '../../../signature/signature';
|
import { Signature } from '../../../signature/signature';
|
||||||
|
import { useExplorerEpochForBlockQuery } from '../../../links/block-link/__generated__/EpochByBlock';
|
||||||
|
import EpochOverview from '../../../epoch-overview/epoch';
|
||||||
|
|
||||||
interface TxDetailsSharedProps {
|
interface TxDetailsSharedProps {
|
||||||
txData: BlockExplorerTransactionResult | undefined;
|
txData: BlockExplorerTransactionResult | undefined;
|
||||||
@@ -44,6 +46,11 @@ export const TxDetailsShared = ({
|
|||||||
blockData,
|
blockData,
|
||||||
hideTypeRow = false,
|
hideTypeRow = false,
|
||||||
}: TxDetailsSharedProps) => {
|
}: TxDetailsSharedProps) => {
|
||||||
|
const { data } = useExplorerEpochForBlockQuery({
|
||||||
|
errorPolicy: 'ignore',
|
||||||
|
variables: { block: txData?.block?.toString() || '' },
|
||||||
|
});
|
||||||
|
|
||||||
if (!txData) {
|
if (!txData) {
|
||||||
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
||||||
}
|
}
|
||||||
@@ -74,7 +81,7 @@ export const TxDetailsShared = ({
|
|||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableCell {...sharedHeaderProps}>{t('Block')}</TableCell>
|
<TableCell {...sharedHeaderProps}>{t('Block')}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<BlockLink height={height} />
|
<BlockLink height={height} showEpoch={false} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
@@ -83,6 +90,7 @@ export const TxDetailsShared = ({
|
|||||||
<Signature signature={txData.signature} />
|
<Signature signature={txData.signature} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableCell {...sharedHeaderProps}>{t('Time')}</TableCell>
|
<TableCell {...sharedHeaderProps}>{t('Time')}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
@@ -100,6 +108,14 @@ export const TxDetailsShared = ({
|
|||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</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">
|
<TableRow modifier="bordered">
|
||||||
<TableCell {...sharedHeaderProps}>{t('Response code')}</TableCell>
|
<TableCell {...sharedHeaderProps}>{t('Response code')}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
query ExplorerTransferStatus($id: ID!) {
|
query ExplorerTransferStatus($id: ID!) {
|
||||||
transfer(id: $id) {
|
transfer(id: $id) {
|
||||||
|
fees {
|
||||||
|
amount
|
||||||
|
epoch
|
||||||
|
}
|
||||||
transfer {
|
transfer {
|
||||||
reference
|
reference
|
||||||
timestamp
|
timestamp
|
||||||
|
|||||||
+5
-1
@@ -8,12 +8,16 @@ export type ExplorerTransferStatusQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
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 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 const ExplorerTransferStatusDocument = gql`
|
export const ExplorerTransferStatusDocument = gql`
|
||||||
query ExplorerTransferStatus($id: ID!) {
|
query ExplorerTransferStatus($id: ID!) {
|
||||||
transfer(id: $id) {
|
transfer(id: $id) {
|
||||||
|
fees {
|
||||||
|
amount
|
||||||
|
epoch
|
||||||
|
}
|
||||||
transfer {
|
transfer {
|
||||||
reference
|
reference
|
||||||
timestamp
|
timestamp
|
||||||
|
|||||||
+45
-4
@@ -44,8 +44,14 @@ const AccountType: Record<AccountTypes, string> = {
|
|||||||
ACCOUNT_TYPE_ORDER_MARGIN: 'Order Margin',
|
ACCOUNT_TYPE_ORDER_MARGIN: 'Order Margin',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TransferFee = {
|
||||||
|
amount?: string;
|
||||||
|
epoch?: number;
|
||||||
|
};
|
||||||
|
|
||||||
interface TransferParticipantsProps {
|
interface TransferParticipantsProps {
|
||||||
transfer: Transfer;
|
transfer: Transfer;
|
||||||
|
fees?: TransferFee[] | null;
|
||||||
from: string;
|
from: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +66,7 @@ interface TransferParticipantsProps {
|
|||||||
export function TransferParticipants({
|
export function TransferParticipants({
|
||||||
transfer,
|
transfer,
|
||||||
from,
|
from,
|
||||||
|
fees,
|
||||||
}: TransferParticipantsProps) {
|
}: TransferParticipantsProps) {
|
||||||
// This mapping is required as the global account types require a type to be set, while
|
// 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.
|
// the underlying protobufs allow for every field to be undefined.
|
||||||
@@ -104,6 +111,9 @@ export function TransferParticipants({
|
|||||||
{transfer.asset ? (
|
{transfer.asset ? (
|
||||||
<SizeInAsset assetId={transfer.asset} size={transfer.amount} />
|
<SizeInAsset assetId={transfer.asset} size={transfer.amount} />
|
||||||
) : null}
|
) : null}
|
||||||
|
{transfer.asset && fees && (
|
||||||
|
<TransferFees assetId={transfer.asset} fees={fees} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Empty divs for the top arrow and the bottom arrow of the transfer inset */}
|
{/* Empty divs for the top arrow and the bottom arrow of the transfer inset */}
|
||||||
@@ -125,10 +135,6 @@ export function TransferParticipants({
|
|||||||
<path d="M0,0L8,9l8,-9Z" />
|
<path d="M0,0L8,9l8,-9Z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -169,3 +175,38 @@ export function TransferRecurringRecipient({
|
|||||||
// Fallback should not happen
|
// Fallback should not happen
|
||||||
return null;
|
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,9 +41,16 @@ export function TransferDetails({ transfer, from, id }: TransferDetailsProps) {
|
|||||||
? TransferStatus.STATUS_REJECTED
|
? TransferStatus.STATUS_REJECTED
|
||||||
: data?.transfer?.transfer.status;
|
: 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 (
|
return (
|
||||||
<div className="flex flex-wrap">
|
<div className="flex flex-wrap">
|
||||||
<TransferParticipants from={from} transfer={transfer} />
|
<TransferParticipants from={from} transfer={transfer} fees={fees} />
|
||||||
{recurring ? <TransferRepeat recurring={transfer.recurring} /> : null}
|
{recurring ? <TransferRepeat recurring={transfer.recurring} /> : null}
|
||||||
<TransferStatusView status={status} error={error} loading={loading} />
|
<TransferStatusView status={status} error={error} loading={loading} />
|
||||||
{recurring && recurring.dispatchStrategy ? (
|
{recurring && recurring.dispatchStrategy ? (
|
||||||
|
|||||||
@@ -113,13 +113,16 @@ export const TxDetailsTransfer = ({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a string description of this transfer
|
* Gets a string description of this transfer
|
||||||
* @param txData A full transfer
|
* @param tx A full transfer
|
||||||
* @returns string Transfer label
|
* @returns string Transfer label
|
||||||
*/
|
*/
|
||||||
export function getTypeLabelForTransfer(tx: Transfer) {
|
export function getTypeLabelForTransfer(tx: Transfer) {
|
||||||
if (tx.to === SPECIAL_CASE_NETWORK || tx.to === SPECIAL_CASE_NETWORK_ID) {
|
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) {
|
if (tx.recurring && tx.recurring.dispatchStrategy) {
|
||||||
return 'Reward top up transfer';
|
return 'Reward transfer';
|
||||||
}
|
}
|
||||||
// Else: we don't know that it's a reward transfer, so let's not guess
|
// Else: we don't know that it's a reward transfer, so let's not guess
|
||||||
} else if (tx.recurring) {
|
} else if (tx.recurring) {
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ import { FilterLabel } from './tx-filter-label';
|
|||||||
|
|
||||||
// All possible transaction types. Should be generated.
|
// All possible transaction types. Should be generated.
|
||||||
export type FilterOption =
|
export type FilterOption =
|
||||||
| 'Amend LiquidityProvision Order'
|
| 'Amend Liquidity Provision Order'
|
||||||
| 'Amend Order'
|
| 'Amend Order'
|
||||||
| 'Apply Referral Code'
|
| 'Apply Referral Code'
|
||||||
| 'Batch Market Instructions'
|
| 'Batch Market Instructions'
|
||||||
| 'Batch Proposal'
|
| 'Batch Proposal'
|
||||||
| 'Cancel LiquidityProvision Order'
|
| 'Cancel Liquidity Provision Order'
|
||||||
| 'Cancel Order'
|
| 'Cancel Order'
|
||||||
| 'Cancel Transfer Funds'
|
| 'Cancel Transfer Funds'
|
||||||
| 'Chain Event'
|
| 'Chain Event'
|
||||||
@@ -53,10 +53,10 @@ export type FilterOption =
|
|||||||
|
|
||||||
export const filterOptions: Record<string, FilterOption[]> = {
|
export const filterOptions: Record<string, FilterOption[]> = {
|
||||||
'Market Instructions': [
|
'Market Instructions': [
|
||||||
'Amend LiquidityProvision Order',
|
'Amend Liquidity Provision Order',
|
||||||
'Amend Order',
|
'Amend Order',
|
||||||
'Batch Market Instructions',
|
'Batch Market Instructions',
|
||||||
'Cancel LiquidityProvision Order',
|
'Cancel Liquidity Provision Order',
|
||||||
'Cancel Order',
|
'Cancel Order',
|
||||||
'Liquidity Provision Order',
|
'Liquidity Provision Order',
|
||||||
'Stop Orders Submission',
|
'Stop Orders Submission',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { t } from '@vegaprotocol/i18n';
|
|||||||
import type { components } from '../../../types/explorer';
|
import type { components } from '../../../types/explorer';
|
||||||
import { VoteIcon } from '../vote-icon/vote-icon';
|
import { VoteIcon } from '../vote-icon/vote-icon';
|
||||||
import { ExternalChainIcon } from '../links/external-explorer-link/external-chain-icon';
|
import { ExternalChainIcon } from '../links/external-explorer-link/external-chain-icon';
|
||||||
|
import { getTypeLabelForTransfer } from './details/tx-transfer';
|
||||||
|
|
||||||
interface TxOrderTypeProps {
|
interface TxOrderTypeProps {
|
||||||
orderType: string;
|
orderType: string;
|
||||||
@@ -95,7 +96,7 @@ export function getLabelForOrderType(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a proposal, will return a specific label
|
* Given a proposal, will return a specific label
|
||||||
* @param chainEvent
|
* @param proposal
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function getLabelForProposal(
|
export function getLabelForProposal(
|
||||||
@@ -142,6 +143,36 @@ 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
|
* Given a chain event, will try to provide a more useful label
|
||||||
* @param chainEvent
|
* @param chainEvent
|
||||||
@@ -225,9 +256,10 @@ export const TxOrderType = ({ orderType, command }: TxOrderTypeProps) => {
|
|||||||
if (type === 'Chain Event' && !!command?.chainEvent) {
|
if (type === 'Chain Event' && !!command?.chainEvent) {
|
||||||
type = getLabelForChainEvent(command.chainEvent);
|
type = getLabelForChainEvent(command.chainEvent);
|
||||||
colours = 'text-white dark-text-white bg-vega-pink dark:bg-vega-pink';
|
colours = 'text-white dark-text-white bg-vega-pink dark:bg-vega-pink';
|
||||||
} else if (type === 'Validator Heartbeat') {
|
} else if (type === 'Transfer Funds' && command?.transfer) {
|
||||||
colours =
|
const res = getLabelForTransfer(command.transfer);
|
||||||
'text-white dark-text-white bg-vega-light-200 dark:bg-vega-dark-100';
|
type = res.type;
|
||||||
|
colours = res.colours;
|
||||||
} else if (type === 'Proposal' || type === 'Governance Proposal') {
|
} else if (type === 'Proposal' || type === 'Governance Proposal') {
|
||||||
if (command && !!command.proposalSubmission) {
|
if (command && !!command.proposalSubmission) {
|
||||||
type = getLabelForProposal(command.proposalSubmission);
|
type = getLabelForProposal(command.proposalSubmission);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ describe('TX: Transfer: getLabelForTransfer', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(getTypeLabelForTransfer(mock)).toEqual('Reward top up transfer');
|
expect(getTypeLabelForTransfer(mock)).toEqual('Reward transfer');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders reward top up label if the TO party is network', () => {
|
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 top up transfer');
|
expect(getTypeLabelForTransfer(mock)).toEqual('Reward transfer');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders recurring label if the tx has a recurring property', () => {
|
it('renders recurring label if the tx has a recurring property', () => {
|
||||||
@@ -81,6 +81,7 @@ describe('TxDetailsTransfer', () => {
|
|||||||
hash: 'test',
|
hash: 'test',
|
||||||
submitter:
|
submitter:
|
||||||
'e1943eea46fed576cf2be42972f3c5515ad3d0ac7ac013f56677c12a53a1b3ed',
|
'e1943eea46fed576cf2be42972f3c5515ad3d0ac7ac013f56677c12a53a1b3ed',
|
||||||
|
block: '100',
|
||||||
command: {
|
command: {
|
||||||
nonce: '5188810881378065222',
|
nonce: '5188810881378065222',
|
||||||
blockHeight: '14951513',
|
blockHeight: '14951513',
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { useBlockInfo } from '@vegaprotocol/tendermint';
|
|||||||
import { NodeLink } from '../../../components/links';
|
import { NodeLink } from '../../../components/links';
|
||||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||||
import EmptyList from '../../../components/empty-list/empty-list';
|
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 };
|
type Params = { block: string };
|
||||||
|
|
||||||
@@ -26,6 +28,11 @@ const Block = () => {
|
|||||||
state: { data: blockData, loading, error },
|
state: { data: blockData, loading, error },
|
||||||
} = useBlockInfo(Number(block));
|
} = useBlockInfo(Number(block));
|
||||||
|
|
||||||
|
const { data } = useExplorerEpochForBlockQuery({
|
||||||
|
errorPolicy: 'ignore',
|
||||||
|
variables: { block: block?.toString() || '' },
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<RouteTitle data-testid="block-header">{t(`BLOCK ${block}`)}</RouteTitle>
|
<RouteTitle data-testid="block-header">{t(`BLOCK ${block}`)}</RouteTitle>
|
||||||
@@ -75,6 +82,7 @@ const Block = () => {
|
|||||||
<code>{blockData.result.block.header.consensus_hash}</code>
|
<code>{blockData.result.block.header.consensus_hash}</code>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableHeader scope="row">Mined by</TableHeader>
|
<TableHeader scope="row">Mined by</TableHeader>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered">
|
||||||
@@ -97,6 +105,14 @@ const Block = () => {
|
|||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</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">
|
<TableRow modifier="bordered">
|
||||||
<TableHeader scope="row">Transactions</TableHeader>
|
<TableHeader scope="row">Transactions</TableHeader>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered">
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
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 { useScrollToLocation } from '../../hooks/scroll-to-location';
|
||||||
import { useDocumentTitle } from '../../hooks/use-document-title';
|
import { useDocumentTitle } from '../../hooks/use-document-title';
|
||||||
import { marketsProvider } from '@vegaprotocol/markets';
|
import { marketsWithDataProvider } from '@vegaprotocol/markets';
|
||||||
import { RouteTitle } from '../../components/route-title';
|
import { RouteTitle } from '../../components/route-title';
|
||||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
@@ -12,7 +12,7 @@ export const MarketsPage = () => {
|
|||||||
useScrollToLocation();
|
useScrollToLocation();
|
||||||
|
|
||||||
const { data, loading, error } = useDataProvider({
|
const { data, loading, error } = useDataProvider({
|
||||||
dataProvider: marketsProvider,
|
dataProvider: marketsWithDataProvider,
|
||||||
variables: undefined,
|
variables: undefined,
|
||||||
skipUpdates: true,
|
skipUpdates: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
addDecimalsFormatNumber,
|
addDecimalsFormatNumber,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
removePaginationWrapper,
|
removePaginationWrapper,
|
||||||
validForSyntaxHighlighter,
|
suitableForSyntaxHighlighter,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { RouteTitle } from '../../components/route-title';
|
import { RouteTitle } from '../../components/route-title';
|
||||||
@@ -134,7 +134,7 @@ export const NetworkParameterRow = ({
|
|||||||
}: {
|
}: {
|
||||||
row: { key: string; value: string };
|
row: { key: string; value: string };
|
||||||
}) => {
|
}) => {
|
||||||
const isSyntaxRow = validForSyntaxHighlighter(value);
|
const isSyntaxRow = suitableForSyntaxHighlighter(value);
|
||||||
useDocumentTitle(['Network Parameters']);
|
useDocumentTitle(['Network Parameters']);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -89,7 +89,40 @@ fragment ExplorerOracleDataSourceSpec on ExternalDataSourceSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query ExplorerOracleFormMarkets {
|
query ExplorerOracleFormMarkets {
|
||||||
marketsConnection {
|
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) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
...ExplorerOracleForMarketsMarket
|
...ExplorerOracleForMarketsMarket
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ 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 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`
|
export const ExplorerOracleFutureFragmentDoc = gql`
|
||||||
fragment ExplorerOracleFuture on Future {
|
fragment ExplorerOracleFuture on Future {
|
||||||
dataSourceSpecForSettlementData {
|
dataSourceSpecForSettlementData {
|
||||||
@@ -113,7 +120,7 @@ export const ExplorerOracleDataSourceSpecFragmentDoc = gql`
|
|||||||
`;
|
`;
|
||||||
export const ExplorerOracleFormMarketsDocument = gql`
|
export const ExplorerOracleFormMarketsDocument = gql`
|
||||||
query ExplorerOracleFormMarkets {
|
query ExplorerOracleFormMarkets {
|
||||||
marketsConnection {
|
marketsConnection(includeSettled: false, pagination: {first: 20}) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
...ExplorerOracleForMarketsMarket
|
...ExplorerOracleForMarketsMarket
|
||||||
@@ -126,7 +133,7 @@ export const ExplorerOracleFormMarketsDocument = gql`
|
|||||||
dataSourceSpec {
|
dataSourceSpec {
|
||||||
...ExplorerOracleDataSourceSpec
|
...ExplorerOracleDataSourceSpec
|
||||||
}
|
}
|
||||||
dataConnection(pagination: {last: 1}) {
|
dataConnection(pagination: {first: 1}) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
externalData {
|
externalData {
|
||||||
@@ -172,4 +179,67 @@ export function useExplorerOracleFormMarketsLazyQuery(baseOptions?: Apollo.LazyQ
|
|||||||
}
|
}
|
||||||
export type ExplorerOracleFormMarketsQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsQuery>;
|
export type ExplorerOracleFormMarketsQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsQuery>;
|
||||||
export type ExplorerOracleFormMarketsLazyQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsLazyQuery>;
|
export type ExplorerOracleFormMarketsLazyQueryHookResult = ReturnType<typeof useExplorerOracleFormMarketsLazyQuery>;
|
||||||
export type ExplorerOracleFormMarketsQueryResult = Apollo.QueryResult<ExplorerOracleFormMarketsQuery, ExplorerOracleFormMarketsQueryVariables>;
|
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>;
|
||||||
@@ -4,8 +4,13 @@ import {
|
|||||||
ExternalExplorerLink,
|
ExternalExplorerLink,
|
||||||
EthExplorerLinkTypes,
|
EthExplorerLinkTypes,
|
||||||
} from '../../../components/links/external-explorer-link/external-explorer-link';
|
} from '../../../components/links/external-explorer-link/external-explorer-link';
|
||||||
import { getExternalChainLabel } from '../../../components/links/external-explorer-link/external-chain';
|
import { getExternalChainLabel } from '@vegaprotocol/environment';
|
||||||
import { t } from 'i18next';
|
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 {
|
interface OracleDetailsEthSourceProps {
|
||||||
sourceType: SourceType;
|
sourceType: SourceType;
|
||||||
@@ -34,21 +39,117 @@ export function OracleEthSource({
|
|||||||
|
|
||||||
const chainLabel = getExternalChainLabel(chain);
|
const chainLabel = getExternalChainLabel(chain);
|
||||||
|
|
||||||
|
const abi = prepareOracleSpecField(sourceType?.sourceType?.abi);
|
||||||
|
const args = prepareOracleSpecField(sourceType?.sourceType?.args);
|
||||||
|
const normalisers = serialiseNormalisers(sourceType.sourceType.normalisers);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableHeader scope="row">
|
<TableHeader scope="row" className="pt-1 align-text-top">
|
||||||
{chainLabel} {t('Contract')}
|
{chainLabel} {t('Contract')}
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered">
|
||||||
<ExternalExplorerLink
|
<details>
|
||||||
chain={chain}
|
<summary className="cursor-pointer">
|
||||||
id={address}
|
<ExternalExplorerLink
|
||||||
type={EthExplorerLinkTypes.address}
|
chain={chain}
|
||||||
code={true}
|
id={address}
|
||||||
/>
|
type={EthExplorerLinkTypes.address}
|
||||||
<span className="mx-3">⇒</span>
|
code={true}
|
||||||
<code>{sourceType.sourceType.method}</code>
|
/>
|
||||||
|
<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>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</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,38 +1,9 @@
|
|||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import { OracleFilter } from './oracle-filter';
|
import { OracleFilter } from './oracle-filter';
|
||||||
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
||||||
import {
|
import { ConditionOperator, DataSourceSpecStatus } from '@vegaprotocol/types';
|
||||||
ConditionOperator,
|
|
||||||
DataSourceSpecStatus,
|
|
||||||
PropertyKeyType,
|
|
||||||
} from '@vegaprotocol/types';
|
|
||||||
import type { Condition } 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) {
|
function renderComponent(data: ExplorerOracleDataSourceFragment) {
|
||||||
return <OracleFilter data={data} />;
|
return <OracleFilter data={data} />;
|
||||||
}
|
}
|
||||||
@@ -50,31 +21,6 @@ describe('Oracle Filter view', () => {
|
|||||||
expect(res.container).toBeEmptyDOMElement();
|
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', () => {
|
it('Renders conditions if type is DataSourceSpecConfigurationTime', () => {
|
||||||
const res = render(
|
const res = render(
|
||||||
renderComponent({
|
renderComponent({
|
||||||
@@ -136,7 +82,7 @@ describe('Oracle Filter view', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// This should never happen, but for coverage sake we test that it does this
|
// This should never happen, but for coverage we test that it does this
|
||||||
const ul = res.getByRole('list');
|
const ul = res.getByRole('list');
|
||||||
expect(ul).toBeInTheDocument();
|
expect(ul).toBeInTheDocument();
|
||||||
expect(ul).toBeEmptyDOMElement();
|
expect(ul).toBeEmptyDOMElement();
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
import type { ExplorerOracleDataSourceFragment } from '../__generated__/Oracles';
|
||||||
import { OracleSpecInternalTimeTrigger } from './oracle-spec/internal-time-trigger';
|
import {
|
||||||
|
OracleSpecInternalTimeTrigger,
|
||||||
|
TimeTrigger,
|
||||||
|
} from './oracle-spec/internal-time-trigger';
|
||||||
import { OracleSpecCondition } from './oracle-spec/condition';
|
import { OracleSpecCondition } from './oracle-spec/condition';
|
||||||
import { getCharacterForOperator } from './oracle-spec/operator';
|
import { getCharacterForOperator } from './oracle-spec/operator';
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ interface OracleFilterProps {
|
|||||||
* Shows the conditions that this oracle is using to filter
|
* Shows the conditions that this oracle is using to filter
|
||||||
* data sources, as a list.
|
* 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
|
* be the case) and if there is data, currently renders a simple
|
||||||
* JSON view.
|
* JSON view.
|
||||||
*/
|
*/
|
||||||
@@ -21,6 +24,7 @@ export function OracleFilter({ data }: OracleFilterProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const s = data.dataSourceSpec.spec.data.sourceType.sourceType;
|
const s = data.dataSourceSpec.spec.data.sourceType.sourceType;
|
||||||
|
|
||||||
if (s.__typename === 'DataSourceSpecConfigurationTime' && s.conditions) {
|
if (s.__typename === 'DataSourceSpecConfigurationTime' && s.conditions) {
|
||||||
return (
|
return (
|
||||||
<ul>
|
<ul>
|
||||||
@@ -41,30 +45,30 @@ export function OracleFilter({ data }: OracleFilterProps) {
|
|||||||
s.triggers
|
s.triggers
|
||||||
) {
|
) {
|
||||||
return <OracleSpecInternalTimeTrigger data={s} />;
|
return <OracleSpecInternalTimeTrigger data={s} />;
|
||||||
} else if (
|
} else if (s.__typename === 'EthCallSpec') {
|
||||||
s.__typename === 'EthCallSpec' ||
|
|
||||||
s.__typename === 'DataSourceSpecConfiguration'
|
|
||||||
) {
|
|
||||||
if (s.filters !== null && s.filters && 'filters' in s) {
|
if (s.filters !== null && s.filters && 'filters' in s) {
|
||||||
return (
|
return (
|
||||||
<ul>
|
<div>
|
||||||
{s.filters.map((f) => {
|
<ul>
|
||||||
const prop = <code title={f.key.type}>{f.key.name}</code>;
|
{s.filters.map((f) => {
|
||||||
|
const prop = <code title={f.key.type}>{f.key.name}</code>;
|
||||||
|
|
||||||
if (!f.conditions || f.conditions.length === 0) {
|
if (!f.conditions || f.conditions.length === 0) {
|
||||||
return prop;
|
return prop;
|
||||||
} else {
|
} else {
|
||||||
return f.conditions.map((c) => {
|
return f.conditions.map((c) => {
|
||||||
return (
|
return (
|
||||||
<li key={`${prop}${c.value}`}>
|
<li key={`${prop}${c.value}`}>
|
||||||
{prop} {getCharacterForOperator(c.operator)}{' '}
|
{prop} {getCharacterForOperator(c.operator)}{' '}
|
||||||
<code>{c.value ? c.value : '-'}</code>
|
<code>{c.value ? c.value : '-'}</code>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
{s.trigger && <TimeTrigger data={s.trigger.trigger} />}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-27
@@ -1,5 +1,10 @@
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import type { DataSourceSpecConfigurationTimeTrigger } from '@vegaprotocol/types';
|
import type {
|
||||||
|
DataSourceSpecConfigurationTimeTrigger,
|
||||||
|
EthTimeTrigger,
|
||||||
|
InternalTimeTrigger,
|
||||||
|
Maybe,
|
||||||
|
} from '@vegaprotocol/types';
|
||||||
import secondsToMinutes from 'date-fns/secondsToMinutes';
|
import secondsToMinutes from 'date-fns/secondsToMinutes';
|
||||||
import fromUnixTime from 'date-fns/fromUnixTime';
|
import fromUnixTime from 'date-fns/fromUnixTime';
|
||||||
|
|
||||||
@@ -13,32 +18,60 @@ export function OracleSpecInternalTimeTrigger({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<span>{t('Time')}</span>,
|
<span>{t('Time')}</span>,
|
||||||
{data.triggers.map((tr) => {
|
{data.triggers.map((tr) => (
|
||||||
return (
|
<TimeTrigger data={tr} />
|
||||||
<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>
|
</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,6 +48,11 @@ export const OracleDetails = ({
|
|||||||
? dataSource.dataSourceSpec.spec.data.sourceType.sourceType.sourceChainId.toString()
|
? dataSource.dataSourceSpec.spec.data.sourceType.sourceType.sourceChainId.toString()
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
const requiredConfirmations =
|
||||||
|
(sourceType.sourceType.__typename === 'EthCallSpec' &&
|
||||||
|
sourceType.sourceType.requiredConfirmations) ||
|
||||||
|
'';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<TableWithTbody className="mb-2">
|
<TableWithTbody className="mb-2">
|
||||||
@@ -64,15 +69,23 @@ export const OracleDetails = ({
|
|||||||
{getStatusString(dataSource.dataSourceSpec.spec.status)}
|
{getStatusString(dataSource.dataSourceSpec.spec.status)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<OracleMarkets id={id} />
|
||||||
<OracleSigners sourceType={sourceType} />
|
<OracleSigners sourceType={sourceType} />
|
||||||
<OracleEthSource sourceType={sourceType} chain={chain} />
|
<OracleEthSource sourceType={sourceType} chain={chain} />
|
||||||
<OracleMarkets id={id} />
|
|
||||||
<TableRow modifier="bordered">
|
<TableRow modifier="bordered">
|
||||||
<TableHeader scope="row">{t('Filter')}</TableHeader>
|
<TableHeader scope="row" className="pt-1 align-text-top">
|
||||||
|
{t('Filter')}
|
||||||
|
</TableHeader>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered">
|
||||||
<OracleFilter data={dataSource} />
|
<OracleFilter data={dataSource} />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
{requiredConfirmations && requiredConfirmations > 0 && (
|
||||||
|
<TableRow modifier="bordered">
|
||||||
|
<TableHeader scope="row">{t('Required Confirmations')}</TableHeader>
|
||||||
|
<TableCell modifier="bordered">{requiredConfirmations}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
</TableWithTbody>
|
</TableWithTbody>
|
||||||
{dataConnection ? <OracleData data={dataConnection} /> : null}
|
{dataConnection ? <OracleData data={dataConnection} /> : null}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
import compact from 'lodash/compact';
|
|
||||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
import { RouteTitle } from '../../../components/route-title';
|
import { RouteTitle } from '../../../components/route-title';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||||
import { useScrollToLocation } from '../../../hooks/scroll-to-location';
|
import { useScrollToLocation } from '../../../hooks/scroll-to-location';
|
||||||
import { useExplorerOracleFormMarketsQuery } from '../__generated__/OraclesForMarkets';
|
import { useExplorerOracleFormMarketsQuery } from '../__generated__/OraclesForMarkets';
|
||||||
import { MarketLink } from '../../../components/links';
|
import { OraclesTable } from '../../../components/oracle-table';
|
||||||
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 Oracles = () => {
|
||||||
const { data, loading, error } = useExplorerOracleFormMarketsQuery({
|
const { data, loading, error } = useExplorerOracleFormMarketsQuery({
|
||||||
@@ -21,8 +14,6 @@ const Oracles = () => {
|
|||||||
useDocumentTitle(['Oracles']);
|
useDocumentTitle(['Oracles']);
|
||||||
useScrollToLocation();
|
useScrollToLocation();
|
||||||
|
|
||||||
const [hoveredOracle, setHoveredOracle] = useState('');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<RouteTitle data-testid="oracle-specs-heading">{t('Oracles')}</RouteTitle>
|
<RouteTitle data-testid="oracle-specs-heading">{t('Oracles')}</RouteTitle>
|
||||||
@@ -38,148 +29,7 @@ const Oracles = () => {
|
|||||||
data.oracleSpecsConnection.edges?.length === 0
|
data.oracleSpecsConnection.edges?.length === 0
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<table className="text-left">
|
<OraclesTable data={data} />
|
||||||
<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>
|
</AsyncRenderer>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useMemo, useState } from 'react';
|
|||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import { SubHeading } from '../../../components/sub-heading';
|
import { SubHeading } from '../../../components/sub-heading';
|
||||||
import { toNonHex } from '../../../components/search/detect-search';
|
import { toNonHex } from '../../../components/search/detect-search';
|
||||||
import { useTxsData } from '../../../hooks/use-txs-data';
|
import { getInitialFilters, useTxsData } from '../../../hooks/use-txs-data';
|
||||||
import { TxsInfiniteList } from '../../../components/txs';
|
import { TxsInfiniteList } from '../../../components/txs';
|
||||||
import { PageHeader } from '../../../components/page-header';
|
import { PageHeader } from '../../../components/page-header';
|
||||||
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
import { useDocumentTitle } from '../../../hooks/use-document-title';
|
||||||
@@ -15,16 +15,18 @@ import { PartyBlockAccounts } from './components/party-block-accounts';
|
|||||||
import { isValidPartyId } from './components/party-id-error';
|
import { isValidPartyId } from './components/party-id-error';
|
||||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||||
import { TxsListNavigation } from '../../../components/txs/tx-list-navigation';
|
import { TxsListNavigation } from '../../../components/txs/tx-list-navigation';
|
||||||
import type { FilterOption } from '../../../components/txs/tx-filter';
|
import {
|
||||||
import { AllFilterOptions, TxsFilter } from '../../../components/txs/tx-filter';
|
TxsFilter,
|
||||||
|
type FilterOption,
|
||||||
|
} from '../../../components/txs/tx-filter';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
type Params = { party: string };
|
type Params = { party: string };
|
||||||
|
|
||||||
const Party = () => {
|
const Party = () => {
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
|
const [filters, setFilters] = useState(getInitialFilters(params));
|
||||||
|
|
||||||
const [filters, setFilters] = useState(new Set(AllFilterOptions));
|
|
||||||
const { party } = useParams<Params>();
|
const { party } = useParams<Params>();
|
||||||
|
|
||||||
useDocumentTitle(['Public keys', party || '-']);
|
useDocumentTitle(['Public keys', party || '-']);
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import Home from './home';
|
|||||||
import OraclePage from './oracles';
|
import OraclePage from './oracles';
|
||||||
import Oracles from './oracles/home';
|
import Oracles from './oracles/home';
|
||||||
import { Oracle } from './oracles/id';
|
import { Oracle } from './oracles/id';
|
||||||
import Party from './parties';
|
|
||||||
import { Parties } from './parties/home';
|
import { Parties } from './parties/home';
|
||||||
import { Party as PartySingle } from './parties/id';
|
import { Party } from './parties/id';
|
||||||
import { ValidatorsPage } from './validators';
|
import { ValidatorsPage } from './validators';
|
||||||
import Genesis from './genesis';
|
import Genesis from './genesis';
|
||||||
import { Block } from './blocks/id';
|
import { Block } from './blocks/id';
|
||||||
@@ -17,6 +16,7 @@ import { TxsList } from './txs/home';
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { Routes } from './route-names';
|
import { Routes } from './route-names';
|
||||||
import { NetworkParameters } from './network-parameters';
|
import { NetworkParameters } from './network-parameters';
|
||||||
|
import { Outlet } from 'react-router-dom';
|
||||||
import type { Params, RouteObject } from 'react-router-dom';
|
import type { Params, RouteObject } from 'react-router-dom';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { MarketPage, MarketsPage } from './markets';
|
import { MarketPage, MarketsPage } from './markets';
|
||||||
@@ -31,6 +31,7 @@ import { Disclaimer } from './pages/disclaimer';
|
|||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
import { useFeatureFlags } from '@vegaprotocol/environment';
|
||||||
import RestrictedPage from './restricted';
|
import RestrictedPage from './restricted';
|
||||||
import { NetworkTreasury } from './treasury';
|
import { NetworkTreasury } from './treasury';
|
||||||
|
import { MarketOraclesPage } from './markets/market-oracles-page';
|
||||||
|
|
||||||
export type Navigable = {
|
export type Navigable = {
|
||||||
path: string;
|
path: string;
|
||||||
@@ -67,7 +68,7 @@ export const useRouterConfig = () => {
|
|||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
path: Routes.PARTIES,
|
path: Routes.PARTIES,
|
||||||
element: <Party />,
|
element: <Outlet />,
|
||||||
handle: {
|
handle: {
|
||||||
name: t('Parties'),
|
name: t('Parties'),
|
||||||
text: t('Parties'),
|
text: t('Parties'),
|
||||||
@@ -80,12 +81,12 @@ export const useRouterConfig = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':party',
|
path: ':party',
|
||||||
element: <Party />,
|
element: <Outlet />,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
index: true,
|
index: true,
|
||||||
element: <PartySingle />,
|
element: <Party />,
|
||||||
handle: {
|
handle: {
|
||||||
breadcrumb: (params: Params<string>) => (
|
breadcrumb: (params: Params<string>) => (
|
||||||
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
||||||
@@ -96,7 +97,7 @@ export const useRouterConfig = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'assets',
|
path: 'assets',
|
||||||
element: <Party />,
|
element: <Outlet />,
|
||||||
handle: {
|
handle: {
|
||||||
breadcrumb: (params: Params<string>) => (
|
breadcrumb: (params: Params<string>) => (
|
||||||
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
<Link to={linkTo(Routes.PARTIES, params.party)}>
|
||||||
@@ -199,12 +200,36 @@ export const useRouterConfig = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':marketId',
|
path: ':marketId',
|
||||||
element: <MarketPage />,
|
element: <Outlet />,
|
||||||
handle: {
|
children: [
|
||||||
breadcrumb: (params: Params<string>) => (
|
{
|
||||||
<MarketLink id={params.marketId as string} />
|
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'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ export const NetworkAccountsTable = () => {
|
|||||||
return (
|
return (
|
||||||
<section className="md:flex md:flex-row flex-wrap">
|
<section className="md:flex md:flex-row flex-wrap">
|
||||||
{c.map((a) => (
|
{c.map((a) => (
|
||||||
<div className="basis-1/2 md:basis-1/4">
|
<div
|
||||||
|
className="basis-1/2 md:basis-1/4"
|
||||||
|
key={`${a.assetId}-${a.balance}`}
|
||||||
|
>
|
||||||
<div className="bg-white rounded overflow-hidden shadow-lg dark:bg-black dark:border-slate-500 dark:border">
|
<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">
|
<div className="text-center p-6 bg-gray-100 dark:bg-slate-900 border-b dark:border-slate-500">
|
||||||
<p className="flex justify-center">
|
<p className="flex justify-center">
|
||||||
|
|||||||
@@ -16,19 +16,21 @@ import type { DeepPartial } from '@apollo/client/utilities';
|
|||||||
|
|
||||||
describe('typeLabel', () => {
|
describe('typeLabel', () => {
|
||||||
it('should return "Transfer" for "OneOffTransfer" kind', () => {
|
it('should return "Transfer" for "OneOffTransfer" kind', () => {
|
||||||
expect(typeLabel('OneOffTransfer')).toBe('Transfer');
|
expect(typeLabel('OneOffTransfer')).toBe('Transfer - one time');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return "Transfer" for "RecurringTransfer" kind', () => {
|
it('should return "Transfer" for "RecurringTransfer" kind', () => {
|
||||||
expect(typeLabel('RecurringTransfer')).toBe('Transfer');
|
expect(typeLabel('RecurringTransfer')).toBe('Transfer - repeating');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return "Governance" for "OneOffGovernanceTransfer" kind', () => {
|
it('should return "Governance" for "OneOffGovernanceTransfer" kind', () => {
|
||||||
expect(typeLabel('OneOffGovernanceTransfer')).toBe('Governance');
|
expect(typeLabel('OneOffGovernanceTransfer')).toBe('Governance - one time');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return "Governance" for "RecurringGovernanceTransfer" kind', () => {
|
it('should return "Governance" for "RecurringGovernanceTransfer" kind', () => {
|
||||||
expect(typeLabel('RecurringGovernanceTransfer')).toBe('Governance');
|
expect(typeLabel('RecurringGovernanceTransfer')).toBe(
|
||||||
|
'Governance - repeating'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return "Unknown" for unknown kind', () => {
|
it('should return "Unknown" for unknown kind', () => {
|
||||||
@@ -256,7 +258,7 @@ describe('NetworkTransfersTable', () => {
|
|||||||
expect(screen.getByTestId('from-account').textContent).toEqual('Treasury');
|
expect(screen.getByTestId('from-account').textContent).toEqual('Treasury');
|
||||||
expect(screen.getByTestId('to-account').textContent).toEqual('7100…97a0');
|
expect(screen.getByTestId('to-account').textContent).toEqual('7100…97a0');
|
||||||
expect(screen.getByTestId('transfer-kind').textContent).toEqual(
|
expect(screen.getByTestId('transfer-kind').textContent).toEqual(
|
||||||
'Governance'
|
'Governance - one time'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { t } from '@vegaprotocol/i18n';
|
|||||||
import { IconNames } from '@blueprintjs/icons';
|
import { IconNames } from '@blueprintjs/icons';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||||
|
import ProposalLink from '../../../components/links/proposal-link/proposal-link';
|
||||||
|
|
||||||
export const colours = {
|
export const colours = {
|
||||||
INCOMING: '!fill-vega-green-600 text-vega-green-600 mr-2',
|
INCOMING: '!fill-vega-green-600 text-vega-green-600 mr-2',
|
||||||
@@ -50,14 +51,24 @@ 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 {
|
export function typeLabel(kind?: string): string {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case 'OneOffTransfer':
|
case 'OneOffTransfer':
|
||||||
|
return t('Transfer - one time');
|
||||||
case 'RecurringTransfer':
|
case 'RecurringTransfer':
|
||||||
return t('Transfer');
|
return t('Transfer - repeating');
|
||||||
case 'OneOffGovernanceTransfer':
|
case 'OneOffGovernanceTransfer':
|
||||||
|
return t('Governance - one time');
|
||||||
case 'RecurringGovernanceTransfer':
|
case 'RecurringGovernanceTransfer':
|
||||||
return t('Governance');
|
return t('Governance - repeating');
|
||||||
default:
|
default:
|
||||||
return t('Unknown');
|
return t('Unknown');
|
||||||
}
|
}
|
||||||
@@ -239,6 +250,11 @@ export const NetworkTransfersTable = () => {
|
|||||||
>
|
>
|
||||||
{a && typeLabel(a.kind.__typename)}
|
{a && typeLabel(a.kind.__typename)}
|
||||||
</span>
|
</span>
|
||||||
|
{isGovernanceTransfer(a?.kind.__typename) && a?.id && (
|
||||||
|
<span className="ml-4">
|
||||||
|
<ProposalLink id={a?.id} text="View" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { t } from '@vegaprotocol/i18n';
|
|||||||
import { RouteTitle } from '../../components/route-title';
|
import { RouteTitle } from '../../components/route-title';
|
||||||
import { NetworkAccountsTable } from './components/network-accounts-table';
|
import { NetworkAccountsTable } from './components/network-accounts-table';
|
||||||
import { NetworkTransfersTable } from './components/network-transfers-table';
|
import { NetworkTransfersTable } from './components/network-transfers-table';
|
||||||
|
import GovernanceLink from '../../components/links/governance-link/governance-link';
|
||||||
|
|
||||||
export type NonZeroAccount = {
|
export type NonZeroAccount = {
|
||||||
assetId: string;
|
assetId: string;
|
||||||
@@ -16,7 +17,33 @@ export const NetworkTreasury = () => {
|
|||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<RouteTitle data-testid="block-header">{t(`Treasury`)}</RouteTitle>
|
<RouteTitle data-testid="block-header">{t(`Treasury`)}</RouteTitle>
|
||||||
<div>
|
<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">
|
||||||
<NetworkAccountsTable />
|
<NetworkAccountsTable />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# App configuration variables
|
# App configuration variables
|
||||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||||
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
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_URL=https://api-validators-testnet.vega.rocks/graphql
|
||||||
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
NX_VEGA_REST=https://api-validators-testnet.vega.rocks/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export const SubHeading = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<h2
|
<h2
|
||||||
className={classNames('text-2xl font-alpha calt uppercase break-words', {
|
className={classNames('text-2xl font-alpha calt break-words', {
|
||||||
'mx-auto': centerContent,
|
'mx-auto': centerContent,
|
||||||
'mb-0': !marginBottom,
|
'mb-0': !marginBottom,
|
||||||
'mb-4': 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
|
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||||
lockedAddress: '0x0', // TODO not deployed to this env
|
lockedAddress: '0x0', // TODO not deployed to this env
|
||||||
},
|
},
|
||||||
VALIDATOR_TESTNET: {
|
VALIDATORS_TESTNET: {
|
||||||
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
claimAddress: '0x8Cef746ab7C83B61F6461cC92882bD61AB65a994', // TODO not deployed to this env, but random address so app doesn't error
|
||||||
lockedAddress: '0x0', // TODO not deployed to this env
|
lockedAddress: '0x0', // TODO not deployed to this env
|
||||||
// This is a fallback contract address for the validator testnet network which does not
|
// This is a fallback contract address for the validator testnet network which does not
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import {
|
|||||||
ViewPartyConnector,
|
ViewPartyConnector,
|
||||||
createConfig,
|
createConfig,
|
||||||
fairground,
|
fairground,
|
||||||
|
validatorsTestnet,
|
||||||
stagnet,
|
stagnet,
|
||||||
mainnet,
|
mainnet,
|
||||||
} from '@vegaprotocol/wallet';
|
} from '@vegaprotocol/wallet';
|
||||||
import { useEnvironment } from '@vegaprotocol/environment';
|
import { CHAIN_IDS, useEnvironment } from '@vegaprotocol/environment';
|
||||||
|
|
||||||
export const useVegaWalletConfig = () => {
|
export const useVegaWalletConfig = () => {
|
||||||
const { VEGA_ENV, VEGA_URL, VEGA_WALLET_URL } = useEnvironment();
|
const { VEGA_ENV, VEGA_URL, VEGA_WALLET_URL } = useEnvironment();
|
||||||
@@ -31,8 +32,8 @@ export const useVegaWalletConfig = () => {
|
|||||||
const viewParty = new ViewPartyConnector();
|
const viewParty = new ViewPartyConnector();
|
||||||
|
|
||||||
const config = createConfig({
|
const config = createConfig({
|
||||||
chains: [mainnet, fairground, stagnet],
|
chains: [mainnet, fairground, validatorsTestnet, stagnet],
|
||||||
defaultChainId: fairground.id,
|
defaultChainId: CHAIN_IDS[VEGA_ENV],
|
||||||
connectors: [injected, snap, jsonRpc, viewParty],
|
connectors: [injected, snap, jsonRpc, viewParty],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ i18n
|
|||||||
load: 'languageOnly',
|
load: 'languageOnly',
|
||||||
debug: isInDev,
|
debug: isInDev,
|
||||||
// have a common namespace used around the full app
|
// have a common namespace used around the full app
|
||||||
ns: ['governance', 'wallet', 'wallet-react'],
|
ns: ['governance', 'wallet', 'wallet-react', 'assets', 'utils'],
|
||||||
defaultNS: 'governance',
|
defaultNS: 'governance',
|
||||||
keySeparator: false, // we use content as keys
|
keySeparator: false, // we use content as keys
|
||||||
nsSeparator: false,
|
nsSeparator: false,
|
||||||
|
|||||||
+4
-1
@@ -38,6 +38,7 @@ import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
|||||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||||
import { MarketName } from '../proposal/market-name';
|
import { MarketName } from '../proposal/market-name';
|
||||||
import { Indicator } from '../proposal/indicator';
|
import { Indicator } from '../proposal/indicator';
|
||||||
|
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||||
|
|
||||||
const ProposalTypeTags = ({
|
const ProposalTypeTags = ({
|
||||||
proposal,
|
proposal,
|
||||||
@@ -540,10 +541,12 @@ const BatchProposalStateText = ({
|
|||||||
|
|
||||||
export const ProposalHeader = ({
|
export const ProposalHeader = ({
|
||||||
proposal,
|
proposal,
|
||||||
|
restData,
|
||||||
isListItem = true,
|
isListItem = true,
|
||||||
voteState,
|
voteState,
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal | BatchProposal;
|
proposal: Proposal | BatchProposal;
|
||||||
|
restData?: ProposalNode | null;
|
||||||
isListItem?: boolean;
|
isListItem?: boolean;
|
||||||
voteState?: VoteState | null;
|
voteState?: VoteState | null;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -595,7 +598,7 @@ export const ProposalHeader = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ProposalDetails proposal={proposal} />
|
<ProposalDetails proposal={proposal} />
|
||||||
<VoteBreakdown proposal={proposal} />
|
<VoteBreakdown proposal={proposal} restData={restData} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+33
-46
@@ -19,6 +19,7 @@ import {
|
|||||||
getSigners,
|
getSigners,
|
||||||
MarginScalingFactorsPanel,
|
MarginScalingFactorsPanel,
|
||||||
marketInfoProvider,
|
marketInfoProvider,
|
||||||
|
PriceMonitoringSettingsInfoPanel,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -49,7 +50,7 @@ export const useMarketDataDialogStore = create<MarketDataDialogState>(
|
|||||||
const marketDataHeaderStyles =
|
const marketDataHeaderStyles =
|
||||||
'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2';
|
'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2';
|
||||||
|
|
||||||
export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
export const ProposalMarketData = ({ marketId }: { marketId: string }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isOpen, open, close } = useMarketDataDialogStore();
|
const { isOpen, open, close } = useMarketDataDialogStore();
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
@@ -58,7 +59,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
dataProvider: marketInfoProvider,
|
dataProvider: marketInfoProvider,
|
||||||
skipUpdates: true,
|
skipUpdates: true,
|
||||||
variables: {
|
variables: {
|
||||||
marketId: proposalId,
|
marketId: marketId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!marketData || !parentMarketData) {
|
if (!marketData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,13 +134,13 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
<h2 className={marketDataHeaderStyles}>{t('Key details')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Key details')}</h2>
|
||||||
<KeyDetailsInfoPanel
|
<KeyDetailsInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData ? parentMarketData : undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>{t('Instrument')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Instrument')}</h2>
|
||||||
<InstrumentInfoPanel
|
<InstrumentInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData ? parentMarketData : undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{settlementData &&
|
{settlementData &&
|
||||||
@@ -155,7 +156,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
isParentSettlementDataEqual ||
|
isParentSettlementDataEqual ||
|
||||||
isParentSettlementScheduleDataEqual
|
isParentSettlementScheduleDataEqual
|
||||||
? undefined
|
? undefined
|
||||||
: parentMarketData
|
: parentMarketData || undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@@ -168,7 +169,9 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
market={marketData}
|
market={marketData}
|
||||||
type="settlementData"
|
type="settlementData"
|
||||||
parentMarket={
|
parentMarket={
|
||||||
isParentSettlementDataEqual ? undefined : parentMarketData
|
isParentSettlementDataEqual
|
||||||
|
? undefined
|
||||||
|
: parentMarketData || undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -184,7 +187,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
parentMarket={
|
parentMarket={
|
||||||
isParentTerminationDataEqual
|
isParentTerminationDataEqual
|
||||||
? undefined
|
? undefined
|
||||||
: parentMarketData
|
: parentMarketData || undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -202,7 +205,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
parentMarket={
|
parentMarket={
|
||||||
isParentSettlementScheduleDataEqual
|
isParentSettlementScheduleDataEqual
|
||||||
? undefined
|
? undefined
|
||||||
: parentMarketData
|
: parentMarketData || undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -216,19 +219,19 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
<h2 className={marketDataHeaderStyles}>{t('Settlement assets')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Settlement assets')}</h2>
|
||||||
<SettlementAssetInfoPanel
|
<SettlementAssetInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>{t('Metadata')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Metadata')}</h2>
|
||||||
<MetadataInfoPanel
|
<MetadataInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>{t('Risk model')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Risk model')}</h2>
|
||||||
<RiskModelInfoPanel
|
<RiskModelInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>
|
<h2 className={marketDataHeaderStyles}>
|
||||||
@@ -236,61 +239,45 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
</h2>
|
</h2>
|
||||||
<MarginScalingFactorsPanel
|
<MarginScalingFactorsPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>{t('Risk factors')}</h2>
|
<h2 className={marketDataHeaderStyles}>{t('Risk factors')}</h2>
|
||||||
<RiskFactorsInfoPanel
|
<RiskFactorsInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{showParentPriceMonitoringBounds &&
|
{showParentPriceMonitoringBounds && (
|
||||||
(
|
// shows bounds for parent market
|
||||||
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}>
|
<h2 className={marketDataHeaderStyles}>
|
||||||
{t(`Price monitoring bounds ${triggerIndex + 1}`)}
|
{t('Parent price monitoring bounds')}
|
||||||
</h2>
|
</h2>
|
||||||
|
<div className="text-vega-dark-300 line-through">
|
||||||
<PriceMonitoringBoundsInfoPanel
|
<PriceMonitoringBoundsInfoPanel market={parentMarketData} />
|
||||||
market={marketData}
|
</div>
|
||||||
triggerIndex={triggerIndex}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
))}
|
)}
|
||||||
|
|
||||||
|
<h2 className={marketDataHeaderStyles}>
|
||||||
|
{t('Price monitoring settings')}
|
||||||
|
</h2>
|
||||||
|
<PriceMonitoringSettingsInfoPanel market={marketData} />
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>
|
<h2 className={marketDataHeaderStyles}>
|
||||||
{t('Liquidity monitoring parameters')}
|
{t('Liquidity monitoring parameters')}
|
||||||
</h2>
|
</h2>
|
||||||
<LiquidityMonitoringParametersInfoPanel
|
<LiquidityMonitoringParametersInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
<h2 className={marketDataHeaderStyles}>
|
<h2 className={marketDataHeaderStyles}>
|
||||||
{t('Liquidity price range')}
|
{t('Liquidity price range')}
|
||||||
</h2>
|
</h2>
|
||||||
<LiquidityPriceRangeInfoPanel
|
<LiquidityPriceRangeInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h2 className={marketDataHeaderStyles}>
|
<h2 className={marketDataHeaderStyles}>
|
||||||
@@ -298,7 +285,7 @@ export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
|||||||
</h2>
|
</h2>
|
||||||
<LiquiditySLAParametersInfoPanel
|
<LiquiditySLAParametersInfoPanel
|
||||||
market={marketData}
|
market={marketData}
|
||||||
parentMarket={parentMarketData}
|
parentMarket={parentMarketData || undefined}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
+16
-2
@@ -17,17 +17,20 @@ import { type ProposalNode } from './proposal-utils';
|
|||||||
import { Lozenge } from '@vegaprotocol/ui-toolkit';
|
import { Lozenge } from '@vegaprotocol/ui-toolkit';
|
||||||
import { Indicator } from './indicator';
|
import { Indicator } from './indicator';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
|
import { determineId } from '@vegaprotocol/wallet';
|
||||||
|
|
||||||
export const ProposalChangeDetails = ({
|
export const ProposalChangeDetails = ({
|
||||||
proposal,
|
proposal,
|
||||||
terms,
|
terms,
|
||||||
restData,
|
restData,
|
||||||
indicator,
|
indicator,
|
||||||
|
termsCount = 0,
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal | BatchProposal;
|
proposal: Proposal | BatchProposal;
|
||||||
terms: ProposalTermsFieldsFragment;
|
terms: ProposalTermsFieldsFragment;
|
||||||
restData: ProposalNode | null;
|
restData: ProposalNode | null;
|
||||||
indicator?: number;
|
indicator?: number;
|
||||||
|
termsCount?: number;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
let details = null;
|
let details = null;
|
||||||
@@ -61,7 +64,18 @@ export const ProposalChangeDetails = ({
|
|||||||
}
|
}
|
||||||
case 'NewMarket': {
|
case 'NewMarket': {
|
||||||
if (proposal.id) {
|
if (proposal.id) {
|
||||||
details = <ProposalMarketData proposalId={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} />;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -69,7 +83,7 @@ export const ProposalChangeDetails = ({
|
|||||||
if (proposal.id) {
|
if (proposal.id) {
|
||||||
details = (
|
details = (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<ProposalMarketData proposalId={proposal.id} />
|
<ProposalMarketData marketId={proposal.id} />
|
||||||
<ProposalMarketChanges
|
<ProposalMarketChanges
|
||||||
indicator={indicator}
|
indicator={indicator}
|
||||||
marketId={terms.change.marketId}
|
marketId={terms.change.marketId}
|
||||||
|
|||||||
@@ -91,6 +91,28 @@ export type ProposalNode = {
|
|||||||
proposal: ProposalData;
|
proposal: ProposalData;
|
||||||
proposalType: ProposalNodeType;
|
proposalType: ProposalNodeType;
|
||||||
proposals: SubProposalData[];
|
proposals: SubProposalData[];
|
||||||
|
yes?: [
|
||||||
|
{
|
||||||
|
partyId: string;
|
||||||
|
elsPerMarket?: [
|
||||||
|
{
|
||||||
|
marketId: string;
|
||||||
|
els: string;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
no?: [
|
||||||
|
{
|
||||||
|
partyId: string;
|
||||||
|
elsPerMarket?: [
|
||||||
|
{
|
||||||
|
marketId: string;
|
||||||
|
els: string;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
type SingleProposalNode = ProposalNode & {
|
type SingleProposalNode = ProposalNode & {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
|||||||
|
|
||||||
<ProposalHeader
|
<ProposalHeader
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
|
restData={restData}
|
||||||
isListItem={false}
|
isListItem={false}
|
||||||
voteState={voteState}
|
voteState={voteState}
|
||||||
/>
|
/>
|
||||||
@@ -77,6 +78,7 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
|||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
terms={p.terms}
|
terms={p.terms}
|
||||||
restData={restData}
|
restData={restData}
|
||||||
|
termsCount={proposal.subProposals?.length}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
import { useBatchVoteInformation } from '../../hooks/use-vote-information';
|
import { useBatchVoteInformation } from '../../hooks/use-vote-information';
|
||||||
import { MarketName } from '../proposal/market-name';
|
import { MarketName } from '../proposal/market-name';
|
||||||
import { Indicator } from '../proposal/indicator';
|
import { Indicator } from '../proposal/indicator';
|
||||||
|
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||||
|
|
||||||
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
||||||
<CompactNumber
|
<CompactNumber
|
||||||
@@ -110,24 +111,64 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
|||||||
|
|
||||||
export const VoteBreakdown = ({
|
export const VoteBreakdown = ({
|
||||||
proposal,
|
proposal,
|
||||||
|
restData,
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal | BatchProposal;
|
proposal: Proposal | BatchProposal;
|
||||||
|
restData?: ProposalNode | null;
|
||||||
}) => {
|
}) => {
|
||||||
if (proposal.__typename === 'Proposal') {
|
if (proposal.__typename === 'Proposal') {
|
||||||
return <VoteBreakdownNormal proposal={proposal} />;
|
return <VoteBreakdownNormal proposal={proposal} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proposal.__typename === 'BatchProposal') {
|
if (proposal.__typename === 'BatchProposal') {
|
||||||
return <VoteBreakdownBatch proposal={proposal} />;
|
return <VoteBreakdownBatch proposal={proposal} restData={restData} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
const VoteBreakdownBatch = ({
|
||||||
|
proposal,
|
||||||
|
restData,
|
||||||
|
}: {
|
||||||
|
proposal: BatchProposal;
|
||||||
|
restData?: ProposalNode | null;
|
||||||
|
}) => {
|
||||||
const [fullBreakdown, setFullBreakdown] = useState(false);
|
const [fullBreakdown, setFullBreakdown] = useState(false);
|
||||||
const { t } = useTranslation();
|
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({
|
const voteInfo = useBatchVoteInformation({
|
||||||
terms: compact(
|
terms: compact(
|
||||||
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
|
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
|
||||||
@@ -194,6 +235,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
|||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
votes={proposal.votes}
|
votes={proposal.votes}
|
||||||
terms={p.terms}
|
terms={p.terms}
|
||||||
|
yesELS={yesELS}
|
||||||
|
noELS={noELS}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -254,6 +297,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
|||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
votes={proposal.votes}
|
votes={proposal.votes}
|
||||||
terms={p.terms}
|
terms={p.terms}
|
||||||
|
yesELS={yesELS}
|
||||||
|
noELS={noELS}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -271,17 +316,17 @@ const VoteBreakdownBatchSubProposal = ({
|
|||||||
votes,
|
votes,
|
||||||
terms,
|
terms,
|
||||||
indicator,
|
indicator,
|
||||||
|
yesELS,
|
||||||
|
noELS,
|
||||||
}: {
|
}: {
|
||||||
proposal: BatchProposal;
|
proposal: BatchProposal;
|
||||||
votes: VoteFieldsFragment;
|
votes: VoteFieldsFragment;
|
||||||
terms: ProposalTermsFieldsFragment;
|
terms: ProposalTermsFieldsFragment;
|
||||||
indicator?: number;
|
indicator?: number;
|
||||||
|
yesELS: Record<string, number[]>;
|
||||||
|
noELS: Record<string, number[]>;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const voteInfo = useVoteInformation({
|
|
||||||
votes,
|
|
||||||
terms,
|
|
||||||
});
|
|
||||||
|
|
||||||
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
||||||
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
|
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
|
||||||
@@ -294,6 +339,15 @@ const VoteBreakdownBatchSubProposal = ({
|
|||||||
marketId = terms.change.market.id;
|
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 ? (
|
const marketName = marketId ? (
|
||||||
<>
|
<>
|
||||||
: <MarketName marketId={marketId} />
|
: <MarketName marketId={marketId} />
|
||||||
|
|||||||
@@ -8,13 +8,18 @@ import {
|
|||||||
type VoteFieldsFragment,
|
type VoteFieldsFragment,
|
||||||
} from '../__generated__/Proposals';
|
} from '../__generated__/Proposals';
|
||||||
import { type ProposalChangeType } from '../types';
|
import { type ProposalChangeType } from '../types';
|
||||||
|
import sum from 'lodash/sum';
|
||||||
|
|
||||||
export const useVoteInformation = ({
|
export const useVoteInformation = ({
|
||||||
votes,
|
votes,
|
||||||
terms,
|
terms,
|
||||||
|
yesELS,
|
||||||
|
noELS,
|
||||||
}: {
|
}: {
|
||||||
votes: VoteFieldsFragment;
|
votes: VoteFieldsFragment;
|
||||||
terms: ProposalTermsFieldsFragment;
|
terms: ProposalTermsFieldsFragment;
|
||||||
|
yesELS?: number[];
|
||||||
|
noELS?: number[];
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
appState: { totalSupply, decimals },
|
appState: { totalSupply, decimals },
|
||||||
@@ -31,7 +36,9 @@ export const useVoteInformation = ({
|
|||||||
paramsForChange,
|
paramsForChange,
|
||||||
votes,
|
votes,
|
||||||
totalSupply,
|
totalSupply,
|
||||||
decimals
|
decimals,
|
||||||
|
yesELS,
|
||||||
|
noELS
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,7 +79,11 @@ const getVoteData = (
|
|||||||
},
|
},
|
||||||
votes: ProposalFieldsFragment['votes'],
|
votes: ProposalFieldsFragment['votes'],
|
||||||
totalSupply: BigNumber,
|
totalSupply: BigNumber,
|
||||||
decimals: number
|
decimals: number,
|
||||||
|
/** A list of ELS yes votes */
|
||||||
|
yesELS?: number[],
|
||||||
|
/** A list if ELS no votes */
|
||||||
|
noELS?: number[]
|
||||||
) => {
|
) => {
|
||||||
const requiredMajorityPercentage = params.requiredMajority
|
const requiredMajorityPercentage = params.requiredMajority
|
||||||
? new BigNumber(params.requiredMajority).times(100)
|
? new BigNumber(params.requiredMajority).times(100)
|
||||||
@@ -86,17 +97,31 @@ const getVoteData = (
|
|||||||
addDecimal(votes.no.totalTokens ?? 0, decimals)
|
addDecimal(votes.no.totalTokens ?? 0, decimals)
|
||||||
);
|
);
|
||||||
|
|
||||||
const noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
let noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(votes.no.totalEquityLikeShareWeight).times(100);
|
: 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(
|
const yesTokens = new BigNumber(
|
||||||
addDecimal(votes.yes.totalTokens ?? 0, decimals)
|
addDecimal(votes.yes.totalTokens ?? 0, decimals)
|
||||||
);
|
);
|
||||||
|
|
||||||
const yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
let yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100);
|
: 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);
|
const totalTokensVoted = yesTokens.plus(noTokens);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { validForSyntaxHighlighter } from '@vegaprotocol/utils';
|
import { suitableForSyntaxHighlighter } from '@vegaprotocol/utils';
|
||||||
import { useNetworkParams } from '@vegaprotocol/network-parameters';
|
import { useNetworkParams } from '@vegaprotocol/network-parameters';
|
||||||
import {
|
import {
|
||||||
getClosingTimestamp,
|
getClosingTimestamp,
|
||||||
@@ -46,7 +46,7 @@ const SelectedNetworkParamCurrentValue = ({
|
|||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<p className="text-sm text-white">{t('CurrentValue')}</p>
|
<p className="text-sm text-white">{t('CurrentValue')}</p>
|
||||||
|
|
||||||
{validForSyntaxHighlighter(value) ? (
|
{suitableForSyntaxHighlighter(value) ? (
|
||||||
<SyntaxHighlighter data={JSON.parse(value)} />
|
<SyntaxHighlighter data={JSON.parse(value)} />
|
||||||
) : (
|
) : (
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
doesValueEquateToParam,
|
doesValueEquateToParam,
|
||||||
} from '@vegaprotocol/proposals';
|
} from '@vegaprotocol/proposals';
|
||||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
import { useValidateJson } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
NetworkParams,
|
NetworkParams,
|
||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
doesValueEquateToParam,
|
doesValueEquateToParam,
|
||||||
} from '@vegaprotocol/proposals';
|
} from '@vegaprotocol/proposals';
|
||||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
import { useValidateJson } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
NetworkParams,
|
NetworkParams,
|
||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
RoundedWrapper,
|
RoundedWrapper,
|
||||||
TextArea,
|
TextArea,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
import { useValidateJson } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
NetworkParams,
|
NetworkParams,
|
||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
doesValueEquateToParam,
|
doesValueEquateToParam,
|
||||||
} from '@vegaprotocol/proposals';
|
} from '@vegaprotocol/proposals';
|
||||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
import { useValidateJson } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
NetworkParams,
|
NetworkParams,
|
||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
|||||||
useProposalSubmit,
|
useProposalSubmit,
|
||||||
} from '@vegaprotocol/proposals';
|
} from '@vegaprotocol/proposals';
|
||||||
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
import { useEnvironment, DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { useValidateJson } from '@vegaprotocol/react-helpers';
|
import { useValidateJson } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
NetworkParams,
|
NetworkParams,
|
||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
|
|||||||
+1
@@ -61,6 +61,7 @@ const mockConsensusValidators: NodesFragmentFragment[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/environment', () => ({
|
jest.mock('@vegaprotocol/environment', () => ({
|
||||||
|
...jest.requireActual('@vegaprotocol/environment'),
|
||||||
useVegaRelease: jest.fn(),
|
useVegaRelease: jest.fn(),
|
||||||
useVegaReleases: jest.fn(),
|
useVegaReleases: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ export const VALIDATOR_LOGO_MAP: { [key: string]: string } = {
|
|||||||
'https://pbs.twimg.com/profile_images/1586047492629712897/ZVMWBE94_400x400.jpg',
|
'https://pbs.twimg.com/profile_images/1586047492629712897/ZVMWBE94_400x400.jpg',
|
||||||
efbdf943443bd7595e83b0d7e88f37b7932d487d1b94aab3d004997273bb43fc:
|
efbdf943443bd7595e83b0d7e88f37b7932d487d1b94aab3d004997273bb43fc:
|
||||||
'https://pbs.twimg.com/profile_images/1026823609979949057/3e-LCHHm_400x400.jpg',
|
'https://pbs.twimg.com/profile_images/1026823609979949057/3e-LCHHm_400x400.jpg',
|
||||||
'126751c5830b50d39eb85412fb2964f46338cce6946ff455b73f1b1be3f5e8cc':
|
|
||||||
'https://pbs.twimg.com/profile_images/1228627868542029824/9aoaLiIx_400x400.jpg',
|
|
||||||
'43697a3e911d8b70c0ce672adde17a5c38ca8f6a0486bf85ed0546e1b9a82887':
|
'43697a3e911d8b70c0ce672adde17a5c38ca8f6a0486bf85ed0546e1b9a82887':
|
||||||
'https://pbs.twimg.com/profile_images/1352167987478843392/XzX82gIb_400x400.jpg',
|
'https://pbs.twimg.com/profile_images/1352167987478843392/XzX82gIb_400x400.jpg',
|
||||||
ac735acc9ab11cf1d8c59c2df2107e00092b4ac96451cb137a1629af5b66242a:
|
ac735acc9ab11cf1d8c59c2df2107e00092b4ac96451cb137a1629af5b66242a:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
@apply text-2xl text-white uppercase mb-4;
|
@apply text-2xl text-white mb-4;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
@apply text-xl text-white mb-4;
|
@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_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.tom
|
||||||
NX_VEGA_URL=https://api-validators-testnet.vega.rocks/graphql
|
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_NETWORKS={'{"TESTNET":"https://multisig-signer.fairground.wtf","MAINNET":"https://multisig-signer.vega.xyz"}'
|
||||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
NX_STOP_ORDERS=true
|
NX_STOP_ORDERS=true
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||||
NX_ISOLATED_MARGIN=true
|
NX_ISOLATED_MARGIN=true
|
||||||
NX_ICEBERG_ORDERS=true
|
NX_ICEBERG_ORDERS=true
|
||||||
NX_METAMASK_SNAPS=true
|
NX_METAMASK_SNAPS=true
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supp
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=false
|
NX_SUCCESSOR_MARKETS=false
|
||||||
NX_STOP_ORDERS=false
|
NX_STOP_ORDERS=false
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=false
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||||
NX_ISOLATED_MARGIN=true
|
NX_ISOLATED_MARGIN=true
|
||||||
# NX_ICEBERG_ORDERS
|
# NX_ICEBERG_ORDERS
|
||||||
# NX_PRODUCT_PERPETUALS
|
# NX_PRODUCT_PERPETUALS
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
NX_STOP_ORDERS=true
|
NX_STOP_ORDERS=true
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=false
|
||||||
NX_ISOLATED_MARGIN=false
|
NX_ISOLATED_MARGIN=false
|
||||||
NX_ICEBERG_ORDERS=true
|
NX_ICEBERG_ORDERS=true
|
||||||
NX_METAMASK_SNAPS=true
|
NX_METAMASK_SNAPS=true
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
NX_STOP_ORDERS=true
|
NX_STOP_ORDERS=true
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||||
NX_ISOLATED_MARGIN=true
|
NX_ISOLATED_MARGIN=true
|
||||||
NX_ICEBERG_ORDERS=true
|
NX_ICEBERG_ORDERS=true
|
||||||
# NX_PRODUCT_PERPETUALS
|
# NX_PRODUCT_PERPETUALS
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
NX_STOP_ORDERS=true
|
NX_STOP_ORDERS=true
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||||
NX_ISOLATED_MARGIN=true
|
NX_ISOLATED_MARGIN=true
|
||||||
NX_ICEBERG_ORDERS=true
|
NX_ICEBERG_ORDERS=true
|
||||||
NX_METAMASK_SNAPS=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_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
||||||
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
|
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_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
|
||||||
NX_VEGA_ENV=VALIDATOR_TESTNET
|
NX_VEGA_ENV=VALIDATORS_TESTNET
|
||||||
NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks
|
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_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
|
NX_VEGA_TOKEN_URL=https://governance.validators-testnet.vega.rocks
|
||||||
@@ -22,6 +22,7 @@ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/m
|
|||||||
# Cosmic elevator flags
|
# Cosmic elevator flags
|
||||||
NX_SUCCESSOR_MARKETS=true
|
NX_SUCCESSOR_MARKETS=true
|
||||||
NX_STOP_ORDERS=true
|
NX_STOP_ORDERS=true
|
||||||
|
NX_TAKE_PROFIT_STOP_LOSS=true
|
||||||
NX_ISOLATED_MARGIN=true
|
NX_ISOLATED_MARGIN=true
|
||||||
NX_ICEBERG_ORDERS=true
|
NX_ICEBERG_ORDERS=true
|
||||||
# NX_PRODUCT_PERPETUALS
|
# NX_PRODUCT_PERPETUALS
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
VegaIcon,
|
VegaIcon,
|
||||||
VegaIconNames,
|
VegaIconNames,
|
||||||
|
Tooltip,
|
||||||
|
TradingAnchorButton,
|
||||||
|
Intent,
|
||||||
|
CopyWithTooltip,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { TransferStatus, type Asset } from '@vegaprotocol/types';
|
import { TransferStatus, type Asset } from '@vegaprotocol/types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -17,7 +21,7 @@ import { Table } from '../../components/table';
|
|||||||
import {
|
import {
|
||||||
addDecimalsFormatNumberQuantum,
|
addDecimalsFormatNumberQuantum,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
getDateTimeFormat,
|
removePaginationWrapper,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
useTeam,
|
useTeam,
|
||||||
@@ -41,10 +45,6 @@ import {
|
|||||||
} from '../../lib/hooks/use-games';
|
} from '../../lib/hooks/use-games';
|
||||||
import { useEpochInfoQuery } from '../../lib/hooks/__generated__/Epoch';
|
import { useEpochInfoQuery } from '../../lib/hooks/__generated__/Epoch';
|
||||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||||
import {
|
|
||||||
ActiveRewardCard,
|
|
||||||
DispatchMetricInfo,
|
|
||||||
} from '../../components/rewards-container/active-rewards';
|
|
||||||
import { type MarketMap, useMarketsMapProvider } from '@vegaprotocol/markets';
|
import { type MarketMap, useMarketsMapProvider } from '@vegaprotocol/markets';
|
||||||
import format from 'date-fns/format';
|
import format from 'date-fns/format';
|
||||||
import {
|
import {
|
||||||
@@ -52,6 +52,13 @@ import {
|
|||||||
isScopedToTeams,
|
isScopedToTeams,
|
||||||
useRewards,
|
useRewards,
|
||||||
} from '../../lib/hooks/use-rewards';
|
} 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 = () => {
|
export const CompetitionsTeam = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
@@ -140,11 +147,25 @@ const TeamPage = ({
|
|||||||
const t = useT();
|
const t = useT();
|
||||||
const [showGames, setShowGames] = useState(true);
|
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 (
|
return (
|
||||||
<LayoutWithGradient>
|
<LayoutWithGradient>
|
||||||
<header className="flex gap-3 lg:gap-4 pt-5 lg:pt-10">
|
<header className="flex gap-3 lg:gap-4 pt-5 lg:pt-10">
|
||||||
<TeamAvatar teamId={team.teamId} imgUrl={team.avatarUrl} />
|
<TeamAvatar teamId={team.teamId} imgUrl={team.avatarUrl} />
|
||||||
<div className="flex flex-col items-start gap-1 lg:gap-3">
|
<div className="flex flex-col items-start gap-1 lg:gap-2">
|
||||||
<h1
|
<h1
|
||||||
className="calt text-2xl lg:text-3xl xl:text-5xl"
|
className="calt text-2xl lg:text-3xl xl:text-5xl"
|
||||||
data-testid="team-name"
|
data-testid="team-name"
|
||||||
@@ -154,6 +175,38 @@ const TeamPage = ({
|
|||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<JoinTeam team={team} partyTeam={partyTeam} refetch={refetch} />
|
<JoinTeam team={team} partyTeam={partyTeam} refetch={refetch} />
|
||||||
<UpdateTeamButton team={team} />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -230,118 +283,138 @@ const Games = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<div className="text-sm">
|
||||||
columns={[
|
<Table
|
||||||
{
|
columns={[
|
||||||
name: 'epoch',
|
{
|
||||||
displayName: t('Epoch'),
|
name: 'epoch',
|
||||||
},
|
displayName: t('Epoch'),
|
||||||
{
|
},
|
||||||
name: 'endtime',
|
{
|
||||||
displayName: t('End time'),
|
name: 'endtime',
|
||||||
},
|
displayName: t('End time'),
|
||||||
{ name: 'type', displayName: t('Type') },
|
},
|
||||||
{
|
{ name: 'type', displayName: t('Type') },
|
||||||
name: 'asset',
|
{
|
||||||
displayName: t('Reward asset'),
|
name: 'asset',
|
||||||
},
|
displayName: t('Reward asset'),
|
||||||
{ name: 'daily', displayName: t('Daily reward amount') },
|
},
|
||||||
{ name: 'rank', displayName: t('Rank') },
|
{ name: 'daily', displayName: t('Daily reward amount') },
|
||||||
{ name: 'amount', displayName: t('Amount earned this epoch') },
|
{ name: 'rank', displayName: t('Rank') },
|
||||||
{ name: 'total', displayName: t('Cumulative amount earned') },
|
{ name: 'amount', displayName: t('Amount earned this epoch') },
|
||||||
{
|
{ name: 'total', displayName: t('Cumulative amount earned') },
|
||||||
name: 'participatingTeams',
|
{
|
||||||
displayName: t('No. of participating teams'),
|
name: 'participatingTeams',
|
||||||
},
|
displayName: t('No. of participating teams'),
|
||||||
{
|
},
|
||||||
name: 'participatingMembers',
|
{
|
||||||
displayName: t('No. of participating members'),
|
name: 'participatingMembers',
|
||||||
},
|
displayName: t('No. of participating members'),
|
||||||
].map((c) => ({ ...c, headerClassName: 'text-left' }))}
|
},
|
||||||
data={games.map((game) => {
|
].map((c) => ({ ...c, headerClassName: 'text-left' }))}
|
||||||
let transfer = transfers?.find((t) => {
|
data={games.map((game) => {
|
||||||
if (!isScopedToTeams(t)) return false;
|
let transfer = transfers?.find((t) => {
|
||||||
|
if (!isScopedToTeams(t)) return false;
|
||||||
|
|
||||||
const idMatch = t.transfer.gameId === game.id;
|
const idMatch = t.transfer.gameId === game.id;
|
||||||
const metricMatch =
|
const metricMatch =
|
||||||
t.transfer.kind.dispatchStrategy?.dispatchMetric ===
|
t.transfer.kind.dispatchStrategy?.dispatchMetric ===
|
||||||
game.team.rewardMetric;
|
game.team.rewardMetric;
|
||||||
|
|
||||||
const start = t.transfer.kind.startEpoch <= game.epoch;
|
const start = t.transfer.kind.startEpoch <= game.epoch;
|
||||||
const end = t.transfer.kind.endEpoch
|
const end = t.transfer.kind.endEpoch
|
||||||
? t.transfer.kind.endEpoch >= game.epoch
|
? t.transfer.kind.endEpoch >= game.epoch
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
const rejected = t.transfer.status === TransferStatus.STATUS_REJECTED;
|
const rejected =
|
||||||
|
t.transfer.status === TransferStatus.STATUS_REJECTED;
|
||||||
|
|
||||||
return idMatch && metricMatch && start && end && !rejected;
|
return idMatch && metricMatch && start && end && !rejected;
|
||||||
});
|
});
|
||||||
if (!transfer || !isScopedToTeams(transfer)) transfer = undefined;
|
if (!transfer || !isScopedToTeams(transfer)) transfer = undefined;
|
||||||
const asset = transfer?.transfer.asset;
|
const asset = transfer?.transfer.asset;
|
||||||
|
|
||||||
const dailyAmount =
|
const dailyAmount =
|
||||||
asset && transfer
|
asset && transfer
|
||||||
|
? addDecimalsFormatNumberQuantum(
|
||||||
|
transfer.transfer.amount,
|
||||||
|
asset.decimals,
|
||||||
|
asset.quantum
|
||||||
|
)
|
||||||
|
: '-';
|
||||||
|
|
||||||
|
const earnedAmount = asset
|
||||||
? addDecimalsFormatNumberQuantum(
|
? addDecimalsFormatNumberQuantum(
|
||||||
transfer.transfer.amount,
|
game.team.rewardEarned,
|
||||||
asset.decimals,
|
asset.decimals,
|
||||||
asset.quantum
|
asset.quantum
|
||||||
)
|
)
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
const earnedAmount = asset
|
const totalAmount = asset
|
||||||
? addDecimalsFormatNumberQuantum(
|
? addDecimalsFormatNumberQuantum(
|
||||||
game.team.rewardEarned,
|
game.team.totalRewardsEarned,
|
||||||
asset.decimals,
|
asset.decimals,
|
||||||
asset.quantum
|
asset.quantum
|
||||||
)
|
)
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
const totalAmount = asset
|
const assetSymbol = asset ? <RewardAssetCell asset={asset} /> : '-';
|
||||||
? addDecimalsFormatNumberQuantum(
|
|
||||||
game.team.totalRewardsEarned,
|
|
||||||
asset.decimals,
|
|
||||||
asset.quantum
|
|
||||||
)
|
|
||||||
: '-';
|
|
||||||
|
|
||||||
const assetSymbol = asset ? <RewardAssetCell asset={asset} /> : '-';
|
return {
|
||||||
|
id: game.id,
|
||||||
return {
|
amount: dependable(earnedAmount),
|
||||||
id: game.id,
|
asset: dependable(assetSymbol),
|
||||||
amount: dependable(earnedAmount),
|
daily: dependable(dailyAmount),
|
||||||
asset: dependable(assetSymbol),
|
endtime: <EndTimeCell epoch={game.epoch} />,
|
||||||
daily: dependable(dailyAmount),
|
epoch: game.epoch,
|
||||||
endtime: <EndTimeCell epoch={game.epoch} />,
|
participatingMembers: game.numberOfParticipants,
|
||||||
epoch: game.epoch,
|
participatingTeams: game.entities.length,
|
||||||
participatingMembers: game.numberOfParticipants,
|
rank: game.team.rank,
|
||||||
participatingTeams: game.entities.length,
|
total: totalAmount,
|
||||||
rank: game.team.rank,
|
// type: DispatchMetricLabels[game.team.rewardMetric as DispatchMetric],
|
||||||
total: totalAmount,
|
type: dependable(
|
||||||
// type: DispatchMetricLabels[game.team.rewardMetric as DispatchMetric],
|
<GameTypeCell transfer={transfer} allMarkets={allMarkets} />
|
||||||
type: dependable(
|
),
|
||||||
<GameTypeCell transfer={transfer} allMarkets={allMarkets} />
|
};
|
||||||
),
|
})}
|
||||||
};
|
noCollapse={false}
|
||||||
})}
|
/>
|
||||||
noCollapse={false}
|
</div>
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Members = ({ members }: { members?: Member[] }) => {
|
const Members = ({ members }: { members?: Member[] }) => {
|
||||||
const t = useT();
|
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) {
|
if (!members?.length) {
|
||||||
return <p>{t('No members')}</p>;
|
return <p>{t('No members')}</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = orderBy(
|
const data = orderBy(
|
||||||
members.map((m) => ({
|
members.map((m) => ({
|
||||||
referee: <RefereeLink pubkey={m.referee} isCreator={m.isCreator} />,
|
referee: (
|
||||||
|
<RefereeLink
|
||||||
|
pubkey={m.referee}
|
||||||
|
isCreator={m.isCreator}
|
||||||
|
profiles={profiles}
|
||||||
|
/>
|
||||||
|
),
|
||||||
rewards: formatNumber(m.totalQuantumRewards),
|
rewards: formatNumber(m.totalQuantumRewards),
|
||||||
volume: formatNumber(m.totalQuantumVolume),
|
volume: formatNumber(m.totalQuantumVolume),
|
||||||
gamesPlayed: formatNumber(m.totalGamesPlayed),
|
gamesPlayed: formatNumber(m.totalGamesPlayed),
|
||||||
joinedAt: getDateTimeFormat().format(new Date(m.joinedAt)),
|
joinedAt: formatDate(new Date(m.joinedAt)),
|
||||||
joinedAtEpoch: Number(m.joinedAtEpoch),
|
joinedAtEpoch: Number(m.joinedAtEpoch),
|
||||||
})),
|
})),
|
||||||
'joinedAtEpoch',
|
'joinedAtEpoch',
|
||||||
@@ -349,45 +422,69 @@ const Members = ({ members }: { members?: Member[] }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<div className="text-sm">
|
||||||
columns={[
|
<Table
|
||||||
{ name: 'referee', displayName: t('Member ID') },
|
columns={[
|
||||||
{ name: 'rewards', displayName: t('Rewards earned') },
|
{ name: 'referee', displayName: t('Member') },
|
||||||
{ name: 'volume', displayName: t('Total volume') },
|
{ name: 'rewards', displayName: t('Rewards earned') },
|
||||||
{ name: 'gamesPlayed', displayName: t('Games played') },
|
{ name: 'volume', displayName: t('Total volume') },
|
||||||
{
|
{ name: 'gamesPlayed', displayName: t('Games played') },
|
||||||
name: 'joinedAt',
|
{
|
||||||
displayName: t('Joined at'),
|
name: 'joinedAt',
|
||||||
},
|
displayName: t('Joined at'),
|
||||||
{
|
},
|
||||||
name: 'joinedAtEpoch',
|
{
|
||||||
displayName: t('Joined epoch'),
|
name: 'joinedAtEpoch',
|
||||||
},
|
displayName: t('Joined epoch'),
|
||||||
]}
|
},
|
||||||
data={data}
|
]}
|
||||||
noCollapse={true}
|
data={data}
|
||||||
/>
|
noCollapse={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const RefereeLink = ({
|
const RefereeLink = ({
|
||||||
pubkey,
|
pubkey,
|
||||||
isCreator,
|
isCreator,
|
||||||
|
profiles,
|
||||||
}: {
|
}: {
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
isCreator: boolean;
|
isCreator: boolean;
|
||||||
|
profiles?: { partyId: string; alias: string }[];
|
||||||
}) => {
|
}) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const linkCreator = useLinks(DApp.Explorer);
|
const linkCreator = useLinks(DApp.Explorer);
|
||||||
const link = linkCreator(EXPLORER_PARTIES.replace(':id', pubkey));
|
const link = linkCreator(EXPLORER_PARTIES.replace(':id', pubkey));
|
||||||
|
|
||||||
|
const alias = profiles?.find((p) => p.partyId === pubkey)?.alias;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="flex items-baseline gap-2">
|
||||||
<Link to={link} target="_blank" className="underline underline-offset-4">
|
<Link to={link} target="_blank" className="underline underline-offset-4">
|
||||||
{truncateMiddle(pubkey)}
|
{alias || truncateMiddle(pubkey)}
|
||||||
</Link>{' '}
|
</Link>
|
||||||
<span className="text-muted text-xs">{isCreator ? t('Owner') : ''}</span>
|
{!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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -411,15 +508,12 @@ const EndTimeCell = ({ epoch }: { epoch?: number }) => {
|
|||||||
variables: {
|
variables: {
|
||||||
epochId: epoch ? epoch.toString() : undefined,
|
epochId: epoch ? epoch.toString() : undefined,
|
||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-first',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (loading) return <Loader size="small" />;
|
if (loading) return <Loader size="small" />;
|
||||||
if (data) {
|
if (data) {
|
||||||
return format(
|
return formatDate(new Date(data.epoch.timestamps.expiry));
|
||||||
new Date(data.epoch.timestamps.expiry),
|
|
||||||
'yyyy/MM/dd hh:mm:ss'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ export const JoinButton = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const t = useT();
|
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) {
|
if (!pubKey || isReadOnly) {
|
||||||
return (
|
return (
|
||||||
<Tooltip description={t('Connect your wallet to join the team')}>
|
<Tooltip description={t('Connect your wallet to join the team')}>
|
||||||
@@ -79,8 +85,9 @@ export const JoinButton = ({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Party is the creator of a team
|
// Party is the creator of a team
|
||||||
else if (partyTeam && partyTeam.referrer === pubKey) {
|
if (partyTeam && partyTeam.referrer === pubKey) {
|
||||||
// Party is the creator of THIS team
|
// Party is the creator of THIS team
|
||||||
if (partyTeam.teamId === team.teamId) {
|
if (partyTeam.teamId === team.teamId) {
|
||||||
return (
|
return (
|
||||||
@@ -105,8 +112,24 @@ export const JoinButton = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Party is in a team, but not this one
|
// Party is in a team, but not this one
|
||||||
else if (partyTeam && partyTeam.teamId !== team.teamId) {
|
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.
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onJoin('switch')}
|
onClick={() => onJoin('switch')}
|
||||||
@@ -117,8 +140,9 @@ export const JoinButton = ({
|
|||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joined. Current party is already in this team
|
// Joined. Current party is already in this team
|
||||||
else if (partyTeam && partyTeam.teamId === team.teamId) {
|
if (partyTeam && partyTeam.teamId === team.teamId) {
|
||||||
return (
|
return (
|
||||||
<Button intent={Intent.None} disabled={true}>
|
<Button intent={Intent.None} disabled={true}>
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
@@ -131,6 +155,17 @@ 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 (
|
return (
|
||||||
<Button onClick={() => onJoin('join')} intent={Intent.Primary}>
|
<Button onClick={() => onJoin('join')} intent={Intent.Primary}>
|
||||||
{t('Join team')}
|
{t('Join team')}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
VegaIcon,
|
VegaIcon,
|
||||||
VegaIconNames,
|
VegaIconNames,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { URL_REGEX, validVegaPublicKey } from '@vegaprotocol/utils';
|
import { URL_REGEX, isValidVegaPublicKey } from '@vegaprotocol/utils';
|
||||||
|
|
||||||
import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
import { type useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction';
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
@@ -217,7 +217,9 @@ export const TeamForm = ({
|
|||||||
validate: {
|
validate: {
|
||||||
allowList: (value) => {
|
allowList: (value) => {
|
||||||
const publicKeys = parseAllowListText(value);
|
const publicKeys = parseAllowListText(value);
|
||||||
if (publicKeys.every((pk) => validVegaPublicKey(pk))) {
|
if (
|
||||||
|
publicKeys.every((pk) => isValidVegaPublicKey(pk))
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return t('Invalid public key found in allow list');
|
return t('Invalid public key found in allow list');
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
|||||||
import { DocsLinks, useEnvironment } from '@vegaprotocol/environment';
|
import { DocsLinks, useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit';
|
import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { Market } from '@vegaprotocol/markets';
|
import type { Market } from '@vegaprotocol/markets';
|
||||||
import { addDecimalsFormatNumber, fromNanoSeconds } from '@vegaprotocol/utils';
|
|
||||||
import {
|
import {
|
||||||
useMarketExpiryDate,
|
addDecimalsFormatNumber,
|
||||||
|
fromNanoSeconds,
|
||||||
getMarketExpiryDate,
|
getMarketExpiryDate,
|
||||||
} from '@vegaprotocol/react-helpers';
|
useExpiryDate,
|
||||||
|
} from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
Last24hPriceChange,
|
Last24hPriceChange,
|
||||||
Last24hVolume,
|
Last24hVolume,
|
||||||
@@ -19,6 +20,7 @@ import {
|
|||||||
useMarketTradingMode,
|
useMarketTradingMode,
|
||||||
useExternalTwap,
|
useExternalTwap,
|
||||||
getQuoteName,
|
getQuoteName,
|
||||||
|
useMarketState,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
import { MarketState as State } from '@vegaprotocol/types';
|
import { MarketState as State } from '@vegaprotocol/types';
|
||||||
import { HeaderStat } from '../../components/header';
|
import { HeaderStat } from '../../components/header';
|
||||||
@@ -43,6 +45,12 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
|||||||
const asset = getAsset(market);
|
const asset = getAsset(market);
|
||||||
const quoteUnit = getQuoteName(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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
||||||
@@ -60,16 +68,13 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
|||||||
<HeaderStat heading={t('Volume (24h)')} testId="market-volume">
|
<HeaderStat heading={t('Volume (24h)')} testId="market-volume">
|
||||||
<Last24hVolume
|
<Last24hVolume
|
||||||
marketId={market.id}
|
marketId={market.id}
|
||||||
positionDecimalPlaces={market.positionDecimalPlaces}
|
|
||||||
marketDecimals={market.decimalPlaces}
|
marketDecimals={market.decimalPlaces}
|
||||||
|
positionDecimalPlaces={market.positionDecimalPlaces}
|
||||||
quoteUnit={quoteUnit}
|
quoteUnit={quoteUnit}
|
||||||
/>
|
/>
|
||||||
</HeaderStat>
|
</HeaderStat>
|
||||||
<HeaderStatMarketTradingMode
|
<HeaderStatMarketTradingMode marketId={market.id} />
|
||||||
marketId={market.id}
|
<MarketState marketId={market.id} />
|
||||||
initialTradingMode={market.tradingMode}
|
|
||||||
/>
|
|
||||||
<MarketState market={market} />
|
|
||||||
{asset ? (
|
{asset ? (
|
||||||
<HeaderStat
|
<HeaderStat
|
||||||
heading={t('Settlement asset')}
|
heading={t('Settlement asset')}
|
||||||
@@ -126,14 +131,25 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
|||||||
{t(
|
{t(
|
||||||
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
||||||
)}
|
)}
|
||||||
{DocsLinks && (
|
<div className="flex flex-col gap-1">
|
||||||
<ExternalLink
|
{DocsLinks && (
|
||||||
href={DocsLinks.ETH_DATA_SOURCES}
|
<ExternalLink
|
||||||
className="mt-2"
|
href={DocsLinks.ETH_DATA_SOURCES}
|
||||||
>
|
className="mt-2"
|
||||||
{t('Find out more')}
|
>
|
||||||
</ExternalLink>
|
{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>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
testId="index-price"
|
testId="index-price"
|
||||||
@@ -263,14 +279,13 @@ export const FundingCountdown = ({ marketId }: { marketId: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
|
const ExpiryLabel = ({ market }: ExpiryLabelProps) => {
|
||||||
const expiryDate = useMarketExpiryDate(
|
const { data: marketState } = useMarketState(market.id);
|
||||||
market.tradableInstrument.instrument.metadata.tags,
|
const content =
|
||||||
market.marketTimestamps.close,
|
useExpiryDate(
|
||||||
market.state
|
market.tradableInstrument.instrument.metadata.tags,
|
||||||
);
|
market.marketTimestamps.close,
|
||||||
const content = market.tradableInstrument.instrument.metadata.tags
|
marketState
|
||||||
? expiryDate
|
) || '-';
|
||||||
: '-';
|
|
||||||
return <div data-testid="trading-expiry">{content}</div>;
|
return <div data-testid="trading-expiry">{content}</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -283,6 +298,7 @@ const ExpiryTooltipContent = ({
|
|||||||
market,
|
market,
|
||||||
explorerUrl,
|
explorerUrl,
|
||||||
}: ExpiryTooltipContentProps) => {
|
}: ExpiryTooltipContentProps) => {
|
||||||
|
const { data: state } = useMarketState(market.id);
|
||||||
const t = useT();
|
const t = useT();
|
||||||
if (market.marketTimestamps.close === null) {
|
if (market.marketTimestamps.close === null) {
|
||||||
const oracleId =
|
const oracleId =
|
||||||
@@ -298,8 +314,8 @@ const ExpiryTooltipContent = ({
|
|||||||
const isExpired =
|
const isExpired =
|
||||||
metadataExpiryDate &&
|
metadataExpiryDate &&
|
||||||
Date.now() - metadataExpiryDate.valueOf() > 0 &&
|
Date.now() - metadataExpiryDate.valueOf() > 0 &&
|
||||||
(market.state === State.STATE_TRADING_TERMINATED ||
|
(state === State.STATE_TRADING_TERMINATED ||
|
||||||
market.state === State.STATE_SETTLED);
|
state === State.STATE_SETTLED);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section data-testid="expiry-tooltip">
|
<section data-testid="expiry-tooltip">
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ describe('Closed', () => {
|
|||||||
|
|
||||||
const market = createMarketFragment({
|
const market = createMarketFragment({
|
||||||
id: marketId,
|
id: marketId,
|
||||||
state: MarketState.STATE_SETTLED,
|
|
||||||
tradableInstrument: {
|
tradableInstrument: {
|
||||||
instrument: {
|
instrument: {
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -96,6 +95,7 @@ describe('Closed', () => {
|
|||||||
|
|
||||||
const marketsData = createMarketsDataFragment({
|
const marketsData = createMarketsDataFragment({
|
||||||
__typename: 'MarketData',
|
__typename: 'MarketData',
|
||||||
|
marketState: MarketState.STATE_SETTLED,
|
||||||
market: {
|
market: {
|
||||||
__typename: 'Market',
|
__typename: 'Market',
|
||||||
id: marketId,
|
id: marketId,
|
||||||
@@ -199,13 +199,16 @@ describe('Closed', () => {
|
|||||||
|
|
||||||
it('renders correctly formatted and filtered rows', async () => {
|
it('renders correctly formatted and filtered rows', async () => {
|
||||||
await renderComponent([marketsMock, marketsDataMock, oracleDataMock]);
|
await renderComponent([marketsMock, marketsDataMock, oracleDataMock]);
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getAllByRole('gridcell').length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
const assetSymbol = getAsset(market).symbol;
|
const assetSymbol = getAsset(market).symbol;
|
||||||
|
|
||||||
const cells = screen.getAllByRole('gridcell');
|
const cells = screen.getAllByRole('gridcell');
|
||||||
const expectedValues = [
|
const expectedValues = [
|
||||||
market.tradableInstrument.instrument.code,
|
market.tradableInstrument.instrument.code,
|
||||||
MarketStateMapping[market.state],
|
MarketStateMapping[marketsData.marketState],
|
||||||
'3 days ago',
|
'3 days ago',
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
addDecimalsFormatNumber(marketsData.bestBidPrice, market.decimalPlaces),
|
addDecimalsFormatNumber(marketsData.bestBidPrice, market.decimalPlaces),
|
||||||
@@ -224,87 +227,6 @@ 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 () => {
|
it('display market actions', async () => {
|
||||||
// Use market with a successor Id as the actions dropdown will optionally
|
// Use market with a successor Id as the actions dropdown will optionally
|
||||||
// show a link to the successor market
|
// show a link to the successor market
|
||||||
@@ -312,8 +234,7 @@ describe('Closed', () => {
|
|||||||
{
|
{
|
||||||
__typename: 'MarketEdge' as const,
|
__typename: 'MarketEdge' as const,
|
||||||
node: createMarketFragment({
|
node: createMarketFragment({
|
||||||
id: 'include-0',
|
id: marketId,
|
||||||
state: MarketState.STATE_SETTLED,
|
|
||||||
successorMarketID: 'successor',
|
successorMarketID: 'successor',
|
||||||
parentMarketID: 'parent',
|
parentMarketID: 'parent',
|
||||||
}),
|
}),
|
||||||
@@ -338,31 +259,33 @@ describe('Closed', () => {
|
|||||||
oracleDataMock,
|
oracleDataMock,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const actionCell = screen
|
await waitFor(async () => {
|
||||||
.getAllByRole('gridcell')
|
const actionCell = screen
|
||||||
.find((el) => el.getAttribute('col-id') === 'market-actions');
|
.getAllByRole('gridcell')
|
||||||
|
.find((el) => el.getAttribute('col-id') === 'market-actions');
|
||||||
|
|
||||||
await userEvent.click(
|
await userEvent.click(
|
||||||
within(actionCell as HTMLElement).getByTestId('dropdown-menu')
|
within(actionCell as HTMLElement).getByTestId('dropdown-menu')
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByRole('menu')).toBeInTheDocument();
|
expect(screen.getByRole('menu')).toBeInTheDocument();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('menuitem', { name: 'Copy Market ID' })
|
screen.getByRole('menuitem', { name: 'Copy Market ID' })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('menuitem', { name: 'View on Explorer' })
|
screen.getByRole('menuitem', { name: 'View on Explorer' })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('menuitem', { name: 'View settlement asset details' })
|
screen.getByRole('menuitem', { name: 'View settlement asset details' })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('menuitem', { name: 'View parent market' })
|
screen.getByRole('menuitem', { name: 'View parent market' })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('menuitem', { name: 'View successor market' })
|
screen.getByRole('menuitem', { name: 'View successor market' })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('successor market should be visible', async () => {
|
it('successor market should be visible', async () => {
|
||||||
@@ -370,8 +293,7 @@ describe('Closed', () => {
|
|||||||
{
|
{
|
||||||
__typename: 'MarketEdge' as const,
|
__typename: 'MarketEdge' as const,
|
||||||
node: createMarketFragment({
|
node: createMarketFragment({
|
||||||
id: 'include-0',
|
id: marketId,
|
||||||
state: MarketState.STATE_SETTLED,
|
|
||||||
successorMarketID: 'successor',
|
successorMarketID: 'successor',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ import { useMemo } from 'react';
|
|||||||
import type { Asset } from '@vegaprotocol/types';
|
import type { Asset } from '@vegaprotocol/types';
|
||||||
import type { ProductType } from '@vegaprotocol/types';
|
import type { ProductType } from '@vegaprotocol/types';
|
||||||
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
|
import { MarketState, MarketStateMapping } from '@vegaprotocol/types';
|
||||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
import {
|
||||||
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers';
|
addDecimalsFormatNumber,
|
||||||
import { closedMarketsWithDataProvider, getAsset } from '@vegaprotocol/markets';
|
getMarketExpiryDate,
|
||||||
|
} from '@vegaprotocol/utils';
|
||||||
|
import { closedMarketsProvider, getAsset } from '@vegaprotocol/markets';
|
||||||
import type { DataSourceFilterFragment } from '@vegaprotocol/markets';
|
import type { DataSourceFilterFragment } from '@vegaprotocol/markets';
|
||||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||||
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
|
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
|
||||||
@@ -33,7 +35,7 @@ interface Row {
|
|||||||
code: string;
|
code: string;
|
||||||
name: string;
|
name: string;
|
||||||
decimalPlaces: number;
|
decimalPlaces: number;
|
||||||
state: MarketState;
|
state?: MarketState;
|
||||||
metadata: string[];
|
metadata: string[];
|
||||||
closeTimestamp: string | null;
|
closeTimestamp: string | null;
|
||||||
bestBidPrice: string | undefined;
|
bestBidPrice: string | undefined;
|
||||||
@@ -51,7 +53,7 @@ interface Row {
|
|||||||
|
|
||||||
export const Closed = () => {
|
export const Closed = () => {
|
||||||
const { data: marketData, error } = useDataProvider({
|
const { data: marketData, error } = useDataProvider({
|
||||||
dataProvider: closedMarketsWithDataProvider,
|
dataProvider: closedMarketsProvider,
|
||||||
variables: undefined,
|
variables: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ export const Closed = () => {
|
|||||||
code: instrument.code,
|
code: instrument.code,
|
||||||
name: instrument.name,
|
name: instrument.name,
|
||||||
decimalPlaces: market.decimalPlaces,
|
decimalPlaces: market.decimalPlaces,
|
||||||
state: market.state,
|
state: market.data?.marketState,
|
||||||
metadata: instrument.metadata.tags ?? [],
|
metadata: instrument.metadata.tags ?? [],
|
||||||
closeTimestamp: market.marketTimestamps.close,
|
closeTimestamp: market.marketTimestamps.close,
|
||||||
bestBidPrice: market.data?.bestBidPrice,
|
bestBidPrice: market.data?.bestBidPrice,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export { ProposalsList } from './proposals-list';
|
||||||
+2
-1
@@ -6,7 +6,7 @@ import {
|
|||||||
ActionsDropdown,
|
ActionsDropdown,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { DApp, TOKEN_PROPOSAL, useLinks } from '@vegaprotocol/environment';
|
import { DApp, TOKEN_PROPOSAL, useLinks } from '@vegaprotocol/environment';
|
||||||
import { useT } from '../use-t';
|
import { useT } from '../../../lib/use-t';
|
||||||
|
|
||||||
export const ProposalActionsDropdown = ({ id }: { id: string }) => {
|
export const ProposalActionsDropdown = ({ id }: { id: string }) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
@@ -18,6 +18,7 @@ export const ProposalActionsDropdown = ({ id }: { id: string }) => {
|
|||||||
<Link
|
<Link
|
||||||
href={linkCreator(TOKEN_PROPOSAL.replace(':id', id))}
|
href={linkCreator(TOKEN_PROPOSAL.replace(':id', id))}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
className="flex items-center gap-2"
|
||||||
>
|
>
|
||||||
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={16} />
|
<VegaIcon name={VegaIconNames.OPEN_EXTERNAL} size={16} />
|
||||||
{t('View proposal')}
|
{t('View proposal')}
|
||||||
+75
-71
@@ -1,77 +1,71 @@
|
|||||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||||
import merge from 'lodash/merge';
|
|
||||||
import type { MockedResponse } from '@apollo/client/testing';
|
import type { MockedResponse } from '@apollo/client/testing';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { ProposalsList } from './proposals-list';
|
import { ProposalsList } from './proposals-list';
|
||||||
import * as Types from '@vegaprotocol/types';
|
import { MarketState } from '@vegaprotocol/types';
|
||||||
import { createProposalListFieldsFragment } from '../../lib/proposals-data-provider/proposals.mock';
|
import {
|
||||||
import type { ProposalsListQuery } from '../../lib';
|
createMarketFragment,
|
||||||
import { ProposalsListDocument } from '../../lib';
|
createMarketsDataFragment,
|
||||||
import type { PartialDeep } from 'type-fest';
|
} from '@vegaprotocol/mock';
|
||||||
|
import {
|
||||||
|
type MarketsQuery,
|
||||||
|
MarketsDocument,
|
||||||
|
type MarketsQueryVariables,
|
||||||
|
type MarketsDataQuery,
|
||||||
|
type MarketsDataQueryVariables,
|
||||||
|
MarketsDataDocument,
|
||||||
|
} from '@vegaprotocol/markets';
|
||||||
|
|
||||||
const parentMarketName = 'Parent Market Name';
|
const parentMarketName = 'Parent Market Name';
|
||||||
const ParentMarketCell = () => <span>{parentMarketName}</span>;
|
const ParentMarketCell = () => <span>{parentMarketName}</span>;
|
||||||
|
|
||||||
describe('ProposalsList', () => {
|
describe('ProposalsList', () => {
|
||||||
const rowContainerSelector = '.ag-center-cols-container';
|
const rowContainerSelector = '.ag-center-cols-container';
|
||||||
|
const market = createMarketFragment();
|
||||||
const createProposalsMock = (override?: PartialDeep<ProposalsListQuery>) => {
|
const marketData = createMarketsDataFragment({
|
||||||
const defaultProposalEdges = [
|
marketState: MarketState.STATE_PROPOSED,
|
||||||
{
|
|
||||||
__typename: 'ProposalEdge' as const,
|
|
||||||
node: createProposalListFieldsFragment({
|
|
||||||
id: 'id-1',
|
|
||||||
state: Types.ProposalState.STATE_OPEN,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
__typename: 'ProposalEdge' as const,
|
|
||||||
node: createProposalListFieldsFragment({
|
|
||||||
id: 'id-2',
|
|
||||||
state: Types.ProposalState.STATE_PASSED,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
__typename: 'ProposalEdge' as const,
|
|
||||||
node: createProposalListFieldsFragment({
|
|
||||||
id: 'id-3',
|
|
||||||
state: Types.ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const data = merge(
|
|
||||||
{
|
|
||||||
proposalsConnection: {
|
|
||||||
__typename: 'ProposalsConnection' as const,
|
|
||||||
edges: defaultProposalEdges,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
override
|
|
||||||
);
|
|
||||||
|
|
||||||
const mock: MockedResponse<ProposalsListQuery> = {
|
|
||||||
request: {
|
|
||||||
query: ProposalsListDocument,
|
|
||||||
variables: {
|
|
||||||
proposalType: Types.ProposalType.TYPE_NEW_MARKET,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: {
|
|
||||||
data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return mock;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be properly rendered', async () => {
|
it('should be properly rendered', async () => {
|
||||||
const mock = createProposalsMock();
|
const marketMock: MockedResponse<MarketsQuery, MarketsQueryVariables> = {
|
||||||
|
request: {
|
||||||
|
query: MarketsDocument,
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
data: {
|
||||||
|
marketsConnection: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: market,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const marketDataMock: MockedResponse<
|
||||||
|
MarketsDataQuery,
|
||||||
|
MarketsDataQueryVariables
|
||||||
|
> = {
|
||||||
|
request: {
|
||||||
|
query: MarketsDataDocument,
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
data: {
|
||||||
|
marketsConnection: {
|
||||||
|
edges: [
|
||||||
|
{
|
||||||
|
node: { data: marketData },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<MockedProvider mocks={[mock]}>
|
<MockedProvider mocks={[marketMock, marketDataMock]}>
|
||||||
<ProposalsList cellRenderers={{ ParentMarketCell }} />
|
<ProposalsList cellRenderers={{ ParentMarketCell }} />
|
||||||
</MockedProvider>
|
</MockedProvider>
|
||||||
);
|
);
|
||||||
@@ -102,37 +96,47 @@ describe('ProposalsList', () => {
|
|||||||
|
|
||||||
expect(await container.findAllByRole('row')).toHaveLength(
|
expect(await container.findAllByRole('row')).toHaveLength(
|
||||||
// @ts-ignore data is mocked
|
// @ts-ignore data is mocked
|
||||||
mock?.result?.data.proposalsConnection.edges.length
|
marketMock?.result?.data.marketsConnection.edges.length
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
container.getAllByRole('gridcell', {
|
container.getAllByRole('gridcell', {
|
||||||
name: (_, element) =>
|
name: (_, element) =>
|
||||||
element.getAttribute('col-id') ===
|
element.getAttribute('col-id') === 'parentMarketID',
|
||||||
'terms.change.successorConfiguration.parentMarketId',
|
|
||||||
})[0]
|
})[0]
|
||||||
).toHaveTextContent(parentMarketName);
|
).toHaveTextContent(parentMarketName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('empty response should causes no data message display', async () => {
|
it('empty response should causes no data message display', async () => {
|
||||||
const mock: MockedResponse<ProposalsListQuery> = {
|
const marketMock: MockedResponse<MarketsQuery, MarketsQueryVariables> = {
|
||||||
request: {
|
request: {
|
||||||
query: ProposalsListDocument,
|
query: MarketsDocument,
|
||||||
variables: {
|
|
||||||
proposalType: Types.ProposalType.TYPE_NEW_MARKET,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
data: {
|
data: {
|
||||||
proposalsConnection: {
|
marketsConnection: {
|
||||||
__typename: 'ProposalsConnection',
|
edges: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const marketDataMock: MockedResponse<
|
||||||
|
MarketsDataQuery,
|
||||||
|
MarketsDataQueryVariables
|
||||||
|
> = {
|
||||||
|
request: {
|
||||||
|
query: MarketsDataDocument,
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
data: {
|
||||||
|
marketsConnection: {
|
||||||
edges: [],
|
edges: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
render(
|
render(
|
||||||
<MockedProvider mocks={[mock]}>
|
<MockedProvider mocks={[marketMock, marketDataMock]}>
|
||||||
<ProposalsList cellRenderers={{ ParentMarketCell }} />
|
<ProposalsList cellRenderers={{ ParentMarketCell }} />
|
||||||
</MockedProvider>
|
</MockedProvider>
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
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}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
+35
-35
@@ -13,12 +13,16 @@ import type {
|
|||||||
VegaValueFormatterParams,
|
VegaValueFormatterParams,
|
||||||
} from '@vegaprotocol/datagrid';
|
} from '@vegaprotocol/datagrid';
|
||||||
import {
|
import {
|
||||||
ProposalProductTypeShortName,
|
MarketStateMapping,
|
||||||
ProposalStateMapping,
|
ProductTypeMapping,
|
||||||
|
ProductTypeShortName,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import type { ProposalListFieldsFragment } from '../../lib/proposals-data-provider/__generated__/Proposals';
|
import { ProposalActionsDropdown } from './proposal-actions-dropdown';
|
||||||
import { ProposalActionsDropdown } from '../proposal-actions-dropdown';
|
import {
|
||||||
import { useT } from '../../use-t';
|
type MarketMaybeWithData,
|
||||||
|
getProductType,
|
||||||
|
} from '@vegaprotocol/markets';
|
||||||
|
import { useT } from '../../../lib/use-t';
|
||||||
|
|
||||||
export const useColumnDefs = () => {
|
export const useColumnDefs = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
@@ -28,7 +32,7 @@ export const useColumnDefs = () => {
|
|||||||
{
|
{
|
||||||
colId: 'market',
|
colId: 'market',
|
||||||
headerName: t('Market'),
|
headerName: t('Market'),
|
||||||
field: 'terms.change.instrument.code',
|
field: 'tradableInstrument.instrument.code',
|
||||||
pinned: true,
|
pinned: true,
|
||||||
cellStyle: { lineHeight: '14px' },
|
cellStyle: { lineHeight: '14px' },
|
||||||
cellRenderer: ({
|
cellRenderer: ({
|
||||||
@@ -36,20 +40,10 @@ export const useColumnDefs = () => {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
value: string;
|
value: string;
|
||||||
data: ProposalListFieldsFragment;
|
data: MarketMaybeWithData;
|
||||||
}) => {
|
}) => {
|
||||||
if (!value || !data) return '-';
|
if (!value || !data) return '-';
|
||||||
|
|
||||||
const getProductType = (data: ProposalListFieldsFragment) => {
|
|
||||||
if (
|
|
||||||
data.terms.__typename === 'ProposalTerms' &&
|
|
||||||
data.terms.change.__typename === 'NewMarket'
|
|
||||||
) {
|
|
||||||
return data.terms.change.instrument.product?.__typename;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const productType = getProductType(data);
|
const productType = getProductType(data);
|
||||||
return (
|
return (
|
||||||
productType && (
|
productType && (
|
||||||
@@ -57,10 +51,10 @@ export const useColumnDefs = () => {
|
|||||||
primary={value}
|
primary={value}
|
||||||
secondary={
|
secondary={
|
||||||
<span
|
<span
|
||||||
title={ProposalProductTypeShortName[productType]}
|
title={ProductTypeMapping[productType]}
|
||||||
className="uppercase"
|
className="uppercase"
|
||||||
>
|
>
|
||||||
{ProposalProductTypeShortName[productType]}
|
{ProductTypeShortName[productType]}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -71,47 +65,53 @@ export const useColumnDefs = () => {
|
|||||||
{
|
{
|
||||||
colId: 'asset',
|
colId: 'asset',
|
||||||
headerName: t('Settlement asset'),
|
headerName: t('Settlement asset'),
|
||||||
field: 'terms.change.instrument.product.settlementAsset.symbol',
|
field: 'tradableInstrument.instrument.product.settlementAsset.symbol',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colId: 'state',
|
colId: 'state',
|
||||||
headerName: t('State'),
|
headerName: t('State'),
|
||||||
field: 'state',
|
field: 'data.marketState',
|
||||||
valueFormatter: ({
|
valueFormatter: ({
|
||||||
value,
|
value,
|
||||||
}: VegaValueFormatterParams<ProposalListFieldsFragment, 'state'>) =>
|
}: VegaValueFormatterParams<
|
||||||
value ? ProposalStateMapping[value] : '-',
|
MarketMaybeWithData,
|
||||||
|
'data.marketState'
|
||||||
|
>) => {
|
||||||
|
return value ? MarketStateMapping[value] : '-';
|
||||||
|
},
|
||||||
filter: SetFilter,
|
filter: SetFilter,
|
||||||
filterParams: {
|
filterParams: {
|
||||||
set: ProposalStateMapping,
|
set: MarketStateMapping,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headerName: t('Parent market'),
|
headerName: t('Parent market'),
|
||||||
field: 'terms.change.successorConfiguration.parentMarketId',
|
field: 'parentMarketID',
|
||||||
cellRenderer: 'ParentMarketCell',
|
cellRenderer: 'ParentMarketCell',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colId: 'closing-date',
|
colId: 'closing-date',
|
||||||
headerName: t('Closing date'),
|
headerName: t('Closing date'),
|
||||||
field: 'terms.closingDatetime',
|
field: 'marketTimestamps.pending',
|
||||||
valueFormatter: ({
|
valueFormatter: ({
|
||||||
value,
|
value,
|
||||||
}: VegaValueFormatterParams<
|
}: VegaValueFormatterParams<
|
||||||
ProposalListFieldsFragment,
|
MarketMaybeWithData,
|
||||||
'terms.closingDatetime'
|
'marketTimestamps.pending'
|
||||||
>) => (value ? getDateTimeFormat().format(new Date(value)) : '-'),
|
>) => {
|
||||||
|
return value ? getDateTimeFormat().format(new Date(value)) : '-';
|
||||||
|
},
|
||||||
filter: DateRangeFilter,
|
filter: DateRangeFilter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colId: 'enactment-date',
|
colId: 'enactment-date',
|
||||||
headerName: t('Enactment date'),
|
headerName: t('Enactment date'),
|
||||||
field: 'terms.enactmentDatetime',
|
field: 'marketTimestamps.open',
|
||||||
valueFormatter: ({
|
valueFormatter: ({
|
||||||
value,
|
value,
|
||||||
}: VegaValueFormatterParams<
|
}: VegaValueFormatterParams<
|
||||||
ProposalListFieldsFragment,
|
MarketMaybeWithData,
|
||||||
'terms.enactmentDatetime'
|
'marketTimestamps.open'
|
||||||
>) => (value ? getDateTimeFormat().format(new Date(value)) : '-'),
|
>) => (value ? getDateTimeFormat().format(new Date(value)) : '-'),
|
||||||
filter: DateRangeFilter,
|
filter: DateRangeFilter,
|
||||||
},
|
},
|
||||||
@@ -120,10 +120,10 @@ export const useColumnDefs = () => {
|
|||||||
...COL_DEFS.actions,
|
...COL_DEFS.actions,
|
||||||
cellRenderer: ({
|
cellRenderer: ({
|
||||||
data,
|
data,
|
||||||
}: VegaICellRendererParams<ProposalListFieldsFragment>) => {
|
}: VegaICellRendererParams<MarketMaybeWithData>) => {
|
||||||
if (!data?.id) return null;
|
if (!data?.marketProposal?.id) return null;
|
||||||
|
|
||||||
return <ProposalActionsDropdown id={data.id} />;
|
return <ProposalActionsDropdown id={data.marketProposal.id} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ProposalsList } from '@vegaprotocol/proposals';
|
import { ProposalsList } from './proposals-list';
|
||||||
import { ParentMarketCell } from './parent-market-cell';
|
import { ParentMarketCell } from './parent-market-cell';
|
||||||
|
|
||||||
const cellRenderers = {
|
const cellRenderers = {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export interface SettlementDataCellProps {
|
|||||||
oracleSpecId: string;
|
oracleSpecId: string;
|
||||||
metaDate: Date | null;
|
metaDate: Date | null;
|
||||||
closeTimestamp: string | null;
|
closeTimestamp: string | null;
|
||||||
marketState: MarketState;
|
marketState?: MarketState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SettlementDateCell = ({
|
export const SettlementDateCell = ({
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
import { ButtonLink, Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { ButtonLink, Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||||
import type {
|
import type {
|
||||||
MarketFieldsFragment,
|
|
||||||
MarketMaybeWithData,
|
MarketMaybeWithData,
|
||||||
MarketMaybeWithDataAndCandles,
|
MarketMaybeWithDataAndCandles,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
@@ -126,7 +125,9 @@ export const useMarketsColumnDefs = () => {
|
|||||||
valueFormatter: ({
|
valueFormatter: ({
|
||||||
data,
|
data,
|
||||||
}: VegaValueFormatterParams<MarketMaybeWithData, 'state'>) => {
|
}: VegaValueFormatterParams<MarketMaybeWithData, 'state'>) => {
|
||||||
return data?.state ? Schema.MarketStateMapping[data.state] : '-';
|
return data?.data?.marketState
|
||||||
|
? Schema.MarketStateMapping[data?.data?.marketState]
|
||||||
|
: '-';
|
||||||
},
|
},
|
||||||
filter: SetFilter,
|
filter: SetFilter,
|
||||||
filterParams: {
|
filterParams: {
|
||||||
@@ -166,9 +167,10 @@ export const useMarketsColumnDefs = () => {
|
|||||||
valueFormatter: ({
|
valueFormatter: ({
|
||||||
data,
|
data,
|
||||||
}: ValueFormatterParams<MarketMaybeWithDataAndCandles, 'candles'>) => {
|
}: ValueFormatterParams<MarketMaybeWithDataAndCandles, 'candles'>) => {
|
||||||
const candles = data?.candles;
|
if (!data) return '-';
|
||||||
|
const candles = data.candles;
|
||||||
const vol = candles ? calcCandleVolume(candles) : '0';
|
const vol = candles ? calcCandleVolume(candles) : '0';
|
||||||
const quoteName = getQuoteName(data as MarketFieldsFragment);
|
const quoteName = getQuoteName(data);
|
||||||
const volPrice =
|
const volPrice =
|
||||||
candles &&
|
candles &&
|
||||||
calcCandleVolumePrice(
|
calcCandleVolumePrice(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type { InMemoryCacheConfig } from '@apollo/client';
|
import type { InMemoryCacheConfig } from '@apollo/client';
|
||||||
import {
|
import {
|
||||||
AppLoader,
|
|
||||||
NetworkLoader,
|
NetworkLoader,
|
||||||
useEnvironment,
|
useEnvironment,
|
||||||
useNodeSwitcherStore,
|
useNodeSwitcherStore,
|
||||||
@@ -86,10 +85,6 @@ export const Bootstrapper = ({ children }: { children: ReactNode }) => {
|
|||||||
}));
|
}));
|
||||||
const config = useVegaWalletConfig();
|
const config = useVegaWalletConfig();
|
||||||
|
|
||||||
if (!config) {
|
|
||||||
return <AppLoader />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ERR_DATA_LOADER = (
|
const ERR_DATA_LOADER = (
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="It appears that the connection to the node <0>{{VEGA_URL}}</0> does not return necessary data, try switching to another node."
|
i18nKey="It appears that the connection to the node <0>{{VEGA_URL}}</0> does not return necessary data, try switching to another node."
|
||||||
@@ -118,7 +113,11 @@ export const Bootstrapper = ({ children }: { children: ReactNode }) => {
|
|||||||
skeleton={<Loading />}
|
skeleton={<Loading />}
|
||||||
failure={<Failure reason={t('Could not configure web3 provider')} />}
|
failure={<Failure reason={t('Could not configure web3 provider')} />}
|
||||||
>
|
>
|
||||||
<WalletProvider config={config}>{children}</WalletProvider>
|
{config ? (
|
||||||
|
<WalletProvider config={config}>{children}</WalletProvider>
|
||||||
|
) : (
|
||||||
|
<Failure reason={t('Could not configure the wallet provider')} />
|
||||||
|
)}
|
||||||
</Web3Provider>
|
</Web3Provider>
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
</NetworkLoader>
|
</NetworkLoader>
|
||||||
@@ -145,6 +144,30 @@ const cacheConfig: InMemoryCacheConfig = {
|
|||||||
Product: {
|
Product: {
|
||||||
keyFields: ['settlementAsset', ['id']],
|
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: {
|
MarketData: {
|
||||||
keyFields: ['market', ['id']],
|
keyFields: ['market', ['id']],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const CompetitionsLeaderboard = ({
|
|||||||
|
|
||||||
const avatar = (
|
const avatar = (
|
||||||
<TeamAvatar
|
<TeamAvatar
|
||||||
|
key={td.teamId}
|
||||||
teamId={td.teamId}
|
teamId={td.teamId}
|
||||||
imgUrl={td.avatarUrl}
|
imgUrl={td.avatarUrl}
|
||||||
alt={td.name}
|
alt={td.name}
|
||||||
@@ -67,7 +68,7 @@ export const CompetitionsLeaderboard = ({
|
|||||||
),
|
),
|
||||||
earned: num(td.totalQuantumRewards),
|
earned: num(td.totalQuantumRewards),
|
||||||
games: num(td.totalGamesPlayed),
|
games: num(td.totalGamesPlayed),
|
||||||
status: td.closed ? t('Closed') : t('Open'),
|
status: td.closed ? t('Private') : t('Public'),
|
||||||
volume: num(td.totalQuantumVolume),
|
volume: num(td.totalQuantumVolume),
|
||||||
};
|
};
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,6 +1,81 @@
|
|||||||
import { ActiveRewardCard } from '../rewards-container/active-rewards';
|
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
import { type EnrichedRewardTransfer } from '../../lib/hooks/use-rewards';
|
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 = ({
|
export const GamesContainer = ({
|
||||||
data,
|
data,
|
||||||
@@ -10,6 +85,23 @@ export const GamesContainer = ({
|
|||||||
currentEpoch: number;
|
currentEpoch: number;
|
||||||
}) => {
|
}) => {
|
||||||
const t = useT();
|
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) {
|
if (!data || data.length === 0) {
|
||||||
return (
|
return (
|
||||||
@@ -20,24 +112,46 @@ export const GamesContainer = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
<div>
|
||||||
{data.map((game, i) => {
|
{/** CARDS FILTER */}
|
||||||
// TODO: Remove `kind` prop from ActiveRewardCard
|
{data.length > 1 && (
|
||||||
const { transfer } = game;
|
<TradingInput
|
||||||
if (
|
onChange={(e) =>
|
||||||
transfer.kind.__typename !== 'RecurringTransfer' ||
|
setFilter((curr) => ({ ...curr, searchTerm: e.target.value }))
|
||||||
!transfer.kind.dispatchStrategy?.dispatchMetric
|
}
|
||||||
) {
|
value={filter.searchTerm}
|
||||||
return null;
|
type="text"
|
||||||
}
|
placeholder={t(
|
||||||
return (
|
'Search by reward dispatch metric, entity scope or asset name'
|
||||||
<ActiveRewardCard
|
)}
|
||||||
key={i}
|
data-testid="search-term"
|
||||||
transferNode={game}
|
className="mb-4 w-20 mr-2 max-w-xl"
|
||||||
currentEpoch={currentEpoch}
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { isValidUrl } from '@vegaprotocol/utils';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
const NUM_AVATARS = 20;
|
const NUM_AVATARS = 20;
|
||||||
const AVATAR_PATHNAME_PATTERN = '/team-avatars/{id}.png';
|
const AVATAR_PATHNAME_PATTERN = '/team-avatars/{id}.png';
|
||||||
@@ -13,26 +11,6 @@ export const getFallbackAvatar = (teamId: string) => {
|
|||||||
return AVATAR_PATHNAME_PATTERN.replace('{id}', avatarId);
|
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 = ({
|
export const TeamAvatar = ({
|
||||||
teamId,
|
teamId,
|
||||||
imgUrl,
|
imgUrl,
|
||||||
@@ -44,11 +22,11 @@ export const TeamAvatar = ({
|
|||||||
alt?: string;
|
alt?: string;
|
||||||
size?: 'large' | 'small';
|
size?: 'large' | 'small';
|
||||||
}) => {
|
}) => {
|
||||||
const img = useAvatar(teamId, imgUrl);
|
// const img = useAvatar(teamId, imgUrl);
|
||||||
return (
|
return (
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
<img
|
<img
|
||||||
src={img}
|
src={imgUrl}
|
||||||
alt={alt || 'Team avatar'}
|
alt={alt || 'Team avatar'}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'rounded-full bg-vega-clight-700 dark:bg-vega-cdark-700 shrink-0',
|
'rounded-full bg-vega-clight-700 dark:bg-vega-cdark-700 shrink-0',
|
||||||
@@ -58,6 +36,9 @@ export const TeamAvatar = ({
|
|||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
referrerPolicy="no-referrer"
|
referrerPolicy="no-referrer"
|
||||||
|
onError={(e) => {
|
||||||
|
e.currentTarget.src = getFallbackAvatar(teamId);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ describe('MarketSettledBanner', () => {
|
|||||||
open: '100',
|
open: '100',
|
||||||
close: '100',
|
close: '100',
|
||||||
volume: '100',
|
volume: '100',
|
||||||
|
notional: '10000',
|
||||||
periodStart: subHours(new Date(now), 1).toISOString(),
|
periodStart: subHours(new Date(now), 1).toISOString(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -125,6 +126,7 @@ describe('MarketSettledBanner', () => {
|
|||||||
open: '100',
|
open: '100',
|
||||||
close: '200',
|
close: '200',
|
||||||
volume: '100',
|
volume: '100',
|
||||||
|
notional: '10000',
|
||||||
periodStart: subHours(new Date(now), 2).toISOString(),
|
periodStart: subHours(new Date(now), 2).toISOString(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -161,6 +163,7 @@ describe('MarketSettledBanner', () => {
|
|||||||
open: '100',
|
open: '100',
|
||||||
close: '100',
|
close: '100',
|
||||||
volume: '100',
|
volume: '100',
|
||||||
|
notional: '10000',
|
||||||
periodStart: '2020-01-01T00:00:00',
|
periodStart: '2020-01-01T00:00:00',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import {
|
|||||||
useSuccessorMarket,
|
useSuccessorMarket,
|
||||||
type Market,
|
type Market,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
import { addDecimalsFormatNumber, isNumeric } from '@vegaprotocol/utils';
|
import {
|
||||||
import { getMarketExpiryDate } from '@vegaprotocol/react-helpers';
|
addDecimalsFormatNumber,
|
||||||
|
getMarketExpiryDate,
|
||||||
|
isNumeric,
|
||||||
|
} from '@vegaprotocol/utils';
|
||||||
import { useT, ns } from '../../lib/use-t';
|
import { useT, ns } from '../../lib/use-t';
|
||||||
import { Links } from '../../lib/links';
|
import { Links } from '../../lib/links';
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ describe('MarketSelectorItem', () => {
|
|||||||
high: '5',
|
high: '5',
|
||||||
low: '5',
|
low: '5',
|
||||||
volume: '50',
|
volume: '50',
|
||||||
|
notional: '10000',
|
||||||
periodStart: yesterday.toISOString(),
|
periodStart: yesterday.toISOString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -87,6 +88,7 @@ describe('MarketSelectorItem', () => {
|
|||||||
high: '10',
|
high: '10',
|
||||||
low: '10',
|
low: '10',
|
||||||
volume: '50',
|
volume: '50',
|
||||||
|
notional: '10000',
|
||||||
periodStart: yesterday.toISOString(),
|
periodStart: yesterday.toISOString(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -72,17 +72,17 @@ const MarketData = ({
|
|||||||
|
|
||||||
const marketTradingMode = marketData
|
const marketTradingMode = marketData
|
||||||
? marketData.marketTradingMode
|
? marketData.marketTradingMode
|
||||||
: market.data
|
: market.data?.marketTradingMode;
|
||||||
? market.data.marketTradingMode
|
|
||||||
: market.tradingMode;
|
|
||||||
|
|
||||||
const mode = [
|
const mode =
|
||||||
MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
|
marketTradingMode &&
|
||||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
[
|
||||||
MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
|
MarketTradingMode.TRADING_MODE_BATCH_AUCTION,
|
||||||
].includes(marketTradingMode)
|
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||||
? MarketTradingModeMapping[marketTradingMode]
|
MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
|
||||||
: '';
|
].includes(marketTradingMode)
|
||||||
|
? MarketTradingModeMapping[marketTradingMode]
|
||||||
|
: '';
|
||||||
|
|
||||||
const { oneDayCandles } = useCandles({ marketId: market.id });
|
const { oneDayCandles } = useCandles({ marketId: market.id });
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export const MarketSelector = ({
|
|||||||
<div data-testid="market-selector-list">
|
<div data-testid="market-selector-list">
|
||||||
<MarketList
|
<MarketList
|
||||||
data={markets}
|
data={markets}
|
||||||
loading={loading}
|
loading={loading && !data}
|
||||||
error={error}
|
error={error}
|
||||||
searchTerm={filter.searchTerm}
|
searchTerm={filter.searchTerm}
|
||||||
currentMarketId={currentMarketId}
|
currentMarketId={currentMarketId}
|
||||||
|
|||||||
@@ -409,7 +409,6 @@ describe('useMarketSelectorList', () => {
|
|||||||
}),
|
}),
|
||||||
createMarketFragment({
|
createMarketFragment({
|
||||||
id: 'market-1',
|
id: 'market-1',
|
||||||
state: MarketState.STATE_ACTIVE,
|
|
||||||
// @ts-ignore data not on fragment
|
// @ts-ignore data not on fragment
|
||||||
data: createMarketsDataFragment({
|
data: createMarketsDataFragment({
|
||||||
marketState: MarketState.STATE_ACTIVE,
|
marketState: MarketState.STATE_ACTIVE,
|
||||||
@@ -424,7 +423,6 @@ describe('useMarketSelectorList', () => {
|
|||||||
}),
|
}),
|
||||||
createMarketFragment({
|
createMarketFragment({
|
||||||
id: 'market-2',
|
id: 'market-2',
|
||||||
state: MarketState.STATE_ACTIVE,
|
|
||||||
// @ts-ignore data not on fragment
|
// @ts-ignore data not on fragment
|
||||||
data: createMarketsDataFragment({
|
data: createMarketsDataFragment({
|
||||||
marketState: MarketState.STATE_ACTIVE,
|
marketState: MarketState.STATE_ACTIVE,
|
||||||
@@ -439,7 +437,6 @@ describe('useMarketSelectorList', () => {
|
|||||||
}),
|
}),
|
||||||
createMarketFragment({
|
createMarketFragment({
|
||||||
id: 'market-3',
|
id: 'market-3',
|
||||||
state: MarketState.STATE_ACTIVE,
|
|
||||||
// @ts-ignore data not on fragment
|
// @ts-ignore data not on fragment
|
||||||
data: createMarketsDataFragment({
|
data: createMarketsDataFragment({
|
||||||
marketState: MarketState.STATE_ACTIVE,
|
marketState: MarketState.STATE_ACTIVE,
|
||||||
|
|||||||
@@ -63,7 +63,11 @@ export const useMarketSelectorList = ({
|
|||||||
[
|
[
|
||||||
(m) => {
|
(m) => {
|
||||||
if (!m.candles?.length) return 0;
|
if (!m.candles?.length) return 0;
|
||||||
return Number(priceChangePercentage(m.candles.map((c) => c.close)));
|
return Number(
|
||||||
|
priceChangePercentage(
|
||||||
|
m.candles.filter((c) => c.close !== '').map((c) => c.close)
|
||||||
|
)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[dir]
|
[dir]
|
||||||
|
|||||||
@@ -1,48 +1,18 @@
|
|||||||
import throttle from 'lodash/throttle';
|
import { useMarketState } from '@vegaprotocol/markets';
|
||||||
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 * as Schema from '@vegaprotocol/types';
|
||||||
import { HeaderStat } from '../header';
|
import { HeaderStat } from '../header';
|
||||||
import { useCallback, useRef, useState } from 'react';
|
|
||||||
import * as constants from '../constants';
|
|
||||||
import { DocsLinks } from '@vegaprotocol/environment';
|
import { DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
|
|
||||||
export const MarketState = ({ market }: { market: Market | null }) => {
|
export const MarketState = ({ marketId }: { marketId?: string }) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const [marketState, setMarketState] = useState<Schema.MarketState | null>(
|
const { data: marketState } = useMarketState(marketId);
|
||||||
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 (
|
return (
|
||||||
<HeaderStat
|
<HeaderStat
|
||||||
heading={t('Status')}
|
heading={t('Status')}
|
||||||
description={useGetMarketStateTooltip(marketState)}
|
description={useGetMarketStateTooltip(marketState ?? undefined)}
|
||||||
testId="market-state"
|
testId="market-state"
|
||||||
>
|
>
|
||||||
{marketState ? Schema.MarketStateMapping[marketState] : '-'}
|
{marketState ? Schema.MarketStateMapping[marketState] : '-'}
|
||||||
@@ -50,7 +20,7 @@ export const MarketState = ({ market }: { market: Market | null }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const useGetMarketStateTooltip = (state: Schema.MarketState | null) => {
|
const useGetMarketStateTooltip = (state?: Schema.MarketState) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
if (state === Schema.MarketState.STATE_ACTIVE) {
|
if (state === Schema.MarketState.STATE_ACTIVE) {
|
||||||
return t('Enactment date reached and usual auction exit checks pass');
|
return t('Enactment date reached and usual auction exit checks pass');
|
||||||
|
|||||||
@@ -26,20 +26,15 @@ const getTradingModeLabel = (
|
|||||||
interface HeaderStatMarketTradingModeProps {
|
interface HeaderStatMarketTradingModeProps {
|
||||||
marketId?: string;
|
marketId?: string;
|
||||||
onSelect?: (marketId: string, metaKey?: boolean) => void;
|
onSelect?: (marketId: string, metaKey?: boolean) => void;
|
||||||
initialTradingMode?: Schema.MarketTradingMode;
|
|
||||||
initialTrigger?: Schema.AuctionTrigger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HeaderStatMarketTradingMode = ({
|
export const HeaderStatMarketTradingMode = ({
|
||||||
marketId,
|
marketId,
|
||||||
onSelect,
|
onSelect,
|
||||||
initialTradingMode,
|
|
||||||
initialTrigger,
|
|
||||||
}: HeaderStatMarketTradingModeProps) => {
|
}: HeaderStatMarketTradingModeProps) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const { data } = useStaticMarketData(marketId);
|
const { data } = useStaticMarketData(marketId);
|
||||||
const marketTradingMode = data?.marketTradingMode ?? initialTradingMode;
|
const { marketTradingMode, trigger } = data || {};
|
||||||
const trigger = data?.trigger ?? initialTrigger;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeaderStat
|
<HeaderStat
|
||||||
@@ -56,8 +51,6 @@ export const HeaderStatMarketTradingMode = ({
|
|||||||
|
|
||||||
export const MarketTradingMode = ({
|
export const MarketTradingMode = ({
|
||||||
marketId,
|
marketId,
|
||||||
initialTradingMode,
|
|
||||||
initialTrigger,
|
|
||||||
inViewRoot,
|
inViewRoot,
|
||||||
}: Omit<HeaderStatMarketTradingModeProps, 'onUpdate'> & {
|
}: Omit<HeaderStatMarketTradingModeProps, 'onUpdate'> & {
|
||||||
inViewRoot?: RefObject<Element>;
|
inViewRoot?: RefObject<Element>;
|
||||||
@@ -72,10 +65,7 @@ export const MarketTradingMode = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span ref={ref}>
|
<span ref={ref}>
|
||||||
{getTradingModeLabel(
|
{getTradingModeLabel(data?.marketTradingMode, data?.trigger)}
|
||||||
data?.marketTradingMode ?? initialTradingMode,
|
|
||||||
data?.trigger ?? initialTrigger
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { NodeHealthContainer, NodeUrl } from './node-health';
|
import { NodeHealthContainer, NodeUrl } from './node-health';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider, type MockedResponse } from '@apollo/client/testing';
|
||||||
|
import {
|
||||||
|
NodeCheckDocument,
|
||||||
|
type NodeCheckQuery,
|
||||||
|
} from '@vegaprotocol/environment';
|
||||||
|
|
||||||
const mockSetNodeSwitcher = jest.fn();
|
const mockSetNodeSwitcher = jest.fn();
|
||||||
|
|
||||||
@@ -15,20 +19,50 @@ jest.mock('@vegaprotocol/environment', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe('NodeHealthContainer', () => {
|
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 () => {
|
it('controls the node switcher dialog', async () => {
|
||||||
render(<NodeHealthContainer />, { wrapper: MockedProvider });
|
renderComponent([nodeCheckMock]);
|
||||||
await waitFor(() => {
|
expect(await screen.findByRole('button')).toBeInTheDocument();
|
||||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
await userEvent.click(screen.getByRole('button'));
|
await userEvent.click(screen.getByRole('button'));
|
||||||
expect(mockSetNodeSwitcher).toHaveBeenCalled();
|
expect(mockSetNodeSwitcher).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Shows node health data on hover', async () => {
|
it('Shows node health data on hover', async () => {
|
||||||
render(<NodeHealthContainer />, { wrapper: MockedProvider });
|
renderComponent([nodeCheckMock]);
|
||||||
await waitFor(() => {
|
expect(await screen.findByRole('button')).toBeInTheDocument();
|
||||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
await userEvent.hover(screen.getByRole('button'));
|
await userEvent.hover(screen.getByRole('button'));
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
const portal = within(
|
const portal = within(
|
||||||
@@ -36,12 +70,13 @@ describe('NodeHealthContainer', () => {
|
|||||||
'[data-radix-popper-content-wrapper]'
|
'[data-radix-popper-content-wrapper]'
|
||||||
) as HTMLElement
|
) as HTMLElement
|
||||||
);
|
);
|
||||||
|
|
||||||
// two tooltips get rendered, I believe for animation purposes
|
// two tooltips get rendered, I believe for animation purposes
|
||||||
const tooltip = within(portal.getAllByTestId('tooltip-content')[0]);
|
const tooltip = within(portal.getAllByTestId('tooltip-content')[0]);
|
||||||
expect(
|
expect(
|
||||||
tooltip.getByRole('link', { name: /^Mainnet status & incidents/ })
|
tooltip.getByRole('link', { name: /^Mainnet status & incidents/ })
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(tooltip.getByText('Non operational')).toBeInTheDocument();
|
expect(tooltip.getByText('Operational')).toBeInTheDocument();
|
||||||
expect(tooltip.getByTitle('Connected node')).toHaveTextContent(
|
expect(tooltip.getByTitle('Connected node')).toHaveTextContent(
|
||||||
'vega-url.wtf'
|
'vega-url.wtf'
|
||||||
);
|
);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user