chore(trading, governance, explorer): 0.74.0 type regen (#5619)
This commit is contained in:
parent
27a9d5f247
commit
6aea10c27b
@ -1,9 +1,11 @@
|
|||||||
query ExplorerProposal($id: ID!) {
|
query ExplorerProposal($id: ID!) {
|
||||||
proposal(id: $id) {
|
proposal(id: $id) {
|
||||||
id
|
... on Proposal {
|
||||||
rationale {
|
id
|
||||||
title
|
rationale {
|
||||||
description
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,18 @@ export type ExplorerProposalQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type ExplorerProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null };
|
export type ExplorerProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null };
|
||||||
|
|
||||||
|
|
||||||
export const ExplorerProposalDocument = gql`
|
export const ExplorerProposalDocument = gql`
|
||||||
query ExplorerProposal($id: ID!) {
|
query ExplorerProposal($id: ID!) {
|
||||||
proposal(id: $id) {
|
proposal(id: $id) {
|
||||||
id
|
... on Proposal {
|
||||||
rationale {
|
id
|
||||||
title
|
rationale {
|
||||||
description
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,11 @@ import { MockedProvider } from '@apollo/client/testing';
|
|||||||
import type { MockedResponse } from '@apollo/client/testing';
|
import type { MockedResponse } from '@apollo/client/testing';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import ProposalLink from './proposal-link';
|
import ProposalLink from './proposal-link';
|
||||||
import { ExplorerProposalDocument } from './__generated__/Proposal';
|
import {
|
||||||
|
ExplorerProposalDocument,
|
||||||
|
type ExplorerProposalQuery,
|
||||||
|
type ExplorerProposalQueryVariables,
|
||||||
|
} from './__generated__/Proposal';
|
||||||
import { GraphQLError } from 'graphql';
|
import { GraphQLError } from 'graphql';
|
||||||
|
|
||||||
function renderComponent(id: string, mocks: MockedResponse[]) {
|
function renderComponent(id: string, mocks: MockedResponse[]) {
|
||||||
@ -23,7 +27,10 @@ describe('Proposal link component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Renders the ID on error', async () => {
|
it('Renders the ID on error', async () => {
|
||||||
const mock = {
|
const mock: MockedResponse<
|
||||||
|
ExplorerProposalQuery,
|
||||||
|
ExplorerProposalQueryVariables
|
||||||
|
> = {
|
||||||
request: {
|
request: {
|
||||||
query: ExplorerProposalDocument,
|
query: ExplorerProposalDocument,
|
||||||
variables: {
|
variables: {
|
||||||
@ -40,17 +47,22 @@ describe('Proposal link component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Renders the proposal title when the query returns a result', async () => {
|
it('Renders the proposal title when the query returns a result', async () => {
|
||||||
const mock = {
|
const proposalId = '123';
|
||||||
|
const mock: MockedResponse<
|
||||||
|
ExplorerProposalQuery,
|
||||||
|
ExplorerProposalQueryVariables
|
||||||
|
> = {
|
||||||
request: {
|
request: {
|
||||||
query: ExplorerProposalDocument,
|
query: ExplorerProposalDocument,
|
||||||
variables: {
|
variables: {
|
||||||
id: '123',
|
id: proposalId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
data: {
|
data: {
|
||||||
proposal: {
|
proposal: {
|
||||||
id: '123',
|
__typename: 'Proposal',
|
||||||
|
id: proposalId,
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'test-title',
|
title: 'test-title',
|
||||||
description: 'test description',
|
description: 'test description',
|
||||||
@ -60,13 +72,16 @@ describe('Proposal link component', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = render(renderComponent('123', [mock]));
|
const res = render(renderComponent(proposalId, [mock]));
|
||||||
expect(res.getByText('123')).toBeInTheDocument();
|
expect(res.getByText(proposalId)).toBeInTheDocument();
|
||||||
expect(await res.findByText('test-title')).toBeInTheDocument();
|
expect(await res.findByText('test-title')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Leaves the proposal id when the market is not found', async () => {
|
it('Leaves the proposal id when the market is not found', async () => {
|
||||||
const mock = {
|
const mock: MockedResponse<
|
||||||
|
ExplorerProposalQuery,
|
||||||
|
ExplorerProposalQueryVariables
|
||||||
|
> = {
|
||||||
request: {
|
request: {
|
||||||
query: ExplorerProposalDocument,
|
query: ExplorerProposalDocument,
|
||||||
variables: {
|
variables: {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import { useExplorerProposalQuery } from './__generated__/Proposal';
|
import {
|
||||||
|
useExplorerProposalQuery,
|
||||||
|
type ExplorerProposalQuery,
|
||||||
|
} from './__generated__/Proposal';
|
||||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import { ENV } from '../../../config/env';
|
import { ENV } from '../../../config/env';
|
||||||
import Hash from '../hash';
|
import Hash from '../hash';
|
||||||
|
|
||||||
export type ProposalLinkProps = {
|
export type ProposalLinkProps = {
|
||||||
id: string;
|
id: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
@ -16,8 +20,13 @@ const ProposalLink = ({ id, text }: ProposalLinkProps) => {
|
|||||||
variables: { id },
|
variables: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const proposal = data?.proposal as Extract<
|
||||||
|
ExplorerProposalQuery['proposal'],
|
||||||
|
{ __typename?: 'Proposal' }
|
||||||
|
>;
|
||||||
|
|
||||||
const base = ENV.dataSources.governanceUrl;
|
const base = ENV.dataSources.governanceUrl;
|
||||||
const label = data?.proposal?.rationale.title || id;
|
const label = proposal?.rationale.title || id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExternalLink href={`${base}/proposals/${id}`}>
|
<ExternalLink href={`${base}/proposals/${id}`}>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
query ExplorerProposalStatus($id: ID!) {
|
query ExplorerProposalStatus($id: ID!) {
|
||||||
proposal(id: $id) {
|
proposal(id: $id) {
|
||||||
id
|
... on Proposal {
|
||||||
state
|
id
|
||||||
rejectionReason
|
state
|
||||||
|
rejectionReason
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,17 @@ export type ExplorerProposalStatusQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type ExplorerProposalStatusQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null } | null };
|
export type ExplorerProposalStatusQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null } | null };
|
||||||
|
|
||||||
|
|
||||||
export const ExplorerProposalStatusDocument = gql`
|
export const ExplorerProposalStatusDocument = gql`
|
||||||
query ExplorerProposalStatus($id: ID!) {
|
query ExplorerProposalStatus($id: ID!) {
|
||||||
proposal(id: $id) {
|
proposal(id: $id) {
|
||||||
id
|
... on Proposal {
|
||||||
state
|
id
|
||||||
rejectionReason
|
state
|
||||||
|
rejectionReason
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -14,16 +14,18 @@ export function format(date: string | undefined, def: string) {
|
|||||||
return new Date().toLocaleDateString() || def;
|
return new Date().toLocaleDateString() || def;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDate(
|
type Proposal = Extract<
|
||||||
data: ExplorerProposalStatusQuery | undefined,
|
ExplorerProposalStatusQuery['proposal'],
|
||||||
terms: Terms
|
{ __typename?: 'Proposal' }
|
||||||
): string {
|
>;
|
||||||
|
|
||||||
|
export function getDate(proposal: Proposal | undefined, terms: Terms): string {
|
||||||
const DEFAULT = t('Unknown');
|
const DEFAULT = t('Unknown');
|
||||||
if (!data?.proposal?.state) {
|
if (!proposal?.state) {
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data.proposal.state) {
|
switch (proposal.state) {
|
||||||
case 'STATE_DECLINED':
|
case 'STATE_DECLINED':
|
||||||
return `${t('Rejected on')}: ${format(terms.closingTimestamp, DEFAULT)}`;
|
return `${t('Rejected on')}: ${format(terms.closingTimestamp, DEFAULT)}`;
|
||||||
case 'STATE_ENACTED':
|
case 'STATE_ENACTED':
|
||||||
@ -62,9 +64,11 @@ export const ProposalDate = ({ terms, id }: ProposalDateProps) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const proposal = data?.proposal as Proposal;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Lozenge className="font-sans text-xs float-right">
|
<Lozenge className="font-sans text-xs float-right">
|
||||||
{getDate(data, terms)}
|
{getDate(proposal, terms)}
|
||||||
</Lozenge>
|
</Lozenge>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,17 +2,8 @@ import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
|||||||
import type { IconProps } from '@vegaprotocol/ui-toolkit';
|
import type { IconProps } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useExplorerProposalStatusQuery } from './__generated__/Proposal';
|
import { useExplorerProposalStatusQuery } from './__generated__/Proposal';
|
||||||
import type { ExplorerProposalStatusQuery } from './__generated__/Proposal';
|
import type { ExplorerProposalStatusQuery } from './__generated__/Proposal';
|
||||||
import type * as Apollo from '@apollo/client';
|
|
||||||
import type * as Types from '@vegaprotocol/types';
|
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
|
|
||||||
type ProposalQueryResult = Apollo.QueryResult<
|
|
||||||
ExplorerProposalStatusQuery,
|
|
||||||
Types.Exact<{
|
|
||||||
id: string;
|
|
||||||
}>
|
|
||||||
>;
|
|
||||||
|
|
||||||
interface ProposalStatusIconProps {
|
interface ProposalStatusIconProps {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
@ -29,29 +20,38 @@ type IconAndLabel = {
|
|||||||
* @param data a data result from useExplorerProposalStatusQuery
|
* @param data a data result from useExplorerProposalStatusQuery
|
||||||
* @returns Icon name
|
* @returns Icon name
|
||||||
*/
|
*/
|
||||||
export function getIconAndLabelForStatus(
|
export function useIconAndLabelForStatus(id: string): IconAndLabel {
|
||||||
res: ProposalQueryResult
|
const { data, loading, error } = useExplorerProposalStatusQuery({
|
||||||
): IconAndLabel {
|
variables: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const proposal = data?.proposal as Extract<
|
||||||
|
ExplorerProposalStatusQuery['proposal'],
|
||||||
|
{ __typename?: 'Proposal' }
|
||||||
|
>;
|
||||||
|
|
||||||
const DEFAULT: IconAndLabel = {
|
const DEFAULT: IconAndLabel = {
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
label: t('Proposal state unknown'),
|
label: t('Proposal state unknown'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (res.loading) {
|
if (loading) {
|
||||||
return {
|
return {
|
||||||
icon: 'more',
|
icon: 'more',
|
||||||
label: t('Loading data'),
|
label: t('Loading data'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res?.data?.proposal || res.error) {
|
if (!data?.proposal || error) {
|
||||||
return {
|
return {
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
label: res.error?.message || DEFAULT.label,
|
label: error?.message || DEFAULT.label,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (res.data.proposal.state) {
|
switch (proposal.state) {
|
||||||
case 'STATE_DECLINED':
|
case 'STATE_DECLINED':
|
||||||
return {
|
return {
|
||||||
icon: 'stop',
|
icon: 'stop',
|
||||||
@ -99,13 +99,7 @@ export function getIconAndLabelForStatus(
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export const ProposalStatusIcon = ({ id }: ProposalStatusIconProps) => {
|
export const ProposalStatusIcon = ({ id }: ProposalStatusIconProps) => {
|
||||||
const { icon, label } = getIconAndLabelForStatus(
|
const { icon, label } = useIconAndLabelForStatus(id);
|
||||||
useExplorerProposalStatusQuery({
|
|
||||||
variables: {
|
|
||||||
id,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="float-left mr-3">
|
<div className="float-left mr-3">
|
||||||
|
@ -31,7 +31,7 @@ import {
|
|||||||
orderByUpgradeBlockHeight,
|
orderByUpgradeBlockHeight,
|
||||||
} from '../proposals/components/proposals-list/proposals-list';
|
} from '../proposals/components/proposals-list/proposals-list';
|
||||||
import { BigNumber } from '../../lib/bignumber';
|
import { BigNumber } from '../../lib/bignumber';
|
||||||
import type { ProposalQuery } from '../proposals/proposal/__generated__/Proposal';
|
import { type Proposal } from '../proposals/types';
|
||||||
|
|
||||||
const nodesToShow = 6;
|
const nodesToShow = 6;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ const HomeProposals = ({
|
|||||||
proposals,
|
proposals,
|
||||||
protocolUpgradeProposals,
|
protocolUpgradeProposals,
|
||||||
}: {
|
}: {
|
||||||
proposals: ProposalQuery['proposal'][];
|
proposals: Proposal[];
|
||||||
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { ProposalInfoLabel } from '../proposal-info-label';
|
import { ProposalInfoLabel } from '../proposal-info-label';
|
||||||
import type { ReactNode } from 'react';
|
import { type ReactNode } from 'react';
|
||||||
import type { ProposalInfoLabelVariant } from '../proposal-info-label';
|
import { type ProposalInfoLabelVariant } from '../proposal-info-label';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
export const CurrentProposalState = ({
|
export const CurrentProposalState = ({ proposal }: { proposal: Proposal }) => {
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
let proposalStatus: ReactNode;
|
let proposalStatus: ReactNode;
|
||||||
let variant = 'tertiary' as ProposalInfoLabelVariant;
|
let variant = 'tertiary' as ProposalInfoLabelVariant;
|
||||||
|
@ -1,272 +0,0 @@
|
|||||||
import type { MockedResponse } from '@apollo/client/testing';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
|
||||||
import { render, screen } from '@testing-library/react';
|
|
||||||
import { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types';
|
|
||||||
import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters';
|
|
||||||
import { NetworkParamsDocument } from '@vegaprotocol/network-parameters';
|
|
||||||
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
import { CurrentProposalStatus } from './current-proposal-status';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
const networkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
|
|
||||||
request: {
|
|
||||||
query: NetworkParamsDocument,
|
|
||||||
},
|
|
||||||
result: {
|
|
||||||
data: {
|
|
||||||
networkParametersConnection: {
|
|
||||||
edges: [
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
__typename: 'NetworkParameter',
|
|
||||||
key: 'governance.proposal.updateNetParam.requiredMajority',
|
|
||||||
value: '0.00000001',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
__typename: 'NetworkParameter',
|
|
||||||
key: 'governance.proposal.updateNetParam.requiredParticipation',
|
|
||||||
value: '0.000000001',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderComponent = ({
|
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: ProposalQuery['proposal'];
|
|
||||||
}) => {
|
|
||||||
render(
|
|
||||||
<AppStateProvider>
|
|
||||||
<MockedProvider mocks={[networkParamsQueryMock]}>
|
|
||||||
<CurrentProposalStatus proposal={proposal} />
|
|
||||||
</MockedProvider>
|
|
||||||
</AppStateProvider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
jest.setSystemTime(60 * 60 * 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal open - renders will fail state if the proposal will fail', async () => {
|
|
||||||
const failedProposal = generateProposal({
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
renderComponent({ proposal: failedProposal });
|
|
||||||
expect(await screen.findByText('Currently expected to')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('fail.')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal open - renders will pass state if the proposal will pass', async () => {
|
|
||||||
const proposal = generateProposal();
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(await screen.findByText('Currently expected to')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('pass.')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal enacted - renders vote passed and time since enactment', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_ENACTED,
|
|
||||||
terms: {
|
|
||||||
enactmentDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(await screen.findByText('Vote passed.')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal passed - renders vote passed and time since vote closed', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(await screen.findByText('Vote passed.')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal waiting for node vote - will pass - renders if the vote will pass and status', async () => {
|
|
||||||
const failedProposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
renderComponent({ proposal: failedProposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Waiting for nodes to validate asset.')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('Currently expected to')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('fail.')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal waiting for node vote - will fail - renders if the vote will pass and status', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Waiting for nodes to validate asset.')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('Currently expected to')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('pass.')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal failed - renders vote failed reason and vote closed ago', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_FAILED,
|
|
||||||
errorDetails: 'foo',
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Vote closed. Failed due to:')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('foo')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal failed - renders rejection reason there are no error details', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_FAILED,
|
|
||||||
rejectionReason: ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Vote closed. Failed due to:')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(
|
|
||||||
await screen.findByText('PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal failed - renders unknown reason if there are no error details or rejection reason', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_FAILED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Vote closed. Failed due to:')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('unknown reason')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal failed - renders participation not met if participation is not met', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_FAILED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Vote closed. Failed due to:')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('Participation not met')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Proposal failed - renders majority not met if majority is not met', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
state: ProposalState.STATE_FAILED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: new Date(0).toISOString(),
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
yes: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalTokens: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
totalNumber: '1',
|
|
||||||
totalTokens: '25242474195500835440000',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
renderComponent({ proposal });
|
|
||||||
expect(
|
|
||||||
await screen.findByText('Vote closed. Failed due to:')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('Majority not met')).toBeInTheDocument();
|
|
||||||
expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument();
|
|
||||||
});
|
|
@ -1,143 +0,0 @@
|
|||||||
import type { ReactNode } from 'react';
|
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
|
||||||
import { useVoteInformation } from '../../hooks';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
export const StatusPass = ({ children }: { children: ReactNode }) => (
|
|
||||||
<span className="text-vega-green">{children}</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const StatusFail = ({ children }: { children: ReactNode }) => (
|
|
||||||
<span className="text-danger">{children}</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
const WillPass = ({
|
|
||||||
willPass,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
willPass: boolean;
|
|
||||||
children?: ReactNode;
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
if (willPass) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{children}
|
|
||||||
<StatusPass>{t('pass')}.</StatusPass>
|
|
||||||
<span className="ml-2">{t('finalOutcomeMayDiffer')}</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{children}
|
|
||||||
<StatusFail>{t('fail')}.</StatusFail>
|
|
||||||
<span className="ml-2">{t('finalOutcomeMayDiffer')}</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const CurrentProposalStatus = ({
|
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
|
||||||
}) => {
|
|
||||||
const { willPassByTokenVote, majorityMet, participationMet } =
|
|
||||||
useVoteInformation({
|
|
||||||
proposal,
|
|
||||||
});
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const daysClosedAgo = formatDistanceToNow(
|
|
||||||
new Date(proposal?.terms.closingDatetime),
|
|
||||||
{ addSuffix: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
const daysEnactedAgo =
|
|
||||||
proposal?.terms.enactmentDatetime &&
|
|
||||||
formatDistanceToNow(new Date(proposal.terms.enactmentDatetime), {
|
|
||||||
addSuffix: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (proposal?.state === ProposalState.STATE_OPEN) {
|
|
||||||
return (
|
|
||||||
<WillPass willPass={willPassByTokenVote}>{t('currentlySetTo')}</WillPass>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
proposal?.state === ProposalState.STATE_FAILED ||
|
|
||||||
proposal?.state === ProposalState.STATE_DECLINED ||
|
|
||||||
proposal?.state === ProposalState.STATE_REJECTED
|
|
||||||
) {
|
|
||||||
if (!participationMet) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>{t('voteFailedReason')}</span>
|
|
||||||
<StatusFail>{t('participationNotMet')}</StatusFail>
|
|
||||||
<span> {daysClosedAgo}</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!majorityMet) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>{t('voteFailedReason')}</span>
|
|
||||||
<StatusFail>{t('majorityNotMet')}</StatusFail>
|
|
||||||
<span> {daysClosedAgo}</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>{t('voteFailedReason')}</span>
|
|
||||||
<StatusFail>
|
|
||||||
{proposal?.errorDetails ||
|
|
||||||
proposal?.rejectionReason ||
|
|
||||||
t('unknownReason')}
|
|
||||||
</StatusFail>
|
|
||||||
<span> {daysClosedAgo}</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
proposal?.state === ProposalState.STATE_ENACTED ||
|
|
||||||
proposal?.state === ProposalState.STATE_PASSED
|
|
||||||
) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>{t('votePassed')}</span>
|
|
||||||
<StatusPass>
|
|
||||||
|
|
||||||
{proposal?.state === ProposalState.STATE_ENACTED
|
|
||||||
? t('Enacted')
|
|
||||||
: t('Passed')}
|
|
||||||
</StatusPass>
|
|
||||||
<span>
|
|
||||||
|
|
||||||
{proposal?.state === ProposalState.STATE_ENACTED
|
|
||||||
? daysEnactedAgo
|
|
||||||
: daysClosedAgo}
|
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proposal?.state === ProposalState.STATE_WAITING_FOR_NODE_VOTE) {
|
|
||||||
return (
|
|
||||||
<WillPass willPass={willPassByTokenVote}>
|
|
||||||
<span>{t('WaitingForNodeVote')}</span>{' '}
|
|
||||||
<span>{t('currentlySetTo')}</span>
|
|
||||||
</WillPass>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
@ -1 +0,0 @@
|
|||||||
export { CurrentProposalStatus } from './current-proposal-status';
|
|
@ -6,11 +6,10 @@ import {
|
|||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
RoundedWrapper,
|
RoundedWrapper,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import { type Proposal } from '../../types';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
interface ProposalChangeTableProps {
|
interface ProposalChangeTableProps {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
|
export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
|
||||||
|
@ -23,8 +23,8 @@ import { useFeatureFlags } from '@vegaprotocol/environment';
|
|||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { VoteState } from '../vote-details/use-user-vote';
|
import { VoteState } from '../vote-details/use-user-vote';
|
||||||
import { useNewTransferProposalDetails } from '@vegaprotocol/proposals';
|
import { useNewTransferProposalDetails } from '@vegaprotocol/proposals';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type MockedResponse } from '@apollo/client/testing';
|
||||||
import type { MockedResponse } from '@apollo/client/testing';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/proposals', () => ({
|
jest.mock('@vegaprotocol/proposals', () => ({
|
||||||
...jest.requireActual('@vegaprotocol/proposals'),
|
...jest.requireActual('@vegaprotocol/proposals'),
|
||||||
@ -36,7 +36,7 @@ jest.mock('@vegaprotocol/proposals', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const renderComponent = (
|
const renderComponent = (
|
||||||
proposal: ProposalQuery['proposal'],
|
proposal: Proposal,
|
||||||
isListItem = true,
|
isListItem = true,
|
||||||
mocks: MockedResponse[] = [],
|
mocks: MockedResponse[] = [],
|
||||||
voteState?: VoteState
|
voteState?: VoteState
|
||||||
@ -64,6 +64,7 @@ describe('Proposal header', () => {
|
|||||||
it('Renders New market proposal', () => {
|
it('Renders New market proposal', () => {
|
||||||
useFeatureFlags.setState({ flags: { SUCCESSOR_MARKETS: true } });
|
useFeatureFlags.setState({ flags: { SUCCESSOR_MARKETS: true } });
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'New some market',
|
title: 'New some market',
|
||||||
@ -102,6 +103,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders Update market proposal', () => {
|
it('Renders Update market proposal', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'New market id',
|
title: 'New market id',
|
||||||
@ -130,6 +132,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders New asset proposal - ERC20', () => {
|
it('Renders New asset proposal - ERC20', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'New asset: Fake currency',
|
title: 'New asset: Fake currency',
|
||||||
@ -159,6 +162,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders New asset proposal - BuiltInAsset', () => {
|
it('Renders New asset proposal - BuiltInAsset', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
terms: {
|
terms: {
|
||||||
change: {
|
change: {
|
||||||
@ -184,6 +188,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders Update network', () => {
|
it('Renders Update network', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'Network parameter',
|
title: 'Network parameter',
|
||||||
@ -213,6 +218,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders Freeform proposal - short rationale', () => {
|
it('Renders Freeform proposal - short rationale', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
id: 'short',
|
id: 'short',
|
||||||
rationale: {
|
rationale: {
|
||||||
@ -234,6 +240,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders Freeform proposal - long rationale (105 chars) - listing', () => {
|
it('Renders Freeform proposal - long rationale (105 chars) - listing', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
id: 'long',
|
id: 'long',
|
||||||
rationale: {
|
rationale: {
|
||||||
@ -259,6 +266,7 @@ describe('Proposal header', () => {
|
|||||||
// Remove once proposals have rationale and re-enable above tests
|
// Remove once proposals have rationale and re-enable above tests
|
||||||
it('Renders Freeform proposal - id for title', () => {
|
it('Renders Freeform proposal - id for title', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
id: 'freeform id',
|
id: 'freeform id',
|
||||||
rationale: {
|
rationale: {
|
||||||
@ -280,6 +288,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders asset change proposal header', () => {
|
it('Renders asset change proposal header', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
terms: {
|
terms: {
|
||||||
change: {
|
change: {
|
||||||
@ -297,6 +306,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it("Renders unknown proposal if it's a different proposal type", () => {
|
it("Renders unknown proposal if it's a different proposal type", () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
terms: {
|
terms: {
|
||||||
change: {
|
change: {
|
||||||
@ -313,6 +323,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders proposal state: Enacted', () => {
|
it('Renders proposal state: Enacted', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_ENACTED,
|
state: ProposalState.STATE_ENACTED,
|
||||||
terms: {
|
terms: {
|
||||||
@ -325,6 +336,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders proposal state: Passed', () => {
|
it('Renders proposal state: Passed', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_PASSED,
|
state: ProposalState.STATE_PASSED,
|
||||||
terms: {
|
terms: {
|
||||||
@ -338,6 +350,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders proposal state: Waiting for node vote', () => {
|
it('Renders proposal state: Waiting for node vote', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
||||||
terms: {
|
terms: {
|
||||||
@ -352,6 +365,7 @@ describe('Proposal header', () => {
|
|||||||
|
|
||||||
it('Renders proposal state: Open', () => {
|
it('Renders proposal state: Open', () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
// @ts-ignore we aren't using batch yet
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_OPEN,
|
state: ProposalState.STATE_OPEN,
|
||||||
votes: {
|
votes: {
|
||||||
|
@ -8,8 +8,7 @@ import {
|
|||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { shorten } from '@vegaprotocol/utils';
|
import { shorten } from '@vegaprotocol/utils';
|
||||||
import { Heading, SubHeading } from '../../../../components/heading';
|
import { Heading, SubHeading } from '../../../../components/heading';
|
||||||
import type { ReactNode } from 'react';
|
import { type ReactNode } from 'react';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { truncateMiddle } from '../../../../lib/truncate-middle';
|
import { truncateMiddle } from '../../../../lib/truncate-middle';
|
||||||
import { CurrentProposalState } from '../current-proposal-state';
|
import { CurrentProposalState } from '../current-proposal-state';
|
||||||
import { ProposalInfoLabel } from '../proposal-info-label';
|
import { ProposalInfoLabel } from '../proposal-info-label';
|
||||||
@ -26,16 +25,17 @@ import {
|
|||||||
} from '@vegaprotocol/environment';
|
} from '@vegaprotocol/environment';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import type { VoteState } from '../vote-details/use-user-vote';
|
import { type VoteState } from '../vote-details/use-user-vote';
|
||||||
import { VoteBreakdown } from '../vote-breakdown';
|
import { VoteBreakdown } from '../vote-breakdown';
|
||||||
import { GovernanceTransferKindMapping } from '@vegaprotocol/types';
|
import { GovernanceTransferKindMapping } from '@vegaprotocol/types';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
export const ProposalHeader = ({
|
export const ProposalHeader = ({
|
||||||
proposal,
|
proposal,
|
||||||
isListItem = true,
|
isListItem = true,
|
||||||
voteState,
|
voteState,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
isListItem?: boolean;
|
isListItem?: boolean;
|
||||||
voteState?: VoteState | null;
|
voteState?: VoteState | null;
|
||||||
}) => {
|
}) => {
|
||||||
@ -53,7 +53,7 @@ export const ProposalHeader = ({
|
|||||||
|
|
||||||
const titleContent = shorten(title ?? '', 100);
|
const titleContent = shorten(title ?? '', 100);
|
||||||
|
|
||||||
const getAsset = (proposal: ProposalQuery['proposal']) => {
|
const getAsset = (proposal: Proposal) => {
|
||||||
const terms = proposal?.terms;
|
const terms = proposal?.terms;
|
||||||
if (
|
if (
|
||||||
terms?.change.__typename === 'NewMarket' &&
|
terms?.change.__typename === 'NewMarket' &&
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import {
|
import {
|
||||||
KeyValueTable,
|
KeyValueTable,
|
||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
@ -14,9 +13,10 @@ import {
|
|||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
import { useAppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalReferralProgramDetailsProps {
|
interface ProposalReferralProgramDetailsProps {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: Proposal | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const formatEndOfProgramTimestamp = (value: string) => {
|
export const formatEndOfProgramTimestamp = (value: string) => {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import { useCancelTransferProposalDetails } from '@vegaprotocol/proposals';
|
import { useCancelTransferProposalDetails } from '@vegaprotocol/proposals';
|
||||||
import {
|
import {
|
||||||
KeyValueTable,
|
KeyValueTable,
|
||||||
@ -8,11 +6,12 @@ import {
|
|||||||
RoundedWrapper,
|
RoundedWrapper,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
export const ProposalCancelTransferDetails = ({
|
export const ProposalCancelTransferDetails = ({
|
||||||
proposal,
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const details = useCancelTransferProposalDetails(proposal?.id);
|
const details = useCancelTransferProposalDetails(proposal?.id);
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -21,11 +19,12 @@ import {
|
|||||||
addDecimalsFormatNumberQuantum,
|
addDecimalsFormatNumberQuantum,
|
||||||
formatDateWithLocalTimezone,
|
formatDateWithLocalTimezone,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
export const ProposalTransferDetails = ({
|
export const ProposalTransferDetails = ({
|
||||||
proposal,
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import {
|
import {
|
||||||
KeyValueTable,
|
KeyValueTable,
|
||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
@ -12,6 +11,7 @@ import {
|
|||||||
} from '../proposal-referral-program-details';
|
} from '../proposal-referral-program-details';
|
||||||
import { formatNumberPercentage } from '@vegaprotocol/utils';
|
import { formatNumberPercentage } from '@vegaprotocol/utils';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
// These types are not generated as it's not known how dynamic these are
|
// These types are not generated as it's not known how dynamic these are
|
||||||
type VestingBenefitTier = {
|
type VestingBenefitTier = {
|
||||||
@ -43,7 +43,7 @@ export const formatVolumeDiscountFactor = (value: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface ProposalReferralProgramDetailsProps {
|
interface ProposalReferralProgramDetailsProps {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: Proposal | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,13 +5,13 @@ import {
|
|||||||
RoundedWrapper,
|
RoundedWrapper,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { Row } from '@vegaprotocol/markets';
|
import { Row } from '@vegaprotocol/markets';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalUpdateMarketStateProps {
|
interface ProposalUpdateMarketStateProps {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: Proposal | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalUpdateMarketState = ({
|
export const ProposalUpdateMarketState = ({
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import {
|
import {
|
||||||
KeyValueTable,
|
KeyValueTable,
|
||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
@ -12,9 +11,10 @@ import {
|
|||||||
} from '../proposal-referral-program-details';
|
} from '../proposal-referral-program-details';
|
||||||
import { formatNumberPercentage } from '@vegaprotocol/utils';
|
import { formatNumberPercentage } from '@vegaprotocol/utils';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalReferralProgramDetailsProps {
|
interface ProposalReferralProgramDetailsProps {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: Proposal | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const formatVolumeDiscountFactor = (value: string) => {
|
export const formatVolumeDiscountFactor = (value: string) => {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
||||||
import type { VegaWalletConfig } from '@vegaprotocol/wallet';
|
import { type VegaWalletConfig } from '@vegaprotocol/wallet';
|
||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
import { generateProposal } from '../../test-helpers/generate-proposals';
|
||||||
import { Proposal } from './proposal';
|
import { Proposal } from './proposal';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { mockNetworkParams } from '../../test-helpers/mocks';
|
import { mockNetworkParams } from '../../test-helpers/mocks';
|
||||||
|
import { type Proposal as IProposal } from '../../types';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/network-parameters', () => ({
|
jest.mock('@vegaprotocol/network-parameters', () => ({
|
||||||
...jest.requireActual('@vegaprotocol/network-parameters'),
|
...jest.requireActual('@vegaprotocol/network-parameters'),
|
||||||
@ -51,14 +51,14 @@ const vegaWalletConfig: VegaWalletConfig = {
|
|||||||
chainId: 'VEGA_CHAIN_ID',
|
chainId: 'VEGA_CHAIN_ID',
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderComponent = (proposal: ProposalQuery['proposal']) => {
|
const renderComponent = (proposal: IProposal) => {
|
||||||
render(
|
render(
|
||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<MockedProvider>
|
<MockedProvider>
|
||||||
<VegaWalletProvider config={vegaWalletConfig}>
|
<VegaWalletProvider config={vegaWalletConfig}>
|
||||||
<Proposal
|
<Proposal
|
||||||
restData={{}}
|
restData={{}}
|
||||||
proposal={proposal as ProposalQuery['proposal']}
|
proposal={proposal}
|
||||||
networkParams={mockNetworkParams}
|
networkParams={mockNetworkParams}
|
||||||
/>
|
/>
|
||||||
</VegaWalletProvider>
|
</VegaWalletProvider>
|
||||||
|
@ -12,14 +12,13 @@ import { UserVote } from '../vote-details';
|
|||||||
import { ListAsset } from '../list-asset';
|
import { ListAsset } from '../list-asset';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { ProposalMarketData } from '../proposal-market-data';
|
import { ProposalMarketData } from '../proposal-market-data';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type MarketInfo } from '@vegaprotocol/markets';
|
||||||
import type { MarketInfo } from '@vegaprotocol/markets';
|
import { type AssetQuery } from '@vegaprotocol/assets';
|
||||||
import type { AssetQuery } from '@vegaprotocol/assets';
|
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { ProposalMarketChanges } from '../proposal-market-changes';
|
import { ProposalMarketChanges } from '../proposal-market-changes';
|
||||||
import { ProposalUpdateMarketState } from '../proposal-update-market-state';
|
import { ProposalUpdateMarketState } from '../proposal-update-market-state';
|
||||||
import type { NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
import { type NetworkParamsResult } from '@vegaprotocol/network-parameters';
|
||||||
import { useVoteSubmit } from '@vegaprotocol/proposals';
|
import { useVoteSubmit } from '@vegaprotocol/proposals';
|
||||||
import { useUserVote } from '../vote-details/use-user-vote';
|
import { useUserVote } from '../vote-details/use-user-vote';
|
||||||
import {
|
import {
|
||||||
@ -28,9 +27,10 @@ import {
|
|||||||
} from '../proposal-transfer';
|
} from '../proposal-transfer';
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
import { useFeatureFlags } from '@vegaprotocol/environment';
|
||||||
import { ProposalUpdateBenefitTiers } from '../proposal-update-benefit-tiers';
|
import { ProposalUpdateBenefitTiers } from '../proposal-update-benefit-tiers';
|
||||||
|
import { type Proposal as IProposal } from '../../types';
|
||||||
|
|
||||||
export interface ProposalProps {
|
export interface ProposalProps {
|
||||||
proposal: ProposalQuery['proposal'];
|
proposal: IProposal;
|
||||||
networkParams: Partial<NetworkParamsResult>;
|
networkParams: Partial<NetworkParamsResult>;
|
||||||
marketData?: MarketInfo | null;
|
marketData?: MarketInfo | null;
|
||||||
parentMarketData?: MarketInfo | null;
|
parentMarketData?: MarketInfo | null;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
import { BrowserRouter as Router } from 'react-router-dom';
|
||||||
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
||||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||||
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 { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
@ -18,10 +18,10 @@ import {
|
|||||||
lastWeek,
|
lastWeek,
|
||||||
nextWeek,
|
nextWeek,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
const renderComponent = (
|
const renderComponent = (
|
||||||
proposal: ProposalQuery['proposal'],
|
proposal: Proposal,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
||||||
) =>
|
) =>
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
|
import { type ReactNode } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Button } from '@vegaprotocol/ui-toolkit';
|
import { Button } from '@vegaprotocol/ui-toolkit';
|
||||||
import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
import {
|
import {
|
||||||
ProposalRejectionReasonMapping,
|
ProposalRejectionReasonMapping,
|
||||||
ProposalState,
|
ProposalState,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import { type Proposal } from '../../types';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
export const ProposalsListItemDetails = ({
|
export const ProposalsListItemDetails = ({
|
||||||
proposal,
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const state = proposal?.state;
|
const state = proposal?.state;
|
||||||
|
@ -2,10 +2,10 @@ import { RoundedWrapper } from '@vegaprotocol/ui-toolkit';
|
|||||||
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
||||||
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
||||||
import { useUserVote } from '../vote-details/use-user-vote';
|
import { useUserVote } from '../vote-details/use-user-vote';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalsListItemProps {
|
interface ProposalsListItemProps {
|
||||||
proposal?: ProposalQuery['proposal'] | null;
|
proposal?: Proposal | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
||||||
|
@ -17,8 +17,8 @@ import {
|
|||||||
lastMonth,
|
lastMonth,
|
||||||
nextMonth,
|
nextMonth,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
const openProposalClosesNextMonth = generateProposal({
|
const openProposalClosesNextMonth = generateProposal({
|
||||||
id: 'proposal1',
|
id: 'proposal1',
|
||||||
@ -63,7 +63,7 @@ const closedProtocolUpgradeProposal = generateProtocolUpgradeProposal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const renderComponent = (
|
const renderComponent = (
|
||||||
proposals: ProposalQuery['proposal'][],
|
proposals: Proposal[],
|
||||||
protocolUpgradeProposals?: ProtocolUpgradeProposalFieldsFragment[]
|
protocolUpgradeProposals?: ProtocolUpgradeProposalFieldsFragment[]
|
||||||
) => (
|
) => (
|
||||||
<Router>
|
<Router>
|
||||||
|
@ -10,20 +10,20 @@ import Routes from '../../../routes';
|
|||||||
import { Button, Toggle } from '@vegaprotocol/ui-toolkit';
|
import { Button, Toggle } from '@vegaprotocol/ui-toolkit';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
|
||||||
import { ExternalLinks } from '@vegaprotocol/environment';
|
import { ExternalLinks } from '@vegaprotocol/environment';
|
||||||
|
import { type ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
||||||
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: Array<ProposalQuery['proposal']>;
|
proposals: Proposal[];
|
||||||
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
lastBlockHeight?: string;
|
lastBlockHeight?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SortedProposalsProps {
|
interface SortedProposalsProps {
|
||||||
open: ProposalQuery['proposal'][];
|
open: Proposal[];
|
||||||
closed: ProposalQuery['proposal'][];
|
closed: Proposal[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SortedProtocolUpgradeProposalsProps {
|
interface SortedProtocolUpgradeProposalsProps {
|
||||||
@ -31,7 +31,7 @@ interface SortedProtocolUpgradeProposalsProps {
|
|||||||
closed: ProtocolUpgradeProposalFieldsFragment[];
|
closed: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const orderByDate = (arr: ProposalQuery['proposal'][]) =>
|
export const orderByDate = (arr: Proposal[]) =>
|
||||||
orderBy(
|
orderBy(
|
||||||
arr,
|
arr,
|
||||||
[
|
[
|
||||||
@ -91,14 +91,10 @@ export const ProposalsList = ({
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
open:
|
open:
|
||||||
initialSorting.open.length > 0
|
initialSorting.open.length > 0 ? orderByDate(initialSorting.open) : [],
|
||||||
? orderByDate(initialSorting.open as ProposalQuery['proposal'][])
|
|
||||||
: [],
|
|
||||||
closed:
|
closed:
|
||||||
initialSorting.closed.length > 0
|
initialSorting.closed.length > 0
|
||||||
? orderByDate(
|
? orderByDate(initialSorting.closed).reverse()
|
||||||
initialSorting.closed as ProposalQuery['proposal'][]
|
|
||||||
).reverse()
|
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
}, [proposals]);
|
}, [proposals]);
|
||||||
@ -125,9 +121,7 @@ export const ProposalsList = ({
|
|||||||
};
|
};
|
||||||
}, [protocolUpgradeProposals, lastBlockHeight]);
|
}, [protocolUpgradeProposals, lastBlockHeight]);
|
||||||
|
|
||||||
const filterPredicate = (
|
const filterPredicate = (p: ProposalFieldsFragment | Proposal) =>
|
||||||
p: ProposalFieldsFragment | ProposalQuery['proposal']
|
|
||||||
) =>
|
|
||||||
p?.id?.includes(filterString) ||
|
p?.id?.includes(filterString) ||
|
||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
nextWeek,
|
nextWeek,
|
||||||
lastMonth,
|
lastMonth,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
const rejectedProposalClosesNextWeek = generateProposal({
|
const rejectedProposalClosesNextWeek = generateProposal({
|
||||||
id: 'rejected1',
|
id: 'rejected1',
|
||||||
@ -35,7 +35,7 @@ const rejectedProposalClosedLastMonth = generateProposal({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderComponent = (proposals: ProposalQuery['proposal'][]) => (
|
const renderComponent = (proposals: Proposal[]) => (
|
||||||
<Router>
|
<Router>
|
||||||
<MockedProvider mocks={[networkParamsQueryMock]}>
|
<MockedProvider mocks={[networkParamsQueryMock]}>
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
|
@ -3,17 +3,17 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { Heading } from '../../../../components/heading';
|
import { Heading } from '../../../../components/heading';
|
||||||
import { ProposalsListItem } from '../proposals-list-item';
|
import { ProposalsListItem } from '../proposals-list-item';
|
||||||
import { ProposalsListFilter } from '../proposals-list-filter';
|
import { ProposalsListFilter } from '../proposals-list-filter';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: ProposalQuery['proposal'][];
|
proposals: Proposal[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [filterString, setFilterString] = useState('');
|
const [filterString, setFilterString] = useState('');
|
||||||
|
|
||||||
const filterPredicate = (p: ProposalQuery['proposal']) =>
|
const filterPredicate = (p: Proposal) =>
|
||||||
p?.id?.includes(filterString) ||
|
p?.id?.includes(filterString) ||
|
||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ import {
|
|||||||
nextWeek,
|
nextWeek,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
import { CompactVotes, VoteBreakdown } from './vote-breakdown';
|
import { CompactVotes, VoteBreakdown } from './vote-breakdown';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type MockedResponse } from '@apollo/client/testing';
|
||||||
import type { MockedResponse } from '@apollo/client/testing';
|
|
||||||
import {
|
import {
|
||||||
generateNoVotes,
|
generateNoVotes,
|
||||||
generateProposal,
|
generateProposal,
|
||||||
@ -18,7 +17,8 @@ import {
|
|||||||
} from '../../test-helpers/generate-proposals';
|
} from '../../test-helpers/generate-proposals';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { BigNumber } from '../../../../lib/bignumber';
|
import { BigNumber } from '../../../../lib/bignumber';
|
||||||
import type { AppState } from '../../../../contexts/app-state/app-state-context';
|
import { type AppState } from '../../../../contexts/app-state/app-state-context';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
const mockTotalSupply = new BigNumber(100);
|
const mockTotalSupply = new BigNumber(100);
|
||||||
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
// Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :)
|
||||||
@ -41,7 +41,7 @@ jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const renderComponent = (
|
const renderComponent = (
|
||||||
proposal: ProposalQuery['proposal'],
|
proposal: Proposal,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
||||||
) =>
|
) =>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { type ReactNode } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -5,10 +6,8 @@ import { useVoteInformation } from '../../hooks';
|
|||||||
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import { formatNumber } from '@vegaprotocol/utils';
|
import { formatNumber } from '@vegaprotocol/utils';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
|
||||||
import { CompactNumber } from '@vegaprotocol/react-helpers';
|
import { CompactNumber } from '@vegaprotocol/react-helpers';
|
||||||
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
||||||
<CompactNumber
|
<CompactNumber
|
||||||
@ -20,7 +19,7 @@ export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
interface VoteBreakdownProps {
|
interface VoteBreakdownProps {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VoteProgressProps {
|
interface VoteProgressProps {
|
||||||
|
@ -5,14 +5,13 @@ import { ProposalState } from '@vegaprotocol/types';
|
|||||||
import { ConnectToVega } from '../../../../components/connect-to-vega';
|
import { ConnectToVega } from '../../../../components/connect-to-vega';
|
||||||
import { VoteButtonsContainer } from './vote-buttons';
|
import { VoteButtonsContainer } from './vote-buttons';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
import type { VoteValue } from '@vegaprotocol/types';
|
import { type VoteValue } from '@vegaprotocol/types';
|
||||||
import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals';
|
import { type DialogProps, type VegaTxState } from '@vegaprotocol/proposals';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import { type VoteState } from './use-user-vote';
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
import { type Proposal } from '../../types';
|
||||||
import type { VoteState } from './use-user-vote';
|
|
||||||
|
|
||||||
interface UserVoteProps {
|
interface UserVoteProps {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
minVoterBalance: string | null | undefined;
|
minVoterBalance: string | null | undefined;
|
||||||
spamProtectionMinTokens: string | null | undefined;
|
spamProtectionMinTokens: string | null | undefined;
|
||||||
transaction: VegaTxState | null;
|
transaction: VegaTxState | null;
|
||||||
|
@ -3,13 +3,12 @@ import {
|
|||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
} from '@vegaprotocol/network-parameters';
|
} from '@vegaprotocol/network-parameters';
|
||||||
import { BigNumber } from '../../../lib/bignumber';
|
import { BigNumber } from '../../../lib/bignumber';
|
||||||
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
|
import { type Proposal } from '../types';
|
||||||
import type { ProposalQuery } from '../proposal/__generated__/Proposal';
|
|
||||||
|
|
||||||
export const useProposalNetworkParams = ({
|
export const useProposalNetworkParams = ({
|
||||||
proposal,
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: Proposal;
|
||||||
}) => {
|
}) => {
|
||||||
const { params } = useNetworkParams([
|
const { params } = useNetworkParams([
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
|
@ -2,15 +2,10 @@ import { useMemo } from 'react';
|
|||||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
||||||
import { BigNumber } from '../../../lib/bignumber';
|
import { BigNumber } from '../../../lib/bignumber';
|
||||||
import { useProposalNetworkParams } from './use-proposal-network-params';
|
import { useProposalNetworkParams } from './use-proposal-network-params';
|
||||||
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
|
|
||||||
import type { ProposalQuery } from '../proposal/__generated__/Proposal';
|
|
||||||
import { addDecimal } from '@vegaprotocol/utils';
|
import { addDecimal } from '@vegaprotocol/utils';
|
||||||
|
import { type Proposal } from '../types';
|
||||||
|
|
||||||
export const useVoteInformation = ({
|
export const useVoteInformation = ({ proposal }: { proposal: Proposal }) => {
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
|
||||||
}) => {
|
|
||||||
const {
|
const {
|
||||||
appState: { totalSupply, decimals },
|
appState: { totalSupply, decimals },
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
|
@ -86,228 +86,65 @@ query Proposal(
|
|||||||
$includeUpdateReferralProgram: Boolean!
|
$includeUpdateReferralProgram: Boolean!
|
||||||
) {
|
) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
rationale {
|
|
||||||
title
|
|
||||||
description
|
|
||||||
}
|
|
||||||
reference
|
|
||||||
state
|
|
||||||
datetime
|
|
||||||
rejectionReason
|
|
||||||
party {
|
|
||||||
id
|
id
|
||||||
}
|
rationale {
|
||||||
errorDetails
|
title
|
||||||
...NewMarketProductField @include(if: $includeNewMarketProductField)
|
description
|
||||||
...UpdateMarketState @include(if: $includeUpdateMarketState)
|
}
|
||||||
...UpdateReferralProgram @include(if: $includeUpdateReferralProgram)
|
reference
|
||||||
...UpdateVolumeDiscountProgram
|
state
|
||||||
terms {
|
datetime
|
||||||
closingDatetime
|
rejectionReason
|
||||||
enactmentDatetime
|
party {
|
||||||
change {
|
id
|
||||||
... on NewMarket {
|
}
|
||||||
decimalPlaces
|
errorDetails
|
||||||
metadata
|
...NewMarketProductField @include(if: $includeNewMarketProductField)
|
||||||
riskParameters {
|
...UpdateMarketState @include(if: $includeUpdateMarketState)
|
||||||
... on LogNormalRiskModel {
|
...UpdateReferralProgram @include(if: $includeUpdateReferralProgram)
|
||||||
riskAversionParameter
|
...UpdateVolumeDiscountProgram
|
||||||
tau
|
terms {
|
||||||
params {
|
closingDatetime
|
||||||
mu
|
enactmentDatetime
|
||||||
r
|
change {
|
||||||
sigma
|
... on NewMarket {
|
||||||
}
|
decimalPlaces
|
||||||
}
|
metadata
|
||||||
... on SimpleRiskModel {
|
riskParameters {
|
||||||
params {
|
... on LogNormalRiskModel {
|
||||||
factorLong
|
riskAversionParameter
|
||||||
factorShort
|
tau
|
||||||
}
|
params {
|
||||||
}
|
mu
|
||||||
}
|
r
|
||||||
instrument {
|
sigma
|
||||||
name
|
|
||||||
code
|
|
||||||
product {
|
|
||||||
... on FutureProduct {
|
|
||||||
settlementAsset {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
}
|
|
||||||
quoteName
|
|
||||||
dataSourceSpecBinding {
|
|
||||||
settlementDataProperty
|
|
||||||
tradingTerminationProperty
|
|
||||||
}
|
|
||||||
dataSourceSpecForSettlementData {
|
|
||||||
sourceType {
|
|
||||||
... on DataSourceDefinitionInternal {
|
|
||||||
sourceType {
|
|
||||||
... on DataSourceSpecConfigurationTime {
|
|
||||||
conditions {
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on DataSourceDefinitionExternal {
|
|
||||||
sourceType {
|
|
||||||
... on DataSourceSpecConfiguration {
|
|
||||||
signers {
|
|
||||||
signer {
|
|
||||||
... on PubKey {
|
|
||||||
key
|
|
||||||
}
|
|
||||||
... on ETHAddress {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filters {
|
|
||||||
key {
|
|
||||||
name
|
|
||||||
type
|
|
||||||
}
|
|
||||||
conditions {
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
... on PerpetualProduct {
|
... on SimpleRiskModel {
|
||||||
settlementAsset {
|
params {
|
||||||
id
|
factorLong
|
||||||
name
|
factorShort
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
}
|
}
|
||||||
quoteName
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
priceMonitoringParameters {
|
|
||||||
triggers {
|
|
||||||
horizonSecs
|
|
||||||
probability
|
|
||||||
auctionExtensionSecs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
liquidityMonitoringParameters {
|
|
||||||
targetStakeParameters {
|
|
||||||
timeWindow
|
|
||||||
scalingFactor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
positionDecimalPlaces
|
|
||||||
linearSlippageFactor
|
|
||||||
}
|
|
||||||
... on UpdateMarket {
|
|
||||||
marketId
|
|
||||||
updateMarketConfiguration {
|
|
||||||
instrument {
|
instrument {
|
||||||
|
name
|
||||||
code
|
code
|
||||||
product {
|
product {
|
||||||
... on UpdateFutureProduct {
|
... on FutureProduct {
|
||||||
quoteName
|
settlementAsset {
|
||||||
dataSourceSpecForSettlementData {
|
id
|
||||||
sourceType {
|
name
|
||||||
... on DataSourceDefinitionInternal {
|
symbol
|
||||||
sourceType {
|
decimals
|
||||||
... on DataSourceSpecConfigurationTime {
|
quantum
|
||||||
conditions {
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on DataSourceDefinitionExternal {
|
|
||||||
sourceType {
|
|
||||||
... on DataSourceSpecConfiguration {
|
|
||||||
signers {
|
|
||||||
signer {
|
|
||||||
... on PubKey {
|
|
||||||
key
|
|
||||||
}
|
|
||||||
... on ETHAddress {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filters {
|
|
||||||
key {
|
|
||||||
name
|
|
||||||
type
|
|
||||||
}
|
|
||||||
conditions {
|
|
||||||
operator
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
# dataSourceSpecForTradingTermination {
|
quoteName
|
||||||
# sourceType {
|
|
||||||
# ... on DataSourceDefinitionInternal {
|
|
||||||
# sourceType {
|
|
||||||
# ... on DataSourceSpecConfigurationTime {
|
|
||||||
# conditions {
|
|
||||||
# operator
|
|
||||||
# value
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# ... on DataSourceDefinitionExternal {
|
|
||||||
# sourceType {
|
|
||||||
# ... on DataSourceSpecConfiguration {
|
|
||||||
# signers {
|
|
||||||
# signer {
|
|
||||||
# ... on PubKey {
|
|
||||||
# key
|
|
||||||
# }
|
|
||||||
# ... on ETHAddress {
|
|
||||||
# address
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# filters {
|
|
||||||
# key {
|
|
||||||
# name
|
|
||||||
# type
|
|
||||||
# }
|
|
||||||
# conditions {
|
|
||||||
# operator
|
|
||||||
# value
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
dataSourceSpecBinding {
|
dataSourceSpecBinding {
|
||||||
settlementDataProperty
|
settlementDataProperty
|
||||||
tradingTerminationProperty
|
tradingTerminationProperty
|
||||||
}
|
}
|
||||||
}
|
|
||||||
... on UpdatePerpetualProduct {
|
|
||||||
quoteName
|
|
||||||
dataSourceSpecForSettlementData {
|
dataSourceSpecForSettlementData {
|
||||||
sourceType {
|
sourceType {
|
||||||
... on DataSourceDefinitionInternal {
|
... on DataSourceDefinitionInternal {
|
||||||
@ -348,14 +185,19 @@ query Proposal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dataSourceSpecBinding {
|
}
|
||||||
settlementDataProperty
|
... on PerpetualProduct {
|
||||||
settlementScheduleProperty
|
settlementAsset {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
symbol
|
||||||
|
decimals
|
||||||
|
quantum
|
||||||
}
|
}
|
||||||
|
quoteName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metadata
|
|
||||||
priceMonitoringParameters {
|
priceMonitoringParameters {
|
||||||
triggers {
|
triggers {
|
||||||
horizonSecs
|
horizonSecs
|
||||||
@ -369,71 +211,231 @@ query Proposal(
|
|||||||
scalingFactor
|
scalingFactor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
riskParameters {
|
positionDecimalPlaces
|
||||||
... on UpdateMarketSimpleRiskModel {
|
linearSlippageFactor
|
||||||
simple {
|
}
|
||||||
factorLong
|
... on UpdateMarket {
|
||||||
factorShort
|
marketId
|
||||||
|
updateMarketConfiguration {
|
||||||
|
instrument {
|
||||||
|
code
|
||||||
|
product {
|
||||||
|
... on UpdateFutureProduct {
|
||||||
|
quoteName
|
||||||
|
dataSourceSpecForSettlementData {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceDefinitionInternal {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceSpecConfigurationTime {
|
||||||
|
conditions {
|
||||||
|
operator
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on DataSourceDefinitionExternal {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceSpecConfiguration {
|
||||||
|
signers {
|
||||||
|
signer {
|
||||||
|
... on PubKey {
|
||||||
|
key
|
||||||
|
}
|
||||||
|
... on ETHAddress {
|
||||||
|
address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filters {
|
||||||
|
key {
|
||||||
|
name
|
||||||
|
type
|
||||||
|
}
|
||||||
|
conditions {
|
||||||
|
operator
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# dataSourceSpecForTradingTermination {
|
||||||
|
# sourceType {
|
||||||
|
# ... on DataSourceDefinitionInternal {
|
||||||
|
# sourceType {
|
||||||
|
# ... on DataSourceSpecConfigurationTime {
|
||||||
|
# conditions {
|
||||||
|
# operator
|
||||||
|
# value
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# ... on DataSourceDefinitionExternal {
|
||||||
|
# sourceType {
|
||||||
|
# ... on DataSourceSpecConfiguration {
|
||||||
|
# signers {
|
||||||
|
# signer {
|
||||||
|
# ... on PubKey {
|
||||||
|
# key
|
||||||
|
# }
|
||||||
|
# ... on ETHAddress {
|
||||||
|
# address
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# filters {
|
||||||
|
# key {
|
||||||
|
# name
|
||||||
|
# type
|
||||||
|
# }
|
||||||
|
# conditions {
|
||||||
|
# operator
|
||||||
|
# value
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
dataSourceSpecBinding {
|
||||||
|
settlementDataProperty
|
||||||
|
tradingTerminationProperty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on UpdatePerpetualProduct {
|
||||||
|
quoteName
|
||||||
|
dataSourceSpecForSettlementData {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceDefinitionInternal {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceSpecConfigurationTime {
|
||||||
|
conditions {
|
||||||
|
operator
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on DataSourceDefinitionExternal {
|
||||||
|
sourceType {
|
||||||
|
... on DataSourceSpecConfiguration {
|
||||||
|
signers {
|
||||||
|
signer {
|
||||||
|
... on PubKey {
|
||||||
|
key
|
||||||
|
}
|
||||||
|
... on ETHAddress {
|
||||||
|
address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filters {
|
||||||
|
key {
|
||||||
|
name
|
||||||
|
type
|
||||||
|
}
|
||||||
|
conditions {
|
||||||
|
operator
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataSourceSpecBinding {
|
||||||
|
settlementDataProperty
|
||||||
|
settlementScheduleProperty
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
... on UpdateMarketLogNormalRiskModel {
|
metadata
|
||||||
logNormal {
|
priceMonitoringParameters {
|
||||||
riskAversionParameter
|
triggers {
|
||||||
tau
|
horizonSecs
|
||||||
params {
|
probability
|
||||||
r
|
auctionExtensionSecs
|
||||||
sigma
|
}
|
||||||
mu
|
}
|
||||||
|
liquidityMonitoringParameters {
|
||||||
|
targetStakeParameters {
|
||||||
|
timeWindow
|
||||||
|
scalingFactor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
riskParameters {
|
||||||
|
... on UpdateMarketSimpleRiskModel {
|
||||||
|
simple {
|
||||||
|
factorLong
|
||||||
|
factorShort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on UpdateMarketLogNormalRiskModel {
|
||||||
|
logNormal {
|
||||||
|
riskAversionParameter
|
||||||
|
tau
|
||||||
|
params {
|
||||||
|
r
|
||||||
|
sigma
|
||||||
|
mu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
... on NewAsset {
|
||||||
... on NewAsset {
|
name
|
||||||
name
|
symbol
|
||||||
symbol
|
decimals
|
||||||
decimals
|
quantum
|
||||||
quantum
|
source {
|
||||||
source {
|
... on BuiltinAsset {
|
||||||
... on BuiltinAsset {
|
maxFaucetAmountMint
|
||||||
maxFaucetAmountMint
|
}
|
||||||
}
|
... on ERC20 {
|
||||||
... on ERC20 {
|
contractAddress
|
||||||
contractAddress
|
lifetimeLimit
|
||||||
lifetimeLimit
|
withdrawThreshold
|
||||||
withdrawThreshold
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
... on UpdateNetworkParameter {
|
||||||
... on UpdateNetworkParameter {
|
networkParameter {
|
||||||
networkParameter {
|
key
|
||||||
key
|
value
|
||||||
value
|
}
|
||||||
}
|
}
|
||||||
}
|
... on UpdateAsset {
|
||||||
... on UpdateAsset {
|
quantum
|
||||||
quantum
|
assetId
|
||||||
assetId
|
source {
|
||||||
source {
|
... on UpdateERC20 {
|
||||||
... on UpdateERC20 {
|
lifetimeLimit
|
||||||
lifetimeLimit
|
withdrawThreshold
|
||||||
withdrawThreshold
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
votes {
|
||||||
votes {
|
yes {
|
||||||
yes {
|
totalTokens
|
||||||
totalTokens
|
totalNumber
|
||||||
totalNumber
|
totalEquityLikeShareWeight
|
||||||
totalEquityLikeShareWeight
|
}
|
||||||
}
|
no {
|
||||||
no {
|
totalTokens
|
||||||
totalTokens
|
totalNumber
|
||||||
totalNumber
|
totalEquityLikeShareWeight
|
||||||
totalEquityLikeShareWeight
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -17,6 +17,7 @@ import {
|
|||||||
import { useParentMarketIdQuery } from '@vegaprotocol/markets';
|
import { useParentMarketIdQuery } from '@vegaprotocol/markets';
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
import { useFeatureFlags } from '@vegaprotocol/environment';
|
||||||
import { useSuccessorMarketProposalDetails } from '@vegaprotocol/proposals';
|
import { useSuccessorMarketProposalDetails } from '@vegaprotocol/proposals';
|
||||||
|
import { type Proposal as IProposal } from '../types';
|
||||||
|
|
||||||
export const ProposalContainer = () => {
|
export const ProposalContainer = () => {
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
const featureFlags = useFeatureFlags((state) => state.flags);
|
||||||
@ -67,6 +68,8 @@ export const ProposalContainer = () => {
|
|||||||
skip: !params.proposalId,
|
skip: !params.proposalId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const proposal = data?.proposal as IProposal;
|
||||||
|
|
||||||
const successor = useSuccessorMarketProposalDetails(params.proposalId);
|
const successor = useSuccessorMarketProposalDetails(params.proposalId);
|
||||||
|
|
||||||
const isSuccessor = !!successor?.parentMarketId || !!successor.code;
|
const isSuccessor = !!successor?.parentMarketId || !!successor.code;
|
||||||
@ -79,12 +82,12 @@ export const ProposalContainer = () => {
|
|||||||
},
|
},
|
||||||
} = useFetch(
|
} = useFetch(
|
||||||
`${ENV.rest}governance?proposalId=${
|
`${ENV.rest}governance?proposalId=${
|
||||||
data?.proposal?.terms.change.__typename === 'UpdateMarket' &&
|
proposal?.terms.change.__typename === 'UpdateMarket' &&
|
||||||
data?.proposal.terms.change.marketId
|
proposal.terms.change.marketId
|
||||||
}`,
|
}`,
|
||||||
undefined,
|
undefined,
|
||||||
true,
|
true,
|
||||||
data?.proposal?.terms.change.__typename !== 'UpdateMarket'
|
proposal?.terms.change.__typename !== 'UpdateMarket'
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -97,7 +100,7 @@ export const ProposalContainer = () => {
|
|||||||
`${ENV.rest}governances?proposalState=STATE_ENACTED&proposalType=TYPE_UPDATE_MARKET`,
|
`${ENV.rest}governances?proposalState=STATE_ENACTED&proposalType=TYPE_UPDATE_MARKET`,
|
||||||
undefined,
|
undefined,
|
||||||
true,
|
true,
|
||||||
data?.proposal?.terms.change.__typename !== 'UpdateMarket'
|
proposal?.terms.change.__typename !== 'UpdateMarket'
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -108,8 +111,8 @@ export const ProposalContainer = () => {
|
|||||||
dataProvider: marketInfoProvider,
|
dataProvider: marketInfoProvider,
|
||||||
skipUpdates: true,
|
skipUpdates: true,
|
||||||
variables: {
|
variables: {
|
||||||
marketId: data?.proposal?.id || '',
|
marketId: proposal?.id || '',
|
||||||
skip: !data?.proposal?.id,
|
skip: !proposal?.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -148,23 +151,22 @@ export const ProposalContainer = () => {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
variables: {
|
variables: {
|
||||||
assetId:
|
assetId:
|
||||||
(data?.proposal?.terms.change.__typename === 'NewAsset' &&
|
(proposal?.terms.change.__typename === 'NewAsset' && proposal?.id) ||
|
||||||
data?.proposal?.id) ||
|
(proposal?.terms.change.__typename === 'UpdateAsset' &&
|
||||||
(data?.proposal?.terms.change.__typename === 'UpdateAsset' &&
|
proposal.terms.change.assetId) ||
|
||||||
data.proposal.terms.change.assetId) ||
|
|
||||||
'',
|
'',
|
||||||
},
|
},
|
||||||
skip: !['NewAsset', 'UpdateAsset'].includes(
|
skip: !['NewAsset', 'UpdateAsset'].includes(
|
||||||
data?.proposal?.terms?.change?.__typename || ''
|
proposal?.terms?.change?.__typename || ''
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
previouslyEnactedMarketProposalsRestData &&
|
previouslyEnactedMarketProposalsRestData &&
|
||||||
data?.proposal?.terms.change.__typename === 'UpdateMarket'
|
proposal?.terms.change.__typename === 'UpdateMarket'
|
||||||
) {
|
) {
|
||||||
const change = data?.proposal?.terms?.change as { marketId: string };
|
const change = proposal?.terms?.change as { marketId: string };
|
||||||
|
|
||||||
const filteredProposals =
|
const filteredProposals =
|
||||||
// @ts-ignore rest data is not typed
|
// @ts-ignore rest data is not typed
|
||||||
@ -188,8 +190,8 @@ export const ProposalContainer = () => {
|
|||||||
}, [
|
}, [
|
||||||
previouslyEnactedMarketProposalsRestData,
|
previouslyEnactedMarketProposalsRestData,
|
||||||
params.proposalId,
|
params.proposalId,
|
||||||
data?.proposal?.terms.change.__typename,
|
proposal?.terms.change.__typename,
|
||||||
data?.proposal?.terms.change,
|
proposal?.terms.change,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -242,7 +244,7 @@ export const ProposalContainer = () => {
|
|||||||
>
|
>
|
||||||
{data?.proposal ? (
|
{data?.proposal ? (
|
||||||
<Proposal
|
<Proposal
|
||||||
proposal={data.proposal}
|
proposal={proposal}
|
||||||
networkParams={networkParams}
|
networkParams={networkParams}
|
||||||
restData={restData}
|
restData={restData}
|
||||||
marketData={marketData}
|
marketData={marketData}
|
||||||
|
@ -8,6 +8,7 @@ import mergeWith from 'lodash/mergeWith';
|
|||||||
import { type PartialDeep } from 'type-fest';
|
import { type PartialDeep } from 'type-fest';
|
||||||
import { type ProposalQuery } from '../proposal/__generated__/Proposal';
|
import { type ProposalQuery } from '../proposal/__generated__/Proposal';
|
||||||
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
|
import { type Proposal } from '../types';
|
||||||
|
|
||||||
export function generateProtocolUpgradeProposal(
|
export function generateProtocolUpgradeProposal(
|
||||||
override: PartialDeep<ProtocolUpgradeProposalFieldsFragment> = {}
|
override: PartialDeep<ProtocolUpgradeProposalFieldsFragment> = {}
|
||||||
@ -43,8 +44,8 @@ export function generateProtocolUpgradeProposal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function generateProposal(
|
export function generateProposal(
|
||||||
override: PartialDeep<ProposalQuery['proposal']> = {}
|
override: PartialDeep<Proposal> = {}
|
||||||
): ProposalQuery['proposal'] {
|
): Proposal {
|
||||||
const defaultProposal: ProposalQuery['proposal'] = {
|
const defaultProposal: ProposalQuery['proposal'] = {
|
||||||
__typename: 'Proposal',
|
__typename: 'Proposal',
|
||||||
id: faker.datatype.uuid(),
|
id: faker.datatype.uuid(),
|
||||||
@ -92,15 +93,16 @@ export function generateProposal(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return mergeWith<
|
return mergeWith<Proposal, PartialDeep<Proposal>>(
|
||||||
ProposalQuery['proposal'],
|
defaultProposal,
|
||||||
PartialDeep<ProposalQuery['proposal']>
|
override,
|
||||||
>(defaultProposal, override, (objValue, srcValue) => {
|
(objValue, srcValue) => {
|
||||||
if (!isArray(objValue)) {
|
if (!isArray(objValue)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
return srcValue;
|
||||||
}
|
}
|
||||||
return srcValue;
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Vote = Pick<Schema.Vote, '__typename' | 'value' | 'party' | 'datetime'>;
|
type Vote = Pick<Schema.Vote, '__typename' | 'value' | 'party' | 'datetime'>;
|
||||||
|
11
apps/governance/src/routes/proposals/types.ts
Normal file
11
apps/governance/src/routes/proposals/types.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import type { ProposalQuery } from './proposal/__generated__/Proposal';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default Proposal type needs extracting from the ProposalNode union type
|
||||||
|
* as lots of fields on the original type don't exist on BatchProposal. Eventually
|
||||||
|
* we will support BatchProposal but for now we don't
|
||||||
|
*/
|
||||||
|
export type Proposal = Extract<
|
||||||
|
ProposalQuery['proposal'],
|
||||||
|
{ __typename?: 'Proposal' }
|
||||||
|
>;
|
@ -11,6 +11,7 @@ import {
|
|||||||
} from '@vegaprotocol/candles-chart';
|
} from '@vegaprotocol/candles-chart';
|
||||||
import { useEnvironment } from '@vegaprotocol/environment';
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { useChartSettings, STUDY_SIZE } from './use-chart-settings';
|
import { useChartSettings, STUDY_SIZE } from './use-chart-settings';
|
||||||
|
import { SUPPORTED_INTERVALS, type SupportedInterval } from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders either the pennant chart or the tradingview chart
|
* Renders either the pennant chart or the tradingview chart
|
||||||
@ -36,7 +37,7 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => {
|
|||||||
const pennantChart = (
|
const pennantChart = (
|
||||||
<CandlesChartContainer
|
<CandlesChartContainer
|
||||||
marketId={marketId}
|
marketId={marketId}
|
||||||
interval={toPennantInterval(interval)}
|
interval={toPennantInterval(interval as SupportedInterval)}
|
||||||
chartType={chartType}
|
chartType={chartType}
|
||||||
overlays={overlays}
|
overlays={overlays}
|
||||||
studies={studies}
|
studies={studies}
|
||||||
@ -63,7 +64,7 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => {
|
|||||||
libraryPath={CHARTING_LIBRARY_PATH}
|
libraryPath={CHARTING_LIBRARY_PATH}
|
||||||
libraryHash={CHARTING_LIBRARY_HASH}
|
libraryHash={CHARTING_LIBRARY_HASH}
|
||||||
marketId={marketId}
|
marketId={marketId}
|
||||||
interval={toTradingViewResolution(interval)}
|
interval={toTradingViewResolution(interval as SupportedInterval)}
|
||||||
onIntervalChange={(newInterval) => {
|
onIntervalChange={(newInterval) => {
|
||||||
setInterval(fromTradingViewResolution(newInterval));
|
setInterval(fromTradingViewResolution(newInterval));
|
||||||
}}
|
}}
|
||||||
@ -83,7 +84,11 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toTradingViewResolution = (interval: Interval) => {
|
const toTradingViewResolution = (interval: SupportedInterval) => {
|
||||||
|
if (!SUPPORTED_INTERVALS.includes(interval)) {
|
||||||
|
throw new Error(`interval ${interval} is not supported`);
|
||||||
|
}
|
||||||
|
|
||||||
const resolution = TRADINGVIEW_INTERVAL_MAP[interval];
|
const resolution = TRADINGVIEW_INTERVAL_MAP[interval];
|
||||||
|
|
||||||
if (!resolution) {
|
if (!resolution) {
|
||||||
@ -107,7 +112,11 @@ const fromTradingViewResolution = (resolution: string) => {
|
|||||||
return interval as Interval;
|
return interval as Interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toPennantInterval = (interval: Interval) => {
|
const toPennantInterval = (interval: SupportedInterval) => {
|
||||||
|
if (!SUPPORTED_INTERVALS.includes(interval)) {
|
||||||
|
throw new Error(`interval ${interval} is not supported`);
|
||||||
|
}
|
||||||
|
|
||||||
const pennantInterval = PENNANT_INTERVAL_MAP[interval];
|
const pennantInterval = PENNANT_INTERVAL_MAP[interval];
|
||||||
|
|
||||||
if (!pennantInterval) {
|
if (!pennantInterval) {
|
||||||
|
@ -18,21 +18,13 @@ import {
|
|||||||
TradingDropdownTrigger,
|
TradingDropdownTrigger,
|
||||||
Icon,
|
Icon,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { Interval } from '@vegaprotocol/types';
|
import { type Interval } from '@vegaprotocol/types';
|
||||||
import { useEnvironment } from '@vegaprotocol/environment';
|
import { useEnvironment } from '@vegaprotocol/environment';
|
||||||
import { ALLOWED_TRADINGVIEW_HOSTNAMES } from '@vegaprotocol/trading-view';
|
import { ALLOWED_TRADINGVIEW_HOSTNAMES } from '@vegaprotocol/trading-view';
|
||||||
import { IconNames, type IconName } from '@blueprintjs/icons';
|
import { IconNames, type IconName } from '@blueprintjs/icons';
|
||||||
import { useChartSettings } from './use-chart-settings';
|
import { useChartSettings } from './use-chart-settings';
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
|
import { SUPPORTED_INTERVALS } from './constants';
|
||||||
const INTERVALS = [
|
|
||||||
Interval.INTERVAL_I1M,
|
|
||||||
Interval.INTERVAL_I5M,
|
|
||||||
Interval.INTERVAL_I15M,
|
|
||||||
Interval.INTERVAL_I1H,
|
|
||||||
Interval.INTERVAL_I6H,
|
|
||||||
Interval.INTERVAL_I1D,
|
|
||||||
];
|
|
||||||
|
|
||||||
const chartTypeIcon = new Map<ChartType, IconName>([
|
const chartTypeIcon = new Map<ChartType, IconName>([
|
||||||
[ChartType.AREA, IconNames.TIMELINE_AREA_CHART],
|
[ChartType.AREA, IconNames.TIMELINE_AREA_CHART],
|
||||||
@ -94,7 +86,7 @@ export const ChartMenu = () => {
|
|||||||
setInterval(value as Interval);
|
setInterval(value as Interval);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{INTERVALS.map((timeInterval) => (
|
{SUPPORTED_INTERVALS.map((timeInterval) => (
|
||||||
<TradingDropdownRadioItem
|
<TradingDropdownRadioItem
|
||||||
key={timeInterval}
|
key={timeInterval}
|
||||||
inset
|
inset
|
||||||
|
12
apps/trading/components/chart-container/constants.ts
Normal file
12
apps/trading/components/chart-container/constants.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { Interval } from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export type SupportedInterval = typeof SUPPORTED_INTERVALS[number];
|
||||||
|
|
||||||
|
export const SUPPORTED_INTERVALS = [
|
||||||
|
Interval.INTERVAL_I1M,
|
||||||
|
Interval.INTERVAL_I5M,
|
||||||
|
Interval.INTERVAL_I15M,
|
||||||
|
Interval.INTERVAL_I1H,
|
||||||
|
Interval.INTERVAL_I6H,
|
||||||
|
Interval.INTERVAL_I1D,
|
||||||
|
] as const;
|
@ -21,106 +21,107 @@ const returnDataMocks = (nodes: CandleFieldsFragment[]): CandlesQuery => {
|
|||||||
} as CandlesQuery;
|
} as CandlesQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataMocks: { [key in Schema.Interval]: Partial<CandleFieldsFragment>[] } =
|
const dataMocks: {
|
||||||
{
|
[key in Schema.Interval]?: Partial<CandleFieldsFragment>[];
|
||||||
[Schema.Interval.INTERVAL_I1M]: [
|
} = {
|
||||||
{
|
[Schema.Interval.INTERVAL_I1M]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:05:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:05:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_I5M]: [
|
],
|
||||||
{
|
[Schema.Interval.INTERVAL_I5M]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:25:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:25:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_I15M]: [
|
],
|
||||||
{
|
[Schema.Interval.INTERVAL_I15M]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T13:15:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T13:15:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_I1H]: [
|
],
|
||||||
{
|
[Schema.Interval.INTERVAL_I1H]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T17:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T17:00:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_I6H]: [
|
],
|
||||||
{
|
[Schema.Interval.INTERVAL_I6H]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T12:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T12:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-11T18:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-11T18:00:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_I1D]: [
|
],
|
||||||
{
|
[Schema.Interval.INTERVAL_I1D]: [
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-10T00:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-10T00:00:00Z',
|
||||||
close: '10',
|
lastUpdateInPeriod: '',
|
||||||
volume: '1',
|
close: '10',
|
||||||
},
|
volume: '1',
|
||||||
{
|
},
|
||||||
__typename: 'Candle',
|
{
|
||||||
periodStart: '2023-05-15T00:00:00Z',
|
__typename: 'Candle',
|
||||||
lastUpdateInPeriod: '',
|
periodStart: '2023-05-15T00:00:00Z',
|
||||||
close: '5',
|
lastUpdateInPeriod: '',
|
||||||
volume: '2',
|
close: '5',
|
||||||
},
|
volume: '2',
|
||||||
],
|
},
|
||||||
[Schema.Interval.INTERVAL_BLOCK]: [],
|
],
|
||||||
};
|
[Schema.Interval.INTERVAL_BLOCK]: [],
|
||||||
|
};
|
||||||
|
|
||||||
describe('VegaDataSource', () => {
|
describe('VegaDataSource', () => {
|
||||||
const marketId = 'marketId';
|
const marketId = 'marketId';
|
||||||
|
@ -263,8 +263,11 @@ export const DealTicket = ({
|
|||||||
marketId: market.id,
|
marketId: market.id,
|
||||||
openVolume,
|
openVolume,
|
||||||
orders,
|
orders,
|
||||||
collateralAvailable:
|
marginAccountBalance: marginAccountBalance,
|
||||||
marginAccountBalance || generalAccountBalance ? balance : undefined,
|
generalAccountBalance: generalAccountBalance,
|
||||||
|
orderMarginAccountBalance: '0', // TODO: Get real balance
|
||||||
|
marginMode: Schema.MarginMode.MARGIN_MODE_CROSS_MARGIN, // TODO: unhardcode this and get users margin mode for the market
|
||||||
|
averageEntryPrice: marketPrice || '0', // TODO: This assumes the order will be entirely filled at the current market price
|
||||||
skip:
|
skip:
|
||||||
!normalizedOrder ||
|
!normalizedOrder ||
|
||||||
(normalizedOrder.type !== Schema.OrderType.TYPE_MARKET &&
|
(normalizedOrder.type !== Schema.OrderType.TYPE_MARKET &&
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { parseISO, isValid, isAfter } from 'date-fns';
|
import { parseISO, isValid, isAfter } from 'date-fns';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useProposalOfMarketQuery } from '@vegaprotocol/proposals';
|
import {
|
||||||
|
useProposalOfMarketQuery,
|
||||||
|
type ProposalOfMarketQuery,
|
||||||
|
type SingleProposal,
|
||||||
|
} from '@vegaprotocol/proposals';
|
||||||
import { DocsLinks } from '@vegaprotocol/environment';
|
import { DocsLinks } from '@vegaprotocol/environment';
|
||||||
import { getDateTimeFormat } from '@vegaprotocol/utils';
|
import { getDateTimeFormat } from '@vegaprotocol/utils';
|
||||||
import * as Schema from '@vegaprotocol/types';
|
import * as Schema from '@vegaprotocol/types';
|
||||||
@ -36,12 +40,15 @@ export const TradingModeTooltip = ({
|
|||||||
marketTradingMode,
|
marketTradingMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// We only fetch Proposals (and not BatchProposals)
|
||||||
|
const proposal = proposalData?.proposal as SingleProposal<
|
||||||
|
ProposalOfMarketQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
if (!market || !marketData) {
|
if (!market || !marketData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const enactmentDate = parseISO(
|
const enactmentDate = parseISO(proposal?.terms.enactmentDatetime);
|
||||||
proposalData?.proposal?.terms.enactmentDatetime
|
|
||||||
);
|
|
||||||
|
|
||||||
const compiledGrid =
|
const compiledGrid =
|
||||||
!skipGrid && compileGridData(t, market, marketData, onSelect);
|
!skipGrid && compileGridData(t, market, marketData, onSelect);
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
|
||||||
import { usePositionEstimate } from './use-position-estimate';
|
|
||||||
import * as positionsModule from '@vegaprotocol/positions';
|
|
||||||
import type {
|
|
||||||
EstimatePositionQuery,
|
|
||||||
EstimatePositionQueryVariables,
|
|
||||||
} from '@vegaprotocol/positions';
|
|
||||||
import type { QueryResult } from '@apollo/client';
|
|
||||||
|
|
||||||
let mockData: object | undefined = {};
|
|
||||||
|
|
||||||
describe('usePositionEstimate', () => {
|
|
||||||
const args = {
|
|
||||||
marketId: 'marketId',
|
|
||||||
openVolume: '10',
|
|
||||||
orders: [],
|
|
||||||
collateralAvailable: '200',
|
|
||||||
skip: false,
|
|
||||||
};
|
|
||||||
it('should return proper data', () => {
|
|
||||||
jest
|
|
||||||
.spyOn(positionsModule, 'useEstimatePositionQuery')
|
|
||||||
.mockReturnValue({ data: mockData } as unknown as QueryResult<
|
|
||||||
EstimatePositionQuery,
|
|
||||||
EstimatePositionQueryVariables
|
|
||||||
>);
|
|
||||||
const { result, rerender } = renderHook(() => usePositionEstimate(args));
|
|
||||||
expect(result.current).toEqual(mockData);
|
|
||||||
mockData = undefined;
|
|
||||||
rerender(true);
|
|
||||||
expect(result.current).toEqual({});
|
|
||||||
});
|
|
||||||
});
|
|
@ -13,7 +13,12 @@ export const usePositionEstimate = ({
|
|||||||
marketId,
|
marketId,
|
||||||
openVolume,
|
openVolume,
|
||||||
orders,
|
orders,
|
||||||
collateralAvailable,
|
generalAccountBalance,
|
||||||
|
marginAccountBalance,
|
||||||
|
orderMarginAccountBalance,
|
||||||
|
averageEntryPrice,
|
||||||
|
marginMode,
|
||||||
|
marginFactor,
|
||||||
skip,
|
skip,
|
||||||
}: PositionEstimateProps) => {
|
}: PositionEstimateProps) => {
|
||||||
const [estimates, setEstimates] = useState<EstimatePositionQuery | undefined>(
|
const [estimates, setEstimates] = useState<EstimatePositionQuery | undefined>(
|
||||||
@ -24,7 +29,12 @@ export const usePositionEstimate = ({
|
|||||||
marketId,
|
marketId,
|
||||||
openVolume,
|
openVolume,
|
||||||
orders,
|
orders,
|
||||||
collateralAvailable,
|
generalAccountBalance,
|
||||||
|
marginAccountBalance,
|
||||||
|
orderMarginAccountBalance,
|
||||||
|
averageEntryPrice,
|
||||||
|
marginMode,
|
||||||
|
marginFactor,
|
||||||
},
|
},
|
||||||
skip,
|
skip,
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
|
@ -65,7 +65,11 @@ import {
|
|||||||
useSuccessorMarketIdsQuery,
|
useSuccessorMarketIdsQuery,
|
||||||
useSuccessorMarketQuery,
|
useSuccessorMarketQuery,
|
||||||
} from '../../__generated__';
|
} from '../../__generated__';
|
||||||
import { useSuccessorMarketProposalDetailsQuery } from '@vegaprotocol/proposals';
|
import {
|
||||||
|
useSuccessorMarketProposalDetailsQuery,
|
||||||
|
type SuccessorMarketProposalDetailsQuery,
|
||||||
|
type SingleProposal,
|
||||||
|
} from '@vegaprotocol/proposals';
|
||||||
import { getQuoteName, getAsset } from '../../market-utils';
|
import { getQuoteName, getAsset } from '../../market-utils';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import compact from 'lodash/compact';
|
import compact from 'lodash/compact';
|
||||||
@ -206,6 +210,11 @@ export const KeyDetailsInfoPanel = ({
|
|||||||
skip: !featureFlags.SUCCESSOR_MARKETS || !market.proposal?.id,
|
skip: !featureFlags.SUCCESSOR_MARKETS || !market.proposal?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const successorProposal =
|
||||||
|
successorProposalDetails?.proposal as SingleProposal<
|
||||||
|
SuccessorMarketProposalDetailsQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
// The following queries are needed as the parent market could also have been a successor market.
|
// The following queries are needed as the parent market could also have been a successor market.
|
||||||
// Note: the parent market is only passed to this component if the successor markets flag is enabled,
|
// Note: the parent market is only passed to this component if the successor markets flag is enabled,
|
||||||
// so that check is not needed in the skip.
|
// so that check is not needed in the skip.
|
||||||
@ -223,6 +232,10 @@ export const KeyDetailsInfoPanel = ({
|
|||||||
},
|
},
|
||||||
skip: !parentMarket?.proposal?.id,
|
skip: !parentMarket?.proposal?.id,
|
||||||
});
|
});
|
||||||
|
const parentProposal =
|
||||||
|
parentSuccessorProposalDetails?.proposal as SingleProposal<
|
||||||
|
SuccessorMarketProposalDetailsQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
const assetDecimals = getAsset(market).decimals;
|
const assetDecimals = getAsset(market).decimals;
|
||||||
|
|
||||||
@ -252,10 +265,9 @@ export const KeyDetailsInfoPanel = ({
|
|||||||
parentMarketID:
|
parentMarketID:
|
||||||
parentMarketIdData?.market?.parentMarketID || '-',
|
parentMarketIdData?.market?.parentMarketID || '-',
|
||||||
insurancePoolFraction:
|
insurancePoolFraction:
|
||||||
(successorProposalDetails?.proposal?.terms.change
|
(successorProposal.terms.change.__typename === 'NewMarket' &&
|
||||||
.__typename === 'NewMarket' &&
|
successorProposal.terms.change.successorConfiguration
|
||||||
successorProposalDetails.proposal.terms.change
|
?.insurancePoolFraction) ||
|
||||||
.successorConfiguration?.insurancePoolFraction) ||
|
|
||||||
'-',
|
'-',
|
||||||
status: market.state && MarketStateMapping[market.state],
|
status: market.state && MarketStateMapping[market.state],
|
||||||
tradingMode:
|
tradingMode:
|
||||||
@ -281,10 +293,9 @@ export const KeyDetailsInfoPanel = ({
|
|||||||
name: parentMarket?.tradableInstrument?.instrument?.name,
|
name: parentMarket?.tradableInstrument?.instrument?.name,
|
||||||
parentMarketID: grandparentMarketIdData?.market?.parentMarketID,
|
parentMarketID: grandparentMarketIdData?.market?.parentMarketID,
|
||||||
insurancePoolFraction:
|
insurancePoolFraction:
|
||||||
parentSuccessorProposalDetails?.proposal?.terms.change
|
parentProposal?.terms.change.__typename === 'NewMarket' &&
|
||||||
.__typename === 'NewMarket' &&
|
parentProposal?.terms.change.successorConfiguration
|
||||||
parentSuccessorProposalDetails.proposal.terms.change
|
?.insurancePoolFraction,
|
||||||
.successorConfiguration?.insurancePoolFraction,
|
|
||||||
status:
|
status:
|
||||||
parentMarket?.state && MarketStateMapping[parentMarket.state],
|
parentMarket?.state && MarketStateMapping[parentMarket.state],
|
||||||
tradingMode:
|
tradingMode:
|
||||||
@ -796,7 +807,6 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MarketInfoTable
|
<MarketInfoTable
|
||||||
key="eth-call-spec"
|
key="eth-call-spec"
|
||||||
data={{
|
data={{
|
||||||
@ -833,7 +843,6 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => {
|
|||||||
<SyntaxHighlighter data={abis} />
|
<SyntaxHighlighter data={abis} />
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
<h3 className={header}>{t('Normalisers')}</h3>
|
<h3 className={header}>{t('Normalisers')}</h3>
|
||||||
{sourceType.normalisers?.map((normaliser, i) => (
|
{sourceType.normalisers?.map((normaliser, i) => (
|
||||||
<MarketInfoTable key={i} data={normaliser} />
|
<MarketInfoTable key={i} data={normaliser} />
|
||||||
@ -844,7 +853,7 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => {
|
|||||||
<>
|
<>
|
||||||
<MarketInfoTable key={i} data={filter.key} />
|
<MarketInfoTable key={i} data={filter.key} />
|
||||||
<h3 className={header}>{t('Conditions')}</h3>
|
<h3 className={header}>{t('Conditions')}</h3>
|
||||||
{filter.conditions?.map((condition, i) => (
|
{filter.conditions?.map((condition) => (
|
||||||
<span>
|
<span>
|
||||||
{ConditionOperatorMapping[condition.operator]} {condition.value}
|
{ConditionOperatorMapping[condition.operator]} {condition.value}
|
||||||
</span>
|
</span>
|
||||||
|
@ -42,13 +42,23 @@ query EstimatePosition(
|
|||||||
$marketId: ID!
|
$marketId: ID!
|
||||||
$openVolume: String!
|
$openVolume: String!
|
||||||
$orders: [OrderInfo!]
|
$orders: [OrderInfo!]
|
||||||
$collateralAvailable: String
|
$averageEntryPrice: String!
|
||||||
|
$marginAccountBalance: String!
|
||||||
|
$generalAccountBalance: String!
|
||||||
|
$orderMarginAccountBalance: String!
|
||||||
|
$marginMode: MarginMode!
|
||||||
|
$marginFactor: String
|
||||||
) {
|
) {
|
||||||
estimatePosition(
|
estimatePosition(
|
||||||
marketId: $marketId
|
marketId: $marketId
|
||||||
openVolume: $openVolume
|
openVolume: $openVolume
|
||||||
orders: $orders
|
orders: $orders
|
||||||
collateralAvailable: $collateralAvailable
|
averageEntryPrice: $averageEntryPrice
|
||||||
|
marginAccountBalance: $marginAccountBalance
|
||||||
|
generalAccountBalance: $generalAccountBalance
|
||||||
|
orderMarginAccountBalance: $orderMarginAccountBalance
|
||||||
|
marginMode: $marginMode
|
||||||
|
marginFactor: $marginFactor
|
||||||
# Everywhere in the codebase we expect price values of the underlying to have the right
|
# Everywhere in the codebase we expect price values of the underlying to have the right
|
||||||
# number of digits for formatting with market.decimalPlaces. By default the estimatePosition
|
# number of digits for formatting with market.decimalPlaces. By default the estimatePosition
|
||||||
# query will return a full value requiring formatting using asset.decimals. For consistency
|
# query will return a full value requiring formatting using asset.decimals. For consistency
|
||||||
|
23
libs/positions/src/lib/__generated__/Positions.ts
generated
23
libs/positions/src/lib/__generated__/Positions.ts
generated
@ -23,7 +23,12 @@ export type EstimatePositionQueryVariables = Types.Exact<{
|
|||||||
marketId: Types.Scalars['ID'];
|
marketId: Types.Scalars['ID'];
|
||||||
openVolume: Types.Scalars['String'];
|
openVolume: Types.Scalars['String'];
|
||||||
orders?: Types.InputMaybe<Array<Types.OrderInfo> | Types.OrderInfo>;
|
orders?: Types.InputMaybe<Array<Types.OrderInfo> | Types.OrderInfo>;
|
||||||
collateralAvailable?: Types.InputMaybe<Types.Scalars['String']>;
|
averageEntryPrice: Types.Scalars['String'];
|
||||||
|
marginAccountBalance: Types.Scalars['String'];
|
||||||
|
generalAccountBalance: Types.Scalars['String'];
|
||||||
|
orderMarginAccountBalance: Types.Scalars['String'];
|
||||||
|
marginMode: Types.MarginMode;
|
||||||
|
marginFactor?: Types.InputMaybe<Types.Scalars['String']>;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
@ -124,12 +129,17 @@ export function usePositionsSubscriptionSubscription(baseOptions: Apollo.Subscri
|
|||||||
export type PositionsSubscriptionSubscriptionHookResult = ReturnType<typeof usePositionsSubscriptionSubscription>;
|
export type PositionsSubscriptionSubscriptionHookResult = ReturnType<typeof usePositionsSubscriptionSubscription>;
|
||||||
export type PositionsSubscriptionSubscriptionResult = Apollo.SubscriptionResult<PositionsSubscriptionSubscription>;
|
export type PositionsSubscriptionSubscriptionResult = Apollo.SubscriptionResult<PositionsSubscriptionSubscription>;
|
||||||
export const EstimatePositionDocument = gql`
|
export const EstimatePositionDocument = gql`
|
||||||
query EstimatePosition($marketId: ID!, $openVolume: String!, $orders: [OrderInfo!], $collateralAvailable: String) {
|
query EstimatePosition($marketId: ID!, $openVolume: String!, $orders: [OrderInfo!], $averageEntryPrice: String!, $marginAccountBalance: String!, $generalAccountBalance: String!, $orderMarginAccountBalance: String!, $marginMode: MarginMode!, $marginFactor: String) {
|
||||||
estimatePosition(
|
estimatePosition(
|
||||||
marketId: $marketId
|
marketId: $marketId
|
||||||
openVolume: $openVolume
|
openVolume: $openVolume
|
||||||
orders: $orders
|
orders: $orders
|
||||||
collateralAvailable: $collateralAvailable
|
averageEntryPrice: $averageEntryPrice
|
||||||
|
marginAccountBalance: $marginAccountBalance
|
||||||
|
generalAccountBalance: $generalAccountBalance
|
||||||
|
orderMarginAccountBalance: $orderMarginAccountBalance
|
||||||
|
marginMode: $marginMode
|
||||||
|
marginFactor: $marginFactor
|
||||||
scaleLiquidationPriceToMarketDecimals: true
|
scaleLiquidationPriceToMarketDecimals: true
|
||||||
) {
|
) {
|
||||||
margin {
|
margin {
|
||||||
@ -177,7 +187,12 @@ export const EstimatePositionDocument = gql`
|
|||||||
* marketId: // value for 'marketId'
|
* marketId: // value for 'marketId'
|
||||||
* openVolume: // value for 'openVolume'
|
* openVolume: // value for 'openVolume'
|
||||||
* orders: // value for 'orders'
|
* orders: // value for 'orders'
|
||||||
* collateralAvailable: // value for 'collateralAvailable'
|
* averageEntryPrice: // value for 'averageEntryPrice'
|
||||||
|
* marginAccountBalance: // value for 'marginAccountBalance'
|
||||||
|
* generalAccountBalance: // value for 'generalAccountBalance'
|
||||||
|
* orderMarginAccountBalance: // value for 'orderMarginAccountBalance'
|
||||||
|
* marginMode: // value for 'marginMode'
|
||||||
|
* marginFactor: // value for 'marginFactor'
|
||||||
* },
|
* },
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
|
@ -6,13 +6,19 @@ import { EstimatePositionDocument } from './__generated__/Positions';
|
|||||||
import type { EstimatePositionQuery } from './__generated__/Positions';
|
import type { EstimatePositionQuery } from './__generated__/Positions';
|
||||||
import { LiquidationPrice } from './liquidation-price';
|
import { LiquidationPrice } from './liquidation-price';
|
||||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||||
|
import { MarginMode } from '@vegaprotocol/types';
|
||||||
|
|
||||||
describe('LiquidationPrice', () => {
|
describe('LiquidationPrice', () => {
|
||||||
const props = {
|
const props = {
|
||||||
marketId: 'market-id',
|
marketId: 'market-id',
|
||||||
openVolume: '100',
|
openVolume: '100',
|
||||||
collateralAvailable: '1000',
|
|
||||||
decimalPlaces: 2,
|
decimalPlaces: 2,
|
||||||
|
averageEntryPrice: '100',
|
||||||
|
generalAccountBalance: '100',
|
||||||
|
marginAccountBalance: '100',
|
||||||
|
orderMarginAccountBalance: '100',
|
||||||
|
marginMode: MarginMode.MARGIN_MODE_CROSS_MARGIN,
|
||||||
|
marginFactor: '1',
|
||||||
};
|
};
|
||||||
const worstCaseOpenVolume = '200';
|
const worstCaseOpenVolume = '200';
|
||||||
const bestCaseOpenVolume = '100';
|
const bestCaseOpenVolume = '100';
|
||||||
@ -22,7 +28,12 @@ describe('LiquidationPrice', () => {
|
|||||||
variables: {
|
variables: {
|
||||||
marketId: props.marketId,
|
marketId: props.marketId,
|
||||||
openVolume: props.openVolume,
|
openVolume: props.openVolume,
|
||||||
collateralAvailable: props.collateralAvailable,
|
averageEntryPrice: props.averageEntryPrice,
|
||||||
|
generalAccountBalance: props.generalAccountBalance,
|
||||||
|
marginAccountBalance: props.marginAccountBalance,
|
||||||
|
orderMarginAccountBalance: props.orderMarginAccountBalance,
|
||||||
|
marginMode: props.marginMode,
|
||||||
|
marginFactor: props.marginFactor,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
|
@ -2,26 +2,43 @@ import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
|||||||
import { useEstimatePositionQuery } from './__generated__/Positions';
|
import { useEstimatePositionQuery } from './__generated__/Positions';
|
||||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||||
import { useT } from '../use-t';
|
import { useT } from '../use-t';
|
||||||
|
import { MarginMode } from '@vegaprotocol/types';
|
||||||
|
|
||||||
export const LiquidationPrice = ({
|
export const LiquidationPrice = ({
|
||||||
marketId,
|
marketId,
|
||||||
openVolume,
|
openVolume,
|
||||||
collateralAvailable,
|
averageEntryPrice,
|
||||||
|
generalAccountBalance,
|
||||||
|
marginAccountBalance,
|
||||||
|
orderMarginAccountBalance,
|
||||||
|
marginMode = MarginMode.MARGIN_MODE_CROSS_MARGIN,
|
||||||
|
marginFactor,
|
||||||
decimalPlaces,
|
decimalPlaces,
|
||||||
className,
|
className,
|
||||||
}: {
|
}: {
|
||||||
marketId: string;
|
marketId: string;
|
||||||
openVolume: string;
|
openVolume: string;
|
||||||
collateralAvailable: string;
|
averageEntryPrice: string;
|
||||||
|
generalAccountBalance: string;
|
||||||
|
marginAccountBalance: string;
|
||||||
|
orderMarginAccountBalance: string;
|
||||||
|
marginMode: MarginMode;
|
||||||
|
marginFactor: string;
|
||||||
decimalPlaces: number;
|
decimalPlaces: number;
|
||||||
className?: string;
|
className?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
|
|
||||||
const { data: currentData, previousData } = useEstimatePositionQuery({
|
const { data: currentData, previousData } = useEstimatePositionQuery({
|
||||||
variables: {
|
variables: {
|
||||||
marketId,
|
marketId,
|
||||||
openVolume,
|
openVolume,
|
||||||
collateralAvailable,
|
averageEntryPrice,
|
||||||
|
generalAccountBalance,
|
||||||
|
marginAccountBalance,
|
||||||
|
orderMarginAccountBalance,
|
||||||
|
marginMode,
|
||||||
|
marginFactor,
|
||||||
},
|
},
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
skip: !openVolume || openVolume === '0',
|
skip: !openVolume || openVolume === '0',
|
||||||
|
@ -42,6 +42,7 @@ import {
|
|||||||
|
|
||||||
export interface Position {
|
export interface Position {
|
||||||
marginMode: MarginFieldsFragment['marginMode'];
|
marginMode: MarginFieldsFragment['marginMode'];
|
||||||
|
marginFactor: MarginFieldsFragment['marginFactor'];
|
||||||
maintenanceLevel: MarginFieldsFragment['maintenanceLevel'] | undefined;
|
maintenanceLevel: MarginFieldsFragment['maintenanceLevel'] | undefined;
|
||||||
assetId: string;
|
assetId: string;
|
||||||
assetSymbol: string;
|
assetSymbol: string;
|
||||||
@ -152,6 +153,7 @@ export const getMetrics = (
|
|||||||
: undefined;
|
: undefined;
|
||||||
metrics.push({
|
metrics.push({
|
||||||
marginMode,
|
marginMode,
|
||||||
|
marginFactor: marginFactor || '0',
|
||||||
maintenanceLevel: margin?.maintenanceLevel,
|
maintenanceLevel: margin?.maintenanceLevel,
|
||||||
assetId: asset.id,
|
assetId: asset.id,
|
||||||
assetSymbol: asset.symbol,
|
assetSymbol: asset.symbol,
|
||||||
|
@ -410,7 +410,12 @@ export const PositionsTable = ({
|
|||||||
className="block text-right grow"
|
className="block text-right grow"
|
||||||
marketId={data.marketId}
|
marketId={data.marketId}
|
||||||
openVolume={data.openVolume}
|
openVolume={data.openVolume}
|
||||||
collateralAvailable={data.totalBalance}
|
generalAccountBalance={data.generalAccountBalance}
|
||||||
|
marginAccountBalance={data.marginAccountBalance}
|
||||||
|
orderMarginAccountBalance={data.orderAccountBalance}
|
||||||
|
averageEntryPrice={data.averageEntryPrice}
|
||||||
|
marginFactor={data.marginFactor}
|
||||||
|
marginMode={data.marginMode}
|
||||||
decimalPlaces={data.marketDecimalPlaces}
|
decimalPlaces={data.marketDecimalPlaces}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -184,6 +184,7 @@ export const singleRow: Position = {
|
|||||||
generalAccountBalance: '12345600',
|
generalAccountBalance: '12345600',
|
||||||
maintenanceLevel: '12300000',
|
maintenanceLevel: '12300000',
|
||||||
marginMode: Schema.MarginMode.MARGIN_MODE_CROSS_MARGIN,
|
marginMode: Schema.MarginMode.MARGIN_MODE_CROSS_MARGIN,
|
||||||
|
marginFactor: '1',
|
||||||
orderAccountBalance: '0',
|
orderAccountBalance: '0',
|
||||||
partyId: 'partyId',
|
partyId: 'partyId',
|
||||||
assetId: 'asset-id',
|
assetId: 'asset-id',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export * from './lib';
|
export * from './lib';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './components';
|
export * from './components';
|
||||||
|
export * from './types';
|
||||||
|
@ -39,22 +39,26 @@ subscription OnProposal {
|
|||||||
|
|
||||||
query ProposalOfMarket($marketId: ID!) {
|
query ProposalOfMarket($marketId: ID!) {
|
||||||
proposal(id: $marketId) {
|
proposal(id: $marketId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
enactmentDatetime
|
terms {
|
||||||
|
enactmentDatetime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query SuccessorMarketProposalDetails($proposalId: ID!) {
|
query SuccessorMarketProposalDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on NewMarket {
|
change {
|
||||||
successorConfiguration {
|
... on NewMarket {
|
||||||
parentMarketId
|
successorConfiguration {
|
||||||
insurancePoolFraction
|
parentMarketId
|
||||||
|
insurancePoolFraction
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,11 +79,13 @@ query InstrumentDetails($marketId: ID!) {
|
|||||||
|
|
||||||
query NewTransferDetails($proposalId: ID!) {
|
query NewTransferDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on NewTransfer {
|
change {
|
||||||
...NewTransferFields
|
... on NewTransfer {
|
||||||
|
...NewTransferFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,11 +94,13 @@ query NewTransferDetails($proposalId: ID!) {
|
|||||||
|
|
||||||
query CancelTransferDetails($proposalId: ID!) {
|
query CancelTransferDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on CancelTransfer {
|
change {
|
||||||
...CancelTransferFields
|
... on CancelTransfer {
|
||||||
|
...CancelTransferFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,14 @@ export type ProposalOfMarketQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
|
export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
|
||||||
|
|
||||||
export type SuccessorMarketProposalDetailsQueryVariables = Types.Exact<{
|
export type SuccessorMarketProposalDetailsQueryVariables = Types.Exact<{
|
||||||
proposalId: Types.Scalars['ID'];
|
proposalId: Types.Scalars['ID'];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type SuccessorMarketProposalDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', successorConfiguration?: { __typename?: 'SuccessorConfiguration', parentMarketId: string, insurancePoolFraction: string } | null } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
export type SuccessorMarketProposalDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', successorConfiguration?: { __typename?: 'SuccessorConfiguration', parentMarketId: string, insurancePoolFraction: string } | null } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
||||||
|
|
||||||
export type InstrumentDetailsQueryVariables = Types.Exact<{
|
export type InstrumentDetailsQueryVariables = Types.Exact<{
|
||||||
marketId: Types.Scalars['ID'];
|
marketId: Types.Scalars['ID'];
|
||||||
@ -46,14 +46,14 @@ export type NewTransferDetailsQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type NewTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer', source: string, sourceType: Types.AccountType, destination: string, destinationType: Types.AccountType, fraction_of_balance: string, amount: string, transferType: Types.GovernanceTransferType, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number, quantum: string }, kind: { __typename: 'OneOffGovernanceTransfer', deliverOn?: any | null } | { __typename: 'RecurringGovernanceTransfer', startEpoch: number, endEpoch?: number | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
export type NewTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer', source: string, sourceType: Types.AccountType, destination: string, destinationType: Types.AccountType, fraction_of_balance: string, amount: string, transferType: Types.GovernanceTransferType, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number, quantum: string }, kind: { __typename: 'OneOffGovernanceTransfer', deliverOn?: any | null } | { __typename: 'RecurringGovernanceTransfer', startEpoch: number, endEpoch?: number | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
||||||
|
|
||||||
export type CancelTransferDetailsQueryVariables = Types.Exact<{
|
export type CancelTransferDetailsQueryVariables = Types.Exact<{
|
||||||
proposalId: Types.Scalars['ID'];
|
proposalId: Types.Scalars['ID'];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type CancelTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer', transferId: string } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
export type CancelTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer', transferId: string } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
|
||||||
|
|
||||||
export const ProposalEventFieldsFragmentDoc = gql`
|
export const ProposalEventFieldsFragmentDoc = gql`
|
||||||
fragment ProposalEventFields on Proposal {
|
fragment ProposalEventFields on Proposal {
|
||||||
@ -146,9 +146,11 @@ export type OnProposalSubscriptionResult = Apollo.SubscriptionResult<OnProposalS
|
|||||||
export const ProposalOfMarketDocument = gql`
|
export const ProposalOfMarketDocument = gql`
|
||||||
query ProposalOfMarket($marketId: ID!) {
|
query ProposalOfMarket($marketId: ID!) {
|
||||||
proposal(id: $marketId) {
|
proposal(id: $marketId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
enactmentDatetime
|
terms {
|
||||||
|
enactmentDatetime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,13 +186,15 @@ export type ProposalOfMarketQueryResult = Apollo.QueryResult<ProposalOfMarketQue
|
|||||||
export const SuccessorMarketProposalDetailsDocument = gql`
|
export const SuccessorMarketProposalDetailsDocument = gql`
|
||||||
query SuccessorMarketProposalDetails($proposalId: ID!) {
|
query SuccessorMarketProposalDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on NewMarket {
|
change {
|
||||||
successorConfiguration {
|
... on NewMarket {
|
||||||
parentMarketId
|
successorConfiguration {
|
||||||
insurancePoolFraction
|
parentMarketId
|
||||||
|
insurancePoolFraction
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,11 +273,13 @@ export type InstrumentDetailsQueryResult = Apollo.QueryResult<InstrumentDetailsQ
|
|||||||
export const NewTransferDetailsDocument = gql`
|
export const NewTransferDetailsDocument = gql`
|
||||||
query NewTransferDetails($proposalId: ID!) {
|
query NewTransferDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on NewTransfer {
|
change {
|
||||||
...NewTransferFields
|
... on NewTransfer {
|
||||||
|
...NewTransferFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,11 +317,13 @@ export type NewTransferDetailsQueryResult = Apollo.QueryResult<NewTransferDetail
|
|||||||
export const CancelTransferDetailsDocument = gql`
|
export const CancelTransferDetailsDocument = gql`
|
||||||
query CancelTransferDetails($proposalId: ID!) {
|
query CancelTransferDetails($proposalId: ID!) {
|
||||||
proposal(id: $proposalId) {
|
proposal(id: $proposalId) {
|
||||||
id
|
... on Proposal {
|
||||||
terms {
|
id
|
||||||
change {
|
terms {
|
||||||
... on CancelTransfer {
|
change {
|
||||||
...CancelTransferFields
|
... on CancelTransfer {
|
||||||
|
...CancelTransferFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import type { CancelTransferFieldsFragment } from '../proposals-data-provider';
|
import { type SingleProposal } from '../../types';
|
||||||
import { useCancelTransferDetailsQuery } from './__generated__/Proposal';
|
import { type CancelTransferFieldsFragment } from '../proposals-data-provider';
|
||||||
|
import {
|
||||||
|
useCancelTransferDetailsQuery,
|
||||||
|
type CancelTransferDetailsQuery,
|
||||||
|
} from './__generated__/Proposal';
|
||||||
|
|
||||||
export const useCancelTransferProposalDetails = (
|
export const useCancelTransferProposalDetails = (
|
||||||
proposalId?: string | null
|
proposalId?: string | null
|
||||||
@ -11,8 +15,12 @@ export const useCancelTransferProposalDetails = (
|
|||||||
skip: !proposalId || proposalId.length === 0,
|
skip: !proposalId || proposalId.length === 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.proposal?.terms.change.__typename === 'CancelTransfer') {
|
const proposal = data?.proposal as SingleProposal<
|
||||||
return data?.proposal?.terms.change as CancelTransferFieldsFragment;
|
CancelTransferDetailsQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
|
if (proposal?.terms.change.__typename === 'CancelTransfer') {
|
||||||
|
return proposal?.terms.change as CancelTransferFieldsFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import type { NewTransferFieldsFragment } from '../proposals-data-provider';
|
import { type SingleProposal } from '../../types';
|
||||||
import { useNewTransferDetailsQuery } from './__generated__/Proposal';
|
import { type NewTransferFieldsFragment } from '../proposals-data-provider';
|
||||||
|
import {
|
||||||
|
useNewTransferDetailsQuery,
|
||||||
|
type NewTransferDetailsQuery,
|
||||||
|
} from './__generated__/Proposal';
|
||||||
|
|
||||||
export const useNewTransferProposalDetails = (proposalId?: string | null) => {
|
export const useNewTransferProposalDetails = (proposalId?: string | null) => {
|
||||||
const { data } = useNewTransferDetailsQuery({
|
const { data } = useNewTransferDetailsQuery({
|
||||||
@ -9,8 +13,12 @@ export const useNewTransferProposalDetails = (proposalId?: string | null) => {
|
|||||||
skip: !proposalId || proposalId.length === 0,
|
skip: !proposalId || proposalId.length === 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.proposal?.terms.change.__typename === 'NewTransfer') {
|
const proposal = data?.proposal as SingleProposal<
|
||||||
return data?.proposal?.terms.change as NewTransferFieldsFragment;
|
NewTransferDetailsQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
|
if (proposal?.terms.change.__typename === 'NewTransfer') {
|
||||||
|
return proposal?.terms.change as NewTransferFieldsFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -2,22 +2,28 @@ import omit from 'lodash/omit';
|
|||||||
import {
|
import {
|
||||||
useInstrumentDetailsQuery,
|
useInstrumentDetailsQuery,
|
||||||
useSuccessorMarketProposalDetailsQuery,
|
useSuccessorMarketProposalDetailsQuery,
|
||||||
|
type SuccessorMarketProposalDetailsQuery,
|
||||||
} from './__generated__/Proposal';
|
} from './__generated__/Proposal';
|
||||||
|
import { type SingleProposal } from '../../types';
|
||||||
|
|
||||||
export const useSuccessorMarketProposalDetails = (
|
export const useSuccessorMarketProposalDetails = (
|
||||||
proposalId?: string | null
|
proposalId?: string | null
|
||||||
) => {
|
) => {
|
||||||
const { data: proposal } = useSuccessorMarketProposalDetailsQuery({
|
const { data } = useSuccessorMarketProposalDetailsQuery({
|
||||||
variables: {
|
variables: {
|
||||||
proposalId: proposalId || '',
|
proposalId: proposalId || '',
|
||||||
},
|
},
|
||||||
skip: !proposalId || proposalId.length === 0,
|
skip: !proposalId || proposalId.length === 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const proposal = data?.proposal as SingleProposal<
|
||||||
|
SuccessorMarketProposalDetailsQuery['proposal']
|
||||||
|
>;
|
||||||
|
|
||||||
const successorDetails =
|
const successorDetails =
|
||||||
(proposal?.proposal &&
|
(proposal &&
|
||||||
proposal.proposal?.terms.change.__typename === 'NewMarket' &&
|
proposal?.terms.change.__typename === 'NewMarket' &&
|
||||||
proposal.proposal.terms.change.successorConfiguration) ||
|
proposal.terms.change.successorConfiguration) ||
|
||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
const { data: market } = useInstrumentDetailsQuery({
|
const { data: market } = useInstrumentDetailsQuery({
|
||||||
|
6
libs/proposals/src/types.ts
Normal file
6
libs/proposals/src/types.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
type Batch = { __typename?: 'BatchProposal' | undefined } | null | undefined;
|
||||||
|
type Single = { __typename?: 'Proposal' | undefined } | null | undefined;
|
||||||
|
export type SingleProposal<T extends Batch | Single> = Extract<
|
||||||
|
T,
|
||||||
|
{ __typename?: 'Proposal' }
|
||||||
|
>;
|
625
libs/types/src/__generated__/types.ts
generated
625
libs/types/src/__generated__/types.ts
generated
File diff suppressed because it is too large
Load Diff
@ -38,7 +38,6 @@ import type { ProductType, ProposalProductType } from './product';
|
|||||||
export const AccountTypeMapping: {
|
export const AccountTypeMapping: {
|
||||||
[T in AccountType]: string;
|
[T in AccountType]: string;
|
||||||
} = {
|
} = {
|
||||||
ACCOUNT_TYPE_ORDER_MARGIN: 'Per asset market account',
|
|
||||||
ACCOUNT_TYPE_BOND: 'Bond account',
|
ACCOUNT_TYPE_BOND: 'Bond account',
|
||||||
ACCOUNT_TYPE_EXTERNAL: 'External account',
|
ACCOUNT_TYPE_EXTERNAL: 'External account',
|
||||||
ACCOUNT_TYPE_FEES_INFRASTRUCTURE: 'Infrastructure fees account',
|
ACCOUNT_TYPE_FEES_INFRASTRUCTURE: 'Infrastructure fees account',
|
||||||
@ -49,6 +48,7 @@ export const AccountTypeMapping: {
|
|||||||
ACCOUNT_TYPE_GLOBAL_REWARD: 'Global reward account',
|
ACCOUNT_TYPE_GLOBAL_REWARD: 'Global reward account',
|
||||||
ACCOUNT_TYPE_INSURANCE: 'Insurance account',
|
ACCOUNT_TYPE_INSURANCE: 'Insurance account',
|
||||||
ACCOUNT_TYPE_MARGIN: 'Margin account',
|
ACCOUNT_TYPE_MARGIN: 'Margin account',
|
||||||
|
ACCOUNT_TYPE_ORDER_MARGIN: 'Per asset market account',
|
||||||
ACCOUNT_TYPE_PENDING_TRANSFERS: 'Pending transfers account',
|
ACCOUNT_TYPE_PENDING_TRANSFERS: 'Pending transfers account',
|
||||||
ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD:
|
ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD:
|
||||||
'Pending fee referral reward account',
|
'Pending fee referral reward account',
|
||||||
@ -116,9 +116,14 @@ export const IntervalMapping: {
|
|||||||
INTERVAL_BLOCK: '1 block',
|
INTERVAL_BLOCK: '1 block',
|
||||||
INTERVAL_I15M: 'I15M',
|
INTERVAL_I15M: 'I15M',
|
||||||
INTERVAL_I1D: 'I1D',
|
INTERVAL_I1D: 'I1D',
|
||||||
|
INTERVAL_I7D: 'I7D',
|
||||||
INTERVAL_I1H: 'I1H',
|
INTERVAL_I1H: 'I1H',
|
||||||
|
INTERVAL_I4H: 'I4H',
|
||||||
|
INTERVAL_I8H: 'I8H',
|
||||||
|
INTERVAL_I12H: 'I12H',
|
||||||
INTERVAL_I1M: 'I1M',
|
INTERVAL_I1M: 'I1M',
|
||||||
INTERVAL_I5M: 'I5M',
|
INTERVAL_I5M: 'I5M',
|
||||||
|
INTERVAL_I30M: 'I30M',
|
||||||
INTERVAL_I6H: 'I6H',
|
INTERVAL_I6H: 'I6H',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user