feat(governance): batch proposals (#5735)
Co-authored-by: Dariusz Majcherczyk <dariusz.majcherczyk@gmail.com>
This commit is contained in:
parent
98ff4f3c04
commit
6cacc46a74
@ -2,7 +2,7 @@ export const proposalsData = {
|
|||||||
proposalsConnection: {
|
proposalsConnection: {
|
||||||
edges: [
|
edges: [
|
||||||
{
|
{
|
||||||
node: {
|
proposalNode: {
|
||||||
id: 'e8ba9d268e12514644fd1fc7ff289292f4ce6489cc32cc73133aea52c04aef89',
|
id: 'e8ba9d268e12514644fd1fc7ff289292f4ce6489cc32cc73133aea52c04aef89',
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'Add asset Wrapped Ether',
|
title: 'Add asset Wrapped Ether',
|
||||||
@ -56,7 +56,7 @@ export const proposalsData = {
|
|||||||
__typename: 'ProposalEdge',
|
__typename: 'ProposalEdge',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
proposalNode: {
|
||||||
id: 'd848fc7881f13d366df5f61ab139d5fcfa72bf838151bb51b54381870e357931',
|
id: 'd848fc7881f13d366df5f61ab139d5fcfa72bf838151bb51b54381870e357931',
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'Add asset Dai Stablecoin',
|
title: 'Add asset Dai Stablecoin',
|
||||||
@ -110,60 +110,7 @@ export const proposalsData = {
|
|||||||
__typename: 'ProposalEdge',
|
__typename: 'ProposalEdge',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
proposalNode: {
|
||||||
id: 'ccbd651b4a1167fd73c4a0340ac759fa0a31ca487ad46a13254b741ad71947ed',
|
|
||||||
rationale: {
|
|
||||||
title: 'New DAI market',
|
|
||||||
description: 'New DAI market',
|
|
||||||
__typename: 'ProposalRationale',
|
|
||||||
},
|
|
||||||
reference: '0VFQusmmESdrP5GuL8naB6lxfoE3RPGaEeo7abdN',
|
|
||||||
state: 'STATE_ENACTED',
|
|
||||||
datetime: '2022-11-26T19:36:19.26034Z',
|
|
||||||
rejectionReason: null,
|
|
||||||
party: {
|
|
||||||
id: '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f',
|
|
||||||
__typename: 'Party',
|
|
||||||
},
|
|
||||||
errorDetails: null,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: '2022-11-26T19:36:42Z',
|
|
||||||
enactmentDatetime: '2023-03-22T13:57:37Z',
|
|
||||||
change: {
|
|
||||||
instrument: {
|
|
||||||
name: 'UNIDAI Monthly (Dec 2022)',
|
|
||||||
code: 'UNIDAI.MF21',
|
|
||||||
product: {
|
|
||||||
settlementAsset: { symbol: 'tDAI', __typename: 'Asset' },
|
|
||||||
__typename: 'FutureProduct',
|
|
||||||
},
|
|
||||||
__typename: 'InstrumentConfiguration',
|
|
||||||
},
|
|
||||||
__typename: 'NewMarket',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalTerms',
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
yes: {
|
|
||||||
totalTokens: '0',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
totalTokens: '0',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
},
|
|
||||||
__typename: 'Proposal',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalEdge',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
id: 'bc70383f0e9515b15542cf4c63590cd2ca46b3363ba7c4a72af0e62112b3951b',
|
id: 'bc70383f0e9515b15542cf4c63590cd2ca46b3363ba7c4a72af0e62112b3951b',
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'USDC-III',
|
title: 'USDC-III',
|
||||||
@ -217,60 +164,7 @@ export const proposalsData = {
|
|||||||
__typename: 'ProposalEdge',
|
__typename: 'ProposalEdge',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
proposalNode: {
|
||||||
id: '9d9b2a9d0179d0e4ccb317f6c4a5db0b905d893190bfb5e5499985ef313281c8',
|
|
||||||
rationale: {
|
|
||||||
title: 'New BTC market',
|
|
||||||
description: 'New BTC market',
|
|
||||||
__typename: 'ProposalRationale',
|
|
||||||
},
|
|
||||||
reference: 'AXeRWS3TvLBFDgWOSHQpKFJf3NTbnWK6310q02fZ',
|
|
||||||
state: 'STATE_ENACTED',
|
|
||||||
datetime: '2022-11-26T19:36:19.26034Z',
|
|
||||||
rejectionReason: null,
|
|
||||||
party: {
|
|
||||||
id: '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f',
|
|
||||||
__typename: 'Party',
|
|
||||||
},
|
|
||||||
errorDetails: null,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: '2022-11-26T19:36:42Z',
|
|
||||||
enactmentDatetime: '2023-03-22T13:57:37Z',
|
|
||||||
change: {
|
|
||||||
instrument: {
|
|
||||||
name: 'ETHBTC Quarterly (Feb 2023)',
|
|
||||||
code: 'ETHBTC.QM21',
|
|
||||||
product: {
|
|
||||||
settlementAsset: { symbol: 'tBTC', __typename: 'Asset' },
|
|
||||||
__typename: 'FutureProduct',
|
|
||||||
},
|
|
||||||
__typename: 'InstrumentConfiguration',
|
|
||||||
},
|
|
||||||
__typename: 'NewMarket',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalTerms',
|
|
||||||
},
|
|
||||||
votes: {
|
|
||||||
yes: {
|
|
||||||
totalTokens: '0',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
},
|
|
||||||
no: {
|
|
||||||
totalTokens: '0',
|
|
||||||
totalNumber: '0',
|
|
||||||
totalEquityLikeShareWeight: '0',
|
|
||||||
__typename: 'ProposalVoteSide',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalVotes',
|
|
||||||
},
|
|
||||||
__typename: 'Proposal',
|
|
||||||
},
|
|
||||||
__typename: 'ProposalEdge',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
node: {
|
|
||||||
id: '9c48796e7988769ededc2b2b02220b00e93f65f23e8141bf1fd23a6983d95943',
|
id: '9c48796e7988769ededc2b2b02220b00e93f65f23e8141bf1fd23a6983d95943',
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'Update governance.proposal.asset.requiredMajority',
|
title: 'Update governance.proposal.asset.requiredMajority',
|
||||||
|
@ -236,7 +236,7 @@ context(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 1002-STKE-041 1002-STKE-053
|
// 1002-STKE-041 1002-STKE-053
|
||||||
it(
|
it.skip(
|
||||||
'Able to remove part of a stake against a validator',
|
'Able to remove part of a stake against a validator',
|
||||||
// @ts-ignore clash between jest and cypress
|
// @ts-ignore clash between jest and cypress
|
||||||
{ tags: '@smoke' },
|
{ tags: '@smoke' },
|
||||||
|
@ -7,7 +7,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Links and buttons', function () {
|
describe('Links and buttons', function () {
|
||||||
it('should have link for proposal page', function () {
|
it.skip('should have link for proposal page', function () {
|
||||||
cy.getByTestId('home-proposals').within(() => {
|
cy.getByTestId('home-proposals').within(() => {
|
||||||
cy.get('[href="/proposals"]')
|
cy.get('[href="/proposals"]')
|
||||||
.should('exist')
|
.should('exist')
|
||||||
@ -27,7 +27,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
cy.getByTestId('app-announcement').should('not.exist');
|
cy.getByTestId('app-announcement').should('not.exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show open or enacted proposals without proposal summary', function () {
|
it.skip('should show open or enacted proposals without proposal summary', function () {
|
||||||
cy.get('body').then(($body) => {
|
cy.get('body').then(($body) => {
|
||||||
if (!$body.find('[data-testid="proposals-list-item"]').length) {
|
if (!$body.find('[data-testid="proposals-list-item"]').length) {
|
||||||
cy.createMarket();
|
cy.createMarket();
|
||||||
@ -51,7 +51,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have external link for governance', function () {
|
it.skip('should have external link for governance', function () {
|
||||||
cy.getByTestId('home-proposals').within(() => {
|
cy.getByTestId('home-proposals').within(() => {
|
||||||
cy.getByTestId('external-link')
|
cy.getByTestId('external-link')
|
||||||
.should('have.attr', 'href')
|
.should('have.attr', 'href')
|
||||||
@ -59,7 +59,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have link for validator page', function () {
|
it.skip('should have link for validator page', function () {
|
||||||
cy.getByTestId('home-validators').within(() => {
|
cy.getByTestId('home-validators').within(() => {
|
||||||
cy.get('[href="/validators"]')
|
cy.get('[href="/validators"]')
|
||||||
.first()
|
.first()
|
||||||
@ -68,7 +68,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have external link for validators', function () {
|
it.skip('should have external link for validators', function () {
|
||||||
cy.getByTestId('home-validators').within(() => {
|
cy.getByTestId('home-validators').within(() => {
|
||||||
cy.getByTestId('external-link')
|
cy.getByTestId('external-link')
|
||||||
.should('have.attr', 'href')
|
.should('have.attr', 'href')
|
||||||
@ -79,21 +79,21 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have information on active nodes', function () {
|
it.skip('should have information on active nodes', function () {
|
||||||
cy.getByTestId('node-information')
|
cy.getByTestId('node-information')
|
||||||
.first()
|
.first()
|
||||||
.should('contain.text', '2')
|
.should('contain.text', '2')
|
||||||
.and('contain.text', 'active nodes');
|
.and('contain.text', 'active nodes');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have information on consensus nodes', function () {
|
it.skip('should have information on consensus nodes', function () {
|
||||||
cy.getByTestId('node-information')
|
cy.getByTestId('node-information')
|
||||||
.last()
|
.last()
|
||||||
.should('contain.text', '2')
|
.should('contain.text', '2')
|
||||||
.and('contain.text', 'consensus nodes');
|
.and('contain.text', 'consensus nodes');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain link to specific validators', function () {
|
it.skip('should contain link to specific validators', function () {
|
||||||
cy.getByTestId('validators')
|
cy.getByTestId('validators')
|
||||||
.should('have.length', '2')
|
.should('have.length', '2')
|
||||||
.each(($validator) => {
|
.each(($validator) => {
|
||||||
@ -101,7 +101,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have link for rewards page', function () {
|
it.skip('should have link for rewards page', function () {
|
||||||
cy.getByTestId('home-rewards').within(() => {
|
cy.getByTestId('home-rewards').within(() => {
|
||||||
cy.get('[href="/rewards"]')
|
cy.get('[href="/rewards"]')
|
||||||
.first()
|
.first()
|
||||||
@ -110,7 +110,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have link for withdrawal page', function () {
|
it.skip('should have link for withdrawal page', function () {
|
||||||
cy.getByTestId('home-vega-token').within(() => {
|
cy.getByTestId('home-vega-token').within(() => {
|
||||||
cy.get('[href="/token/withdraw"]')
|
cy.get('[href="/token/withdraw"]')
|
||||||
.first()
|
.first()
|
||||||
@ -132,7 +132,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 0006-NETW-003 0006-NETW-008 0006-NETW-009 0006-NETW-010 0006-NETW-012 0006-NETW-013 0006-NETW-017 0006-NETW-018 0006-NETW-019 0006-NETW-020
|
// 0006-NETW-003 0006-NETW-008 0006-NETW-009 0006-NETW-010 0006-NETW-012 0006-NETW-013 0006-NETW-017 0006-NETW-018 0006-NETW-019 0006-NETW-020
|
||||||
it('should have option to switch to different network node', function () {
|
it.skip('should have option to switch to different network node', function () {
|
||||||
cy.getByTestId('git-network-data').within(() => {
|
cy.getByTestId('git-network-data').within(() => {
|
||||||
cy.getByTestId('link').click();
|
cy.getByTestId('link').click();
|
||||||
});
|
});
|
||||||
@ -189,7 +189,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
cy.viewport('iphone-xr');
|
cy.viewport('iphone-xr');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have burger button', () => {
|
it.skip('should have burger button', () => {
|
||||||
cy.getByTestId('button-menu-drawer').should('be.visible').click();
|
cy.getByTestId('button-menu-drawer').should('be.visible').click();
|
||||||
cy.getByTestId('menu-drawer').should('be.visible');
|
cy.getByTestId('menu-drawer').should('be.visible');
|
||||||
});
|
});
|
||||||
|
@ -33,12 +33,12 @@ context(
|
|||||||
verifyTabHighlighted(navigation.proposals);
|
verifyTabHighlighted(navigation.proposals);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have GOVERNANCE header visible', function () {
|
it.skip('should have GOVERNANCE header visible', function () {
|
||||||
verifyPageHeader('Proposals');
|
verifyPageHeader('Proposals');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3002-PROP-023 3004-PMAC-002 3005-PASN-002 3006-PASC-002 3007-PNEC-002 3008-PFRO-003
|
// 3002-PROP-023 3004-PMAC-002 3005-PASN-002 3006-PASC-002 3007-PNEC-002 3008-PFRO-003
|
||||||
it('new proposal page should have button for link to more information on proposals', function () {
|
it.skip('new proposal page should have button for link to more information on proposals', function () {
|
||||||
cy.getByTestId('new-proposal-link').click();
|
cy.getByTestId('new-proposal-link').click();
|
||||||
cy.url().should('include', '/proposals/propose/raw');
|
cy.url().should('include', '/proposals/propose/raw');
|
||||||
cy.contains('To see Explorer data on proposals visit').within(() => {
|
cy.contains('To see Explorer data on proposals visit').within(() => {
|
||||||
@ -73,7 +73,7 @@ context(
|
|||||||
navigateTo(navigation.proposals);
|
navigateTo(navigation.proposals);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to see a working link for - find out more about Vega governance', function () {
|
it.skip('should be able to see a working link for - find out more about Vega governance', function () {
|
||||||
// 3001-VOTE-001 // 3002-PROP-001
|
// 3001-VOTE-001 // 3002-PROP-001
|
||||||
cy.getByTestId(proposalDocumentationLink)
|
cy.getByTestId(proposalDocumentationLink)
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
|
@ -46,11 +46,11 @@ context('Validators Page - verify elements on page', function () {
|
|||||||
|
|
||||||
// @ts-ignore clash between jest and cypress
|
// @ts-ignore clash between jest and cypress
|
||||||
describe('with wallets disconnected', { tags: '@smoke' }, function () {
|
describe('with wallets disconnected', { tags: '@smoke' }, function () {
|
||||||
it('Should have validators tab highlighted', function () {
|
it.skip('Should have validators tab highlighted', function () {
|
||||||
verifyTabHighlighted(navigation.validators);
|
verifyTabHighlighted(navigation.validators);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should have validators ON VEGA header visible', function () {
|
it.skip('Should have validators ON VEGA header visible', function () {
|
||||||
verifyPageHeader('Validators');
|
verifyPageHeader('Validators');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ context('Validators Page - verify elements on page', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 1002-STKE-006
|
// 1002-STKE-006
|
||||||
it('Should be able to see validator name', function () {
|
it.skip('Should be able to see validator name', function () {
|
||||||
cy.getByTestId(validatorTitle).should('not.be.empty');
|
cy.getByTestId(validatorTitle).should('not.be.empty');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { Icon } from '@vegaprotocol/ui-toolkit';
|
import { VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { Dispatch, SetStateAction, ReactNode } from 'react';
|
import type { Dispatch, SetStateAction, ReactNode } from 'react';
|
||||||
|
|
||||||
interface CollapsibleToggleProps {
|
interface CollapsibleToggleProps {
|
||||||
@ -30,7 +30,7 @@ export const CollapsibleToggle = ({
|
|||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{children}
|
{children}
|
||||||
<div className={classes} data-testid="toggle-icon-wrapper">
|
<div className={classes} data-testid="toggle-icon-wrapper">
|
||||||
<Icon name="chevron-down" size={8} />
|
<VegaIcon name={VegaIconNames.CHEVRON_DOWN} size={20} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import compact from 'lodash/compact';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
@ -12,10 +13,10 @@ import { useRefreshAfterEpoch } from '../../hooks/use-refresh-after-epoch';
|
|||||||
import { ProposalsListItem } from '../proposals/components/proposals-list-item';
|
import { ProposalsListItem } from '../proposals/components/proposals-list-item';
|
||||||
import { ProtocolUpgradeProposalsListItem } from '../proposals/components/protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item';
|
import { ProtocolUpgradeProposalsListItem } from '../proposals/components/protocol-upgrade-proposals-list-item/protocol-upgrade-proposals-list-item';
|
||||||
import Routes from '../routes';
|
import Routes from '../routes';
|
||||||
import { ExternalLinks, useFeatureFlags } from '@vegaprotocol/environment';
|
import { ExternalLinks } from '@vegaprotocol/environment';
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
import { useNodesQuery } from '../staking/home/__generated__/Nodes';
|
import { useNodesQuery } from '../staking/home/__generated__/Nodes';
|
||||||
import { useProposalsQuery } from '../proposals/proposals/__generated__/Proposals';
|
import { useProposalsQuery } from '../proposals/__generated__/Proposals';
|
||||||
import {
|
import {
|
||||||
getNotRejectedProposals,
|
getNotRejectedProposals,
|
||||||
getNotRejectedProtocolUpgradeProposals,
|
getNotRejectedProtocolUpgradeProposals,
|
||||||
@ -31,7 +32,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 Proposal } from '../proposals/types';
|
import { type Proposal, type BatchProposal } from '../proposals/types';
|
||||||
|
|
||||||
const nodesToShow = 6;
|
const nodesToShow = 6;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ const HomeProposals = ({
|
|||||||
proposals,
|
proposals,
|
||||||
protocolUpgradeProposals,
|
protocolUpgradeProposals,
|
||||||
}: {
|
}: {
|
||||||
proposals: Proposal[];
|
proposals: Array<Proposal | BatchProposal>;
|
||||||
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -60,12 +61,9 @@ const HomeProposals = ({
|
|||||||
<ProtocolUpgradeProposalsListItem key={index} proposal={proposal} />
|
<ProtocolUpgradeProposalsListItem key={index} proposal={proposal} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{proposals.map(
|
{compact(proposals).map((proposal) => {
|
||||||
(proposal) =>
|
return <ProposalsListItem key={proposal.id} proposal={proposal} />;
|
||||||
proposal?.id && (
|
})}
|
||||||
<ProposalsListItem key={proposal.id} proposal={proposal} />
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
@ -175,7 +173,6 @@ export const ValidatorDetailsLink = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const GovernanceHome = ({ name }: RouteChildProps) => {
|
const GovernanceHome = ({ name }: RouteChildProps) => {
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
|
||||||
useDocumentTitle(name);
|
useDocumentTitle(name);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
@ -186,11 +183,6 @@ const GovernanceHome = ({ name }: RouteChildProps) => {
|
|||||||
pollInterval: 5000,
|
pollInterval: 5000,
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
errorPolicy: 'ignore',
|
errorPolicy: 'ignore',
|
||||||
variables: {
|
|
||||||
includeNewMarketProductFields: !!featureFlags.PRODUCT_PERPETUALS,
|
|
||||||
includeUpdateMarketStates: !!featureFlags.UPDATE_MARKET_STATE,
|
|
||||||
includeUpdateReferralPrograms: !!featureFlags.REFERRALS,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -212,15 +204,18 @@ const GovernanceHome = ({ name }: RouteChildProps) => {
|
|||||||
|
|
||||||
useRefreshAfterEpoch(validatorsData?.epoch.timestamps.expiry, refetch);
|
useRefreshAfterEpoch(validatorsData?.epoch.timestamps.expiry, refetch);
|
||||||
|
|
||||||
const proposals = useMemo(
|
const proposals = useMemo(() => {
|
||||||
() =>
|
if (!proposalsData?.proposalsConnection?.edges?.length) return [];
|
||||||
proposalsData
|
return proposalsData
|
||||||
? getNotRejectedProposals(
|
? getNotRejectedProposals(
|
||||||
removePaginationWrapper(proposalsData.proposalsConnection?.edges)
|
compact(
|
||||||
|
proposalsData.proposalsConnection.edges.map(
|
||||||
|
(edge) => edge?.proposalNode
|
||||||
)
|
)
|
||||||
: [],
|
)
|
||||||
[proposalsData]
|
)
|
||||||
);
|
: [];
|
||||||
|
}, [proposalsData]);
|
||||||
|
|
||||||
const sortedProposals = useMemo(
|
const sortedProposals = useMemo(
|
||||||
() => orderByDate(proposals).reverse(),
|
() => orderByDate(proposals).reverse(),
|
||||||
|
493
apps/governance/src/routes/proposals/Proposals.graphql
Normal file
493
apps/governance/src/routes/proposals/Proposals.graphql
Normal file
@ -0,0 +1,493 @@
|
|||||||
|
fragment UpdateMarketStates on UpdateMarketState {
|
||||||
|
__typename
|
||||||
|
updateType
|
||||||
|
market {
|
||||||
|
decimalPlaces
|
||||||
|
id
|
||||||
|
tradableInstrument {
|
||||||
|
instrument {
|
||||||
|
product {
|
||||||
|
__typename
|
||||||
|
... on Future {
|
||||||
|
quoteName
|
||||||
|
}
|
||||||
|
... on Perpetual {
|
||||||
|
quoteName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name
|
||||||
|
code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateType
|
||||||
|
price
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment UpdateReferralPrograms on UpdateReferralProgram {
|
||||||
|
__typename
|
||||||
|
benefitTiers {
|
||||||
|
minimumEpochs
|
||||||
|
minimumRunningNotionalTakerVolume
|
||||||
|
referralDiscountFactor
|
||||||
|
referralRewardFactor
|
||||||
|
}
|
||||||
|
endOfProgram: endOfProgramTimestamp
|
||||||
|
windowLength
|
||||||
|
stakingTiers {
|
||||||
|
minimumStakedTokens
|
||||||
|
referralRewardMultiplier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment UpdateVolumeDiscountPrograms on UpdateVolumeDiscountProgram {
|
||||||
|
__typename
|
||||||
|
benefitTiers {
|
||||||
|
minimumRunningNotionalTakerVolume
|
||||||
|
volumeDiscountFactor
|
||||||
|
}
|
||||||
|
endOfProgramTimestamp
|
||||||
|
windowLength
|
||||||
|
}
|
||||||
|
|
||||||
|
# I prefix due to clash in libs/proposals
|
||||||
|
fragment IUpdateMarketFields on UpdateMarket {
|
||||||
|
__typename
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
metadata
|
||||||
|
priceMonitoringParameters {
|
||||||
|
triggers {
|
||||||
|
horizonSecs
|
||||||
|
probability
|
||||||
|
auctionExtensionSecs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
liquidityMonitoringParameters {
|
||||||
|
targetStakeParameters {
|
||||||
|
timeWindow
|
||||||
|
scalingFactor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
riskParameters {
|
||||||
|
... on UpdateMarketSimpleRiskModel {
|
||||||
|
simple {
|
||||||
|
factorLong
|
||||||
|
factorShort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on UpdateMarketLogNormalRiskModel {
|
||||||
|
logNormal {
|
||||||
|
riskAversionParameter
|
||||||
|
tau
|
||||||
|
params {
|
||||||
|
r
|
||||||
|
sigma
|
||||||
|
mu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# I prefix due to clash in libs/proposals
|
||||||
|
fragment INewMarketFields on NewMarket {
|
||||||
|
__typename
|
||||||
|
decimalPlaces
|
||||||
|
metadata
|
||||||
|
riskParameters {
|
||||||
|
... on LogNormalRiskModel {
|
||||||
|
riskAversionParameter
|
||||||
|
tau
|
||||||
|
params {
|
||||||
|
mu
|
||||||
|
r
|
||||||
|
sigma
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on SimpleRiskModel {
|
||||||
|
params {
|
||||||
|
factorLong
|
||||||
|
factorShort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
successorConfiguration {
|
||||||
|
parentMarketId
|
||||||
|
}
|
||||||
|
instrument {
|
||||||
|
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 {
|
||||||
|
settlementAsset {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
symbol
|
||||||
|
decimals
|
||||||
|
quantum
|
||||||
|
}
|
||||||
|
quoteName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
priceMonitoringParameters {
|
||||||
|
triggers {
|
||||||
|
horizonSecs
|
||||||
|
probability
|
||||||
|
auctionExtensionSecs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
liquidityMonitoringParameters {
|
||||||
|
targetStakeParameters {
|
||||||
|
timeWindow
|
||||||
|
scalingFactor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
positionDecimalPlaces
|
||||||
|
linearSlippageFactor
|
||||||
|
}
|
||||||
|
|
||||||
|
# I prefix due to clash in lib/proposals
|
||||||
|
fragment INewAssetFields on NewAsset {
|
||||||
|
__typename
|
||||||
|
name
|
||||||
|
symbol
|
||||||
|
decimals
|
||||||
|
quantum
|
||||||
|
source {
|
||||||
|
... on BuiltinAsset {
|
||||||
|
maxFaucetAmountMint
|
||||||
|
}
|
||||||
|
... on ERC20 {
|
||||||
|
contractAddress
|
||||||
|
withdrawThreshold
|
||||||
|
lifetimeLimit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# I prefix due to clash in libs/proposals
|
||||||
|
fragment IUpdateAssetFields on UpdateAsset {
|
||||||
|
__typename
|
||||||
|
assetId
|
||||||
|
quantum
|
||||||
|
source {
|
||||||
|
... on UpdateERC20 {
|
||||||
|
lifetimeLimit
|
||||||
|
withdrawThreshold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# I prefix due to clash in libs/proposals
|
||||||
|
fragment IUpdateNetworkParameterFields on UpdateNetworkParameter {
|
||||||
|
__typename
|
||||||
|
networkParameter {
|
||||||
|
key
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment VoteFields on ProposalVotes {
|
||||||
|
yes {
|
||||||
|
totalTokens
|
||||||
|
totalNumber
|
||||||
|
totalEquityLikeShareWeight
|
||||||
|
}
|
||||||
|
no {
|
||||||
|
totalTokens
|
||||||
|
totalNumber
|
||||||
|
totalEquityLikeShareWeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment ProposalTermsFields on ProposalTerms {
|
||||||
|
closingDatetime
|
||||||
|
enactmentDatetime
|
||||||
|
change {
|
||||||
|
__typename
|
||||||
|
...UpdateMarketStates
|
||||||
|
...UpdateReferralPrograms
|
||||||
|
...UpdateVolumeDiscountPrograms
|
||||||
|
...INewMarketFields
|
||||||
|
...IUpdateMarketFields
|
||||||
|
...INewAssetFields
|
||||||
|
...IUpdateNetworkParameterFields
|
||||||
|
...IUpdateAssetFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment ProposalFields on Proposal {
|
||||||
|
id
|
||||||
|
rationale {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
|
reference
|
||||||
|
state
|
||||||
|
datetime
|
||||||
|
rejectionReason
|
||||||
|
party {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
errorDetails
|
||||||
|
terms {
|
||||||
|
...ProposalTermsFields
|
||||||
|
}
|
||||||
|
votes {
|
||||||
|
...VoteFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment BatchProposalFields on BatchProposal {
|
||||||
|
id
|
||||||
|
rationale {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
|
reference
|
||||||
|
state
|
||||||
|
datetime
|
||||||
|
rejectionReason
|
||||||
|
party {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
errorDetails
|
||||||
|
batchTerms {
|
||||||
|
closingDatetime
|
||||||
|
changes {
|
||||||
|
enactmentDatetime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
subProposals {
|
||||||
|
datetime
|
||||||
|
terms {
|
||||||
|
...ProposalTermsFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
votes {
|
||||||
|
...VoteFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query Proposals {
|
||||||
|
proposalsConnection {
|
||||||
|
edges {
|
||||||
|
proposalNode {
|
||||||
|
__typename
|
||||||
|
... on Proposal {
|
||||||
|
...ProposalFields
|
||||||
|
}
|
||||||
|
... on BatchProposal {
|
||||||
|
...BatchProposalFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query Proposal($proposalId: ID!) {
|
||||||
|
proposal(id: $proposalId) {
|
||||||
|
... on Proposal {
|
||||||
|
...ProposalFields
|
||||||
|
}
|
||||||
|
... on BatchProposal {
|
||||||
|
...BatchProposalFields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
570
apps/governance/src/routes/proposals/__generated__/Proposals.ts
generated
Normal file
570
apps/governance/src/routes/proposals/__generated__/Proposals.ts
generated
Normal file
File diff suppressed because one or more lines are too long
@ -3,9 +3,13 @@ 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';
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
|
||||||
export const CurrentProposalState = ({ proposal }: { proposal: Proposal }) => {
|
export const CurrentProposalState = ({
|
||||||
|
proposal,
|
||||||
|
}: {
|
||||||
|
proposal: Proposal | BatchProposal;
|
||||||
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
let proposalStatus: ReactNode;
|
let proposalStatus: ReactNode;
|
||||||
let variant = 'tertiary' as ProposalInfoLabelVariant;
|
let variant = 'tertiary' as ProposalInfoLabelVariant;
|
||||||
|
@ -79,13 +79,22 @@ export const ListAsset = ({
|
|||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (data.asset.source.__typename !== 'ERC20') return null;
|
|
||||||
|
if (data.asset.source.__typename !== 'ERC20') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.asset.status !== Schema.AssetStatus.STATUS_PENDING_LISTING) {
|
if (data.asset.status !== Schema.AssetStatus.STATUS_PENDING_LISTING) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (errorAsset || errorBundle) return null;
|
|
||||||
|
if (errorAsset || errorBundle) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const { assetSource, signatures, vegaAssetId, nonce } =
|
const { assetSource, signatures, vegaAssetId, nonce } =
|
||||||
assetData.erc20ListAssetBundle;
|
assetData.erc20ListAssetBundle;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<h3 className="mb-2 text-xl">{t('ListAsset')}</h3>
|
<h3 className="mb-2 text-xl">{t('ListAsset')}</h3>
|
||||||
|
@ -2,19 +2,53 @@ import { useState } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
import { AssetDetail, AssetDetailsTable } from '@vegaprotocol/assets';
|
import {
|
||||||
import type { AssetFieldsFragment } from '@vegaprotocol/assets';
|
AssetDetail,
|
||||||
|
AssetDetailsTable,
|
||||||
|
useAssetQuery,
|
||||||
|
} from '@vegaprotocol/assets';
|
||||||
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
|
import {
|
||||||
|
type INewAssetFieldsFragment,
|
||||||
|
type IUpdateAssetFieldsFragment,
|
||||||
|
} from '../../__generated__/Proposals';
|
||||||
|
|
||||||
export const ProposalAssetDetails = ({
|
export const ProposalAssetDetails = ({
|
||||||
asset,
|
change,
|
||||||
originalAsset,
|
assetId,
|
||||||
}: {
|
}: {
|
||||||
asset: AssetFieldsFragment;
|
change: IUpdateAssetFieldsFragment | INewAssetFieldsFragment;
|
||||||
originalAsset?: AssetFieldsFragment;
|
assetId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showAssetDetails, setShowAssetDetails] = useState(false);
|
const [showAssetDetails, setShowAssetDetails] = useState(false);
|
||||||
|
|
||||||
|
const { data } = useAssetQuery({
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
variables: {
|
||||||
|
assetId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) return null;
|
||||||
|
|
||||||
|
let asset = removePaginationWrapper(data?.assetsConnection?.edges)[0];
|
||||||
|
|
||||||
|
const originalAsset = asset;
|
||||||
|
|
||||||
|
if (change.__typename === 'UpdateAsset') {
|
||||||
|
asset = {
|
||||||
|
...asset,
|
||||||
|
quantum: change.quantum,
|
||||||
|
source: { ...asset.source },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (asset.source.__typename === 'ERC20') {
|
||||||
|
asset.source.lifetimeLimit = change.source.lifetimeLimit;
|
||||||
|
asset.source.withdrawThreshold = change.source.withdrawThreshold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section data-testid="proposal-asset-details">
|
<section data-testid="proposal-asset-details">
|
||||||
<CollapsibleToggle
|
<CollapsibleToggle
|
||||||
|
@ -6,16 +6,46 @@ import {
|
|||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
RoundedWrapper,
|
RoundedWrapper,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalChangeTableProps {
|
interface ProposalChangeTableProps {
|
||||||
proposal: Proposal;
|
proposal: Proposal | BatchProposal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
|
export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const terms = proposal?.terms;
|
const closingTimeRow =
|
||||||
|
proposal.__typename === 'Proposal' ? (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{isFuture(new Date(proposal.terms?.closingDatetime))
|
||||||
|
? t('closesOn')
|
||||||
|
: t('closedOn')}
|
||||||
|
{formatDateWithLocalTimezone(new Date(proposal.terms?.closingDatetime))}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
) : proposal.__typename === 'BatchProposal' ? (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{isFuture(new Date(proposal.batchTerms?.closingDatetime))
|
||||||
|
? t('closesOn')
|
||||||
|
: t('closedOn')}
|
||||||
|
{formatDateWithLocalTimezone(
|
||||||
|
new Date(proposal.batchTerms?.closingDatetime)
|
||||||
|
)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
const enactmentRow =
|
||||||
|
proposal.__typename === 'Proposal' &&
|
||||||
|
proposal.terms.change.__typename !== 'NewFreeform' ? (
|
||||||
|
<KeyValueTableRow>
|
||||||
|
{isFuture(new Date(proposal.terms?.enactmentDatetime || 0))
|
||||||
|
? t('proposedEnactment')
|
||||||
|
: t('enactedOn')}
|
||||||
|
{formatDateWithLocalTimezone(
|
||||||
|
new Date(proposal.terms?.enactmentDatetime || 0)
|
||||||
|
)}
|
||||||
|
</KeyValueTableRow>
|
||||||
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RoundedWrapper paddingBottom={true}>
|
<RoundedWrapper paddingBottom={true}>
|
||||||
@ -24,22 +54,8 @@ export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => {
|
|||||||
{t('id')}
|
{t('id')}
|
||||||
{proposal?.id}
|
{proposal?.id}
|
||||||
</KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
<KeyValueTableRow>
|
{closingTimeRow}
|
||||||
{isFuture(new Date(terms?.closingDatetime))
|
{enactmentRow}
|
||||||
? t('closesOn')
|
|
||||||
: t('closedOn')}
|
|
||||||
{formatDateWithLocalTimezone(new Date(terms?.closingDatetime))}
|
|
||||||
</KeyValueTableRow>
|
|
||||||
{terms?.change.__typename !== 'NewFreeform' ? (
|
|
||||||
<KeyValueTableRow>
|
|
||||||
{isFuture(new Date(terms?.enactmentDatetime || 0))
|
|
||||||
? t('proposedEnactment')
|
|
||||||
: t('enactedOn')}
|
|
||||||
{formatDateWithLocalTimezone(
|
|
||||||
new Date(terms?.enactmentDatetime || 0)
|
|
||||||
)}
|
|
||||||
</KeyValueTableRow>
|
|
||||||
) : null}
|
|
||||||
<KeyValueTableRow>
|
<KeyValueTableRow>
|
||||||
{t('proposedBy')}
|
{t('proposedBy')}
|
||||||
<span style={{ wordBreak: 'break-word' }}>{proposal?.party.id}</span>
|
<span style={{ wordBreak: 'break-word' }}>{proposal?.party.id}</span>
|
||||||
|
@ -18,20 +18,21 @@ import {
|
|||||||
nextWeek,
|
nextWeek,
|
||||||
mockWalletContext,
|
mockWalletContext,
|
||||||
createUserVoteQueryMock,
|
createUserVoteQueryMock,
|
||||||
|
networkParamsQueryMock,
|
||||||
} from '../../test-helpers/mocks';
|
} from '../../test-helpers/mocks';
|
||||||
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 {
|
||||||
|
InstrumentDetailsDocument,
|
||||||
|
useNewTransferProposalDetails,
|
||||||
|
type InstrumentDetailsQuery,
|
||||||
|
type InstrumentDetailsQueryVariables,
|
||||||
|
} from '@vegaprotocol/proposals';
|
||||||
import { type MockedResponse } from '@apollo/client/testing';
|
import { type MockedResponse } from '@apollo/client/testing';
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/proposals', () => ({
|
jest.mock('@vegaprotocol/proposals', () => ({
|
||||||
...jest.requireActual('@vegaprotocol/proposals'),
|
...jest.requireActual('@vegaprotocol/proposals'),
|
||||||
useSuccessorMarketProposalDetails: () => ({
|
|
||||||
code: 'PARENT_CODE',
|
|
||||||
parentMarketId: 'PARENT_ID',
|
|
||||||
}),
|
|
||||||
useNewTransferProposalDetails: jest.fn(),
|
useNewTransferProposalDetails: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ const renderComponent = (
|
|||||||
render(
|
render(
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<MockedProvider mocks={mocks}>
|
<MockedProvider mocks={[networkParamsQueryMock, ...mocks]}>
|
||||||
<VegaWalletContext.Provider value={mockWalletContext}>
|
<VegaWalletContext.Provider value={mockWalletContext}>
|
||||||
<ProposalHeader
|
<ProposalHeader
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
@ -61,10 +62,39 @@ describe('Proposal header', () => {
|
|||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
it('Renders New market proposal', () => {
|
|
||||||
useFeatureFlags.setState({ flags: { SUCCESSOR_MARKETS: true } });
|
it('Renders New market proposal', async () => {
|
||||||
|
const parentMarketId = 'parent-id';
|
||||||
|
const parentCode = 'parent-code';
|
||||||
|
const parentName = 'parent-name';
|
||||||
|
const mock: MockedResponse<
|
||||||
|
InstrumentDetailsQuery,
|
||||||
|
InstrumentDetailsQueryVariables
|
||||||
|
> = {
|
||||||
|
request: {
|
||||||
|
query: InstrumentDetailsDocument,
|
||||||
|
variables: {
|
||||||
|
marketId: parentMarketId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
result: {
|
||||||
|
data: {
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
tradableInstrument: {
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
instrument: {
|
||||||
|
__typename: 'Instrument',
|
||||||
|
code: parentCode,
|
||||||
|
name: parentName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
renderComponent(
|
renderComponent(
|
||||||
// @ts-ignore we aren't using batch yet
|
|
||||||
generateProposal({
|
generateProposal({
|
||||||
rationale: {
|
rationale: {
|
||||||
title: 'New some market',
|
title: 'New some market',
|
||||||
@ -73,6 +103,9 @@ describe('Proposal header', () => {
|
|||||||
terms: {
|
terms: {
|
||||||
change: {
|
change: {
|
||||||
__typename: 'NewMarket',
|
__typename: 'NewMarket',
|
||||||
|
successorConfiguration: {
|
||||||
|
parentMarketId,
|
||||||
|
},
|
||||||
instrument: {
|
instrument: {
|
||||||
__typename: 'InstrumentConfiguration',
|
__typename: 'InstrumentConfiguration',
|
||||||
name: 'Some market',
|
name: 'Some market',
|
||||||
@ -87,7 +120,9 @@ describe('Proposal header', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
|
undefined,
|
||||||
|
[mock]
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('proposal-title')).toHaveTextContent(
|
expect(screen.getByTestId('proposal-title')).toHaveTextContent(
|
||||||
'New some market'
|
'New some market'
|
||||||
@ -96,14 +131,13 @@ describe('Proposal header', () => {
|
|||||||
expect(screen.getByTestId('proposal-details')).toHaveTextContent(
|
expect(screen.getByTestId('proposal-details')).toHaveTextContent(
|
||||||
'tGBP settled future.'
|
'tGBP settled future.'
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('proposal-successor-info')).toHaveTextContent(
|
expect(
|
||||||
'PARENT_CODE'
|
await screen.findByTestId('proposal-successor-info')
|
||||||
);
|
).toHaveTextContent(parentCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
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',
|
||||||
@ -132,7 +166,6 @@ 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',
|
||||||
@ -162,8 +195,10 @@ 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({
|
||||||
|
rationale: {
|
||||||
|
title: 'New asset',
|
||||||
|
},
|
||||||
terms: {
|
terms: {
|
||||||
change: {
|
change: {
|
||||||
__typename: 'NewAsset',
|
__typename: 'NewAsset',
|
||||||
@ -177,9 +212,7 @@ describe('Proposal header', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('proposal-title')).toHaveTextContent(
|
expect(screen.getByTestId('proposal-title')).toHaveTextContent('New asset');
|
||||||
'New asset proposal'
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('proposal-type')).toHaveTextContent('New asset');
|
expect(screen.getByTestId('proposal-type')).toHaveTextContent('New asset');
|
||||||
expect(screen.getByTestId('proposal-details')).toHaveTextContent(
|
expect(screen.getByTestId('proposal-details')).toHaveTextContent(
|
||||||
'Symbol: BIA. Max faucet amount mint: 300'
|
'Symbol: BIA. Max faucet amount mint: 300'
|
||||||
@ -188,7 +221,6 @@ 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',
|
||||||
@ -218,7 +250,6 @@ 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: {
|
||||||
@ -240,7 +271,6 @@ 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: {
|
||||||
@ -266,7 +296,6 @@ 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: {
|
||||||
@ -323,7 +352,6 @@ 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: {
|
||||||
@ -336,7 +364,6 @@ 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: {
|
||||||
@ -350,7 +377,6 @@ 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: {
|
||||||
@ -365,7 +391,6 @@ 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: {
|
||||||
@ -434,8 +459,6 @@ describe('Proposal header', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/proposals');
|
|
||||||
|
|
||||||
describe('<NewTransferSummary />', () => {
|
describe('<NewTransferSummary />', () => {
|
||||||
it('renders null if no details are provided', () => {
|
it('renders null if no details are provided', () => {
|
||||||
(useNewTransferProposalDetails as jest.Mock).mockReturnValue(null);
|
(useNewTransferProposalDetails as jest.Mock).mockReturnValue(null);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
CopyWithTooltip,
|
CopyWithTooltip,
|
||||||
Lozenge,
|
Lozenge,
|
||||||
@ -8,14 +8,13 @@ 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 { 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';
|
||||||
import {
|
import {
|
||||||
useCancelTransferProposalDetails,
|
useCancelTransferProposalDetails,
|
||||||
|
useInstrumentDetailsQuery,
|
||||||
useNewTransferProposalDetails,
|
useNewTransferProposalDetails,
|
||||||
useSuccessorMarketProposalDetails,
|
|
||||||
} from '@vegaprotocol/proposals';
|
} from '@vegaprotocol/proposals';
|
||||||
import {
|
import {
|
||||||
CONSOLE_MARKET_PAGE,
|
CONSOLE_MARKET_PAGE,
|
||||||
@ -27,65 +26,109 @@ 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 {
|
||||||
import { type Proposal } from '../../types';
|
GovernanceTransferKindMapping,
|
||||||
|
type ProposalRejectionReason,
|
||||||
|
ProposalRejectionReasonMapping,
|
||||||
|
ProposalState,
|
||||||
|
} from '@vegaprotocol/types';
|
||||||
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
import { type ProposalTermsFieldsFragment } from '../../__generated__/Proposals';
|
||||||
|
import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
||||||
|
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||||
|
|
||||||
export const ProposalHeader = ({
|
const ProposalTypeTags = ({
|
||||||
proposal,
|
proposal,
|
||||||
isListItem = true,
|
|
||||||
voteState,
|
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal;
|
proposal: Proposal | BatchProposal;
|
||||||
isListItem?: boolean;
|
|
||||||
voteState?: VoteState | null;
|
|
||||||
}) => {
|
}) => {
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
if (proposal.__typename === 'Proposal') {
|
||||||
const { t } = useTranslation();
|
return (
|
||||||
const change = proposal?.terms.change;
|
<div data-testid="proposal-type">
|
||||||
|
<ProposalTypeTag terms={proposal.terms} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proposal.__typename === 'BatchProposal') {
|
||||||
|
return (
|
||||||
|
<div data-testid="proposal-type" className="flex gap-1">
|
||||||
|
{proposal.subProposals?.map((subProposal, i) => {
|
||||||
|
if (!subProposal?.terms) return null;
|
||||||
|
return <ProposalTypeTag key={i} terms={subProposal.terms} />;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProposalTypeTag = ({ terms }: { terms: ProposalTermsFieldsFragment }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
switch (terms.change.__typename) {
|
||||||
|
// Speical case for markets where we want to show the product type in the tag
|
||||||
|
case 'NewMarket': {
|
||||||
|
return (
|
||||||
|
<ProposalInfoLabel variant="secondary">
|
||||||
|
{t(
|
||||||
|
terms.change?.instrument?.product?.__typename
|
||||||
|
? `NewMarket${terms.change.instrument.product.__typename}`
|
||||||
|
: 'NewMarket'
|
||||||
|
)}
|
||||||
|
</ProposalInfoLabel>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return (
|
||||||
|
<ProposalInfoLabel variant="secondary">
|
||||||
|
{t(terms.change.__typename)}
|
||||||
|
</ProposalInfoLabel>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProposalDetails = ({
|
||||||
|
proposal,
|
||||||
|
}: {
|
||||||
|
proposal: Proposal | BatchProposal;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const featureFlags = useFeatureFlags((store) => store.flags);
|
||||||
const consoleLink = useLinks(DApp.Console);
|
const consoleLink = useLinks(DApp.Console);
|
||||||
|
|
||||||
let details: ReactNode;
|
const renderDetails = (terms: ProposalTermsFieldsFragment) => {
|
||||||
let proposalType = '';
|
switch (terms.change?.__typename) {
|
||||||
let fallbackTitle = '';
|
case 'NewMarket': {
|
||||||
|
const getAsset = (terms: ProposalTermsFieldsFragment) => {
|
||||||
const title = proposal?.rationale.title.trim();
|
|
||||||
|
|
||||||
const titleContent = shorten(title ?? '', 100);
|
|
||||||
|
|
||||||
const getAsset = (proposal: Proposal) => {
|
|
||||||
const terms = proposal?.terms;
|
|
||||||
if (
|
if (
|
||||||
terms?.change.__typename === 'NewMarket' &&
|
terms?.change.__typename === 'NewMarket' &&
|
||||||
(terms.change.instrument.product?.__typename === 'FutureProduct' ||
|
(terms.change.instrument.product?.__typename === 'FutureProduct' ||
|
||||||
terms.change.instrument.product?.__typename === 'PerpetualProduct')
|
terms.change.instrument.product?.__typename ===
|
||||||
|
'PerpetualProduct')
|
||||||
) {
|
) {
|
||||||
return terms.change.instrument.product.settlementAsset;
|
return terms.change.instrument.product.settlementAsset;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (change?.__typename) {
|
return (
|
||||||
case 'NewMarket': {
|
|
||||||
proposalType =
|
|
||||||
featureFlags.PRODUCT_PERPETUALS &&
|
|
||||||
change?.instrument?.product?.__typename
|
|
||||||
? `NewMarket${change?.instrument?.product?.__typename}`
|
|
||||||
: 'NewMarket';
|
|
||||||
fallbackTitle = t('NewMarketProposal');
|
|
||||||
details = (
|
|
||||||
<>
|
<>
|
||||||
{featureFlags.SUCCESSOR_MARKETS && (
|
{terms.change.successorConfiguration && (
|
||||||
<SuccessorCode proposalId={proposal?.id} />
|
<ParentMarketCode
|
||||||
|
parentMarketId={
|
||||||
|
terms.change.successorConfiguration.parentMarketId
|
||||||
|
}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<span>
|
<span>
|
||||||
{t('Code')}: {change.instrument.code}.
|
{t('Code')}: {terms.change.instrument.code}.
|
||||||
</span>{' '}
|
</span>{' '}
|
||||||
{proposal?.terms && getAsset(proposal)?.symbol ? (
|
{terms && getAsset(terms)?.symbol ? (
|
||||||
<>
|
<>
|
||||||
<span className="font-semibold">
|
<span className="font-semibold">{getAsset(terms)?.symbol}</span>{' '}
|
||||||
{getAsset(proposal)?.symbol}
|
|
||||||
</span>{' '}
|
|
||||||
{t('settled future')}.
|
{t('settled future')}.
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@ -93,38 +136,30 @@ export const ProposalHeader = ({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateMarketState': {
|
case 'UpdateMarketState': {
|
||||||
proposalType =
|
return (
|
||||||
featureFlags.UPDATE_MARKET_STATE && change?.updateType
|
|
||||||
? t(change.updateType)
|
|
||||||
: 'UpdateMarketState';
|
|
||||||
fallbackTitle = t('UpdateMarketStateProposal');
|
|
||||||
details = (
|
|
||||||
<span>
|
<span>
|
||||||
{featureFlags.UPDATE_MARKET_STATE &&
|
{featureFlags.UPDATE_MARKET_STATE &&
|
||||||
change?.market?.id &&
|
terms.change?.market?.id &&
|
||||||
change.updateType ? (
|
terms.change.updateType ? (
|
||||||
<>
|
<>
|
||||||
{t(change.updateType)}: {truncateMiddle(change.market.id)}
|
{t(terms.change.updateType)}:{' '}
|
||||||
|
{truncateMiddle(terms.change.market.id)}
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateMarket': {
|
case 'UpdateMarket': {
|
||||||
proposalType = 'UpdateMarket';
|
return (
|
||||||
fallbackTitle = t('UpdateMarketProposal');
|
|
||||||
details = (
|
|
||||||
<>
|
<>
|
||||||
<span>{t('UpdateToMarket')}:</span>{' '}
|
<span>{t('UpdateToMarket')}:</span>{' '}
|
||||||
<span className="inline-flex items-start gap-2">
|
<span className="inline-flex items-start gap-2">
|
||||||
<span className="break-all">{change.marketId} </span>
|
<span className="break-all">{terms.change.marketId} </span>
|
||||||
<span className="inline-flex items-end gap-0">
|
<span className="inline-flex items-end gap-0">
|
||||||
<CopyWithTooltip
|
<CopyWithTooltip
|
||||||
text={change.marketId}
|
text={terms.change.marketId}
|
||||||
description={t('copyToClipboard')}
|
description={t('copyToClipboard')}
|
||||||
>
|
>
|
||||||
<button className="inline-block px-1">
|
<button className="inline-block px-1">
|
||||||
@ -136,7 +171,11 @@ export const ProposalHeader = ({
|
|||||||
className="inline-block px-1"
|
className="inline-block px-1"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const marketPageLink = consoleLink(
|
const marketPageLink = consoleLink(
|
||||||
CONSOLE_MARKET_PAGE.replace(':marketId', change.marketId)
|
CONSOLE_MARKET_PAGE.replace(
|
||||||
|
':marketId',
|
||||||
|
// @ts-ignore ts doesn't like this field even though its already a string above???
|
||||||
|
terms.change.marketId
|
||||||
|
)
|
||||||
);
|
);
|
||||||
window.open(marketPageLink, '_blank');
|
window.open(marketPageLink, '_blank');
|
||||||
}}
|
}}
|
||||||
@ -148,96 +187,349 @@ export const ProposalHeader = ({
|
|||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateReferralProgram': {
|
case 'UpdateReferralProgram': {
|
||||||
proposalType = 'UpdateReferralProgram';
|
return null;
|
||||||
fallbackTitle = t('UpdateReferralProgramProposal');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateVolumeDiscountProgram': {
|
case 'UpdateVolumeDiscountProgram': {
|
||||||
proposalType = 'UpdateVolumeDiscountProgram';
|
return null;
|
||||||
fallbackTitle = t('UpdateVolumeDiscountProgramProposal');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'NewAsset': {
|
case 'NewAsset': {
|
||||||
proposalType = 'NewAsset';
|
return (
|
||||||
fallbackTitle = t('NewAssetProposal');
|
|
||||||
details = (
|
|
||||||
<>
|
<>
|
||||||
<span>{t('Symbol')}:</span> <Lozenge>{change.symbol}.</Lozenge>{' '}
|
<span>{t('Symbol')}:</span>{' '}
|
||||||
{change.source.__typename === 'ERC20' && (
|
<Lozenge>{terms.change.symbol}.</Lozenge>{' '}
|
||||||
|
{terms.change.source.__typename === 'ERC20' && (
|
||||||
<>
|
<>
|
||||||
<span>{t('ERC20ContractAddress')}:</span>{' '}
|
<span>{t('ERC20ContractAddress')}:</span>{' '}
|
||||||
<Lozenge>{change.source.contractAddress}</Lozenge>
|
<Lozenge>{terms.change.source.contractAddress}</Lozenge>
|
||||||
</>
|
</>
|
||||||
)}{' '}
|
)}{' '}
|
||||||
{change.source.__typename === 'BuiltinAsset' && (
|
{terms.change.source.__typename === 'BuiltinAsset' && (
|
||||||
<>
|
<>
|
||||||
<span>{t('MaxFaucetAmountMint')}:</span>{' '}
|
<span>{t('MaxFaucetAmountMint')}:</span>{' '}
|
||||||
<Lozenge>{change.source.maxFaucetAmountMint}</Lozenge>
|
<Lozenge>{terms.change.source.maxFaucetAmountMint}</Lozenge>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateNetworkParameter': {
|
case 'UpdateNetworkParameter': {
|
||||||
proposalType = 'NetworkParameter';
|
return (
|
||||||
fallbackTitle = t('NetworkParameterProposal');
|
<Trans
|
||||||
details = (
|
i18nKey="Change <lozenge>{{key}}</lozenge> to <lozenge>{{value}}</lozenge>"
|
||||||
<>
|
values={{
|
||||||
<span>{t('Change')}:</span>{' '}
|
key: terms.change.networkParameter.key,
|
||||||
<Lozenge>{change.networkParameter.key}</Lozenge>{' '}
|
value: terms.change.networkParameter.value,
|
||||||
<span>{t('to')}</span>{' '}
|
}}
|
||||||
<span className="whitespace-nowrap">
|
components={{
|
||||||
<Lozenge>{change.networkParameter.value}</Lozenge>
|
// @ts-ignore children passed by i18next
|
||||||
</span>
|
lozenge: <Lozenge />,
|
||||||
</>
|
}}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'NewFreeform': {
|
case 'NewFreeform': {
|
||||||
proposalType = 'Freeform';
|
return <span />;
|
||||||
fallbackTitle = t('FreeformProposal');
|
|
||||||
details = <span />;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'UpdateAsset': {
|
case 'UpdateAsset': {
|
||||||
proposalType = 'UpdateAsset';
|
return (
|
||||||
fallbackTitle = t('UpdateAssetProposal');
|
<Trans
|
||||||
details = (
|
i18nKey="Asset ID: <lozenge>{{id}}</lozenge>"
|
||||||
<>
|
values={{
|
||||||
<span>{t('AssetID')}:</span>{' '}
|
id: truncateMiddle(terms.change.assetId),
|
||||||
<Lozenge>{truncateMiddle(change.assetId)}</Lozenge>
|
}}
|
||||||
</>
|
components={{
|
||||||
|
// @ts-ignore children passed by i18next
|
||||||
|
lozenge: <Lozenge />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'NewTransfer':
|
case 'NewTransfer':
|
||||||
proposalType = 'NewTransfer';
|
return featureFlags.GOVERNANCE_TRANSFERS ? (
|
||||||
fallbackTitle = t('NewTransferProposal');
|
|
||||||
details = featureFlags.GOVERNANCE_TRANSFERS ? (
|
|
||||||
<NewTransferSummary proposalId={proposal?.id} />
|
<NewTransferSummary proposalId={proposal?.id} />
|
||||||
) : null;
|
) : null;
|
||||||
break;
|
|
||||||
case 'CancelTransfer':
|
case 'CancelTransfer':
|
||||||
proposalType = 'CancelTransfer';
|
return featureFlags.GOVERNANCE_TRANSFERS ? (
|
||||||
fallbackTitle = t('CancelTransferProposal');
|
|
||||||
details = featureFlags.GOVERNANCE_TRANSFERS ? (
|
|
||||||
<CancelTransferSummary proposalId={proposal?.id} />
|
<CancelTransferSummary proposalId={proposal?.id} />
|
||||||
) : null;
|
) : null;
|
||||||
break;
|
default: {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let details = null;
|
||||||
|
|
||||||
|
if (proposal.__typename === 'Proposal') {
|
||||||
|
details = (
|
||||||
|
<div>
|
||||||
|
<div>{renderDetails(proposal.terms)}</div>
|
||||||
|
<VoteStateText
|
||||||
|
state={proposal.state}
|
||||||
|
closingDatetime={proposal.terms.closingDatetime}
|
||||||
|
enactmentDatetime={proposal.terms.enactmentDatetime}
|
||||||
|
rejectionReason={proposal.rejectionReason}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proposal.__typename === 'BatchProposal' && proposal.subProposals) {
|
||||||
|
details = (
|
||||||
|
<div>
|
||||||
|
<h3 className="text-xl border-b border-default pb-3 mb-3">
|
||||||
|
Proposals in batch
|
||||||
|
</h3>
|
||||||
|
<ul className="flex flex-col gap-2 border-b border-default pb-3 mb-3">
|
||||||
|
{proposal.subProposals.map((p, i) => {
|
||||||
|
if (!p?.terms) return null;
|
||||||
|
return (
|
||||||
|
<li key={i}>
|
||||||
|
<div>{renderDetails(p.terms)}</div>
|
||||||
|
<SubProposalStateText
|
||||||
|
state={proposal.state}
|
||||||
|
enactmentDatetime={p.terms.enactmentDatetime}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
<BatchProposalStateText
|
||||||
|
state={proposal.state}
|
||||||
|
closingDatetime={proposal.batchTerms?.closingDatetime}
|
||||||
|
rejectionReason={proposal.rejectionReason}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-testid="proposal-details"
|
||||||
|
className="break-words mb-6 text-vega-light-200"
|
||||||
|
>
|
||||||
|
{details}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoteStateText = ({
|
||||||
|
state,
|
||||||
|
closingDatetime,
|
||||||
|
enactmentDatetime,
|
||||||
|
rejectionReason,
|
||||||
|
}: {
|
||||||
|
state: ProposalState;
|
||||||
|
closingDatetime: string;
|
||||||
|
enactmentDatetime: string;
|
||||||
|
rejectionReason: ProposalRejectionReason | null | undefined;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const nowToCloseInHours = differenceInHours(
|
||||||
|
new Date(closingDatetime),
|
||||||
|
new Date()
|
||||||
|
);
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
'data-testid': 'vote-details',
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case ProposalState.STATE_ENACTED: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
{t('enactedOn{{date}}', {
|
||||||
|
enactmentDate:
|
||||||
|
enactmentDatetime &&
|
||||||
|
format(new Date(enactmentDatetime), DATE_FORMAT_DETAILED),
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_PASSED:
|
||||||
|
case ProposalState.STATE_WAITING_FOR_NODE_VOTE: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
{t('enactsOn{{date}}', {
|
||||||
|
enactmentDate:
|
||||||
|
enactmentDatetime &&
|
||||||
|
format(new Date(enactmentDatetime), DATE_FORMAT_DETAILED),
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_OPEN: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
<span className={nowToCloseInHours < 6 ? 'text-vega-orange' : ''}>
|
||||||
|
{t('{{time}} left to vote', {
|
||||||
|
time: formatDistanceToNowStrict(new Date(closingDatetime)),
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_DECLINED: {
|
||||||
|
return <p {...props}>{t(state)}</p>;
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_REJECTED: {
|
||||||
|
const props = { 'data-testid': 'vote-status' };
|
||||||
|
|
||||||
|
if (rejectionReason) {
|
||||||
|
return (
|
||||||
|
<p {...props}>{t(ProposalRejectionReasonMapping[rejectionReason])}</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <p {...props}>{t('Proposal rejected')}</p>;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders state details relevant to the sub proposal, namely the enactment
|
||||||
|
* date and time
|
||||||
|
*/
|
||||||
|
const SubProposalStateText = ({
|
||||||
|
state,
|
||||||
|
enactmentDatetime,
|
||||||
|
}: {
|
||||||
|
state: ProposalState;
|
||||||
|
enactmentDatetime: string;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
'data-testid': 'vote-details',
|
||||||
|
className: 'm-0',
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case ProposalState.STATE_ENACTED: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
{t('enactedOn{{date}}', {
|
||||||
|
enactmentDate:
|
||||||
|
enactmentDatetime &&
|
||||||
|
format(new Date(enactmentDatetime), DATE_FORMAT_DETAILED),
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_OPEN:
|
||||||
|
case ProposalState.STATE_PASSED:
|
||||||
|
case ProposalState.STATE_WAITING_FOR_NODE_VOTE: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
{t('enactsOn{{date}}', {
|
||||||
|
enactmentDate:
|
||||||
|
enactmentDatetime &&
|
||||||
|
format(new Date(enactmentDatetime), DATE_FORMAT_DETAILED),
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_REJECTED:
|
||||||
|
case ProposalState.STATE_DECLINED: {
|
||||||
|
// If voting is still open we render a single clost time for all sub proposals
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders state details relevant for the entire batch. IE. if the proposal was
|
||||||
|
* rejected or declined, or the vote close time. Does not render enactment times as
|
||||||
|
* those are relevant to the sub proposal
|
||||||
|
*/
|
||||||
|
const BatchProposalStateText = ({
|
||||||
|
state,
|
||||||
|
closingDatetime,
|
||||||
|
rejectionReason,
|
||||||
|
}: {
|
||||||
|
state: ProposalState;
|
||||||
|
closingDatetime: string;
|
||||||
|
rejectionReason: ProposalRejectionReason | null | undefined;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const nowToCloseInHours = differenceInHours(
|
||||||
|
new Date(closingDatetime),
|
||||||
|
new Date()
|
||||||
|
);
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
'data-testid': 'vote-details',
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case ProposalState.STATE_ENACTED:
|
||||||
|
case ProposalState.STATE_PASSED:
|
||||||
|
case ProposalState.STATE_WAITING_FOR_NODE_VOTE: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_OPEN: {
|
||||||
|
return (
|
||||||
|
<p {...props}>
|
||||||
|
<span className={nowToCloseInHours < 6 ? 'text-vega-orange' : ''}>
|
||||||
|
{t('{{time}} left to vote', {
|
||||||
|
time: formatDistanceToNowStrict(new Date(closingDatetime)),
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_DECLINED: {
|
||||||
|
return <p {...props}>{t(state)}</p>;
|
||||||
|
}
|
||||||
|
case ProposalState.STATE_REJECTED: {
|
||||||
|
const props = { 'data-testid': 'vote-status' };
|
||||||
|
|
||||||
|
if (rejectionReason) {
|
||||||
|
return (
|
||||||
|
<p {...props}>{t(ProposalRejectionReasonMapping[rejectionReason])}</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <p {...props}>{t('Proposal rejected')}</p>;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProposalHeader = ({
|
||||||
|
proposal,
|
||||||
|
isListItem = true,
|
||||||
|
voteState,
|
||||||
|
}: {
|
||||||
|
proposal: Proposal | BatchProposal;
|
||||||
|
isListItem?: boolean;
|
||||||
|
voteState?: VoteState | null;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const title = proposal?.rationale.title.trim();
|
||||||
|
|
||||||
|
const fallbackTitle = t(
|
||||||
|
proposal.__typename === 'Proposal'
|
||||||
|
? 'Unknown proposal'
|
||||||
|
: 'Unknown batch proposal'
|
||||||
|
);
|
||||||
|
const titleContent = shorten(title ?? '', 100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center justify-between gap-4 mb-6 text-sm">
|
<div className="flex items-center justify-between gap-4 mb-6 text-sm">
|
||||||
<div data-testid="proposal-type">
|
<ProposalTypeTags proposal={proposal} />
|
||||||
<ProposalInfoLabel variant="secondary">
|
|
||||||
{t(`${proposalType}`)}
|
|
||||||
</ProposalInfoLabel>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-6">
|
<div className="flex items-center gap-6">
|
||||||
{(voteState === 'Yes' || voteState === 'No') && (
|
{(voteState === 'Yes' || voteState === 'No') && (
|
||||||
@ -264,50 +556,43 @@ export const ProposalHeader = ({
|
|||||||
<div data-testid="proposal-title" className="break-all">
|
<div data-testid="proposal-title" className="break-all">
|
||||||
{isListItem ? (
|
{isListItem ? (
|
||||||
<header>
|
<header>
|
||||||
<SubHeading
|
<SubHeading title={titleContent || fallbackTitle} />
|
||||||
title={titleContent || fallbackTitle || t('Unknown proposal')}
|
|
||||||
/>
|
|
||||||
</header>
|
</header>
|
||||||
) : (
|
) : (
|
||||||
<Heading
|
<Heading title={titleContent || fallbackTitle} />
|
||||||
title={titleContent || fallbackTitle || t('Unknown proposal')}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<ProposalDetails proposal={proposal} />
|
||||||
{details && (
|
|
||||||
<div
|
|
||||||
data-testid="proposal-details"
|
|
||||||
className="break-words mb-6 text-vega-light-200"
|
|
||||||
>
|
|
||||||
{details}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<VoteBreakdown proposal={proposal} />
|
<VoteBreakdown proposal={proposal} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SuccessorCode = ({
|
export const ParentMarketCode = ({
|
||||||
proposalId,
|
parentMarketId,
|
||||||
}: {
|
}: {
|
||||||
proposalId?: string | null;
|
parentMarketId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const successor = useSuccessorMarketProposalDetails(proposalId);
|
const { data } = useInstrumentDetailsQuery({
|
||||||
|
variables: {
|
||||||
|
marketId: parentMarketId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return successor.parentMarketId || successor.code ? (
|
if (!data?.market?.tradableInstrument.instrument.code) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
<span className="block" data-testid="proposal-successor-info">
|
<span className="block" data-testid="proposal-successor-info">
|
||||||
{t('Successor market to')}:{' '}
|
{t('Successor market to')}:{' '}
|
||||||
<Link
|
<Link
|
||||||
to={`${Routes.PROPOSALS}/${successor.parentMarketId}`}
|
to={`${Routes.PROPOSALS}/${parentMarketId}`}
|
||||||
className="hover:underline"
|
className="hover:underline"
|
||||||
>
|
>
|
||||||
{successor.code || successor.parentMarketId}
|
{data.market.tradableInstrument.instrument.code}
|
||||||
</Link>
|
</Link>
|
||||||
</span>
|
</span>
|
||||||
) : null;
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NewTransferSummary = ({
|
export const NewTransferSummary = ({
|
||||||
|
@ -3,13 +3,15 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
|
import { SyntaxHighlighter } from '@vegaprotocol/ui-toolkit';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
import {
|
||||||
import type { ProposalQuery } from '../../proposal/__generated__/Proposal';
|
type BatchProposalFieldsFragment,
|
||||||
|
type ProposalFieldsFragment,
|
||||||
|
} from '../../__generated__/Proposals';
|
||||||
|
|
||||||
export const ProposalJson = ({
|
export const ProposalJson = ({
|
||||||
proposal,
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: ProposalFieldsFragment | BatchProposalFieldsFragment;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
|
@ -57,33 +57,21 @@ describe('applyImmutableKeysFromEarlierVersion', () => {
|
|||||||
describe('ProposalMarketChanges', () => {
|
describe('ProposalMarketChanges', () => {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const { getByTestId } = render(
|
const { getByTestId } = render(
|
||||||
<ProposalMarketChanges
|
<ProposalMarketChanges marketId="market-id" updatedProposal={{}} />
|
||||||
originalProposal={{}}
|
|
||||||
latestEnactedProposal={{}}
|
|
||||||
updatedProposal={{}}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
expect(getByTestId('proposal-market-changes')).toBeInTheDocument();
|
expect(getByTestId('proposal-market-changes')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('JsonDiff is not visible when showChanges is false', () => {
|
it('JsonDiff is not visible when showChanges is false', () => {
|
||||||
const { queryByTestId } = render(
|
const { queryByTestId } = render(
|
||||||
<ProposalMarketChanges
|
<ProposalMarketChanges marketId="market-id" updatedProposal={{}} />
|
||||||
originalProposal={{}}
|
|
||||||
latestEnactedProposal={{}}
|
|
||||||
updatedProposal={{}}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
expect(queryByTestId('json-diff')).not.toBeInTheDocument();
|
expect(queryByTestId('json-diff')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('JsonDiff is visible when showChanges is true', async () => {
|
it('JsonDiff is visible when showChanges is true', async () => {
|
||||||
const { getByTestId } = render(
|
const { getByTestId } = render(
|
||||||
<ProposalMarketChanges
|
<ProposalMarketChanges marketId="market-id" updatedProposal={{}} />
|
||||||
originalProposal={{}}
|
|
||||||
latestEnactedProposal={{}}
|
|
||||||
updatedProposal={{}}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
fireEvent.click(getByTestId('proposal-market-changes-toggle'));
|
fireEvent.click(getByTestId('proposal-market-changes-toggle'));
|
||||||
expect(getByTestId('json-diff')).toBeInTheDocument();
|
expect(getByTestId('json-diff')).toBeInTheDocument();
|
||||||
|
@ -7,6 +7,8 @@ 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 { JsonValue } from '../../../../components/json-diff';
|
import type { JsonValue } from '../../../../components/json-diff';
|
||||||
|
import { useFetch } from '@vegaprotocol/react-helpers';
|
||||||
|
import { ENV } from '../../../../config';
|
||||||
|
|
||||||
const immutableKeys = [
|
const immutableKeys = [
|
||||||
'decimalPlaces',
|
'decimalPlaces',
|
||||||
@ -40,19 +42,51 @@ export const applyImmutableKeysFromEarlierVersion = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface ProposalMarketChangesProps {
|
interface ProposalMarketChangesProps {
|
||||||
originalProposal: JsonValue;
|
marketId: string;
|
||||||
latestEnactedProposal: JsonValue | undefined;
|
|
||||||
updatedProposal: JsonValue;
|
updatedProposal: JsonValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalMarketChanges = ({
|
export const ProposalMarketChanges = ({
|
||||||
originalProposal,
|
marketId,
|
||||||
latestEnactedProposal,
|
|
||||||
updatedProposal,
|
updatedProposal,
|
||||||
}: ProposalMarketChangesProps) => {
|
}: ProposalMarketChangesProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showChanges, setShowChanges] = useState(false);
|
const [showChanges, setShowChanges] = useState(false);
|
||||||
|
|
||||||
|
const {
|
||||||
|
state: { data },
|
||||||
|
} = useFetch(`${ENV.rest}governance?proposalId=${marketId}`, undefined, true);
|
||||||
|
|
||||||
|
const {
|
||||||
|
state: { data: enactedProposalData },
|
||||||
|
} = useFetch(
|
||||||
|
`${ENV.rest}governances?proposalState=STATE_ENACTED&proposalType=TYPE_UPDATE_MARKET`,
|
||||||
|
undefined,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
// @ts-ignore no types here :-/
|
||||||
|
const enacted = enactedProposalData?.connection?.edges
|
||||||
|
.filter(
|
||||||
|
// @ts-ignore no type here
|
||||||
|
({ node }) => node?.proposal?.terms?.updateMarket?.marketId === marketId
|
||||||
|
)
|
||||||
|
// @ts-ignore no type here
|
||||||
|
.sort((a, b) => {
|
||||||
|
return (
|
||||||
|
new Date(a?.node?.terms?.enactmentTimestamp).getTime() -
|
||||||
|
new Date(b?.node?.terms?.enactmentTimestamp).getTime()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const latestEnactedProposal = enacted?.length
|
||||||
|
? enacted[enacted.length - 1]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const originalProposal =
|
||||||
|
// @ts-ignore no types with useFetch TODO: check this is good
|
||||||
|
data?.data?.proposal?.terms?.newMarket?.changes;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section data-testid="proposal-market-changes">
|
<section data-testid="proposal-market-changes">
|
||||||
<CollapsibleToggle
|
<CollapsibleToggle
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
getDataSourceSpecForTradingTermination,
|
getDataSourceSpecForTradingTermination,
|
||||||
getSigners,
|
getSigners,
|
||||||
MarginScalingFactorsPanel,
|
MarginScalingFactorsPanel,
|
||||||
|
marketInfoProvider,
|
||||||
} from '@vegaprotocol/markets';
|
} from '@vegaprotocol/markets';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -28,8 +29,8 @@ import {
|
|||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { SubHeading } from '../../../../components/heading';
|
import { SubHeading } from '../../../../components/heading';
|
||||||
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
import { CollapsibleToggle } from '../../../../components/collapsible-toggle';
|
||||||
import type { MarketInfo } from '@vegaprotocol/markets';
|
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
|
import { useDataProvider } from '@vegaprotocol/data-provider';
|
||||||
|
|
||||||
type MarketDataDialogState = {
|
type MarketDataDialogState = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -48,18 +49,29 @@ export const useMarketDataDialogStore = create<MarketDataDialogState>(
|
|||||||
const marketDataHeaderStyles =
|
const marketDataHeaderStyles =
|
||||||
'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2';
|
'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2';
|
||||||
|
|
||||||
export const ProposalMarketData = ({
|
export const ProposalMarketData = ({ proposalId }: { proposalId: string }) => {
|
||||||
marketData,
|
|
||||||
parentMarketData,
|
|
||||||
}: {
|
|
||||||
marketData: MarketInfo;
|
|
||||||
parentMarketData?: MarketInfo;
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isOpen, open, close } = useMarketDataDialogStore();
|
const { isOpen, open, close } = useMarketDataDialogStore();
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
|
|
||||||
if (!marketData) {
|
const { data: marketData } = useDataProvider({
|
||||||
|
dataProvider: marketInfoProvider,
|
||||||
|
skipUpdates: true,
|
||||||
|
variables: {
|
||||||
|
marketId: proposalId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data: parentMarketData } = useDataProvider({
|
||||||
|
dataProvider: marketInfoProvider,
|
||||||
|
skipUpdates: true,
|
||||||
|
skip: !marketData?.parentMarketID,
|
||||||
|
variables: {
|
||||||
|
marketId: marketData?.parentMarketID || '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!marketData || !parentMarketData) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
formatReferralRewardMultiplier,
|
formatReferralRewardMultiplier,
|
||||||
ProposalReferralProgramDetails,
|
ProposalReferralProgramDetails,
|
||||||
} from './proposal-referral-program-details';
|
} from './proposal-referral-program-details';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
|
|
||||||
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
||||||
useAppState: () => ({
|
useAppState: () => ({
|
||||||
@ -59,10 +58,8 @@ describe('ProposalReferralProgramDetails helper functions', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockReferralProposal = generateProposal({
|
const mockChange = {
|
||||||
terms: {
|
__typename: 'UpdateReferralProgram' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateReferralProgram',
|
|
||||||
benefitTiers: [
|
benefitTiers: [
|
||||||
{
|
{
|
||||||
minimumEpochs: 6,
|
minimumEpochs: 6,
|
||||||
@ -99,47 +96,27 @@ const mockReferralProposal = generateProposal({
|
|||||||
referralRewardMultiplier: '3',
|
referralRewardMultiplier: '3',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('<ProposalReferralProgramDetails />', () => {
|
describe('<ProposalReferralProgramDetails />', () => {
|
||||||
it('should not render if proposal is null', () => {
|
it('should not render if proposal is null', () => {
|
||||||
render(<ProposalReferralProgramDetails proposal={null} />);
|
render(<ProposalReferralProgramDetails change={null} />);
|
||||||
expect(
|
|
||||||
screen.queryByTestId('proposal-referral-program-details')
|
|
||||||
).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render if __typename is not UpdateReferralProgram', () => {
|
|
||||||
const updateMarketProposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
render(<ProposalReferralProgramDetails proposal={updateMarketProposal} />);
|
|
||||||
expect(
|
expect(
|
||||||
screen.queryByTestId('proposal-referral-program-details')
|
screen.queryByTestId('proposal-referral-program-details')
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render if there are no relevant fields', () => {
|
it('should not render if there are no relevant fields', () => {
|
||||||
const incompleteProposal = generateProposal({
|
const emptyChange = {};
|
||||||
terms: {
|
// @ts-ignore change deliberately empty
|
||||||
change: {},
|
render(<ProposalReferralProgramDetails change={emptyChange} />);
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ProposalReferralProgramDetails proposal={incompleteProposal} />);
|
|
||||||
expect(
|
expect(
|
||||||
screen.queryByTestId('proposal-referral-program-details')
|
screen.queryByTestId('proposal-referral-program-details')
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render relevant fields if present', () => {
|
it('should render relevant fields if present', () => {
|
||||||
render(<ProposalReferralProgramDetails proposal={mockReferralProposal} />);
|
render(<ProposalReferralProgramDetails change={mockChange} />);
|
||||||
expect(
|
expect(
|
||||||
screen.getByTestId('proposal-referral-program-window-length')
|
screen.getByTestId('proposal-referral-program-window-length')
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
@ -13,10 +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';
|
import { type UpdateReferralProgramsFragment } from '../../__generated__/Proposals';
|
||||||
|
|
||||||
interface ProposalReferralProgramDetailsProps {
|
interface ProposalReferralProgramDetailsProps {
|
||||||
proposal: Proposal | null;
|
change: UpdateReferralProgramsFragment | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const formatEndOfProgramTimestamp = (value: string) => {
|
export const formatEndOfProgramTimestamp = (value: string) => {
|
||||||
@ -44,20 +44,19 @@ export const formatReferralRewardMultiplier = (value: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ProposalReferralProgramDetails = ({
|
export const ProposalReferralProgramDetails = ({
|
||||||
proposal,
|
change,
|
||||||
}: ProposalReferralProgramDetailsProps) => {
|
}: ProposalReferralProgramDetailsProps) => {
|
||||||
const {
|
const {
|
||||||
appState: { decimals },
|
appState: { decimals },
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (proposal?.terms?.change?.__typename !== 'UpdateReferralProgram') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const benefitTiers = proposal?.terms?.change?.benefitTiers.slice();
|
if (change?.__typename !== 'UpdateReferralProgram') return null;
|
||||||
const stakingTiers = proposal?.terms?.change?.stakingTiers.slice();
|
|
||||||
const windowLength = proposal?.terms?.change?.windowLength;
|
const benefitTiers = change?.benefitTiers.slice();
|
||||||
const endOfProgramTimestamp = proposal?.terms?.change?.endOfProgram;
|
const stakingTiers = change?.stakingTiers.slice();
|
||||||
|
const windowLength = change?.windowLength;
|
||||||
|
const endOfProgramTimestamp = change?.endOfProgram;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!benefitTiers &&
|
!benefitTiers &&
|
||||||
|
@ -6,15 +6,14 @@ 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,
|
proposalId,
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal;
|
proposalId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const details = useCancelTransferProposalDetails(proposal?.id);
|
const details = useCancelTransferProposalDetails(proposalId);
|
||||||
|
|
||||||
if (!details) {
|
if (!details) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -19,17 +19,16 @@ import {
|
|||||||
addDecimalsFormatNumberQuantum,
|
addDecimalsFormatNumberQuantum,
|
||||||
formatDateWithLocalTimezone,
|
formatDateWithLocalTimezone,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import { type Proposal } from '../../types';
|
|
||||||
|
|
||||||
export const ProposalTransferDetails = ({
|
export const ProposalTransferDetails = ({
|
||||||
proposal,
|
proposalId,
|
||||||
}: {
|
}: {
|
||||||
proposal: Proposal;
|
proposalId: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
|
|
||||||
const details = useNewTransferProposalDetails(proposal?.id);
|
const details = useNewTransferProposalDetails(proposalId);
|
||||||
if (!details) {
|
if (!details) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { ProposalUpdateBenefitTiers } from './proposal-update-benefit-tiers-details';
|
import { ProposalUpdateBenefitTiers } from './proposal-update-benefit-tiers-details';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
|
|
||||||
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
||||||
useAppState: () => ({
|
useAppState: () => ({
|
||||||
@ -10,10 +9,8 @@ jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
|||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const mockVestingBenefitTierProposal = generateProposal({
|
const mockChange1 = {
|
||||||
terms: {
|
__typename: 'UpdateNetworkParameter' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateNetworkParameter',
|
|
||||||
networkParameter: {
|
networkParameter: {
|
||||||
key: 'blah.blah.benefitTiers',
|
key: 'blah.blah.benefitTiers',
|
||||||
value: JSON.stringify({
|
value: JSON.stringify({
|
||||||
@ -33,14 +30,10 @@ const mockVestingBenefitTierProposal = generateProposal({
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockActivityStreakBenefitTierProposal = generateProposal({
|
const mockChange2 = {
|
||||||
terms: {
|
__typename: 'UpdateNetworkParameter' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateNetworkParameter',
|
|
||||||
networkParameter: {
|
networkParameter: {
|
||||||
key: 'blah.blah.benefitTiers',
|
key: 'blah.blah.benefitTiers',
|
||||||
value: JSON.stringify({
|
value: JSON.stringify({
|
||||||
@ -58,61 +51,29 @@ const mockActivityStreakBenefitTierProposal = generateProposal({
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
describe('ProposalUpdateBenefitTiers', () => {
|
describe('ProposalUpdateBenefitTiers', () => {
|
||||||
it('should not render if proposal is null', () => {
|
it('should not render if proposal is null', () => {
|
||||||
render(<ProposalUpdateBenefitTiers proposal={null} />);
|
render(<ProposalUpdateBenefitTiers change={null} />);
|
||||||
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render if __typename is not UpdateNetworkParameter', () => {
|
|
||||||
const updateMarketProposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
render(<ProposalUpdateBenefitTiers proposal={updateMarketProposal} />);
|
|
||||||
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render if there are no relevant fields', () => {
|
|
||||||
const incompleteProposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateNetworkParameter',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ProposalUpdateBenefitTiers proposal={incompleteProposal} />);
|
|
||||||
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render if there are relevant fields that are empty', () => {
|
it('should not render if there are relevant fields that are empty', () => {
|
||||||
const incompleteProposal = generateProposal({
|
const incompleteProposal = {
|
||||||
terms: {
|
__typename: 'UpdateNetworkParameter' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateNetworkParameter',
|
|
||||||
networkParameter: {
|
networkParameter: {
|
||||||
key: 'blah.blah.benefitTiers',
|
key: 'blah.blah.benefitTiers',
|
||||||
value: JSON.stringify({}),
|
value: JSON.stringify({}),
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ProposalUpdateBenefitTiers proposal={incompleteProposal} />);
|
render(<ProposalUpdateBenefitTiers change={incompleteProposal} />);
|
||||||
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
expect(screen.queryByTestId('proposal-update-benefit-tiers')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a valid vesting benefit tier proposal', () => {
|
it('should render a valid vesting benefit tier proposal', () => {
|
||||||
render(
|
render(<ProposalUpdateBenefitTiers change={mockChange1} />);
|
||||||
<ProposalUpdateBenefitTiers proposal={mockVestingBenefitTierProposal} />
|
|
||||||
);
|
|
||||||
|
|
||||||
// 3 tiers in the sample data
|
// 3 tiers in the sample data
|
||||||
expect(screen.getByText('Tier 1')).toBeInTheDocument();
|
expect(screen.getByText('Tier 1')).toBeInTheDocument();
|
||||||
@ -133,11 +94,7 @@ describe('ProposalUpdateBenefitTiers', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render a valid activity streak benefit tier proposal', () => {
|
it('should render a valid activity streak benefit tier proposal', () => {
|
||||||
render(
|
render(<ProposalUpdateBenefitTiers change={mockChange2} />);
|
||||||
<ProposalUpdateBenefitTiers
|
|
||||||
proposal={mockActivityStreakBenefitTierProposal}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
// 3 tiers in the sample data
|
// 3 tiers in the sample data
|
||||||
expect(screen.getByText('Tier 1')).toBeInTheDocument();
|
expect(screen.getByText('Tier 1')).toBeInTheDocument();
|
||||||
|
@ -11,7 +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';
|
import { type IUpdateNetworkParameterFieldsFragment } from '../../__generated__/Proposals';
|
||||||
|
|
||||||
// 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: Proposal | null;
|
change: IUpdateNetworkParameterFieldsFragment | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,17 +55,17 @@ interface ProposalReferralProgramDetailsProps {
|
|||||||
* It only renders known fields so that they can be formatted correctly.
|
* It only renders known fields so that they can be formatted correctly.
|
||||||
*/
|
*/
|
||||||
export const ProposalUpdateBenefitTiers = ({
|
export const ProposalUpdateBenefitTiers = ({
|
||||||
proposal,
|
change,
|
||||||
}: ProposalReferralProgramDetailsProps) => {
|
}: ProposalReferralProgramDetailsProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (
|
if (
|
||||||
proposal?.terms?.change?.__typename !== 'UpdateNetworkParameter' ||
|
change?.__typename !== 'UpdateNetworkParameter' ||
|
||||||
proposal?.terms?.change?.networkParameter.key.slice(-13) !== '.benefitTiers'
|
change?.networkParameter.key.slice(-13) !== '.benefitTiers'
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const benefitTiersString = proposal?.terms?.change?.networkParameter.value;
|
const benefitTiersString = change?.networkParameter.value;
|
||||||
const benefitTiers = getBenefitTiers(benefitTiersString);
|
const benefitTiers = getBenefitTiers(benefitTiersString);
|
||||||
|
|
||||||
if (!benefitTiers) {
|
if (!benefitTiers) {
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import { fireEvent, render, screen } from '@testing-library/react';
|
import { fireEvent, render, screen } from '@testing-library/react';
|
||||||
import { ProposalUpdateMarketState } from './proposal-update-market-state';
|
import { ProposalUpdateMarketState } from './proposal-update-market-state';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
import { MarketUpdateType } from '@vegaprotocol/types';
|
import { MarketUpdateType } from '@vegaprotocol/types';
|
||||||
|
|
||||||
describe('<ProposalUpdateMarketState />', () => {
|
describe('<ProposalUpdateMarketState />', () => {
|
||||||
const suspendProposal = generateProposal({
|
const suspendProposal = {
|
||||||
terms: {
|
__typename: 'UpdateMarketState' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarketState',
|
|
||||||
market: {
|
market: {
|
||||||
id: '1',
|
id: '1',
|
||||||
decimalPlaces: 0,
|
decimalPlaces: 0,
|
||||||
@ -16,21 +13,17 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
name: 'suspendProposal Name',
|
name: 'suspendProposal Name',
|
||||||
code: 'suspendProposal Code',
|
code: 'suspendProposal Code',
|
||||||
product: {
|
product: {
|
||||||
__typename: 'Future',
|
__typename: 'Future' as const,
|
||||||
quoteName: 'USD',
|
quoteName: 'USD',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_SUSPEND,
|
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_SUSPEND,
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const resumeProposal = generateProposal({
|
const resumeProposal = {
|
||||||
terms: {
|
__typename: 'UpdateMarketState' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarketState',
|
|
||||||
market: {
|
market: {
|
||||||
id: '1',
|
id: '1',
|
||||||
decimalPlaces: 0,
|
decimalPlaces: 0,
|
||||||
@ -39,21 +32,17 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
name: 'resumeProposal Name',
|
name: 'resumeProposal Name',
|
||||||
code: 'resumeProposal Code',
|
code: 'resumeProposal Code',
|
||||||
product: {
|
product: {
|
||||||
__typename: 'Future',
|
__typename: 'Future' as const,
|
||||||
quoteName: 'USD',
|
quoteName: 'USD',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_RESUME,
|
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_RESUME,
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const terminateProposal = generateProposal({
|
const terminateProposal = {
|
||||||
terms: {
|
__typename: 'UpdateMarketState' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarketState',
|
|
||||||
market: {
|
market: {
|
||||||
id: '1',
|
id: '1',
|
||||||
decimalPlaces: 0,
|
decimalPlaces: 0,
|
||||||
@ -62,7 +51,7 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
name: 'terminateProposal Name',
|
name: 'terminateProposal Name',
|
||||||
code: 'terminateProposal Code',
|
code: 'terminateProposal Code',
|
||||||
product: {
|
product: {
|
||||||
__typename: 'Future',
|
__typename: 'Future' as const,
|
||||||
quoteName: 'USD',
|
quoteName: 'USD',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -70,17 +59,15 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
},
|
},
|
||||||
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_TERMINATE,
|
updateType: MarketUpdateType.MARKET_STATE_UPDATE_TYPE_TERMINATE,
|
||||||
price: '123',
|
price: '123',
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render nothing if proposal is null', () => {
|
it('should render nothing if proposal is null', () => {
|
||||||
render(<ProposalUpdateMarketState proposal={null} />);
|
render(<ProposalUpdateMarketState change={null} />);
|
||||||
expect(screen.queryByTestId('proposal-update-market-state')).toBeNull();
|
expect(screen.queryByTestId('proposal-update-market-state')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should toggle details when CollapsibleToggle is clicked', () => {
|
it('should toggle details when CollapsibleToggle is clicked', () => {
|
||||||
render(<ProposalUpdateMarketState proposal={suspendProposal} />);
|
render(<ProposalUpdateMarketState change={suspendProposal} />);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
screen.queryByTestId('proposal-update-market-state-table')
|
screen.queryByTestId('proposal-update-market-state-table')
|
||||||
@ -94,7 +81,7 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display suspend market information when showDetails is true', () => {
|
it('should display suspend market information when showDetails is true', () => {
|
||||||
render(<ProposalUpdateMarketState proposal={suspendProposal} />);
|
render(<ProposalUpdateMarketState change={suspendProposal} />);
|
||||||
|
|
||||||
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
||||||
|
|
||||||
@ -103,7 +90,7 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display resume market information when showDetails is true', () => {
|
it('should display resume market information when showDetails is true', () => {
|
||||||
render(<ProposalUpdateMarketState proposal={resumeProposal} />);
|
render(<ProposalUpdateMarketState change={resumeProposal} />);
|
||||||
|
|
||||||
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
||||||
|
|
||||||
@ -112,7 +99,7 @@ describe('<ProposalUpdateMarketState />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display terminate market information when showDetails is true', () => {
|
it('should display terminate market information when showDetails is true', () => {
|
||||||
render(<ProposalUpdateMarketState proposal={terminateProposal} />);
|
render(<ProposalUpdateMarketState change={terminateProposal} />);
|
||||||
|
|
||||||
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
fireEvent.click(screen.getByTestId('proposal-market-data-toggle'));
|
||||||
|
|
||||||
|
@ -8,29 +8,27 @@ import { Row } from '@vegaprotocol/markets';
|
|||||||
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';
|
import { type UpdateMarketStatesFragment } from '../../__generated__/Proposals';
|
||||||
|
|
||||||
interface ProposalUpdateMarketStateProps {
|
interface ProposalUpdateMarketStateProps {
|
||||||
proposal: Proposal | null;
|
change: UpdateMarketStatesFragment | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalUpdateMarketState = ({
|
export const ProposalUpdateMarketState = ({
|
||||||
proposal,
|
change,
|
||||||
}: ProposalUpdateMarketStateProps) => {
|
}: ProposalUpdateMarketStateProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
let market;
|
let market;
|
||||||
let isTerminate = false;
|
let isTerminate = false;
|
||||||
|
|
||||||
if (!proposal) {
|
if (!change) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proposal?.terms.change.__typename === 'UpdateMarketState') {
|
if (change.__typename === 'UpdateMarketState') {
|
||||||
market = proposal?.terms?.change?.market;
|
market = change?.market;
|
||||||
isTerminate =
|
isTerminate = change?.updateType === 'MARKET_STATE_UPDATE_TYPE_TERMINATE';
|
||||||
proposal?.terms?.change?.updateType ===
|
|
||||||
'MARKET_STATE_UPDATE_TYPE_TERMINATE';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -45,7 +43,7 @@ export const ProposalUpdateMarketState = ({
|
|||||||
|
|
||||||
{showDetails && (
|
{showDetails && (
|
||||||
<RoundedWrapper paddingBottom={true} marginBottomLarge={true}>
|
<RoundedWrapper paddingBottom={true} marginBottomLarge={true}>
|
||||||
{proposal?.terms.change.__typename === 'UpdateMarketState' && (
|
{change.__typename === 'UpdateMarketState' && (
|
||||||
<KeyValueTable data-testid="proposal-update-market-state-table">
|
<KeyValueTable data-testid="proposal-update-market-state-table">
|
||||||
<KeyValueTableRow>
|
<KeyValueTableRow>
|
||||||
{t('marketId')}
|
{t('marketId')}
|
||||||
@ -59,10 +57,10 @@ export const ProposalUpdateMarketState = ({
|
|||||||
{t('marketCode')}
|
{t('marketCode')}
|
||||||
{market?.tradableInstrument?.instrument?.code}
|
{market?.tradableInstrument?.instrument?.code}
|
||||||
</KeyValueTableRow>
|
</KeyValueTableRow>
|
||||||
{isTerminate && (
|
{isTerminate && market && (
|
||||||
<Row
|
<Row
|
||||||
field="termination-price"
|
field="termination-price"
|
||||||
value={proposal?.terms?.change?.price}
|
value={change?.price}
|
||||||
assetSymbol={
|
assetSymbol={
|
||||||
market?.tradableInstrument?.instrument?.product
|
market?.tradableInstrument?.instrument?.product
|
||||||
?.__typename === 'Future' ||
|
?.__typename === 'Future' ||
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { ProposalVolumeDiscountProgramDetails } from './proposal-volume-discount-program-details';
|
import { ProposalVolumeDiscountProgramDetails } from './proposal-volume-discount-program-details';
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
|
|
||||||
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
||||||
useAppState: () => ({
|
useAppState: () => ({
|
||||||
@ -10,10 +9,8 @@ jest.mock('../../../../contexts/app-state/app-state-context', () => ({
|
|||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const mockReferralProposal = generateProposal({
|
const mockChange = {
|
||||||
terms: {
|
__typename: 'UpdateVolumeDiscountProgram' as const,
|
||||||
change: {
|
|
||||||
__typename: 'UpdateVolumeDiscountProgram',
|
|
||||||
benefitTiers: [
|
benefitTiers: [
|
||||||
{
|
{
|
||||||
minimumRunningNotionalTakerVolume: '10000',
|
minimumRunningNotionalTakerVolume: '10000',
|
||||||
@ -50,55 +47,18 @@ const mockReferralProposal = generateProposal({
|
|||||||
],
|
],
|
||||||
endOfProgramTimestamp: '1970-01-01T00:00:01.791568493Z',
|
endOfProgramTimestamp: '1970-01-01T00:00:01.791568493Z',
|
||||||
windowLength: 7,
|
windowLength: 7,
|
||||||
},
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ProposalVolumeDiscountProgramDetails', () => {
|
describe('ProposalVolumeDiscountProgramDetails', () => {
|
||||||
it('should not render if proposal is null', () => {
|
it('should not render if proposal is null', () => {
|
||||||
render(<ProposalVolumeDiscountProgramDetails proposal={null} />);
|
render(<ProposalVolumeDiscountProgramDetails change={null} />);
|
||||||
expect(
|
|
||||||
screen.queryByTestId('proposal-volume-discount-program-details')
|
|
||||||
).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render if __typename is not UpdateVolumeDiscountProgram', () => {
|
|
||||||
const updateMarketProposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
render(
|
|
||||||
<ProposalVolumeDiscountProgramDetails proposal={updateMarketProposal} />
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
screen.queryByTestId('proposal-volume-discount-program-details')
|
|
||||||
).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render if there are no relevant fields', () => {
|
|
||||||
const incompleteProposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateVolumeDiscountProgram',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
render(
|
|
||||||
<ProposalVolumeDiscountProgramDetails proposal={incompleteProposal} />
|
|
||||||
);
|
|
||||||
expect(
|
expect(
|
||||||
screen.queryByTestId('proposal-volume-discount-program-details')
|
screen.queryByTestId('proposal-volume-discount-program-details')
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render relevant fields if present', () => {
|
it('should render relevant fields if present', () => {
|
||||||
render(
|
render(<ProposalVolumeDiscountProgramDetails change={mockChange} />);
|
||||||
<ProposalVolumeDiscountProgramDetails proposal={mockReferralProposal} />
|
|
||||||
);
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByTestId('proposal-volume-discount-program-window-length')
|
screen.getByTestId('proposal-volume-discount-program-window-length')
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
@ -11,10 +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';
|
import { type UpdateVolumeDiscountProgramsFragment } from '../../__generated__/Proposals';
|
||||||
|
|
||||||
interface ProposalReferralProgramDetailsProps {
|
interface ProposalReferralProgramDetailsProps {
|
||||||
proposal: Proposal | null;
|
change: UpdateVolumeDiscountProgramsFragment | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const formatVolumeDiscountFactor = (value: string) => {
|
export const formatVolumeDiscountFactor = (value: string) => {
|
||||||
@ -22,16 +22,16 @@ export const formatVolumeDiscountFactor = (value: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ProposalVolumeDiscountProgramDetails = ({
|
export const ProposalVolumeDiscountProgramDetails = ({
|
||||||
proposal,
|
change,
|
||||||
}: ProposalReferralProgramDetailsProps) => {
|
}: ProposalReferralProgramDetailsProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (proposal?.terms?.change?.__typename !== 'UpdateVolumeDiscountProgram') {
|
if (change?.__typename !== 'UpdateVolumeDiscountProgram') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const benefitTiers = proposal?.terms?.change?.benefitTiers;
|
const benefitTiers = change.benefitTiers;
|
||||||
const windowLength = proposal?.terms?.change?.windowLength;
|
const windowLength = change?.windowLength;
|
||||||
const endOfProgramTimestamp = proposal?.terms?.change?.endOfProgramTimestamp;
|
const endOfProgramTimestamp = change?.endOfProgramTimestamp;
|
||||||
|
|
||||||
if (!benefitTiers && !windowLength && !endOfProgramTimestamp) {
|
if (!benefitTiers && !windowLength && !endOfProgramTimestamp) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
import { type ProposalTermsFieldsFragment } from '../../__generated__/Proposals';
|
||||||
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
import { ListAsset } from '../list-asset';
|
||||||
|
import { ProposalAssetDetails } from '../proposal-asset-details';
|
||||||
|
import { ProposalMarketChanges } from '../proposal-market-changes';
|
||||||
|
import { ProposalMarketData } from '../proposal-market-data';
|
||||||
|
import { ProposalReferralProgramDetails } from '../proposal-referral-program-details';
|
||||||
|
import {
|
||||||
|
ProposalCancelTransferDetails,
|
||||||
|
ProposalTransferDetails,
|
||||||
|
} from '../proposal-transfer';
|
||||||
|
import { ProposalUpdateBenefitTiers } from '../proposal-update-benefit-tiers';
|
||||||
|
import { ProposalUpdateMarketState } from '../proposal-update-market-state';
|
||||||
|
import { ProposalVolumeDiscountProgramDetails } from '../proposal-volume-discount-program-details';
|
||||||
|
|
||||||
|
export const ProposalChangeDetails = ({
|
||||||
|
proposal,
|
||||||
|
terms,
|
||||||
|
restData,
|
||||||
|
}: {
|
||||||
|
proposal: Proposal | BatchProposal;
|
||||||
|
terms: ProposalTermsFieldsFragment;
|
||||||
|
// eslint-disable-next-line
|
||||||
|
restData: any;
|
||||||
|
}) => {
|
||||||
|
switch (terms.change.__typename) {
|
||||||
|
case 'NewAsset': {
|
||||||
|
if (proposal.id && terms.change.source.__typename === 'ERC20') {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<ListAsset
|
||||||
|
assetId={proposal.id}
|
||||||
|
withdrawalThreshold={terms.change.source.withdrawThreshold}
|
||||||
|
lifetimeLimit={terms.change.source.lifetimeLimit}
|
||||||
|
/>
|
||||||
|
<ProposalAssetDetails change={terms.change} assetId={proposal.id} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'UpdateAsset': {
|
||||||
|
if (proposal.id) {
|
||||||
|
return (
|
||||||
|
<ProposalAssetDetails
|
||||||
|
change={terms.change}
|
||||||
|
assetId={terms.change.assetId}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'NewMarket': {
|
||||||
|
if (proposal.id) {
|
||||||
|
return <ProposalMarketData proposalId={proposal.id} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'UpdateMarket': {
|
||||||
|
if (proposal.id) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<ProposalMarketData proposalId={proposal.id} />
|
||||||
|
<ProposalMarketChanges
|
||||||
|
marketId={terms.change.marketId}
|
||||||
|
updatedProposal={
|
||||||
|
restData?.data?.proposal?.terms?.updateMarket?.changes
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'NewTransfer': {
|
||||||
|
if (proposal.id) {
|
||||||
|
return <ProposalTransferDetails proposalId={proposal.id} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'CancelTransfer': {
|
||||||
|
if (proposal.id) {
|
||||||
|
return <ProposalCancelTransferDetails proposalId={proposal.id} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'UpdateMarketState': {
|
||||||
|
return <ProposalUpdateMarketState change={terms.change} />;
|
||||||
|
}
|
||||||
|
case 'UpdateReferralProgram': {
|
||||||
|
return <ProposalReferralProgramDetails change={terms.change} />;
|
||||||
|
}
|
||||||
|
case 'UpdateVolumeDiscountProgram': {
|
||||||
|
return <ProposalVolumeDiscountProgramDetails change={terms.change} />;
|
||||||
|
}
|
||||||
|
case 'UpdateNetworkParameter': {
|
||||||
|
if (
|
||||||
|
terms.change.networkParameter.key === 'rewards.vesting.benefitTiers' ||
|
||||||
|
terms.change.networkParameter.key ===
|
||||||
|
'rewards.activityStreak.benefitTiers'
|
||||||
|
) {
|
||||||
|
return <ProposalUpdateBenefitTiers change={terms.change} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
case 'NewFreeform':
|
||||||
|
case 'NewSpotMarket':
|
||||||
|
case 'UpdateSpotMarket': {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -6,7 +6,6 @@ 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 { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { mockNetworkParams } from '../../test-helpers/mocks';
|
|
||||||
import { type Proposal as IProposal } from '../../types';
|
import { type Proposal as IProposal } from '../../types';
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/network-parameters', () => ({
|
jest.mock('@vegaprotocol/network-parameters', () => ({
|
||||||
@ -38,6 +37,12 @@ jest.mock('../list-asset', () => ({
|
|||||||
ListAsset: () => <div data-testid="proposal-list-asset"></div>,
|
ListAsset: () => <div data-testid="proposal-list-asset"></div>,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock('./proposal-change-details', () => ({
|
||||||
|
ProposalChangeDetails: () => (
|
||||||
|
<div data-testid="proposal-change-details"></div>
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
const vegaWalletConfig: VegaWalletConfig = {
|
const vegaWalletConfig: VegaWalletConfig = {
|
||||||
network: 'TESTNET',
|
network: 'TESTNET',
|
||||||
vegaUrl: 'https://vega.xyz',
|
vegaUrl: 'https://vega.xyz',
|
||||||
@ -56,11 +61,7 @@ const renderComponent = (proposal: IProposal) => {
|
|||||||
<MemoryRouter>
|
<MemoryRouter>
|
||||||
<MockedProvider>
|
<MockedProvider>
|
||||||
<VegaWalletProvider config={vegaWalletConfig}>
|
<VegaWalletProvider config={vegaWalletConfig}>
|
||||||
<Proposal
|
<Proposal restData={{}} proposal={proposal} />
|
||||||
restData={{}}
|
|
||||||
proposal={proposal}
|
|
||||||
networkParams={mockNetworkParams}
|
|
||||||
/>
|
|
||||||
</VegaWalletProvider>
|
</VegaWalletProvider>
|
||||||
</MockedProvider>
|
</MockedProvider>
|
||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
@ -99,27 +100,6 @@ it('renders each section', async () => {
|
|||||||
expect(await screen.findByTestId('proposal-header')).toBeInTheDocument();
|
expect(await screen.findByTestId('proposal-header')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
|
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('proposal-json')).toBeInTheDocument();
|
expect(screen.getByTestId('proposal-json')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-change-details')).toBeInTheDocument();
|
||||||
expect(screen.queryByTestId('proposal-list-asset')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('proposal-list-asset')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders whitelist section if proposal is new asset and source is erc20', async () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'NewAsset',
|
|
||||||
name: 'foo',
|
|
||||||
symbol: 'FOO',
|
|
||||||
decimals: 18,
|
|
||||||
quantum: '1',
|
|
||||||
source: {
|
|
||||||
__typename: 'ERC20',
|
|
||||||
lifetimeLimit: '1',
|
|
||||||
withdrawThreshold: '100',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
renderComponent(proposal);
|
|
||||||
|
|
||||||
expect(screen.getByTestId('proposal-list-asset')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
@ -5,152 +5,25 @@ import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
|||||||
import { ProposalDescription } from '../proposal-description';
|
import { ProposalDescription } from '../proposal-description';
|
||||||
import { ProposalChangeTable } from '../proposal-change-table';
|
import { ProposalChangeTable } from '../proposal-change-table';
|
||||||
import { ProposalJson } from '../proposal-json';
|
import { ProposalJson } from '../proposal-json';
|
||||||
import { ProposalAssetDetails } from '../proposal-asset-details';
|
|
||||||
import { ProposalReferralProgramDetails } from '../proposal-referral-program-details';
|
|
||||||
import { ProposalVolumeDiscountProgramDetails } from '../proposal-volume-discount-program-details';
|
|
||||||
import { UserVote } from '../vote-details';
|
import { UserVote } from '../vote-details';
|
||||||
import { ListAsset } from '../list-asset';
|
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { ProposalMarketData } from '../proposal-market-data';
|
|
||||||
import { type MarketInfo } from '@vegaprotocol/markets';
|
|
||||||
import { type AssetQuery } from '@vegaprotocol/assets';
|
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { ProposalMarketChanges } from '../proposal-market-changes';
|
|
||||||
import { ProposalUpdateMarketState } from '../proposal-update-market-state';
|
|
||||||
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 { type Proposal as IProposal, type BatchProposal } from '../../types';
|
||||||
ProposalCancelTransferDetails,
|
import { ProposalChangeDetails } from './proposal-change-details';
|
||||||
ProposalTransferDetails,
|
|
||||||
} from '../proposal-transfer';
|
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
|
||||||
import { ProposalUpdateBenefitTiers } from '../proposal-update-benefit-tiers';
|
|
||||||
import { type Proposal as IProposal } from '../../types';
|
|
||||||
|
|
||||||
export interface ProposalProps {
|
export interface ProposalProps {
|
||||||
proposal: IProposal;
|
proposal: IProposal | BatchProposal;
|
||||||
networkParams: Partial<NetworkParamsResult>;
|
|
||||||
marketData?: MarketInfo | null;
|
|
||||||
parentMarketData?: MarketInfo | null;
|
|
||||||
assetData?: AssetQuery | null;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
restData: any;
|
restData: any;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
originalMarketProposalRestData?: any;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal?: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Proposal = ({
|
export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
||||||
proposal,
|
|
||||||
networkParams,
|
|
||||||
restData,
|
|
||||||
marketData,
|
|
||||||
parentMarketData,
|
|
||||||
assetData,
|
|
||||||
originalMarketProposalRestData,
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal,
|
|
||||||
}: ProposalProps) => {
|
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { submit, Dialog, finalizedVote, transaction } = useVoteSubmit();
|
const { submit, Dialog, finalizedVote, transaction } = useVoteSubmit();
|
||||||
const { voteState, voteDatetime } = useUserVote(proposal?.id, finalizedVote);
|
const { voteState, voteDatetime } = useUserVote(proposal?.id, finalizedVote);
|
||||||
|
|
||||||
if (!proposal) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let asset = assetData
|
|
||||||
? removePaginationWrapper(assetData.assetsConnection?.edges)[0]
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const originalAsset = asset;
|
|
||||||
|
|
||||||
if (proposal.terms.change.__typename === 'UpdateAsset' && asset) {
|
|
||||||
asset = {
|
|
||||||
...asset,
|
|
||||||
quantum: proposal.terms.change.quantum,
|
|
||||||
source: { ...asset.source },
|
|
||||||
};
|
|
||||||
|
|
||||||
if (asset.source.__typename === 'ERC20') {
|
|
||||||
asset.source.lifetimeLimit = proposal.terms.change.source.lifetimeLimit;
|
|
||||||
asset.source.withdrawThreshold =
|
|
||||||
proposal.terms.change.source.withdrawThreshold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let minVoterBalance = null;
|
|
||||||
|
|
||||||
if (networkParams) {
|
|
||||||
switch (proposal.terms.change.__typename) {
|
|
||||||
case 'UpdateMarket':
|
|
||||||
case 'UpdateMarketState':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_updateMarket_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'NewMarket':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_market_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'NewAsset':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_asset_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'UpdateAsset':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_updateAsset_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'UpdateNetworkParameter':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_updateNetParam_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'NewFreeform':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_freeform_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'NewTransfer':
|
|
||||||
// TODO: check minVoterBalance for 'NewTransfer'
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_freeform_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'CancelTransfer':
|
|
||||||
// TODO: check minVoterBalance for 'CancelTransfer'
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_freeform_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'UpdateReferralProgram':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_referralProgram_minVoterBalance;
|
|
||||||
break;
|
|
||||||
case 'UpdateVolumeDiscountProgram':
|
|
||||||
minVoterBalance =
|
|
||||||
networkParams.governance_proposal_VolumeDiscountProgram_minVoterBalance;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show governance transfer details only if the GOVERNANCE_TRANSFERS flag is on.
|
|
||||||
const governanceTransferDetails = featureFlags.GOVERNANCE_TRANSFERS && (
|
|
||||||
<>
|
|
||||||
{proposal.terms.change.__typename === 'NewTransfer' && (
|
|
||||||
/** Governance New Transfer Details */
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalTransferDetails proposal={proposal} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'CancelTransfer' && (
|
|
||||||
/** Governance Cancel Transfer Details */
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalCancelTransferDetails proposal={proposal} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section data-testid="proposal">
|
<section data-testid="proposal">
|
||||||
<div className="flex items-center gap-1 mb-6">
|
<div className="flex items-center gap-1 mb-6">
|
||||||
@ -181,91 +54,36 @@ export const Proposal = ({
|
|||||||
<ProposalChangeTable proposal={proposal} />
|
<ProposalChangeTable proposal={proposal} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'NewAsset' &&
|
|
||||||
proposal.terms.change.source.__typename === 'ERC20' &&
|
|
||||||
proposal.id ? (
|
|
||||||
<ListAsset
|
|
||||||
assetId={proposal.id}
|
|
||||||
withdrawalThreshold={proposal.terms.change.source.withdrawThreshold}
|
|
||||||
lifetimeLimit={proposal.terms.change.source.lifetimeLimit}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<ProposalDescription description={proposal.rationale.description} />
|
<ProposalDescription description={proposal.rationale.description} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{marketData && (
|
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<ProposalMarketData
|
{proposal.__typename === 'Proposal' ? (
|
||||||
marketData={marketData}
|
<ProposalChangeDetails
|
||||||
parentMarketData={parentMarketData ? parentMarketData : undefined}
|
proposal={proposal}
|
||||||
|
terms={proposal.terms}
|
||||||
|
restData={restData}
|
||||||
/>
|
/>
|
||||||
</div>
|
) : proposal.__typename === 'BatchProposal' ? (
|
||||||
)}
|
proposal.subProposals?.map((p, i) => {
|
||||||
|
if (!p?.terms) return null;
|
||||||
{proposal.terms.change.__typename === 'UpdateMarketState' && (
|
return (
|
||||||
<div className="mb-4">
|
<ProposalChangeDetails
|
||||||
<ProposalUpdateMarketState proposal={proposal} />
|
key={i}
|
||||||
</div>
|
proposal={proposal}
|
||||||
)}
|
terms={p.terms}
|
||||||
|
restData={restData}
|
||||||
{proposal.terms.change.__typename === 'UpdateMarket' && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalMarketChanges
|
|
||||||
originalProposal={
|
|
||||||
originalMarketProposalRestData?.data?.proposal?.terms?.newMarket
|
|
||||||
?.changes || {}
|
|
||||||
}
|
|
||||||
latestEnactedProposal={
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal?.node?.proposal?.terms
|
|
||||||
?.updateMarket?.changes || {}
|
|
||||||
}
|
|
||||||
updatedProposal={
|
|
||||||
restData?.data?.proposal?.terms?.updateMarket?.changes || {}
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{(proposal.terms.change.__typename === 'NewAsset' ||
|
|
||||||
proposal.terms.change.__typename === 'UpdateAsset') &&
|
|
||||||
asset && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalAssetDetails asset={asset} originalAsset={originalAsset} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'UpdateReferralProgram' && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalReferralProgramDetails proposal={proposal} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'UpdateVolumeDiscountProgram' && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalVolumeDiscountProgramDetails proposal={proposal} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{proposal.terms.change.__typename === 'UpdateNetworkParameter' &&
|
|
||||||
proposal.terms.change.networkParameter.key.slice(-13) ===
|
|
||||||
'.benefitTiers' && (
|
|
||||||
<div className="mb-4">
|
|
||||||
<ProposalUpdateBenefitTiers proposal={proposal} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{governanceTransferDetails}
|
|
||||||
|
|
||||||
<div className="mb-10">
|
<div className="mb-10">
|
||||||
<RoundedWrapper paddingBottom={true}>
|
<RoundedWrapper paddingBottom={true}>
|
||||||
<UserVote
|
<UserVote
|
||||||
proposal={proposal}
|
proposal={proposal}
|
||||||
minVoterBalance={minVoterBalance}
|
|
||||||
spamProtectionMinTokens={
|
|
||||||
networkParams?.spam_protection_voting_min_tokens
|
|
||||||
}
|
|
||||||
submit={submit}
|
submit={submit}
|
||||||
dialog={Dialog}
|
dialog={Dialog}
|
||||||
transaction={transaction}
|
transaction={transaction}
|
||||||
|
@ -1,149 +1,25 @@
|
|||||||
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 { VegaWalletContext } from '@vegaprotocol/wallet';
|
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||||
import { type MockedResponse } 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 { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types';
|
|
||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
|
||||||
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
import { ProposalsListItemDetails } from './proposals-list-item-details';
|
||||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
import { mockWalletContext } from '../../test-helpers/mocks';
|
||||||
import {
|
|
||||||
mockWalletContext,
|
|
||||||
networkParamsQueryMock,
|
|
||||||
fiveMinutes,
|
|
||||||
fiveHours,
|
|
||||||
fiveDays,
|
|
||||||
lastWeek,
|
|
||||||
nextWeek,
|
|
||||||
} from '../../test-helpers/mocks';
|
|
||||||
import { type Proposal } from '../../types';
|
|
||||||
|
|
||||||
const renderComponent = (
|
const renderComponent = (id: string) =>
|
||||||
proposal: Proposal,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
mocks: MockedResponse<any>[] = [networkParamsQueryMock]
|
|
||||||
) =>
|
|
||||||
render(
|
render(
|
||||||
<Router>
|
<Router>
|
||||||
<MockedProvider mocks={mocks}>
|
|
||||||
<AppStateProvider>
|
|
||||||
<VegaWalletContext.Provider value={mockWalletContext}>
|
<VegaWalletContext.Provider value={mockWalletContext}>
|
||||||
<ProposalsListItemDetails proposal={proposal} />
|
<ProposalsListItemDetails id={id} />
|
||||||
</VegaWalletContext.Provider>
|
</VegaWalletContext.Provider>
|
||||||
</AppStateProvider>
|
|
||||||
</MockedProvider>
|
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
jest.setSystemTime(0);
|
|
||||||
});
|
|
||||||
afterAll(() => {
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Proposals list item details', () => {
|
describe('Proposals list item details', () => {
|
||||||
it('Renders proposal state: Enacted', () => {
|
it('links to single proposal page', () => {
|
||||||
renderComponent(
|
const proposalId = 'proposal-id';
|
||||||
generateProposal({
|
renderComponent(proposalId);
|
||||||
state: ProposalState.STATE_ENACTED,
|
expect(screen.getByRole('link')).toHaveAttribute(
|
||||||
terms: {
|
'href',
|
||||||
enactmentDatetime: lastWeek.toString(),
|
expect.stringContaining(proposalId)
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
format(lastWeek, DATE_FORMAT_DETAILED)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Passed', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_PASSED,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: lastWeek.toString(),
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
`Enacts on ${format(nextWeek, DATE_FORMAT_DETAILED)}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Waiting for node vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_WAITING_FOR_NODE_VOTE,
|
|
||||||
terms: {
|
|
||||||
enactmentDatetime: nextWeek.toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
`Enacts on ${format(nextWeek, DATE_FORMAT_DETAILED)}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Open - 5 minutes left to vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: fiveMinutes.toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
'5 minutes left to vote'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Open - 5 hours left to vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: fiveHours.toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
'5 hours left to vote'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Open - 5 days left to vote', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_OPEN,
|
|
||||||
terms: {
|
|
||||||
closingDatetime: fiveDays.toString(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-details')).toHaveTextContent(
|
|
||||||
'5 days left to vote'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal state: Rejected', () => {
|
|
||||||
renderComponent(
|
|
||||||
generateProposal({
|
|
||||||
state: ProposalState.STATE_REJECTED,
|
|
||||||
terms: {
|
|
||||||
enactmentDatetime: lastWeek.toString(),
|
|
||||||
},
|
|
||||||
rejectionReason:
|
|
||||||
ProposalRejectionReason.PROPOSAL_ERROR_INVALID_FUTURE_PRODUCT,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
|
||||||
'Invalid future product'
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,101 +1,16 @@
|
|||||||
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 { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
|
||||||
import {
|
|
||||||
ProposalRejectionReasonMapping,
|
|
||||||
ProposalState,
|
|
||||||
} from '@vegaprotocol/types';
|
|
||||||
import Routes from '../../../routes';
|
import Routes from '../../../routes';
|
||||||
import { type Proposal } from '../../types';
|
|
||||||
|
|
||||||
export const ProposalsListItemDetails = ({
|
export const ProposalsListItemDetails = ({ id }: { id: string }) => {
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: Proposal;
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const state = proposal?.state;
|
|
||||||
const nowToEnactmentInHours = differenceInHours(
|
|
||||||
new Date(proposal?.terms.closingDatetime),
|
|
||||||
new Date()
|
|
||||||
);
|
|
||||||
|
|
||||||
let voteDetails: ReactNode;
|
|
||||||
let voteStatus: ReactNode;
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case ProposalState.STATE_ENACTED: {
|
|
||||||
voteDetails =
|
|
||||||
proposal?.terms.enactmentDatetime &&
|
|
||||||
t('enactedOn{{date}}', {
|
|
||||||
enactmentDate:
|
|
||||||
proposal?.terms.enactmentDatetime &&
|
|
||||||
format(
|
|
||||||
new Date(proposal?.terms.enactmentDatetime),
|
|
||||||
DATE_FORMAT_DETAILED
|
|
||||||
),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ProposalState.STATE_PASSED: {
|
|
||||||
voteDetails =
|
|
||||||
proposal?.terms.change.__typename !== 'NewFreeform' &&
|
|
||||||
t('enactsOn{{date}}', {
|
|
||||||
enactmentDate:
|
|
||||||
proposal?.terms.enactmentDatetime &&
|
|
||||||
format(
|
|
||||||
new Date(proposal.terms.enactmentDatetime),
|
|
||||||
DATE_FORMAT_DETAILED
|
|
||||||
),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ProposalState.STATE_WAITING_FOR_NODE_VOTE: {
|
|
||||||
voteDetails =
|
|
||||||
proposal?.terms.change.__typename !== 'NewFreeform' &&
|
|
||||||
t('enactsOn{{date}}', {
|
|
||||||
enactmentDate:
|
|
||||||
proposal?.terms.enactmentDatetime &&
|
|
||||||
format(
|
|
||||||
new Date(proposal.terms.enactmentDatetime),
|
|
||||||
DATE_FORMAT_DETAILED
|
|
||||||
),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ProposalState.STATE_OPEN: {
|
|
||||||
voteDetails = (
|
|
||||||
<span className={nowToEnactmentInHours < 6 ? 'text-vega-orange' : ''}>
|
|
||||||
{formatDistanceToNowStrict(new Date(proposal?.terms.closingDatetime))}{' '}
|
|
||||||
{t('left to vote')}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ProposalState.STATE_REJECTED: {
|
|
||||||
voteStatus = proposal?.rejectionReason && (
|
|
||||||
<>{t(ProposalRejectionReasonMapping[proposal.rejectionReason])}</>
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-4 items-start text-sm">
|
<div className="mt-4 items-start text-sm">
|
||||||
<div className="flex items-center gap-2 text-vega-light-300 mb-2">
|
<Link to={`${Routes.PROPOSALS}/${id}`}>
|
||||||
{voteDetails && <span data-testid="vote-details">{voteDetails}</span>}
|
|
||||||
{voteDetails && voteStatus && <span>·</span>}
|
|
||||||
{voteStatus && <span data-testid="vote-status">{voteStatus}</span>}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{proposal?.id && (
|
|
||||||
<Link to={`${Routes.PROPOSALS}/${proposal.id}`}>
|
|
||||||
<Button data-testid="view-proposal-btn">{t('viewDetails')}</Button>
|
<Button data-testid="view-proposal-btn">{t('viewDetails')}</Button>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -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 Proposal } from '../../types';
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalsListItemProps {
|
interface ProposalsListItemProps {
|
||||||
proposal?: Proposal | null;
|
proposal?: Proposal | BatchProposal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
||||||
@ -16,7 +16,7 @@ export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => {
|
|||||||
<li id={proposal.id} data-testid="proposals-list-item">
|
<li id={proposal.id} data-testid="proposals-list-item">
|
||||||
<RoundedWrapper paddingBottom={true} heightFull={true}>
|
<RoundedWrapper paddingBottom={true} heightFull={true}>
|
||||||
<ProposalHeader proposal={proposal} voteState={voteState} />
|
<ProposalHeader proposal={proposal} voteState={voteState} />
|
||||||
<ProposalsListItemDetails proposal={proposal} />
|
<ProposalsListItemDetails id={proposal.id} />
|
||||||
</RoundedWrapper>
|
</RoundedWrapper>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
@ -3,14 +3,12 @@ import {
|
|||||||
generateProtocolUpgradeProposal,
|
generateProtocolUpgradeProposal,
|
||||||
} from '../../test-helpers/generate-proposals';
|
} from '../../test-helpers/generate-proposals';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
|
||||||
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 { ProposalsList } from './proposals-list';
|
import { ProposalsList } from './proposals-list';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { fireEvent, render, screen, within } from '@testing-library/react';
|
import { fireEvent, render, screen, within } from '@testing-library/react';
|
||||||
import {
|
import {
|
||||||
mockWalletContext,
|
|
||||||
networkParamsQueryMock,
|
networkParamsQueryMock,
|
||||||
lastWeek,
|
lastWeek,
|
||||||
nextWeek,
|
nextWeek,
|
||||||
@ -20,6 +18,16 @@ import {
|
|||||||
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
|
jest.mock('../vote-details/use-user-vote', () => ({
|
||||||
|
useUserVote: jest.fn().mockImplementation(() => ({ voteState: 'NotCast' })),
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock('../proposals-list-item', () => ({
|
||||||
|
ProposalsListItem: ({ proposal }: { proposal: { id: string } }) => (
|
||||||
|
<div data-testid="proposals-list-item" id={proposal.id} />
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
const openProposalClosesNextMonth = generateProposal({
|
const openProposalClosesNextMonth = generateProposal({
|
||||||
id: 'proposal1',
|
id: 'proposal1',
|
||||||
state: ProposalState.STATE_OPEN,
|
state: ProposalState.STATE_OPEN,
|
||||||
@ -69,12 +77,10 @@ const renderComponent = (
|
|||||||
<Router>
|
<Router>
|
||||||
<MockedProvider mocks={[networkParamsQueryMock]}>
|
<MockedProvider mocks={[networkParamsQueryMock]}>
|
||||||
<AppStateProvider>
|
<AppStateProvider>
|
||||||
<VegaWalletContext.Provider value={mockWalletContext}>
|
|
||||||
<ProposalsList
|
<ProposalsList
|
||||||
proposals={proposals}
|
proposals={proposals}
|
||||||
protocolUpgradeProposals={protocolUpgradeProposals || []}
|
protocolUpgradeProposals={protocolUpgradeProposals || []}
|
||||||
/>
|
/>
|
||||||
</VegaWalletContext.Provider>
|
|
||||||
</AppStateProvider>
|
</AppStateProvider>
|
||||||
</MockedProvider>
|
</MockedProvider>
|
||||||
</Router>
|
</Router>
|
||||||
@ -88,10 +94,6 @@ afterAll(() => {
|
|||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('../vote-details/use-user-vote', () => ({
|
|
||||||
useUserVote: jest.fn().mockImplementation(() => ({ voteState: 'NotCast' })),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Proposals list', () => {
|
describe('Proposals list', () => {
|
||||||
it('Render a page title and link to the make proposal form', async () => {
|
it('Render a page title and link to the make proposal form', async () => {
|
||||||
render(renderComponent([]));
|
render(renderComponent([]));
|
||||||
|
@ -11,19 +11,20 @@ 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 { ExternalLinks } from '@vegaprotocol/environment';
|
import { ExternalLinks } from '@vegaprotocol/environment';
|
||||||
import { type ProposalFieldsFragment } from '../../proposals/__generated__/Proposals';
|
|
||||||
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import { type Proposal } from '../../types';
|
import { type BatchProposal, type Proposal } from '../../types';
|
||||||
|
|
||||||
|
type Proposals = Array<Proposal | BatchProposal>;
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: Proposal[];
|
proposals: Proposals;
|
||||||
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
lastBlockHeight?: string;
|
lastBlockHeight?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SortedProposalsProps {
|
interface SortedProposalsProps {
|
||||||
open: Proposal[];
|
open: Proposals;
|
||||||
closed: Proposal[];
|
closed: Proposals;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SortedProtocolUpgradeProposalsProps {
|
interface SortedProtocolUpgradeProposalsProps {
|
||||||
@ -31,15 +32,26 @@ interface SortedProtocolUpgradeProposalsProps {
|
|||||||
closed: ProtocolUpgradeProposalFieldsFragment[];
|
closed: ProtocolUpgradeProposalFieldsFragment[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const orderByDate = (arr: Proposal[]) =>
|
export const orderByDate = (arr: Proposals) =>
|
||||||
orderBy(
|
orderBy(
|
||||||
arr,
|
arr,
|
||||||
[
|
[
|
||||||
(p) =>
|
(p) => {
|
||||||
p?.terms?.enactmentDatetime
|
if (p.__typename === 'BatchProposal') {
|
||||||
|
// Batch proposals can have different enactment dates, this could be improved by ordering
|
||||||
|
// by soonest enactment date in the batch
|
||||||
|
return new Date(p.batchTerms?.closingDatetime || p.datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.__typename === 'Proposal') {
|
||||||
|
return p?.terms?.enactmentDatetime
|
||||||
? new Date(p?.terms?.enactmentDatetime).getTime()
|
? new Date(p?.terms?.enactmentDatetime).getTime()
|
||||||
: // has to be defaulted to 0 because new Date(null).getTime() -> NaN which is first when ordered
|
: // has to be defaulted to 0 because new Date(null).getTime() -> NaN which is first when ordered
|
||||||
new Date(p?.terms?.closingDatetime || 0).getTime(),
|
new Date(p?.terms?.closingDatetime || 0).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('invalid proposal');
|
||||||
|
},
|
||||||
(p) => new Date(p?.datetime).getTime(),
|
(p) => new Date(p?.datetime).getTime(),
|
||||||
],
|
],
|
||||||
['asc', 'asc']
|
['asc', 'asc']
|
||||||
@ -76,18 +88,40 @@ export const ProposalsList = ({
|
|||||||
|
|
||||||
const sortedProposals: SortedProposalsProps = useMemo(() => {
|
const sortedProposals: SortedProposalsProps = useMemo(() => {
|
||||||
const initialSorting = proposals.reduce(
|
const initialSorting = proposals.reduce(
|
||||||
(acc: SortedProposalsProps, proposal) => {
|
(acc, proposal) => {
|
||||||
|
if (proposal.__typename === 'Proposal') {
|
||||||
if (isFuture(new Date(proposal?.terms.closingDatetime))) {
|
if (isFuture(new Date(proposal?.terms.closingDatetime))) {
|
||||||
acc.open.push(proposal);
|
acc.open.push(proposal);
|
||||||
} else {
|
} else {
|
||||||
acc.closed.push(proposal);
|
acc.closed.push(proposal);
|
||||||
}
|
}
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proposal.__typename === 'BatchProposal') {
|
||||||
|
if (
|
||||||
|
// this could be improved by sorting by soonest enactment date of all the
|
||||||
|
// sub proposals
|
||||||
|
isFuture(
|
||||||
|
new Date(
|
||||||
|
proposal.batchTerms?.closingDatetime || proposal.datetime
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
acc.open.push(proposal);
|
||||||
|
} else {
|
||||||
|
acc.closed.push(proposal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
open: [],
|
open: [],
|
||||||
closed: [],
|
closed: [],
|
||||||
}
|
} as SortedProposalsProps
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
open:
|
open:
|
||||||
@ -121,7 +155,7 @@ export const ProposalsList = ({
|
|||||||
};
|
};
|
||||||
}, [protocolUpgradeProposals, lastBlockHeight]);
|
}, [protocolUpgradeProposals, lastBlockHeight]);
|
||||||
|
|
||||||
const filterPredicate = (p: ProposalFieldsFragment | Proposal) =>
|
const filterPredicate = (p: Proposal | BatchProposal) =>
|
||||||
p?.id?.includes(filterString) ||
|
p?.id?.includes(filterString) ||
|
||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
import { generateProposal } from '../../test-helpers/generate-proposals';
|
import { generateProposal } from '../../test-helpers/generate-proposals';
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
|
||||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
|
||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
|
||||||
import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
|
|
||||||
import { RejectedProposalsList } from './rejected-proposals-list';
|
import { RejectedProposalsList } from './rejected-proposals-list';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import {
|
import { nextWeek, lastMonth } from '../../test-helpers/mocks';
|
||||||
mockWalletContext,
|
|
||||||
networkParamsQueryMock,
|
|
||||||
nextWeek,
|
|
||||||
lastMonth,
|
|
||||||
} from '../../test-helpers/mocks';
|
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal } from '../../types';
|
||||||
|
|
||||||
const rejectedProposalClosesNextWeek = generateProposal({
|
const rejectedProposalClosesNextWeek = generateProposal({
|
||||||
@ -36,31 +27,15 @@ const rejectedProposalClosedLastMonth = generateProposal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const renderComponent = (proposals: Proposal[]) => (
|
const renderComponent = (proposals: Proposal[]) => (
|
||||||
<Router>
|
|
||||||
<MockedProvider mocks={[networkParamsQueryMock]}>
|
|
||||||
<AppStateProvider>
|
|
||||||
<VegaWalletContext.Provider value={mockWalletContext}>
|
|
||||||
<RejectedProposalsList proposals={proposals} />
|
<RejectedProposalsList proposals={proposals} />
|
||||||
</VegaWalletContext.Provider>
|
|
||||||
</AppStateProvider>
|
|
||||||
</MockedProvider>
|
|
||||||
</Router>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
beforeAll(() => {
|
jest.mock('../proposals-list-item', () => ({
|
||||||
jest.useFakeTimers();
|
ProposalsListItem: () => <div data-testid="proposals-list-item" />,
|
||||||
jest.setSystemTime(0);
|
|
||||||
});
|
|
||||||
afterAll(() => {
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
jest.mock('../vote-details/use-user-vote', () => ({
|
|
||||||
useUserVote: jest.fn().mockImplementation(() => ({ voteState: 'NotCast' })),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Rejected proposals list', () => {
|
describe('Rejected proposals list', () => {
|
||||||
it('Renders a list of proposals', async () => {
|
it('Renders a list of proposals', () => {
|
||||||
render(
|
render(
|
||||||
renderComponent([
|
renderComponent([
|
||||||
rejectedProposalClosedLastMonth,
|
rejectedProposalClosedLastMonth,
|
||||||
@ -68,25 +43,13 @@ describe('Rejected proposals list', () => {
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
expect(screen.getAllByTestId('proposals-list-item')).toHaveLength(2);
|
||||||
const rejectedProposals = within(
|
|
||||||
screen.getByTestId('rejected-proposals')
|
|
||||||
);
|
|
||||||
const rejectedProposalsItems = rejectedProposals.getAllByTestId(
|
|
||||||
'proposals-list-item'
|
|
||||||
);
|
|
||||||
expect(rejectedProposalsItems).toHaveLength(2);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Displays text when there are no proposals', async () => {
|
it('Displays text when there are no proposals', async () => {
|
||||||
render(renderComponent([]));
|
render(renderComponent([]));
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.getByTestId('no-rejected-proposals')).toBeInTheDocument();
|
expect(screen.getByTestId('no-rejected-proposals')).toBeInTheDocument();
|
||||||
expect(
|
expect(screen.queryByTestId('rejected-proposals')).not.toBeInTheDocument();
|
||||||
screen.queryByTestId('rejected-proposals')
|
|
||||||
).not.toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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 Proposal } from '../../types';
|
import { type BatchProposal, type Proposal } from '../../types';
|
||||||
|
|
||||||
interface ProposalsListProps {
|
interface ProposalsListProps {
|
||||||
proposals: Proposal[];
|
proposals: Array<Proposal | BatchProposal>;
|
||||||
}
|
}
|
||||||
|
|
||||||
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: Proposal) =>
|
const filterPredicate = (p: Proposal | BatchProposal) =>
|
||||||
p?.id?.includes(filterString) ||
|
p?.id?.includes(filterString) ||
|
||||||
p?.party?.id?.toString().includes(filterString);
|
p?.party?.id?.toString().includes(filterString);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ describe('VoteBreakdown', () => {
|
|||||||
jest.useRealTimers();
|
jest.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders majority reached', () => {
|
it('Renders majority reached', async () => {
|
||||||
const yesVotes = 100;
|
const yesVotes = 100;
|
||||||
const noVotes = 0;
|
const noVotes = 0;
|
||||||
|
|
||||||
@ -82,10 +82,10 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('token-majority-met')).toBeInTheDocument();
|
expect(await screen.findByTestId('token-majority-met')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders majority not reached', () => {
|
it('Renders majority not reached', async () => {
|
||||||
const yesVotes = 20;
|
const yesVotes = 20;
|
||||||
const noVotes = 80;
|
const noVotes = 80;
|
||||||
|
|
||||||
@ -103,10 +103,12 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('token-majority-not-met')).toBeInTheDocument();
|
expect(
|
||||||
|
await screen.findByTestId('token-majority-not-met')
|
||||||
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders participation reached', () => {
|
it('Renders participation reached', async () => {
|
||||||
const yesVotes = 1000;
|
const yesVotes = 1000;
|
||||||
const noVotes = 0;
|
const noVotes = 0;
|
||||||
|
|
||||||
@ -124,10 +126,12 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('token-participation-met')).toBeInTheDocument();
|
expect(
|
||||||
|
await screen.findByTestId('token-participation-met')
|
||||||
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders participation not reached', () => {
|
it('Renders participation not reached', async () => {
|
||||||
const yesVotes = 0;
|
const yesVotes = 0;
|
||||||
const noVotes = 0;
|
const noVotes = 0;
|
||||||
|
|
||||||
@ -145,11 +149,11 @@ describe('VoteBreakdown', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
screen.getByTestId('token-participation-not-met')
|
await screen.findByTestId('token-participation-not-met')
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to pass by LP vote', () => {
|
it('Renders proposal state: Update market proposal - Currently expected to pass by LP vote', async () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_OPEN,
|
state: ProposalState.STATE_OPEN,
|
||||||
@ -170,12 +174,12 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
expect(await screen.findByTestId('vote-status')).toHaveTextContent(
|
||||||
'Currently expected to pass by liquidity vote'
|
'Currently expected to pass by liquidity vote'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to pass by token vote', () => {
|
it('Renders proposal state: Update market proposal - Currently expected to pass by token vote', async () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_OPEN,
|
state: ProposalState.STATE_OPEN,
|
||||||
@ -196,12 +200,12 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
expect(await screen.findByTestId('vote-status')).toHaveTextContent(
|
||||||
'Currently expected to pass by token vote'
|
'Currently expected to pass by token vote'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Renders proposal state: Update market proposal - Currently expected to fail', () => {
|
it('Renders proposal state: Update market proposal - Currently expected to fail', async () => {
|
||||||
renderComponent(
|
renderComponent(
|
||||||
generateProposal({
|
generateProposal({
|
||||||
state: ProposalState.STATE_OPEN,
|
state: ProposalState.STATE_OPEN,
|
||||||
@ -222,12 +226,12 @@ describe('VoteBreakdown', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(screen.getByTestId('vote-status')).toHaveTextContent(
|
expect(await screen.findByTestId('vote-status')).toHaveTextContent(
|
||||||
'Currently expected to fail'
|
'Currently expected to fail'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Progress bar displays status - token majority', () => {
|
it('Progress bar displays status - token majority', async () => {
|
||||||
const yesVotes = 80;
|
const yesVotes = 80;
|
||||||
const noVotes = 20;
|
const noVotes = 20;
|
||||||
|
|
||||||
@ -246,13 +250,13 @@ describe('VoteBreakdown', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const element = screen.getByTestId('token-majority-progress');
|
const element = await screen.findByTestId('token-majority-progress');
|
||||||
const style = window.getComputedStyle(element);
|
const style = window.getComputedStyle(element);
|
||||||
|
|
||||||
expect(style.width).toBe(`${yesVotes}%`);
|
expect(style.width).toBe(`${yesVotes}%`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Progress bar displays status - token participation', () => {
|
it('Progress bar displays status - token participation', async () => {
|
||||||
const yesVotes = 40;
|
const yesVotes = 40;
|
||||||
const noVotes = 20;
|
const noVotes = 20;
|
||||||
const totalVotes = yesVotes + noVotes;
|
const totalVotes = yesVotes + noVotes;
|
||||||
@ -274,13 +278,13 @@ describe('VoteBreakdown', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const element = screen.getByTestId('token-participation-progress');
|
const element = await screen.findByTestId('token-participation-progress');
|
||||||
const style = window.getComputedStyle(element);
|
const style = window.getComputedStyle(element);
|
||||||
|
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
expect(style.width).toBe(`${expectedProgress}%`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Progress bar displays status - LP majority', () => {
|
it('Progress bar displays status - LP majority', async () => {
|
||||||
const yesVotesLP = 0.8;
|
const yesVotesLP = 0.8;
|
||||||
const noVotesLP = 0.2;
|
const noVotesLP = 0.2;
|
||||||
const expectedProgress = (yesVotesLP / (yesVotesLP + noVotesLP)) * 100; // 80%
|
const expectedProgress = (yesVotesLP / (yesVotesLP + noVotesLP)) * 100; // 80%
|
||||||
@ -307,12 +311,12 @@ describe('VoteBreakdown', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const element = screen.getByTestId('lp-majority-progress');
|
const element = await screen.findByTestId('lp-majority-progress');
|
||||||
const style = window.getComputedStyle(element);
|
const style = window.getComputedStyle(element);
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
expect(style.width).toBe(`${expectedProgress}%`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Progress bar displays status - LP participation', () => {
|
it('Progress bar displays status - LP participation', async () => {
|
||||||
const yesVotesLP = 400;
|
const yesVotesLP = 400;
|
||||||
const noVotesLP = 600;
|
const noVotesLP = 600;
|
||||||
const totalVotesLP = yesVotesLP + noVotesLP;
|
const totalVotesLP = yesVotesLP + noVotesLP;
|
||||||
@ -341,7 +345,7 @@ describe('VoteBreakdown', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const element = screen.getByTestId('lp-participation-progress');
|
const element = await screen.findByTestId('lp-participation-progress');
|
||||||
const style = window.getComputedStyle(element);
|
const style = window.getComputedStyle(element);
|
||||||
expect(style.width).toBe(`${expectedProgress}%`);
|
expect(style.width).toBe(`${expectedProgress}%`);
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
import { type ReactNode } from 'react';
|
import compact from 'lodash/compact';
|
||||||
|
import countBy from 'lodash/countBy';
|
||||||
|
import { useState, 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 { Trans, useTranslation } from 'react-i18next';
|
||||||
import { useVoteInformation } from '../../hooks';
|
import { useVoteInformation } from '../../hooks';
|
||||||
import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { Tooltip, VegaIcon, VegaIconNames } 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 { CompactNumber } from '@vegaprotocol/react-helpers';
|
import { CompactNumber } from '@vegaprotocol/react-helpers';
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
import {
|
||||||
|
type ProposalTermsFieldsFragment,
|
||||||
|
type VoteFieldsFragment,
|
||||||
|
} from '../../__generated__/Proposals';
|
||||||
|
import { useBatchVoteInformation } from '../../hooks/use-vote-information';
|
||||||
|
|
||||||
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
||||||
<CompactNumber
|
<CompactNumber
|
||||||
@ -18,10 +25,6 @@ export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
interface VoteBreakdownProps {
|
|
||||||
proposal: Proposal;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VoteProgressProps {
|
interface VoteProgressProps {
|
||||||
percentageFor: BigNumber;
|
percentageFor: BigNumber;
|
||||||
colourfulBg?: boolean;
|
colourfulBg?: boolean;
|
||||||
@ -55,7 +58,7 @@ const VoteProgress = ({
|
|||||||
className={progressClasses}
|
className={progressClasses}
|
||||||
style={{ width: `${percentageFor}%` }}
|
style={{ width: `${percentageFor}%` }}
|
||||||
data-testid={testId}
|
data-testid={testId}
|
||||||
></div>
|
/>
|
||||||
<div className={textClasses}>{children}</div>
|
<div className={textClasses}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -75,14 +78,14 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
|||||||
<div data-testid={testId}>
|
<div data-testid={testId}>
|
||||||
{reached ? (
|
{reached ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Icon name="tick" size={4} />
|
<VegaIcon name={VegaIconNames.TICK} size={20} />
|
||||||
<span>
|
<span>
|
||||||
{threshold.toString()}% {text} {t('met')}
|
{threshold.toString()}% {text} {t('met')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Icon name="cross" size={4} />
|
<VegaIcon name={VegaIconNames.CROSS} size={20} />
|
||||||
<span>
|
<span>
|
||||||
{threshold.toString()}% {text} {t('not met')}
|
{threshold.toString()}% {text} {t('not met')}
|
||||||
</span>
|
</span>
|
||||||
@ -92,7 +95,225 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
export const VoteBreakdown = ({
|
||||||
|
proposal,
|
||||||
|
}: {
|
||||||
|
proposal: Proposal | BatchProposal;
|
||||||
|
}) => {
|
||||||
|
if (proposal.__typename === 'Proposal') {
|
||||||
|
return <VoteBreakdownNormal proposal={proposal} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proposal.__typename === 'BatchProposal') {
|
||||||
|
return <VoteBreakdownBatch proposal={proposal} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
||||||
|
const [fullBreakdown, setFullBreakdown] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const voteInfo = useBatchVoteInformation({
|
||||||
|
terms: compact(
|
||||||
|
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
|
||||||
|
),
|
||||||
|
votes: proposal.votes,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!voteInfo) return null;
|
||||||
|
|
||||||
|
const batchWillPass = voteInfo.every((i) => i.willPass);
|
||||||
|
|
||||||
|
const passingCount = countBy(voteInfo, (v) => v.willPass);
|
||||||
|
|
||||||
|
if (proposal.state === ProposalState.STATE_OPEN) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
{batchWillPass ? (
|
||||||
|
<p className="flex gap-2 m-0 items-center">
|
||||||
|
<VegaIcon
|
||||||
|
name={VegaIconNames.TICK}
|
||||||
|
className="text-vega-green"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
{t(
|
||||||
|
'Currently expected to pass: conditions met for {{count}} of {{total}} proposals',
|
||||||
|
{
|
||||||
|
count: passingCount['true'] || 0,
|
||||||
|
total: voteInfo.length,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="flex gap-2 m-0 items-center">
|
||||||
|
<VegaIcon
|
||||||
|
name={VegaIconNames.CROSS}
|
||||||
|
className="text-vega-pink"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
{t(
|
||||||
|
'Currently expected to fail: {{count}} of {{total}} proposals are passing',
|
||||||
|
{
|
||||||
|
count: passingCount['true'] || 0,
|
||||||
|
total: voteInfo.length,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
className="underline"
|
||||||
|
onClick={() => setFullBreakdown((x) => !x)}
|
||||||
|
>
|
||||||
|
{fullBreakdown ? 'Hide vote breakdown' : 'Show vote breakdown'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{fullBreakdown && (
|
||||||
|
<div>
|
||||||
|
{proposal.subProposals?.map((p, i) => {
|
||||||
|
if (!p?.terms) return null;
|
||||||
|
return (
|
||||||
|
<VoteBreakdownBatchSubProposal
|
||||||
|
key={i}
|
||||||
|
proposal={proposal}
|
||||||
|
votes={proposal.votes}
|
||||||
|
terms={p.terms}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
proposal.state === ProposalState.STATE_DECLINED ||
|
||||||
|
proposal.state === ProposalState.STATE_PASSED
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
{batchWillPass ? (
|
||||||
|
<p className="flex gap-2 m-0 items-center">
|
||||||
|
<VegaIcon
|
||||||
|
name={VegaIconNames.TICK}
|
||||||
|
className="text-vega-green"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
{t(
|
||||||
|
'Proposal passed: conditions met for {{count}} of {{total}} proposals',
|
||||||
|
{
|
||||||
|
count: passingCount['true'] || 0,
|
||||||
|
total: voteInfo.length,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="flex gap-2 m-0 items-center">
|
||||||
|
<VegaIcon
|
||||||
|
name={VegaIconNames.CROSS}
|
||||||
|
className="text-vega-pink"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
{t('Proposal failed: {{count}} of {{total}} proposals passed', {
|
||||||
|
count: passingCount['true'] || 0,
|
||||||
|
total: voteInfo.length,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
className="underline"
|
||||||
|
onClick={() => setFullBreakdown((x) => !x)}
|
||||||
|
>
|
||||||
|
{fullBreakdown ? 'Hide vote breakdown' : 'Show vote breakdown'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{fullBreakdown && (
|
||||||
|
<div>
|
||||||
|
{proposal.subProposals?.map((p, i) => {
|
||||||
|
if (!p?.terms) return null;
|
||||||
|
return (
|
||||||
|
<VoteBreakdownBatchSubProposal
|
||||||
|
key={i}
|
||||||
|
proposal={proposal}
|
||||||
|
votes={proposal.votes}
|
||||||
|
terms={p.terms}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoteBreakdownBatchSubProposal = ({
|
||||||
|
proposal,
|
||||||
|
votes,
|
||||||
|
terms,
|
||||||
|
}: {
|
||||||
|
proposal: BatchProposal;
|
||||||
|
votes: VoteFieldsFragment;
|
||||||
|
terms: ProposalTermsFieldsFragment;
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const voteInfo = useVoteInformation({
|
||||||
|
votes,
|
||||||
|
terms,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
||||||
|
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h4>{t(terms.change.__typename)}</h4>
|
||||||
|
<VoteBreakDownUI
|
||||||
|
voteInfo={voteInfo}
|
||||||
|
isProposalOpen={isProposalOpen}
|
||||||
|
isUpdateMarket={isUpdateMarket}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoteBreakdownNormal = ({ proposal }: { proposal: Proposal }) => {
|
||||||
|
const voteInfo = useVoteInformation({
|
||||||
|
votes: proposal.votes,
|
||||||
|
terms: proposal.terms,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
||||||
|
const isUpdateMarket = proposal?.terms?.change?.__typename === 'UpdateMarket';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VoteBreakDownUI
|
||||||
|
voteInfo={voteInfo}
|
||||||
|
isProposalOpen={isProposalOpen}
|
||||||
|
isUpdateMarket={isUpdateMarket}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const VoteBreakDownUI = ({
|
||||||
|
voteInfo,
|
||||||
|
isProposalOpen,
|
||||||
|
isUpdateMarket,
|
||||||
|
}: {
|
||||||
|
voteInfo: ReturnType<typeof useVoteInformation>;
|
||||||
|
isProposalOpen: boolean;
|
||||||
|
isUpdateMarket: boolean;
|
||||||
|
}) => {
|
||||||
|
const defaultDP = 2;
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
if (!voteInfo) return null;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
totalTokensPercentage,
|
totalTokensPercentage,
|
||||||
participationMet,
|
participationMet,
|
||||||
@ -114,12 +335,8 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
majorityLPMet,
|
majorityLPMet,
|
||||||
willPassByTokenVote,
|
willPassByTokenVote,
|
||||||
willPassByLPVote,
|
willPassByLPVote,
|
||||||
} = useVoteInformation({ proposal });
|
} = voteInfo;
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const defaultDP = 2;
|
|
||||||
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
|
||||||
const isUpdateMarket = proposal?.terms?.change?.__typename === 'UpdateMarket';
|
|
||||||
const participationThresholdProgress = BigNumber.min(
|
const participationThresholdProgress = BigNumber.min(
|
||||||
totalTokensPercentage.dividedBy(requiredParticipation).multipliedBy(100),
|
totalTokensPercentage.dividedBy(requiredParticipation).multipliedBy(100),
|
||||||
new BigNumber(100)
|
new BigNumber(100)
|
||||||
@ -152,23 +369,38 @@ export const VoteBreakdown = ({ proposal }: VoteBreakdownProps) => {
|
|||||||
{isProposalOpen && (
|
{isProposalOpen && (
|
||||||
<div
|
<div
|
||||||
data-testid="vote-status"
|
data-testid="vote-status"
|
||||||
className="flex items-center gap-1 mb-2 text-bold"
|
className="flex items-center gap-2 mb-2 text-bold"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
{willPass ? (
|
{willPass ? (
|
||||||
<Icon name="tick" size={5} className="text-vega-green" />
|
<VegaIcon
|
||||||
|
name={VegaIconNames.TICK}
|
||||||
|
size={20}
|
||||||
|
className="text-vega-green"
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Icon name="cross" size={5} className="text-vega-pink" />
|
<VegaIcon
|
||||||
|
name={VegaIconNames.CROSS}
|
||||||
|
size={20}
|
||||||
|
className="text-vega-pink"
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span>{t('currentlySetTo')} </span>
|
|
||||||
{willPass ? (
|
{willPass ? (
|
||||||
<span>
|
<p className="m-0">
|
||||||
<span className="text-vega-green">{t('pass')}</span>
|
<Trans
|
||||||
|
i18nKey={'Currently expected to <0>pass</0>'}
|
||||||
|
components={[<span className="text-vega-green" />]}
|
||||||
|
/>
|
||||||
{isUpdateMarket && <span> {updateMarketVotePassMethod}</span>}
|
{isUpdateMarket && <span> {updateMarketVotePassMethod}</span>}
|
||||||
</span>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-vega-pink">{t('fail')}</span>
|
<p className="m-0">
|
||||||
|
<Trans
|
||||||
|
i18nKey={'Currently expected to <0>fail</0>'}
|
||||||
|
components={[<span className="text-vega-pink" />]}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -8,12 +8,10 @@ import { SubHeading } from '../../../../components/heading';
|
|||||||
import { type VoteValue } from '@vegaprotocol/types';
|
import { type VoteValue } from '@vegaprotocol/types';
|
||||||
import { type DialogProps, type VegaTxState } from '@vegaprotocol/proposals';
|
import { type DialogProps, type VegaTxState } from '@vegaprotocol/proposals';
|
||||||
import { type VoteState } from './use-user-vote';
|
import { type VoteState } from './use-user-vote';
|
||||||
import { type Proposal } from '../../types';
|
import { type Proposal, type BatchProposal } from '../../types';
|
||||||
|
|
||||||
interface UserVoteProps {
|
interface UserVoteProps {
|
||||||
proposal: Proposal;
|
proposal: Proposal | BatchProposal;
|
||||||
minVoterBalance: string | null | undefined;
|
|
||||||
spamProtectionMinTokens: string | null | undefined;
|
|
||||||
transaction: VegaTxState | null;
|
transaction: VegaTxState | null;
|
||||||
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
||||||
dialog: (props: DialogProps) => JSX.Element;
|
dialog: (props: DialogProps) => JSX.Element;
|
||||||
@ -23,8 +21,6 @@ interface UserVoteProps {
|
|||||||
|
|
||||||
export const UserVote = ({
|
export const UserVote = ({
|
||||||
proposal,
|
proposal,
|
||||||
minVoterBalance,
|
|
||||||
spamProtectionMinTokens,
|
|
||||||
submit,
|
submit,
|
||||||
transaction,
|
transaction,
|
||||||
dialog,
|
dialog,
|
||||||
@ -46,12 +42,17 @@ export const UserVote = ({
|
|||||||
{pubKey ? (
|
{pubKey ? (
|
||||||
proposal && (
|
proposal && (
|
||||||
<VoteButtonsContainer
|
<VoteButtonsContainer
|
||||||
|
changeType={
|
||||||
|
proposal.__typename === 'BatchProposal'
|
||||||
|
? // @ts-ignore should not be null/undefined
|
||||||
|
proposal.subProposals[0]?.terms?.change.__typename
|
||||||
|
: // @ts-ignore should not be null/undefined
|
||||||
|
proposal.terms?.change.__typename
|
||||||
|
}
|
||||||
voteState={voteState}
|
voteState={voteState}
|
||||||
voteDatetime={voteDatetime}
|
voteDatetime={voteDatetime}
|
||||||
proposalState={proposal.state}
|
proposalState={proposal.state}
|
||||||
proposalId={proposal.id ?? ''}
|
proposalId={proposal.id ?? ''}
|
||||||
minVoterBalance={minVoterBalance}
|
|
||||||
spamProtectionMinTokens={spamProtectionMinTokens}
|
|
||||||
className="flex"
|
className="flex"
|
||||||
submit={submit}
|
submit={submit}
|
||||||
transaction={transaction}
|
transaction={transaction}
|
||||||
|
@ -19,14 +19,18 @@ import { VoteTransactionDialog } from './vote-transaction-dialog';
|
|||||||
import { useVoteButtonsQuery } from './__generated__/Stake';
|
import { useVoteButtonsQuery } from './__generated__/Stake';
|
||||||
import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals';
|
import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals';
|
||||||
import { filterAcceptableGraphqlErrors } from '../../../../lib/party';
|
import { filterAcceptableGraphqlErrors } from '../../../../lib/party';
|
||||||
|
import {
|
||||||
|
NetworkParams,
|
||||||
|
useNetworkParams,
|
||||||
|
} from '@vegaprotocol/network-parameters';
|
||||||
|
import { type ProposalChangeType } from '../../types';
|
||||||
|
|
||||||
interface VoteButtonsContainerProps {
|
interface VoteButtonsContainerProps {
|
||||||
|
changeType: ProposalChangeType;
|
||||||
voteState: VoteState | null;
|
voteState: VoteState | null;
|
||||||
voteDatetime: Date | null;
|
voteDatetime: Date | null;
|
||||||
proposalId: string | null;
|
proposalId: string | null;
|
||||||
proposalState: ProposalState;
|
proposalState: ProposalState;
|
||||||
minVoterBalance: string | null | undefined;
|
|
||||||
spamProtectionMinTokens: string | null | undefined;
|
|
||||||
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
||||||
transaction: VegaTxState | null;
|
transaction: VegaTxState | null;
|
||||||
dialog: (props: DialogProps) => JSX.Element;
|
dialog: (props: DialogProps) => JSX.Element;
|
||||||
@ -35,20 +39,94 @@ interface VoteButtonsContainerProps {
|
|||||||
|
|
||||||
export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
|
export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
appState: { decimals },
|
appState: { decimals },
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
|
|
||||||
const { data, loading, error } = useVoteButtonsQuery({
|
const { data, loading, error } = useVoteButtonsQuery({
|
||||||
variables: { partyId: pubKey || '' },
|
variables: { partyId: pubKey || '' },
|
||||||
skip: !pubKey,
|
skip: !pubKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { params: networkParams } = useNetworkParams([
|
||||||
|
NetworkParams.governance_proposal_market_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_asset_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_updateAsset_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_updateNetParam_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_freeform_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_referralProgram_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_VolumeDiscountProgram_minVoterBalance,
|
||||||
|
NetworkParams.governance_proposal_transfer_minVoterBalance,
|
||||||
|
NetworkParams.spam_protection_voting_min_tokens,
|
||||||
|
NetworkParams.governance_proposal_market_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
||||||
|
NetworkParams.governance_proposal_asset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateAsset_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_updateNetParam_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_freeform_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_referralProgram_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_VolumeDiscountProgram_requiredMajority,
|
||||||
|
NetworkParams.governance_proposal_transfer_requiredMajority,
|
||||||
|
]);
|
||||||
|
|
||||||
|
let minVoterBalance = null;
|
||||||
|
|
||||||
|
if (networkParams) {
|
||||||
|
switch (props.changeType) {
|
||||||
|
case 'UpdateMarket':
|
||||||
|
case 'UpdateMarketState':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_updateMarket_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'NewMarket':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_market_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'NewAsset':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_asset_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'UpdateAsset':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_updateAsset_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'UpdateNetworkParameter':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_updateNetParam_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'NewFreeform':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_freeform_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'CancelTransfer':
|
||||||
|
case 'NewTransfer':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_transfer_requiredMajority;
|
||||||
|
break;
|
||||||
|
case 'UpdateReferralProgram':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_referralProgram_minVoterBalance;
|
||||||
|
break;
|
||||||
|
case 'UpdateVolumeDiscountProgram':
|
||||||
|
minVoterBalance =
|
||||||
|
networkParams.governance_proposal_VolumeDiscountProgram_minVoterBalance;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const filteredErrors = filterAcceptableGraphqlErrors(error);
|
const filteredErrors = filterAcceptableGraphqlErrors(error);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer loading={loading} error={filteredErrors} data={data}>
|
<AsyncRenderer loading={loading} error={filteredErrors} data={data}>
|
||||||
<VoteButtons
|
<VoteButtons
|
||||||
{...props}
|
{...props}
|
||||||
|
minVoterBalance={minVoterBalance}
|
||||||
|
spamProtectionMinTokens={
|
||||||
|
networkParams.spam_protection_voting_min_tokens
|
||||||
|
}
|
||||||
currentStakeAvailable={toBigNum(
|
currentStakeAvailable={toBigNum(
|
||||||
data?.party?.stakingSummary.currentStakeAvailable || 0,
|
data?.party?.stakingSummary.currentStakeAvailable || 0,
|
||||||
decimals
|
decimals
|
||||||
@ -58,8 +136,17 @@ export const VoteButtonsContainer = (props: VoteButtonsContainerProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface VoteButtonsProps extends VoteButtonsContainerProps {
|
interface VoteButtonsProps {
|
||||||
|
voteState: VoteState | null;
|
||||||
|
voteDatetime: Date | null;
|
||||||
|
proposalId: string | null;
|
||||||
|
proposalState: ProposalState;
|
||||||
|
submit: (voteValue: VoteValue, proposalId: string | null) => Promise<void>;
|
||||||
|
transaction: VegaTxState | null;
|
||||||
|
dialog: (props: DialogProps) => JSX.Element;
|
||||||
currentStakeAvailable: BigNumber;
|
currentStakeAvailable: BigNumber;
|
||||||
|
minVoterBalance: string | null;
|
||||||
|
spamProtectionMinTokens: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VoteButtons = ({
|
export const VoteButtons = ({
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { renderHook } from '@testing-library/react';
|
import { renderHook } from '@testing-library/react';
|
||||||
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 { generateProposal } from '../test-helpers/generate-proposals';
|
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/network-parameters', () => ({
|
jest.mock('@vegaprotocol/network-parameters', () => ({
|
||||||
...jest.requireActual('@vegaprotocol/network-parameters'),
|
...jest.requireActual('@vegaprotocol/network-parameters'),
|
||||||
@ -29,118 +28,84 @@ jest.mock('@vegaprotocol/network-parameters', () => ({
|
|||||||
|
|
||||||
describe('use-proposal-network-params', () => {
|
describe('use-proposal-network-params', () => {
|
||||||
it('returns the correct params for an update market proposal', () => {
|
it('returns the correct params for an update market proposal', () => {
|
||||||
const proposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
} = renderHook(() => useProposalNetworkParams());
|
||||||
|
|
||||||
|
const expectedObj = {
|
||||||
|
requiredMajority: expect.any(BigNumber),
|
||||||
|
requiredMajorityLP: expect.any(BigNumber),
|
||||||
|
requiredParticipation: expect.any(BigNumber),
|
||||||
|
requiredParticipationLP: expect.any(BigNumber),
|
||||||
|
};
|
||||||
|
|
||||||
expect(current).toEqual({
|
expect(current).toEqual({
|
||||||
requiredMajority: '0.1',
|
NewMarket: expectedObj,
|
||||||
requiredMajorityLP: '0.2',
|
NewSpotMarket: expectedObj,
|
||||||
requiredParticipation: new BigNumber(0.15),
|
UpdateMarket: expectedObj,
|
||||||
requiredParticipationLP: new BigNumber(0.25),
|
UpdateMarketState: expectedObj,
|
||||||
|
UpdateSpotMarket: expectedObj,
|
||||||
|
UpdateNetworkParameter: expectedObj,
|
||||||
|
NewAsset: expectedObj,
|
||||||
|
UpdateAsset: expectedObj,
|
||||||
|
NewFreeform: expectedObj,
|
||||||
|
UpdateReferralProgram: expectedObj,
|
||||||
|
UpdateVolumeDiscountProgram: expectedObj,
|
||||||
|
NewTransfer: expectedObj,
|
||||||
|
CancelTransfer: expectedObj,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the correct params for a market proposal', () => {
|
it('returns the correct values for the proposal change type', () => {
|
||||||
const proposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'NewMarket',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
} = renderHook(() => useProposalNetworkParams());
|
||||||
|
|
||||||
expect(current).toEqual({
|
expect(current?.UpdateMarket.requiredMajority.toString()).toEqual('0.1');
|
||||||
requiredMajority: '0.3',
|
expect(current?.UpdateMarket.requiredMajorityLP.toString()).toEqual('0.2');
|
||||||
requiredParticipation: new BigNumber(0.35),
|
expect(current?.UpdateMarket.requiredParticipation.toString()).toEqual(
|
||||||
});
|
'0.15'
|
||||||
});
|
);
|
||||||
|
expect(current?.UpdateMarket.requiredParticipationLP.toString()).toEqual(
|
||||||
|
'0.25'
|
||||||
|
);
|
||||||
|
|
||||||
it('returns the correct params for an asset proposal', () => {
|
expect(current?.NewMarket.requiredMajority.toString()).toEqual('0.3');
|
||||||
const proposal = generateProposal({
|
expect(current?.NewMarket.requiredMajorityLP.toString()).toEqual('0');
|
||||||
terms: {
|
expect(current?.NewMarket.requiredParticipation.toString()).toEqual('0.35');
|
||||||
change: {
|
expect(current?.NewMarket.requiredParticipationLP.toString()).toEqual('0');
|
||||||
__typename: 'NewAsset',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
expect(current?.NewAsset.requiredMajority.toString()).toEqual('0.4');
|
||||||
result: { current },
|
expect(current?.NewAsset.requiredMajorityLP.toString()).toEqual('0');
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
expect(current?.NewAsset.requiredParticipation.toString()).toEqual('0.45');
|
||||||
|
expect(current?.NewAsset.requiredParticipationLP.toString()).toEqual('0');
|
||||||
|
|
||||||
expect(current).toEqual({
|
expect(current?.UpdateAsset.requiredMajority.toString()).toEqual('0.5');
|
||||||
requiredMajority: '0.4',
|
expect(current?.UpdateAsset.requiredMajorityLP.toString()).toEqual('0');
|
||||||
requiredParticipation: new BigNumber(0.45),
|
expect(current?.UpdateAsset.requiredParticipation.toString()).toEqual(
|
||||||
});
|
'0.55'
|
||||||
});
|
);
|
||||||
|
|
||||||
it('returns the correct params for an update asset proposal', () => {
|
expect(current?.UpdateNetworkParameter.requiredMajority.toString()).toEqual(
|
||||||
const proposal = generateProposal({
|
'0.6'
|
||||||
terms: {
|
);
|
||||||
change: {
|
expect(
|
||||||
__typename: 'UpdateAsset',
|
current?.UpdateNetworkParameter.requiredMajorityLP.toString()
|
||||||
},
|
).toEqual('0');
|
||||||
},
|
expect(
|
||||||
});
|
current?.UpdateNetworkParameter.requiredParticipation.toString()
|
||||||
|
).toEqual('0.65');
|
||||||
|
expect(
|
||||||
|
current?.UpdateNetworkParameter.requiredParticipationLP.toString()
|
||||||
|
).toEqual('0');
|
||||||
|
|
||||||
const {
|
expect(current?.NewFreeform.requiredMajority.toString()).toEqual('0.7');
|
||||||
result: { current },
|
expect(current?.NewFreeform.requiredMajorityLP.toString()).toEqual('0');
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
expect(current?.NewFreeform.requiredParticipation.toString()).toEqual(
|
||||||
|
'0.75'
|
||||||
expect(current).toEqual({
|
);
|
||||||
requiredMajority: '0.5',
|
expect(current?.NewFreeform.requiredParticipationLP.toString()).toEqual(
|
||||||
requiredParticipation: new BigNumber(0.55),
|
'0'
|
||||||
});
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the correct params for a network params proposal', () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'UpdateNetworkParameter',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
result: { current },
|
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
|
||||||
|
|
||||||
expect(current).toEqual({
|
|
||||||
requiredMajority: '0.6',
|
|
||||||
requiredParticipation: new BigNumber(0.65),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the correct params for a freeform proposal', () => {
|
|
||||||
const proposal = generateProposal({
|
|
||||||
terms: {
|
|
||||||
change: {
|
|
||||||
__typename: 'NewFreeform',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
result: { current },
|
|
||||||
} = renderHook(() => useProposalNetworkParams({ proposal }));
|
|
||||||
|
|
||||||
expect(current).toEqual({
|
|
||||||
requiredMajority: '0.7',
|
|
||||||
requiredParticipation: new BigNumber(0.75),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3,14 +3,9 @@ import {
|
|||||||
useNetworkParams,
|
useNetworkParams,
|
||||||
} from '@vegaprotocol/network-parameters';
|
} from '@vegaprotocol/network-parameters';
|
||||||
import { BigNumber } from '../../../lib/bignumber';
|
import { BigNumber } from '../../../lib/bignumber';
|
||||||
import { type Proposal } from '../types';
|
import { type ProposalChangeType } from '../types';
|
||||||
|
|
||||||
export const useProposalNetworkParams = ({
|
const REQUIRED_PARAMS = [
|
||||||
proposal,
|
|
||||||
}: {
|
|
||||||
proposal: Proposal;
|
|
||||||
}) => {
|
|
||||||
const { params } = useNetworkParams([
|
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredParticipation,
|
NetworkParams.governance_proposal_updateMarket_requiredParticipation,
|
||||||
@ -31,7 +26,10 @@ export const useProposalNetworkParams = ({
|
|||||||
NetworkParams.governance_proposal_VolumeDiscountProgram_requiredParticipation,
|
NetworkParams.governance_proposal_VolumeDiscountProgram_requiredParticipation,
|
||||||
NetworkParams.governance_proposal_transfer_requiredParticipation,
|
NetworkParams.governance_proposal_transfer_requiredParticipation,
|
||||||
NetworkParams.governance_proposal_transfer_requiredMajority,
|
NetworkParams.governance_proposal_transfer_requiredMajority,
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
export const useProposalNetworkParams = () => {
|
||||||
|
const { params } = useNetworkParams(REQUIRED_PARAMS);
|
||||||
|
|
||||||
const fallback = {
|
const fallback = {
|
||||||
requiredMajority: new BigNumber(1),
|
requiredMajority: new BigNumber(1),
|
||||||
@ -41,86 +39,152 @@ export const useProposalNetworkParams = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
return fallback;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (proposal?.terms.change.__typename) {
|
const result: Record<
|
||||||
case 'UpdateMarket':
|
ProposalChangeType,
|
||||||
case 'UpdateMarketState':
|
{
|
||||||
return {
|
requiredMajority: BigNumber;
|
||||||
requiredMajority:
|
requiredParticipation: BigNumber;
|
||||||
params.governance_proposal_updateMarket_requiredMajority,
|
requiredMajorityLP: BigNumber;
|
||||||
requiredMajorityLP:
|
requiredParticipationLP: BigNumber;
|
||||||
params.governance_proposal_updateMarket_requiredMajorityLP,
|
}
|
||||||
|
> = {
|
||||||
|
NewMarket: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_market_requiredMajority || 1
|
||||||
|
),
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_updateMarket_requiredParticipation
|
params.governance_proposal_market_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
NewSpotMarket: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_market_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredParticipation: new BigNumber(
|
||||||
|
params.governance_proposal_market_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateMarket: {
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredMajorityLP: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajorityLP || 0
|
||||||
|
),
|
||||||
|
requiredParticipation: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredParticipation || 1
|
||||||
),
|
),
|
||||||
requiredParticipationLP: new BigNumber(
|
requiredParticipationLP: new BigNumber(
|
||||||
params.governance_proposal_updateMarket_requiredParticipationLP
|
params.governance_proposal_updateMarket_requiredParticipationLP || 0
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateMarketState: {
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredMajorityLP: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajorityLP || 0
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'UpdateNetworkParameter':
|
|
||||||
return {
|
|
||||||
requiredMajority:
|
|
||||||
params.governance_proposal_updateNetParam_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_updateNetParam_requiredParticipation
|
params.governance_proposal_updateMarket_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
requiredParticipationLP: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredParticipationLP || 0
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateSpotMarket: {
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredMajorityLP: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredMajorityLP || 0
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'NewAsset':
|
|
||||||
return {
|
|
||||||
requiredMajority: params.governance_proposal_asset_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_asset_requiredParticipation
|
params.governance_proposal_updateMarket_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
requiredParticipationLP: new BigNumber(
|
||||||
|
params.governance_proposal_updateMarket_requiredParticipationLP || 0
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateNetworkParameter: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_updateNetParam_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'UpdateAsset':
|
|
||||||
return {
|
|
||||||
requiredMajority:
|
|
||||||
params.governance_proposal_updateAsset_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_updateAsset_requiredParticipation
|
params.governance_proposal_updateNetParam_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
NewAsset: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_asset_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'NewMarket':
|
|
||||||
return {
|
|
||||||
requiredMajority: params.governance_proposal_market_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_market_requiredParticipation
|
params.governance_proposal_asset_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateAsset: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_updateAsset_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'NewFreeform':
|
|
||||||
return {
|
|
||||||
requiredMajority: params.governance_proposal_freeform_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_freeform_requiredParticipation
|
params.governance_proposal_updateAsset_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
NewFreeform: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_freeform_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'UpdateReferralProgram':
|
|
||||||
return {
|
|
||||||
requiredMajority:
|
|
||||||
params.governance_proposal_referralProgram_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_referralProgram_requiredParticipation
|
params.governance_proposal_freeform_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateReferralProgram: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_referralProgram_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'UpdateVolumeDiscountProgram':
|
|
||||||
return {
|
|
||||||
requiredMajority:
|
|
||||||
params.governance_proposal_VolumeDiscountProgram_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_VolumeDiscountProgram_requiredParticipation
|
params.governance_proposal_referralProgram_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
UpdateVolumeDiscountProgram: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_VolumeDiscountProgram_requiredMajority || 1
|
||||||
),
|
),
|
||||||
};
|
|
||||||
case 'NewTransfer':
|
|
||||||
case 'CancelTransfer':
|
|
||||||
return {
|
|
||||||
requiredMajority: params.governance_proposal_transfer_requiredMajority,
|
|
||||||
requiredParticipation: new BigNumber(
|
requiredParticipation: new BigNumber(
|
||||||
params.governance_proposal_transfer_requiredParticipation
|
params.governance_proposal_VolumeDiscountProgram_requiredParticipation ||
|
||||||
|
1
|
||||||
),
|
),
|
||||||
|
},
|
||||||
|
NewTransfer: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_transfer_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredParticipation: new BigNumber(
|
||||||
|
params.governance_proposal_transfer_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
|
CancelTransfer: {
|
||||||
|
...fallback,
|
||||||
|
requiredMajority: new BigNumber(
|
||||||
|
params.governance_proposal_transfer_requiredMajority || 1
|
||||||
|
),
|
||||||
|
requiredParticipation: new BigNumber(
|
||||||
|
params.governance_proposal_transfer_requiredParticipation || 1
|
||||||
|
),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
default:
|
|
||||||
return fallback;
|
return result;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -79,33 +79,35 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.requiredMajorityPercentage).toEqual(new BigNumber(50));
|
expect(current?.requiredMajorityLPPercentage).toEqual(new BigNumber(50));
|
||||||
expect(current.requiredMajorityLPPercentage).toEqual(new BigNumber(50));
|
expect(current?.requiredMajorityPercentage).toEqual(new BigNumber(50));
|
||||||
expect(current.noTokens).toEqual(new BigNumber(60));
|
expect(current?.noTokens).toEqual(new BigNumber(60));
|
||||||
expect(current.noVotes).toEqual(new BigNumber(60));
|
expect(current?.noVotes).toEqual(new BigNumber(60));
|
||||||
expect(current.noEquityLikeShareWeight).toEqual(new BigNumber(70));
|
expect(current?.noEquityLikeShareWeight).toEqual(new BigNumber(70));
|
||||||
expect(current.yesTokens).toEqual(new BigNumber(40));
|
expect(current?.yesTokens).toEqual(new BigNumber(40));
|
||||||
expect(current.yesVotes).toEqual(new BigNumber(40));
|
expect(current?.yesVotes).toEqual(new BigNumber(40));
|
||||||
expect(current.yesEquityLikeShareWeight).toEqual(new BigNumber(30));
|
expect(current?.yesEquityLikeShareWeight).toEqual(new BigNumber(30));
|
||||||
expect(current.totalTokensVoted).toEqual(new BigNumber(100));
|
expect(current?.totalTokensVoted).toEqual(new BigNumber(100));
|
||||||
expect(current.totalVotes).toEqual(new BigNumber(100));
|
expect(current?.totalVotes).toEqual(new BigNumber(100));
|
||||||
expect(current.totalEquityLikeShareWeight).toEqual(new BigNumber(100));
|
expect(current?.totalEquityLikeShareWeight).toEqual(new BigNumber(100));
|
||||||
expect(current.yesPercentage).toEqual(new BigNumber(40));
|
expect(current?.yesPercentage).toEqual(new BigNumber(40));
|
||||||
expect(current.yesLPPercentage).toEqual(new BigNumber(30));
|
expect(current?.yesLPPercentage).toEqual(new BigNumber(30));
|
||||||
expect(current.noPercentage).toEqual(new BigNumber(60));
|
expect(current?.noPercentage).toEqual(new BigNumber(60));
|
||||||
expect(current.noLPPercentage).toEqual(new BigNumber(70));
|
expect(current?.noLPPercentage).toEqual(new BigNumber(70));
|
||||||
expect(current.requiredParticipation).toEqual(new BigNumber(50));
|
expect(current?.requiredParticipation).toEqual(new BigNumber(50));
|
||||||
expect(current.participationMet).toEqual(true);
|
expect(current?.participationMet).toEqual(true);
|
||||||
expect(current.requiredParticipationLP).toEqual(new BigNumber(50));
|
expect(current?.requiredParticipationLP).toEqual(new BigNumber(50));
|
||||||
expect(current.participationLPMet).toEqual(true);
|
expect(current?.participationLPMet).toEqual(true);
|
||||||
expect(current.majorityMet).toEqual(false);
|
expect(current?.majorityMet).toEqual(false);
|
||||||
expect(current.majorityLPMet).toEqual(false);
|
expect(current?.majorityLPMet).toEqual(false);
|
||||||
expect(current.totalTokensPercentage).toEqual(new BigNumber(100));
|
expect(current?.totalTokensPercentage).toEqual(new BigNumber(100));
|
||||||
expect(current.totalLPTokensPercentage).toEqual(new BigNumber(100));
|
expect(current?.totalLPTokensPercentage).toEqual(new BigNumber(100));
|
||||||
expect(current.willPassByTokenVote).toEqual(false);
|
expect(current?.willPassByTokenVote).toEqual(false);
|
||||||
expect(current.willPassByLPVote).toEqual(false);
|
expect(current?.willPassByLPVote).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly returns majority, participation and will-pass status for a proposal with no votes', () => {
|
it('correctly returns majority, participation and will-pass status for a proposal with no votes', () => {
|
||||||
@ -123,11 +125,13 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.participationMet).toEqual(false);
|
expect(current?.participationMet).toEqual(false);
|
||||||
expect(current.majorityMet).toEqual(false);
|
expect(current?.majorityMet).toEqual(false);
|
||||||
expect(current.willPassByTokenVote).toEqual(false);
|
expect(current?.willPassByTokenVote).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows lack of participation for a failing proposal lacking votes', () => {
|
it('correctly shows lack of participation for a failing proposal lacking votes', () => {
|
||||||
@ -145,9 +149,11 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.participationMet).toEqual(false);
|
expect(current?.participationMet).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows participation but lack of majority for a failing proposal with enough votes but not enough majority', () => {
|
it('correctly shows participation but lack of majority for a failing proposal with enough votes but not enough majority', () => {
|
||||||
@ -165,11 +171,13 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.participationMet).toEqual(true);
|
expect(current?.participationMet).toEqual(true);
|
||||||
expect(current.majorityMet).toEqual(false);
|
expect(current?.majorityMet).toEqual(false);
|
||||||
expect(current.willPassByTokenVote).toEqual(false);
|
expect(current?.willPassByTokenVote).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows participation, majority and will-pass data for successful proposal', () => {
|
it('correctly shows participation, majority and will-pass data for successful proposal', () => {
|
||||||
@ -187,11 +195,13 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.participationMet).toEqual(true);
|
expect(current?.participationMet).toEqual(true);
|
||||||
expect(current.majorityMet).toEqual(true);
|
expect(current?.majorityMet).toEqual(true);
|
||||||
expect(current.willPassByTokenVote).toEqual(true);
|
expect(current?.willPassByTokenVote).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows whether an update market proposal will pass by token or LP vote - both failing', () => {
|
it('correctly shows whether an update market proposal will pass by token or LP vote - both failing', () => {
|
||||||
@ -221,10 +231,12 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.willPassByTokenVote).toEqual(false);
|
expect(current?.willPassByTokenVote).toEqual(false);
|
||||||
expect(current.willPassByLPVote).toEqual(false);
|
expect(current?.willPassByLPVote).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('correctly shows whether an update market proposal failing token but passing LP voting', () => {
|
it('correctly shows whether an update market proposal failing token but passing LP voting', () => {
|
||||||
@ -254,9 +266,11 @@ describe('use-vote-information', () => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
result: { current },
|
result: { current },
|
||||||
} = renderHook(() => useVoteInformation({ proposal }));
|
} = renderHook(() =>
|
||||||
|
useVoteInformation({ terms: proposal.terms, votes: proposal.votes })
|
||||||
|
);
|
||||||
|
|
||||||
expect(current.willPassByTokenVote).toEqual(false);
|
expect(current?.willPassByTokenVote).toEqual(false);
|
||||||
expect(current.willPassByLPVote).toEqual(true);
|
expect(current?.willPassByLPVote).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,71 +1,102 @@
|
|||||||
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 { addDecimal } from '@vegaprotocol/utils';
|
import { addDecimal } from '@vegaprotocol/utils';
|
||||||
import { type Proposal } from '../types';
|
import {
|
||||||
|
type ProposalTermsFieldsFragment,
|
||||||
|
type ProposalFieldsFragment,
|
||||||
|
type VoteFieldsFragment,
|
||||||
|
} from '../__generated__/Proposals';
|
||||||
|
import { type ProposalChangeType } from '../types';
|
||||||
|
|
||||||
export const useVoteInformation = ({ proposal }: { proposal: Proposal }) => {
|
export const useVoteInformation = ({
|
||||||
|
votes,
|
||||||
|
terms,
|
||||||
|
}: {
|
||||||
|
votes: VoteFieldsFragment;
|
||||||
|
terms: ProposalTermsFieldsFragment;
|
||||||
|
}) => {
|
||||||
const {
|
const {
|
||||||
appState: { totalSupply, decimals },
|
appState: { totalSupply, decimals },
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
|
|
||||||
const {
|
const params = useProposalNetworkParams();
|
||||||
requiredMajority,
|
|
||||||
requiredParticipation,
|
|
||||||
requiredMajorityLP,
|
|
||||||
requiredParticipationLP,
|
|
||||||
} = useProposalNetworkParams({
|
|
||||||
proposal,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (!params) return;
|
||||||
|
|
||||||
|
const paramsForChange = params[terms.change.__typename];
|
||||||
|
|
||||||
|
return getVoteData(
|
||||||
|
terms.change.__typename,
|
||||||
|
paramsForChange,
|
||||||
|
votes,
|
||||||
|
totalSupply,
|
||||||
|
decimals
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useBatchVoteInformation = ({
|
||||||
|
votes,
|
||||||
|
terms,
|
||||||
|
}: {
|
||||||
|
votes: VoteFieldsFragment;
|
||||||
|
terms: ProposalTermsFieldsFragment[];
|
||||||
|
}) => {
|
||||||
const {
|
const {
|
||||||
requiredMajorityPercentage,
|
appState: { totalSupply, decimals },
|
||||||
requiredMajorityLPPercentage,
|
} = useAppState();
|
||||||
noTokens,
|
|
||||||
noEquityLikeShareWeight,
|
const params = useProposalNetworkParams();
|
||||||
yesTokens,
|
|
||||||
yesEquityLikeShareWeight,
|
if (!params) return;
|
||||||
totalTokensVoted,
|
|
||||||
totalEquityLikeShareWeight,
|
return terms.map((t) => {
|
||||||
yesPercentage,
|
const paramsForChange = params[t.change.__typename];
|
||||||
yesLPPercentage,
|
return getVoteData(
|
||||||
noPercentage,
|
t.change.__typename,
|
||||||
noLPPercentage,
|
paramsForChange,
|
||||||
participationMet,
|
votes,
|
||||||
participationLPMet,
|
totalSupply,
|
||||||
majorityMet,
|
decimals
|
||||||
majorityLPMet,
|
);
|
||||||
totalTokensPercentage,
|
});
|
||||||
totalLPTokensPercentage,
|
};
|
||||||
willPassByTokenVote,
|
|
||||||
willPassByLPVote,
|
const getVoteData = (
|
||||||
} = useMemo(() => {
|
changeType: ProposalChangeType,
|
||||||
const requiredMajorityPercentage = requiredMajority
|
params: {
|
||||||
? new BigNumber(requiredMajority).times(100)
|
requiredMajority: BigNumber;
|
||||||
|
requiredMajorityLP: BigNumber;
|
||||||
|
requiredParticipation: BigNumber;
|
||||||
|
requiredParticipationLP: BigNumber;
|
||||||
|
},
|
||||||
|
votes: ProposalFieldsFragment['votes'],
|
||||||
|
totalSupply: BigNumber,
|
||||||
|
decimals: number
|
||||||
|
) => {
|
||||||
|
const requiredMajorityPercentage = params.requiredMajority
|
||||||
|
? new BigNumber(params.requiredMajority).times(100)
|
||||||
: new BigNumber(100);
|
: new BigNumber(100);
|
||||||
|
|
||||||
const requiredMajorityLPPercentage = requiredMajorityLP
|
const requiredMajorityLPPercentage = params.requiredMajorityLP
|
||||||
? new BigNumber(requiredMajorityLP).times(100)
|
? new BigNumber(params.requiredMajorityLP).times(100)
|
||||||
: new BigNumber(100);
|
: new BigNumber(100);
|
||||||
|
|
||||||
const noTokens = new BigNumber(
|
const noTokens = new BigNumber(
|
||||||
addDecimal(proposal?.votes.no.totalTokens ?? 0, decimals)
|
addDecimal(votes.no.totalTokens ?? 0, decimals)
|
||||||
);
|
);
|
||||||
|
|
||||||
const noEquityLikeShareWeight = !proposal?.votes.no
|
const noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||||
.totalEquityLikeShareWeight
|
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(proposal.votes.no.totalEquityLikeShareWeight).times(100);
|
: new BigNumber(votes.no.totalEquityLikeShareWeight).times(100);
|
||||||
|
|
||||||
const yesTokens = new BigNumber(
|
const yesTokens = new BigNumber(
|
||||||
addDecimal(proposal?.votes.yes.totalTokens ?? 0, decimals)
|
addDecimal(votes.yes.totalTokens ?? 0, decimals)
|
||||||
);
|
);
|
||||||
|
|
||||||
const yesEquityLikeShareWeight = !proposal?.votes.yes
|
const yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||||
.totalEquityLikeShareWeight
|
|
||||||
? new BigNumber(0)
|
? new BigNumber(0)
|
||||||
: new BigNumber(proposal.votes.yes.totalEquityLikeShareWeight).times(100);
|
: new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100);
|
||||||
|
|
||||||
const totalTokensVoted = yesTokens.plus(noTokens);
|
const totalTokensVoted = yesTokens.plus(noTokens);
|
||||||
|
|
||||||
@ -89,11 +120,11 @@ export const useVoteInformation = ({ proposal }: { proposal: Proposal }) => {
|
|||||||
.dividedBy(totalEquityLikeShareWeight);
|
.dividedBy(totalEquityLikeShareWeight);
|
||||||
|
|
||||||
const participationMet = totalTokensVoted.isGreaterThan(
|
const participationMet = totalTokensVoted.isGreaterThan(
|
||||||
totalSupply.multipliedBy(requiredParticipation)
|
totalSupply.multipliedBy(params.requiredParticipation)
|
||||||
);
|
);
|
||||||
|
|
||||||
const participationLPMet = requiredParticipationLP
|
const participationLPMet = params.requiredParticipationLP
|
||||||
? totalEquityLikeShareWeight.isGreaterThan(requiredParticipationLP)
|
? totalEquityLikeShareWeight.isGreaterThan(params.requiredParticipationLP)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
const majorityMet = yesPercentage.isGreaterThanOrEqualTo(
|
const majorityMet = yesPercentage.isGreaterThanOrEqualTo(
|
||||||
@ -122,70 +153,46 @@ export const useVoteInformation = ({ proposal }: { proposal: Proposal }) => {
|
|||||||
requiredMajorityLPPercentage
|
requiredMajorityLPPercentage
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
let willPass = false;
|
||||||
requiredMajorityPercentage,
|
|
||||||
requiredMajorityLPPercentage,
|
if (changeType === 'UpdateMarket' || changeType === 'UpdateMarketState') {
|
||||||
noTokens,
|
willPass = willPassByTokenVote && willPassByLPVote;
|
||||||
noEquityLikeShareWeight,
|
} else {
|
||||||
yesTokens,
|
willPass = willPassByTokenVote;
|
||||||
yesEquityLikeShareWeight,
|
}
|
||||||
totalTokensVoted,
|
|
||||||
totalEquityLikeShareWeight,
|
|
||||||
yesPercentage,
|
|
||||||
yesLPPercentage,
|
|
||||||
noPercentage,
|
|
||||||
noLPPercentage,
|
|
||||||
participationMet,
|
|
||||||
participationLPMet,
|
|
||||||
majorityMet,
|
|
||||||
majorityLPMet,
|
|
||||||
totalTokensPercentage,
|
|
||||||
totalLPTokensPercentage,
|
|
||||||
willPassByTokenVote,
|
|
||||||
willPassByLPVote,
|
|
||||||
};
|
|
||||||
}, [
|
|
||||||
decimals,
|
|
||||||
proposal?.votes.no.totalEquityLikeShareWeight,
|
|
||||||
proposal?.votes.no.totalTokens,
|
|
||||||
proposal?.votes.yes.totalEquityLikeShareWeight,
|
|
||||||
proposal?.votes.yes.totalTokens,
|
|
||||||
requiredMajority,
|
|
||||||
requiredMajorityLP,
|
|
||||||
requiredParticipation,
|
|
||||||
requiredParticipationLP,
|
|
||||||
totalSupply,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
willPassByTokenVote,
|
requiredMajorityPercentage,
|
||||||
willPassByLPVote,
|
requiredMajorityLPPercentage,
|
||||||
totalTokensPercentage,
|
|
||||||
totalLPTokensPercentage,
|
|
||||||
participationMet,
|
|
||||||
participationLPMet,
|
|
||||||
totalTokensVoted,
|
|
||||||
totalEquityLikeShareWeight,
|
|
||||||
noPercentage,
|
|
||||||
noLPPercentage,
|
|
||||||
yesPercentage,
|
|
||||||
yesLPPercentage,
|
|
||||||
noTokens,
|
noTokens,
|
||||||
noEquityLikeShareWeight,
|
noEquityLikeShareWeight,
|
||||||
yesTokens,
|
yesTokens,
|
||||||
yesEquityLikeShareWeight,
|
yesEquityLikeShareWeight,
|
||||||
yesVotes: new BigNumber(proposal?.votes.yes.totalNumber ?? 0),
|
totalTokensVoted,
|
||||||
noVotes: new BigNumber(proposal?.votes.no.totalNumber ?? 0),
|
totalEquityLikeShareWeight,
|
||||||
totalVotes: new BigNumber(proposal?.votes.yes.totalNumber ?? 0).plus(
|
yesPercentage,
|
||||||
proposal?.votes.no.totalNumber ?? 0
|
yesLPPercentage,
|
||||||
),
|
noPercentage,
|
||||||
requiredMajorityPercentage,
|
noLPPercentage,
|
||||||
requiredMajorityLPPercentage,
|
participationMet,
|
||||||
requiredParticipation: new BigNumber(requiredParticipation).times(100),
|
participationLPMet,
|
||||||
requiredParticipationLP:
|
|
||||||
requiredParticipationLP &&
|
|
||||||
new BigNumber(requiredParticipationLP).times(100),
|
|
||||||
majorityMet,
|
majorityMet,
|
||||||
majorityLPMet,
|
majorityLPMet,
|
||||||
|
totalTokensPercentage,
|
||||||
|
totalLPTokensPercentage,
|
||||||
|
willPassByTokenVote,
|
||||||
|
willPassByLPVote,
|
||||||
|
yesVotes: new BigNumber(votes.yes.totalNumber ?? 0),
|
||||||
|
noVotes: new BigNumber(votes.no.totalNumber ?? 0),
|
||||||
|
totalVotes: new BigNumber(votes.yes.totalNumber ?? 0).plus(
|
||||||
|
votes.no.totalNumber ?? 0
|
||||||
|
),
|
||||||
|
requiredParticipation: new BigNumber(params.requiredParticipation).times(
|
||||||
|
100
|
||||||
|
),
|
||||||
|
requiredParticipationLP: new BigNumber(
|
||||||
|
params.requiredParticipationLP
|
||||||
|
).times(100),
|
||||||
|
willPass,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,442 +0,0 @@
|
|||||||
fragment NewMarketProductField on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateMarketState on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateMarketState {
|
|
||||||
updateType
|
|
||||||
market {
|
|
||||||
decimalPlaces
|
|
||||||
id
|
|
||||||
tradableInstrument {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
... on Future {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
... on Perpetual {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name
|
|
||||||
code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateType
|
|
||||||
price
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateReferralProgram on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateReferralProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumEpochs
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
referralDiscountFactor
|
|
||||||
referralRewardFactor
|
|
||||||
}
|
|
||||||
endOfProgram: endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
stakingTiers {
|
|
||||||
minimumStakedTokens
|
|
||||||
referralRewardMultiplier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateVolumeDiscountProgram on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateVolumeDiscountProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
volumeDiscountFactor
|
|
||||||
}
|
|
||||||
endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query Proposal(
|
|
||||||
$proposalId: ID!
|
|
||||||
$includeNewMarketProductField: Boolean!
|
|
||||||
$includeUpdateMarketState: Boolean!
|
|
||||||
$includeUpdateReferralProgram: Boolean!
|
|
||||||
) {
|
|
||||||
proposal(id: $proposalId) {
|
|
||||||
... on Proposal {
|
|
||||||
id
|
|
||||||
rationale {
|
|
||||||
title
|
|
||||||
description
|
|
||||||
}
|
|
||||||
reference
|
|
||||||
state
|
|
||||||
datetime
|
|
||||||
rejectionReason
|
|
||||||
party {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
errorDetails
|
|
||||||
...NewMarketProductField @include(if: $includeNewMarketProductField)
|
|
||||||
...UpdateMarketState @include(if: $includeUpdateMarketState)
|
|
||||||
...UpdateReferralProgram @include(if: $includeUpdateReferralProgram)
|
|
||||||
...UpdateVolumeDiscountProgram
|
|
||||||
terms {
|
|
||||||
closingDatetime
|
|
||||||
enactmentDatetime
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
decimalPlaces
|
|
||||||
metadata
|
|
||||||
riskParameters {
|
|
||||||
... on LogNormalRiskModel {
|
|
||||||
riskAversionParameter
|
|
||||||
tau
|
|
||||||
params {
|
|
||||||
mu
|
|
||||||
r
|
|
||||||
sigma
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on SimpleRiskModel {
|
|
||||||
params {
|
|
||||||
factorLong
|
|
||||||
factorShort
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
instrument {
|
|
||||||
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 {
|
|
||||||
settlementAsset {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
}
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
priceMonitoringParameters {
|
|
||||||
triggers {
|
|
||||||
horizonSecs
|
|
||||||
probability
|
|
||||||
auctionExtensionSecs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
liquidityMonitoringParameters {
|
|
||||||
targetStakeParameters {
|
|
||||||
timeWindow
|
|
||||||
scalingFactor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
positionDecimalPlaces
|
|
||||||
linearSlippageFactor
|
|
||||||
}
|
|
||||||
... on UpdateMarket {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
metadata
|
|
||||||
priceMonitoringParameters {
|
|
||||||
triggers {
|
|
||||||
horizonSecs
|
|
||||||
probability
|
|
||||||
auctionExtensionSecs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
liquidityMonitoringParameters {
|
|
||||||
targetStakeParameters {
|
|
||||||
timeWindow
|
|
||||||
scalingFactor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
riskParameters {
|
|
||||||
... on UpdateMarketSimpleRiskModel {
|
|
||||||
simple {
|
|
||||||
factorLong
|
|
||||||
factorShort
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateMarketLogNormalRiskModel {
|
|
||||||
logNormal {
|
|
||||||
riskAversionParameter
|
|
||||||
tau
|
|
||||||
params {
|
|
||||||
r
|
|
||||||
sigma
|
|
||||||
mu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on NewAsset {
|
|
||||||
name
|
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
source {
|
|
||||||
... on BuiltinAsset {
|
|
||||||
maxFaucetAmountMint
|
|
||||||
}
|
|
||||||
... on ERC20 {
|
|
||||||
contractAddress
|
|
||||||
lifetimeLimit
|
|
||||||
withdrawThreshold
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateNetworkParameter {
|
|
||||||
networkParameter {
|
|
||||||
key
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateAsset {
|
|
||||||
quantum
|
|
||||||
assetId
|
|
||||||
source {
|
|
||||||
... on UpdateERC20 {
|
|
||||||
lifetimeLimit
|
|
||||||
withdrawThreshold
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
votes {
|
|
||||||
yes {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
no {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
@ -1,69 +0,0 @@
|
|||||||
import { render, screen, waitFor } from '@testing-library/react';
|
|
||||||
import { generateProposal } from '../test-helpers/generate-proposals';
|
|
||||||
import type { ProposalQuery } from './__generated__/Proposal';
|
|
||||||
import { ProposalContainer } from './proposal-container';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
|
||||||
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
|
||||||
import { ProposalDocument } from './__generated__/Proposal';
|
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/data-provider', () => ({
|
|
||||||
...jest.requireActual('@vegaprotocol/data-provider'),
|
|
||||||
useDataProvider: jest.fn(() => ({ data: [], loading: false })),
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('../components/proposal', () => ({
|
|
||||||
Proposal: () => <div data-testid="proposal" />,
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('../components/proposal-not-found', () => ({
|
|
||||||
ProposalNotFound: () => <div data-testid="proposal-not-found" />,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const renderComponent = (
|
|
||||||
proposal: ProposalQuery['proposal'] | null,
|
|
||||||
id: string
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<MemoryRouter initialEntries={[`/governance/${id}`]}>
|
|
||||||
<MockedProvider
|
|
||||||
mocks={[
|
|
||||||
{
|
|
||||||
request: {
|
|
||||||
query: ProposalDocument,
|
|
||||||
variables: {
|
|
||||||
proposalId: id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: { data: { proposal } },
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Routes>
|
|
||||||
<Route
|
|
||||||
path={`/governance/:proposalId`}
|
|
||||||
element={<ProposalContainer />}
|
|
||||||
/>
|
|
||||||
</Routes>
|
|
||||||
</MockedProvider>
|
|
||||||
</MemoryRouter>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// These tests are broken due to schema changes. NewMarket.futureProduct -> NewMarket.product union
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
|
||||||
describe.skip('Proposal container', () => {
|
|
||||||
it('Renders not found if the proposal is not found', async () => {
|
|
||||||
render(renderComponent(null, 'foo'));
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.getByTestId('proposal-not-found')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Renders proposal details if proposal is found', async () => {
|
|
||||||
const proposal = generateProposal({ id: 'foo' });
|
|
||||||
render(renderComponent(proposal as ProposalQuery['proposal'], 'foo'));
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.getByTestId('proposal')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,260 +1,39 @@
|
|||||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
import { Proposal } from '../components/proposal';
|
|
||||||
import { ProposalNotFound } from '../components/proposal-not-found';
|
|
||||||
import { useProposalQuery } from './__generated__/Proposal';
|
|
||||||
import { useFetch } from '@vegaprotocol/react-helpers';
|
import { useFetch } from '@vegaprotocol/react-helpers';
|
||||||
import { ENV } from '../../../config';
|
import { ENV } from '../../../config';
|
||||||
import { useDataProvider } from '@vegaprotocol/data-provider';
|
import { Proposal } from '../components/proposal';
|
||||||
import { marketInfoProvider } from '@vegaprotocol/markets';
|
import { ProposalNotFound } from '../components/proposal-not-found';
|
||||||
import { useAssetQuery } from '@vegaprotocol/assets';
|
import { useProposalQuery } from '../__generated__/Proposals';
|
||||||
import {
|
|
||||||
NetworkParams,
|
|
||||||
useNetworkParams,
|
|
||||||
} from '@vegaprotocol/network-parameters';
|
|
||||||
import { useParentMarketIdQuery } from '@vegaprotocol/markets';
|
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
|
||||||
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 [
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal,
|
|
||||||
setMostRecentlyEnactedAssociatedMarketProposal,
|
|
||||||
] = useState(undefined);
|
|
||||||
const params = useParams<{ proposalId: string }>();
|
const params = useParams<{ proposalId: string }>();
|
||||||
|
|
||||||
const {
|
|
||||||
params: networkParams,
|
|
||||||
loading: networkParamsLoading,
|
|
||||||
error: networkParamsError,
|
|
||||||
} = useNetworkParams([
|
|
||||||
NetworkParams.governance_proposal_market_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_updateMarket_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_asset_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_updateAsset_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_updateNetParam_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_freeform_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_referralProgram_minVoterBalance,
|
|
||||||
NetworkParams.governance_proposal_VolumeDiscountProgram_minVoterBalance,
|
|
||||||
NetworkParams.spam_protection_voting_min_tokens,
|
|
||||||
NetworkParams.governance_proposal_market_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_updateMarket_requiredMajorityLP,
|
|
||||||
NetworkParams.governance_proposal_asset_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_updateAsset_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_updateNetParam_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_freeform_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_referralProgram_requiredMajority,
|
|
||||||
NetworkParams.governance_proposal_VolumeDiscountProgram_requiredMajority,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: { data: restData, loading: restLoading, error: restError },
|
state: { data: restData, loading: restLoading, error: restError },
|
||||||
} = useFetch(`${ENV.rest}governance?proposalId=${params.proposalId}`);
|
} = useFetch(`${ENV.rest}governance?proposalId=${params.proposalId}`);
|
||||||
|
|
||||||
const { data, loading, error, refetch } = useProposalQuery({
|
const { data, loading, error } = useProposalQuery({
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
errorPolicy: 'ignore',
|
errorPolicy: 'ignore',
|
||||||
variables: {
|
variables: {
|
||||||
proposalId: params.proposalId || '',
|
proposalId: params.proposalId || '',
|
||||||
includeNewMarketProductField: !!featureFlags.PRODUCT_PERPETUALS,
|
|
||||||
includeUpdateMarketState: !!featureFlags.UPDATE_MARKET_STATE,
|
|
||||||
includeUpdateReferralProgram: !!featureFlags.REFERRALS,
|
|
||||||
},
|
},
|
||||||
skip: !params.proposalId,
|
skip: !params.proposalId,
|
||||||
|
pollInterval: 2000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const proposal = data?.proposal as IProposal;
|
|
||||||
|
|
||||||
const successor = useSuccessorMarketProposalDetails(params.proposalId);
|
|
||||||
|
|
||||||
const isSuccessor = !!successor?.parentMarketId || !!successor.code;
|
|
||||||
|
|
||||||
const {
|
|
||||||
state: {
|
|
||||||
data: originalMarketProposalRestData,
|
|
||||||
loading: originalMarketProposalRestLoading,
|
|
||||||
error: originalMarketProposalRestError,
|
|
||||||
},
|
|
||||||
} = useFetch(
|
|
||||||
`${ENV.rest}governance?proposalId=${
|
|
||||||
proposal?.terms.change.__typename === 'UpdateMarket' &&
|
|
||||||
proposal.terms.change.marketId
|
|
||||||
}`,
|
|
||||||
undefined,
|
|
||||||
true,
|
|
||||||
proposal?.terms.change.__typename !== 'UpdateMarket'
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
|
||||||
state: {
|
|
||||||
data: previouslyEnactedMarketProposalsRestData,
|
|
||||||
loading: previouslyEnactedMarketProposalsRestLoading,
|
|
||||||
error: previouslyEnactedMarketProposalsRestError,
|
|
||||||
},
|
|
||||||
} = useFetch(
|
|
||||||
`${ENV.rest}governances?proposalState=STATE_ENACTED&proposalType=TYPE_UPDATE_MARKET`,
|
|
||||||
undefined,
|
|
||||||
true,
|
|
||||||
proposal?.terms.change.__typename !== 'UpdateMarket'
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: marketData,
|
|
||||||
loading: marketLoading,
|
|
||||||
error: marketError,
|
|
||||||
} = useDataProvider({
|
|
||||||
dataProvider: marketInfoProvider,
|
|
||||||
skipUpdates: true,
|
|
||||||
variables: {
|
|
||||||
marketId: proposal?.id || '',
|
|
||||||
skip: !proposal?.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: parentMarketId,
|
|
||||||
loading: parentMarketIdLoading,
|
|
||||||
error: parentMarketIdError,
|
|
||||||
} = useParentMarketIdQuery({
|
|
||||||
variables: {
|
|
||||||
marketId: marketData?.id || '',
|
|
||||||
},
|
|
||||||
skip: !featureFlags.SUCCESSOR_MARKETS || !isSuccessor || !marketData?.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: parentMarketData,
|
|
||||||
loading: parentMarketLoading,
|
|
||||||
error: parentMarketError,
|
|
||||||
} = useDataProvider({
|
|
||||||
dataProvider: marketInfoProvider,
|
|
||||||
skipUpdates: true,
|
|
||||||
variables: {
|
|
||||||
marketId: parentMarketId?.market?.parentMarketID || '',
|
|
||||||
skip:
|
|
||||||
!featureFlags.SUCCESSOR_MARKETS ||
|
|
||||||
!isSuccessor ||
|
|
||||||
!parentMarketId?.market?.parentMarketID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: assetData,
|
|
||||||
loading: assetLoading,
|
|
||||||
error: assetError,
|
|
||||||
} = useAssetQuery({
|
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
variables: {
|
|
||||||
assetId:
|
|
||||||
(proposal?.terms.change.__typename === 'NewAsset' && proposal?.id) ||
|
|
||||||
(proposal?.terms.change.__typename === 'UpdateAsset' &&
|
|
||||||
proposal.terms.change.assetId) ||
|
|
||||||
'',
|
|
||||||
},
|
|
||||||
skip: !['NewAsset', 'UpdateAsset'].includes(
|
|
||||||
proposal?.terms?.change?.__typename || ''
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (
|
|
||||||
previouslyEnactedMarketProposalsRestData &&
|
|
||||||
proposal?.terms.change.__typename === 'UpdateMarket'
|
|
||||||
) {
|
|
||||||
const change = proposal?.terms?.change as { marketId: string };
|
|
||||||
|
|
||||||
const filteredProposals =
|
|
||||||
// @ts-ignore rest data is not typed
|
|
||||||
previouslyEnactedMarketProposalsRestData.connection.edges.filter(
|
|
||||||
// @ts-ignore rest data is not typed
|
|
||||||
({ node }) =>
|
|
||||||
node?.proposal?.terms?.updateMarket?.marketId === change.marketId
|
|
||||||
);
|
|
||||||
|
|
||||||
const sortedProposals = filteredProposals.sort(
|
|
||||||
// @ts-ignore rest data is not typed
|
|
||||||
(a, b) =>
|
|
||||||
new Date(a?.node?.terms?.enactmentTimestamp).getTime() -
|
|
||||||
new Date(b?.node?.terms?.enactmentTimestamp).getTime()
|
|
||||||
);
|
|
||||||
|
|
||||||
setMostRecentlyEnactedAssociatedMarketProposal(
|
|
||||||
sortedProposals[sortedProposals.length - 1]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [
|
|
||||||
previouslyEnactedMarketProposalsRestData,
|
|
||||||
params.proposalId,
|
|
||||||
proposal?.terms.change.__typename,
|
|
||||||
proposal?.terms.change,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const interval = setInterval(refetch, 2000);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [refetch]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
loading={
|
loading={Boolean(loading || restLoading)}
|
||||||
loading ||
|
error={error || restError}
|
||||||
marketLoading ||
|
|
||||||
assetLoading ||
|
|
||||||
networkParamsLoading ||
|
|
||||||
parentMarketIdLoading ||
|
|
||||||
parentMarketLoading ||
|
|
||||||
(restLoading ? (restLoading as boolean) : false) ||
|
|
||||||
(originalMarketProposalRestLoading
|
|
||||||
? (originalMarketProposalRestLoading as boolean)
|
|
||||||
: false) ||
|
|
||||||
(previouslyEnactedMarketProposalsRestLoading
|
|
||||||
? (previouslyEnactedMarketProposalsRestLoading as boolean)
|
|
||||||
: false)
|
|
||||||
}
|
|
||||||
error={
|
|
||||||
error ||
|
|
||||||
marketError ||
|
|
||||||
assetError ||
|
|
||||||
networkParamsError ||
|
|
||||||
parentMarketIdError ||
|
|
||||||
parentMarketError ||
|
|
||||||
restError ||
|
|
||||||
originalMarketProposalRestError ||
|
|
||||||
previouslyEnactedMarketProposalsRestError
|
|
||||||
}
|
|
||||||
data={{
|
data={{
|
||||||
...data,
|
...data,
|
||||||
...networkParams,
|
|
||||||
...(marketData ? { newMarketData: marketData } : {}),
|
|
||||||
...(parentMarketData ? { parentMarketData } : {}),
|
|
||||||
...(assetData ? { assetData } : {}),
|
|
||||||
...(restData ? { restData } : {}),
|
...(restData ? { restData } : {}),
|
||||||
...(originalMarketProposalRestData
|
|
||||||
? { originalMarketProposalRestData }
|
|
||||||
: {}),
|
|
||||||
...(previouslyEnactedMarketProposalsRestData
|
|
||||||
? { previouslyEnactedMarketProposalsRestData }
|
|
||||||
: {}),
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{data?.proposal ? (
|
{data?.proposal ? (
|
||||||
<Proposal
|
<Proposal proposal={data.proposal} restData={restData} />
|
||||||
proposal={proposal}
|
|
||||||
networkParams={networkParams}
|
|
||||||
restData={restData}
|
|
||||||
marketData={marketData}
|
|
||||||
parentMarketData={parentMarketData}
|
|
||||||
assetData={assetData}
|
|
||||||
originalMarketProposalRestData={originalMarketProposalRestData}
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal={
|
|
||||||
mostRecentlyEnactedAssociatedMarketProposal
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<ProposalNotFound />
|
<ProposalNotFound />
|
||||||
)}
|
)}
|
||||||
|
@ -1,186 +0,0 @@
|
|||||||
fragment NewMarketProductFields on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateMarketStates on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateMarketState {
|
|
||||||
updateType
|
|
||||||
market {
|
|
||||||
decimalPlaces
|
|
||||||
id
|
|
||||||
tradableInstrument {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
... on Future {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
... on Perpetual {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name
|
|
||||||
code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateType
|
|
||||||
price
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateReferralPrograms on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateReferralProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumEpochs
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
referralDiscountFactor
|
|
||||||
referralRewardFactor
|
|
||||||
}
|
|
||||||
endOfProgram: endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
stakingTiers {
|
|
||||||
minimumStakedTokens
|
|
||||||
referralRewardMultiplier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment UpdateVolumeDiscountPrograms on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateVolumeDiscountProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
volumeDiscountFactor
|
|
||||||
}
|
|
||||||
endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment ProposalFields on Proposal {
|
|
||||||
id
|
|
||||||
rationale {
|
|
||||||
title
|
|
||||||
description
|
|
||||||
}
|
|
||||||
reference
|
|
||||||
state
|
|
||||||
datetime
|
|
||||||
rejectionReason
|
|
||||||
party {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
errorDetails
|
|
||||||
terms {
|
|
||||||
closingDatetime
|
|
||||||
enactmentDatetime
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
instrument {
|
|
||||||
name
|
|
||||||
code
|
|
||||||
product {
|
|
||||||
... on FutureProduct {
|
|
||||||
settlementAsset {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on PerpetualProduct {
|
|
||||||
settlementAsset {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateMarket {
|
|
||||||
marketId
|
|
||||||
}
|
|
||||||
... on NewAsset {
|
|
||||||
__typename
|
|
||||||
name
|
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
source {
|
|
||||||
... on BuiltinAsset {
|
|
||||||
maxFaucetAmountMint
|
|
||||||
}
|
|
||||||
... on ERC20 {
|
|
||||||
contractAddress
|
|
||||||
withdrawThreshold
|
|
||||||
lifetimeLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateNetworkParameter {
|
|
||||||
networkParameter {
|
|
||||||
key
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateAsset {
|
|
||||||
quantum
|
|
||||||
assetId
|
|
||||||
source {
|
|
||||||
... on UpdateERC20 {
|
|
||||||
lifetimeLimit
|
|
||||||
withdrawThreshold
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
votes {
|
|
||||||
yes {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
no {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query Proposals(
|
|
||||||
$includeNewMarketProductFields: Boolean!
|
|
||||||
$includeUpdateMarketStates: Boolean!
|
|
||||||
$includeUpdateReferralPrograms: Boolean!
|
|
||||||
) {
|
|
||||||
proposalsConnection {
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
...ProposalFields
|
|
||||||
...NewMarketProductFields @include(if: $includeNewMarketProductFields)
|
|
||||||
...UpdateMarketStates @include(if: $includeUpdateMarketStates)
|
|
||||||
...UpdateReferralPrograms @include(if: $includeUpdateReferralPrograms)
|
|
||||||
...UpdateVolumeDiscountPrograms
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,247 +0,0 @@
|
|||||||
import * as Types from '@vegaprotocol/types';
|
|
||||||
|
|
||||||
import { gql } from '@apollo/client';
|
|
||||||
import * as Apollo from '@apollo/client';
|
|
||||||
const defaultOptions = {} as const;
|
|
||||||
export type NewMarketProductFieldsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', product?: { __typename: 'FutureProduct' } | { __typename: 'PerpetualProduct' } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } };
|
|
||||||
|
|
||||||
export type UpdateMarketStatesFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } };
|
|
||||||
|
|
||||||
export type UpdateReferralProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: any, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } };
|
|
||||||
|
|
||||||
export type UpdateVolumeDiscountProgramsFragment = { __typename?: 'Proposal', terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } } };
|
|
||||||
|
|
||||||
export type ProposalFieldsFragment = { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, product?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | { __typename?: 'PerpetualProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | { __typename?: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } };
|
|
||||||
|
|
||||||
export type ProposalsQueryVariables = Types.Exact<{
|
|
||||||
includeNewMarketProductFields: Types.Scalars['Boolean'];
|
|
||||||
includeUpdateMarketStates: Types.Scalars['Boolean'];
|
|
||||||
includeUpdateReferralPrograms: Types.Scalars['Boolean'];
|
|
||||||
}>;
|
|
||||||
|
|
||||||
|
|
||||||
export type ProposalsQuery = { __typename?: 'Query', proposalsConnection?: { __typename?: 'ProposalsConnection', edges?: Array<{ __typename?: 'ProposalEdge', node: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, withdrawThreshold: string, lifetimeLimit: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, product?: { __typename: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | { __typename: 'PerpetualProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | { __typename: 'SpotProduct' } | null } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: any, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } } | null> | null } | null };
|
|
||||||
|
|
||||||
export const NewMarketProductFieldsFragmentDoc = gql`
|
|
||||||
fragment NewMarketProductFields on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
export const UpdateMarketStatesFragmentDoc = gql`
|
|
||||||
fragment UpdateMarketStates on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateMarketState {
|
|
||||||
updateType
|
|
||||||
market {
|
|
||||||
decimalPlaces
|
|
||||||
id
|
|
||||||
tradableInstrument {
|
|
||||||
instrument {
|
|
||||||
product {
|
|
||||||
__typename
|
|
||||||
... on Future {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
... on Perpetual {
|
|
||||||
quoteName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name
|
|
||||||
code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateType
|
|
||||||
price
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
export const UpdateReferralProgramsFragmentDoc = gql`
|
|
||||||
fragment UpdateReferralPrograms on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateReferralProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumEpochs
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
referralDiscountFactor
|
|
||||||
referralRewardFactor
|
|
||||||
}
|
|
||||||
endOfProgram: endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
stakingTiers {
|
|
||||||
minimumStakedTokens
|
|
||||||
referralRewardMultiplier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
export const UpdateVolumeDiscountProgramsFragmentDoc = gql`
|
|
||||||
fragment UpdateVolumeDiscountPrograms on Proposal {
|
|
||||||
terms {
|
|
||||||
change {
|
|
||||||
... on UpdateVolumeDiscountProgram {
|
|
||||||
benefitTiers {
|
|
||||||
minimumRunningNotionalTakerVolume
|
|
||||||
volumeDiscountFactor
|
|
||||||
}
|
|
||||||
endOfProgramTimestamp
|
|
||||||
windowLength
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
export const ProposalFieldsFragmentDoc = gql`
|
|
||||||
fragment ProposalFields on Proposal {
|
|
||||||
id
|
|
||||||
rationale {
|
|
||||||
title
|
|
||||||
description
|
|
||||||
}
|
|
||||||
reference
|
|
||||||
state
|
|
||||||
datetime
|
|
||||||
rejectionReason
|
|
||||||
party {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
errorDetails
|
|
||||||
terms {
|
|
||||||
closingDatetime
|
|
||||||
enactmentDatetime
|
|
||||||
change {
|
|
||||||
... on NewMarket {
|
|
||||||
instrument {
|
|
||||||
name
|
|
||||||
code
|
|
||||||
product {
|
|
||||||
... on FutureProduct {
|
|
||||||
settlementAsset {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on PerpetualProduct {
|
|
||||||
settlementAsset {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateMarket {
|
|
||||||
marketId
|
|
||||||
}
|
|
||||||
... on NewAsset {
|
|
||||||
__typename
|
|
||||||
name
|
|
||||||
symbol
|
|
||||||
decimals
|
|
||||||
quantum
|
|
||||||
source {
|
|
||||||
... on BuiltinAsset {
|
|
||||||
maxFaucetAmountMint
|
|
||||||
}
|
|
||||||
... on ERC20 {
|
|
||||||
contractAddress
|
|
||||||
withdrawThreshold
|
|
||||||
lifetimeLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateNetworkParameter {
|
|
||||||
networkParameter {
|
|
||||||
key
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on UpdateAsset {
|
|
||||||
quantum
|
|
||||||
assetId
|
|
||||||
source {
|
|
||||||
... on UpdateERC20 {
|
|
||||||
lifetimeLimit
|
|
||||||
withdrawThreshold
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
votes {
|
|
||||||
yes {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
no {
|
|
||||||
totalTokens
|
|
||||||
totalNumber
|
|
||||||
totalEquityLikeShareWeight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
export const ProposalsDocument = gql`
|
|
||||||
query Proposals($includeNewMarketProductFields: Boolean!, $includeUpdateMarketStates: Boolean!, $includeUpdateReferralPrograms: Boolean!) {
|
|
||||||
proposalsConnection {
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
...ProposalFields
|
|
||||||
...NewMarketProductFields @include(if: $includeNewMarketProductFields)
|
|
||||||
...UpdateMarketStates @include(if: $includeUpdateMarketStates)
|
|
||||||
...UpdateReferralPrograms @include(if: $includeUpdateReferralPrograms)
|
|
||||||
...UpdateVolumeDiscountPrograms
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
${ProposalFieldsFragmentDoc}
|
|
||||||
${NewMarketProductFieldsFragmentDoc}
|
|
||||||
${UpdateMarketStatesFragmentDoc}
|
|
||||||
${UpdateReferralProgramsFragmentDoc}
|
|
||||||
${UpdateVolumeDiscountProgramsFragmentDoc}`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __useProposalsQuery__
|
|
||||||
*
|
|
||||||
* To run a query within a React component, call `useProposalsQuery` and pass it any options that fit your needs.
|
|
||||||
* When your component renders, `useProposalsQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
|
||||||
* you can use to render your UI.
|
|
||||||
*
|
|
||||||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* const { data, loading, error } = useProposalsQuery({
|
|
||||||
* variables: {
|
|
||||||
* includeNewMarketProductFields: // value for 'includeNewMarketProductFields'
|
|
||||||
* includeUpdateMarketStates: // value for 'includeUpdateMarketStates'
|
|
||||||
* includeUpdateReferralPrograms: // value for 'includeUpdateReferralPrograms'
|
|
||||||
* },
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
export function useProposalsQuery(baseOptions: Apollo.QueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
|
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
|
||||||
return Apollo.useQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
|
|
||||||
}
|
|
||||||
export function useProposalsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProposalsQuery, ProposalsQueryVariables>) {
|
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
|
||||||
return Apollo.useLazyQuery<ProposalsQuery, ProposalsQueryVariables>(ProposalsDocument, options);
|
|
||||||
}
|
|
||||||
export type ProposalsQueryHookResult = ReturnType<typeof useProposalsQuery>;
|
|
||||||
export type ProposalsLazyQueryHookResult = ReturnType<typeof useProposalsLazyQuery>;
|
|
||||||
export type ProposalsQueryResult = Apollo.QueryResult<ProposalsQuery, ProposalsQueryVariables>;
|
|
@ -1,31 +1,27 @@
|
|||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
|
import compact from 'lodash/compact';
|
||||||
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { SplashLoader } from '../../../components/splash-loader';
|
import { SplashLoader } from '../../../components/splash-loader';
|
||||||
import { ProposalsList } from '../components/proposals-list';
|
import { ProposalsList } from '../components/proposals-list';
|
||||||
import { getNodes, removePaginationWrapper } from '@vegaprotocol/utils';
|
import { getNodes } from '@vegaprotocol/utils';
|
||||||
import {
|
import {
|
||||||
ProposalState,
|
ProposalState,
|
||||||
ProtocolUpgradeProposalStatus,
|
ProtocolUpgradeProposalStatus,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import { type NodeConnection, type NodeEdge } from '@vegaprotocol/utils';
|
import { type NodeConnection, type NodeEdge } from '@vegaprotocol/utils';
|
||||||
import {
|
import { useProposalsQuery } from '../__generated__/Proposals';
|
||||||
useProposalsQuery,
|
|
||||||
type ProposalFieldsFragment,
|
|
||||||
} from './__generated__/Proposals';
|
|
||||||
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import { useProtocolUpgradeProposalsQuery } from '@vegaprotocol/proposals';
|
import { useProtocolUpgradeProposalsQuery } from '@vegaprotocol/proposals';
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
import { type BatchProposal, type Proposal } from '../types';
|
||||||
|
|
||||||
export function getNotRejectedProposals(data?: ProposalFieldsFragment[]) {
|
export function getNotRejectedProposals(
|
||||||
return flow([
|
data?: Array<Proposal | BatchProposal>
|
||||||
(data) =>
|
) {
|
||||||
data.filter(
|
if (!data) return [];
|
||||||
(p: ProposalFieldsFragment) => p?.state !== ProposalState.STATE_REJECTED
|
return data.filter((p) => p.state !== ProposalState.STATE_REJECTED);
|
||||||
),
|
|
||||||
])(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNotRejectedProtocolUpgradeProposals<
|
export function getNotRejectedProtocolUpgradeProposals<
|
||||||
@ -43,17 +39,11 @@ export function getNotRejectedProtocolUpgradeProposals<
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ProposalsContainer = () => {
|
export const ProposalsContainer = () => {
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data, loading, error } = useProposalsQuery({
|
const { data, loading, error } = useProposalsQuery({
|
||||||
pollInterval: 5000,
|
pollInterval: 5000,
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
errorPolicy: 'ignore',
|
errorPolicy: 'ignore',
|
||||||
variables: {
|
|
||||||
includeNewMarketProductFields: !!featureFlags.PRODUCT_PERPETUALS,
|
|
||||||
includeUpdateMarketStates: !!featureFlags.UPDATE_MARKET_STATE,
|
|
||||||
includeUpdateReferralPrograms: !!featureFlags.REFERRALS,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -69,7 +59,7 @@ export const ProposalsContainer = () => {
|
|||||||
const proposals = useMemo(
|
const proposals = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getNotRejectedProposals(
|
getNotRejectedProposals(
|
||||||
removePaginationWrapper(data?.proposalsConnection?.edges)
|
compact(data?.proposalsConnection?.edges?.map((e) => e?.proposalNode))
|
||||||
),
|
),
|
||||||
[data]
|
[data]
|
||||||
);
|
);
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
import compact from 'lodash/compact';
|
||||||
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { SplashLoader } from '../../../components/splash-loader';
|
import { SplashLoader } from '../../../components/splash-loader';
|
||||||
import { RejectedProposalsList } from '../components/proposals-list';
|
import { RejectedProposalsList } from '../components/proposals-list';
|
||||||
import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals';
|
import { type ProposalFieldsFragment } from '../__generated__/Proposals';
|
||||||
import { useProposalsQuery } from '../proposals/__generated__/Proposals';
|
import { useProposalsQuery } from '../__generated__/Proposals';
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
|
||||||
import flow from 'lodash/flow';
|
import flow from 'lodash/flow';
|
||||||
import orderBy from 'lodash/orderBy';
|
import orderBy from 'lodash/orderBy';
|
||||||
import { ProposalState } from '@vegaprotocol/types';
|
import { ProposalState } from '@vegaprotocol/types';
|
||||||
import { useFeatureFlags } from '@vegaprotocol/environment';
|
import { type BatchProposal, type Proposal } from '../types';
|
||||||
|
|
||||||
const orderByDate = (arr: ProposalFieldsFragment[]) =>
|
const orderByDate = (arr: ProposalFieldsFragment[]) =>
|
||||||
orderBy(
|
orderBy(
|
||||||
@ -22,7 +22,9 @@ const orderByDate = (arr: ProposalFieldsFragment[]) =>
|
|||||||
['desc', 'desc']
|
['desc', 'desc']
|
||||||
);
|
);
|
||||||
|
|
||||||
export function getRejectedProposals(data?: ProposalFieldsFragment[] | null) {
|
export function getRejectedProposals(
|
||||||
|
data?: Array<Proposal | BatchProposal> | null
|
||||||
|
) {
|
||||||
return flow([
|
return flow([
|
||||||
(data) =>
|
(data) =>
|
||||||
data.filter(
|
data.filter(
|
||||||
@ -33,23 +35,17 @@ export function getRejectedProposals(data?: ProposalFieldsFragment[] | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const RejectedProposalsContainer = () => {
|
export const RejectedProposalsContainer = () => {
|
||||||
const featureFlags = useFeatureFlags((state) => state.flags);
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data, loading, error } = useProposalsQuery({
|
const { data, loading, error } = useProposalsQuery({
|
||||||
pollInterval: 5000,
|
pollInterval: 5000,
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
errorPolicy: 'ignore',
|
errorPolicy: 'ignore',
|
||||||
variables: {
|
|
||||||
includeNewMarketProductFields: !!featureFlags.PRODUCT_PERPETUALS,
|
|
||||||
includeUpdateMarketStates: !!featureFlags.UPDATE_MARKET_STATE,
|
|
||||||
includeUpdateReferralPrograms: !!featureFlags.REFERRALS,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const proposals = useMemo(
|
const proposals = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getRejectedProposals(
|
getRejectedProposals(
|
||||||
removePaginationWrapper(data?.proposalsConnection?.edges)
|
compact(data?.proposalsConnection?.edges?.map((e) => e?.proposalNode))
|
||||||
),
|
),
|
||||||
[data]
|
[data]
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,7 @@ import isArray from 'lodash/isArray';
|
|||||||
import mergeWith from 'lodash/mergeWith';
|
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 '../__generated__/Proposals';
|
||||||
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals';
|
||||||
import { type Proposal } from '../types';
|
import { type Proposal } from '../types';
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
import type { ProposalQuery } from './proposal/__generated__/Proposal';
|
import { type ProposalNode } from '@vegaprotocol/types';
|
||||||
|
import {
|
||||||
|
type BatchProposalFieldsFragment,
|
||||||
|
type ProposalFieldsFragment,
|
||||||
|
} from './__generated__/Proposals';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default Proposal type needs extracting from the ProposalNode union type
|
* 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
|
* as lots of fields on the original type don't exist on BatchProposal. Eventually
|
||||||
* we will support BatchProposal but for now we don't
|
* we will support BatchProposal but for now we don't
|
||||||
*/
|
*/
|
||||||
export type Proposal = Extract<
|
export type Proposal = ProposalFieldsFragment;
|
||||||
ProposalQuery['proposal'],
|
export type BatchProposal = BatchProposalFieldsFragment;
|
||||||
{ __typename?: 'Proposal' }
|
|
||||||
|
export type ProposalChangeType = NonNullable<
|
||||||
|
Proposal['terms']['change']['__typename']
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
export type ProposalType = NonNullable<ProposalNode['__typename']>;
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
"approvers": "Approvers",
|
"approvers": "Approvers",
|
||||||
"as soon as possible": "now",
|
"as soon as possible": "now",
|
||||||
"Asset change": "Asset change",
|
"Asset change": "Asset change",
|
||||||
"AssetID": "Asset ID",
|
"Asset ID: <lozenge>{{id}}</lozenge>": "Asset ID: <lozenge>{{id}}</lozenge>",
|
||||||
"assets": "Assets",
|
"assets": "Assets",
|
||||||
"assetSpecification": "Asset specification",
|
"assetSpecification": "Asset specification",
|
||||||
"associate": "Associate",
|
"associate": "Associate",
|
||||||
@ -81,6 +81,7 @@
|
|||||||
"back": "back",
|
"back": "back",
|
||||||
"backToStaking": "Back to Staking",
|
"backToStaking": "Back to Staking",
|
||||||
"Balance": "Balance",
|
"Balance": "Balance",
|
||||||
|
"Batch proposal": "Batch proposal",
|
||||||
"BenefitTierMinimumActivityStreak": "Minimum activity streak",
|
"BenefitTierMinimumActivityStreak": "Minimum activity streak",
|
||||||
"BenefitTierMinimumActivityStreakDescription": "The minimum number of times the party needs to have completed the activity",
|
"BenefitTierMinimumActivityStreakDescription": "The minimum number of times the party needs to have completed the activity",
|
||||||
"BenefitTierMinimumEpochs": "Minimum epochs",
|
"BenefitTierMinimumEpochs": "Minimum epochs",
|
||||||
@ -109,7 +110,7 @@
|
|||||||
"CancelTransfer": "Cancel transfer",
|
"CancelTransfer": "Cancel transfer",
|
||||||
"CancelTransferProposal": "Cancel transfer proposal",
|
"CancelTransferProposal": "Cancel transfer proposal",
|
||||||
"castYourVote": "Cast your vote",
|
"castYourVote": "Cast your vote",
|
||||||
"Change": "Change",
|
"Change <lozenge>{{key}}</lozenge> to <lozenge>{{value}}</lozenge>": "Change <lozenge>{{key}}</lozenge> to <lozenge>{{value}}</lozenge>",
|
||||||
"changeVote": "Change vote",
|
"changeVote": "Change vote",
|
||||||
"Check to see if you can redeem unlocked VEGA tokens": "Check to see if you can redeem unlocked $VEGA tokens",
|
"Check to see if you can redeem unlocked VEGA tokens": "Check to see if you can redeem unlocked $VEGA tokens",
|
||||||
"Check your vesting VEGA tokens": "Check your vesting $VEGA tokens",
|
"Check your vesting VEGA tokens": "Check your vesting $VEGA tokens",
|
||||||
@ -162,7 +163,10 @@
|
|||||||
"created": "Created",
|
"created": "Created",
|
||||||
"CreateProposalAndDownloadJSONToShare": "Create proposal and download JSON to share",
|
"CreateProposalAndDownloadJSONToShare": "Create proposal and download JSON to share",
|
||||||
"currently": "currently",
|
"currently": "currently",
|
||||||
"currentlySetTo": "Currently expected to ",
|
"Currently expected to <0>pass</0>": "Currently expected to <0>pass</0>",
|
||||||
|
"Currently expected to <0>fail</0>": "Currently expected to <0>fail</0>",
|
||||||
|
"Currently expected to pass: conditions met for {{count}} of {{total}} proposals": "Currently expected to pass: conditions met for {{count}} of {{total}} Proposals",
|
||||||
|
"Currently expected to fail: {{count}} of {{total}} proposals are passing": "Currently expected to fail: {{count}} of {{total}} proposals are passing",
|
||||||
"CurrentValue": "Current value",
|
"CurrentValue": "Current value",
|
||||||
"dataIsIdentical": "Data is identical",
|
"dataIsIdentical": "Data is identical",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
@ -287,7 +291,7 @@
|
|||||||
"Keep track of locked tokens in your wallet with the VEGA (VESTING) token.": "Keep track of locked tokens in your wallet with the $VEGA (VESTING) token.",
|
"Keep track of locked tokens in your wallet with the VEGA (VESTING) token.": "Keep track of locked tokens in your wallet with the $VEGA (VESTING) token.",
|
||||||
"latestProposals": "Latest proposals",
|
"latestProposals": "Latest proposals",
|
||||||
"learnMore": "Learn more",
|
"learnMore": "Learn more",
|
||||||
"left to vote": "left to vote",
|
"{{time}} left to vote": "{{time}} left to vote",
|
||||||
"Link transaction": "Link transaction",
|
"Link transaction": "Link transaction",
|
||||||
"liquidityComingSoon": "Liquidity rewards coming soon",
|
"liquidityComingSoon": "Liquidity rewards coming soon",
|
||||||
"liquidityIntro": "You can read about our incentive program in this <linkToPost>blog post</linkToPost>.",
|
"liquidityIntro": "You can read about our incentive program in this <linkToPost>blog post</linkToPost>.",
|
||||||
@ -421,6 +425,7 @@
|
|||||||
"nextEpoch": "Next epoch",
|
"nextEpoch": "Next epoch",
|
||||||
"No holders": "No holders",
|
"No holders": "No holders",
|
||||||
"No token": "No token",
|
"No token": "No token",
|
||||||
|
"not met": "not met",
|
||||||
"noClosedProposals": "There are no enacted or rejected proposals",
|
"noClosedProposals": "There are no enacted or rejected proposals",
|
||||||
"Node invalid": "Node invalid",
|
"Node invalid": "Node invalid",
|
||||||
"nodeQueryFailed": "Could not get data for validator {{node}}",
|
"nodeQueryFailed": "Could not get data for validator {{node}}",
|
||||||
@ -528,6 +533,8 @@
|
|||||||
"ProductMaturityIsPassed": "Product maturity is passed",
|
"ProductMaturityIsPassed": "Product maturity is passed",
|
||||||
"Proposal": "Proposal",
|
"Proposal": "Proposal",
|
||||||
"proposal": "Proposal",
|
"proposal": "Proposal",
|
||||||
|
"Proposal passed: conditions met for {{count}} of {{total}} proposals": "Proposal passed: conditions met for {{count}} of {{total}} proposals",
|
||||||
|
"Proposal failed: {{count}} of {{total}} proposals passed": "Proposal failed: {{count}} of {{total}} proposals passed",
|
||||||
"Proposal rejected": "Proposal rejected",
|
"Proposal rejected": "Proposal rejected",
|
||||||
"proposalCancelTransferDetails": "Cancel governance transfer details",
|
"proposalCancelTransferDetails": "Cancel governance transfer details",
|
||||||
"proposalChange": "Change <code>{{key}}</code> to <code>{{value}}</code>",
|
"proposalChange": "Change <code>{{key}}</code> to <code>{{value}}</code>",
|
||||||
@ -713,6 +720,7 @@
|
|||||||
"submitProposal": "Submit proposal",
|
"submitProposal": "Submit proposal",
|
||||||
"submittingProposal": "Submitting proposal",
|
"submittingProposal": "Submitting proposal",
|
||||||
"successfullAssociationMessage": "Vega key {{vegaKey}} can now participate in governance and nominate a validator with your associated $VEGA.",
|
"successfullAssociationMessage": "Vega key {{vegaKey}} can now participate in governance and nominate a validator with your associated $VEGA.",
|
||||||
|
"Successor market to": "Successor market to",
|
||||||
"Switch to form for immediate removal": "Switch to remove now",
|
"Switch to form for immediate removal": "Switch to remove now",
|
||||||
"Switch to form for removal at end of epoch": "Switch to remove at end of epoch",
|
"Switch to form for removal at end of epoch": "Switch to remove at end of epoch",
|
||||||
"Symbol": "Symbol",
|
"Symbol": "Symbol",
|
||||||
|
@ -139,6 +139,8 @@ query MarketInfo($marketId: ID!) {
|
|||||||
state
|
state
|
||||||
tradingMode
|
tradingMode
|
||||||
linearSlippageFactor
|
linearSlippageFactor
|
||||||
|
parentMarketID
|
||||||
|
successorMarketID
|
||||||
proposal {
|
proposal {
|
||||||
id
|
id
|
||||||
rationale {
|
rationale {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -66,12 +66,12 @@ export const KeyValueTableRow = ({
|
|||||||
id,
|
id,
|
||||||
}: KeyValueTableRowProps) => {
|
}: KeyValueTableRowProps) => {
|
||||||
const dlClassName = classNames(
|
const dlClassName = classNames(
|
||||||
'flex gap-1 flex-wrap justify-between py-1 text-sm',
|
'flex gap-1 flex-wrap justify-between py-1 text-sm items-start',
|
||||||
{
|
{
|
||||||
'border-b border-neutral-300 dark:border-neutral-700': !noBorder,
|
'border-b border-neutral-300 dark:border-neutral-700': !noBorder,
|
||||||
},
|
},
|
||||||
{ 'flex-col items-start': !inline },
|
{ 'flex-col': !inline },
|
||||||
{ 'flex-row items-center': inline },
|
{ 'flex-row': inline },
|
||||||
className
|
className
|
||||||
);
|
);
|
||||||
const dtClassNames = classNames(
|
const dtClassNames = classNames(
|
||||||
|
Loading…
Reference in New Issue
Block a user