Compare commits

...
Author SHA1 Message Date
Edd c1497b8bce feat(explorer): add successor details flag and on proposal summary 2023-07-18 15:04:07 +01:00
8 changed files with 85 additions and 1 deletions
+1
View File
@@ -27,3 +27,4 @@ NX_EXPLORER_VALIDATORS=1
NX_EXPLORER_MARKETS=1
NX_EXPLORER_ORACLES=1
NX_EXPLORER_TXS_LIST=1
NX_EXPLORER_SUPPORTS_SUCCESSOR_MARKETS=0
+2
View File
@@ -10,3 +10,5 @@ NX_VEGA_URL=https://api.devnet1.vega.xyz/graphql
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
NX_VEGA_EXPLORER_URL=/
NX_EXPLORER_SUPPORTS_SUCCESSOR_MARKETS=1
+1
View File
@@ -1,2 +1,3 @@
# .env is stagnet1, so there are no overrides required
NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz","STAGNET1":"https://stagnet1.explorer.vega.xyz"}'
NX_EXPLORER_SUPPORTS_SUCCESSOR_MARKETS='true'
@@ -0,0 +1,49 @@
import { render } from '@testing-library/react';
import { ProposalSummary } from './summary';
import type { ProposalTerms } from '../tx-proposal';
import { MockedProvider } from '@apollo/client/testing';
import { MemoryRouter } from 'react-router-dom';
jest.mock('../../../../config/flags', () => ({
successorMarkets: true,
}));
describe('tx-proposal', () => {
it('should render extra paragraph when parentMarketId is set', () => {
const terms = {
newMarket: {
changes: {
successorConfiguration: {
parentMarketId: 'market123',
},
},
},
};
const { getByTestId } = render(
<MemoryRouter>
<MockedProvider>
<ProposalSummary id="123" terms={terms as unknown as ProposalTerms} />
</MockedProvider>
</MemoryRouter>
);
expect(getByTestId('successor-link')).toBeInTheDocument();
});
it('should not render extra paragraph when parentMarketId is not set', () => {
const terms: ProposalTerms = {
// add other required properties for terms object
};
const { queryByTestId } = render(
<MemoryRouter>
<MockedProvider>
<ProposalSummary id="123" terms={terms} />
</MockedProvider>
</MemoryRouter>
);
expect(queryByTestId('successor-link')).not.toBeInTheDocument();
});
});
@@ -8,6 +8,9 @@ import { ProposalStatusIcon } from './proposal-status-icon';
import ReactMarkdown from 'react-markdown';
import { ProposalDate } from './proposal-date';
import { t } from '@vegaprotocol/i18n';
import flags from '../../../../config/flags';
import { MarketLink } from '../../../links';
import classNames from 'classnames';
type Rationale = components['schemas']['vegaProposalRationale'];
@@ -56,10 +59,25 @@ export const ProposalSummary = ({
})
: '';
const newMarketSuccessorId = flags.successorMarkets
? terms?.newMarket?.changes?.successorConfiguration?.parentMarketId
: undefined;
console.dir(flags);
console.dir(newMarketSuccessorId);
const successorMarketClasses = classNames({
'text-xs leading-tight pb-2': true,
});
return (
<div className="w-auto max-w-lg border-2 border-solid border-vega-light-100 dark:border-vega-dark-200 p-5">
{id && <ProposalStatusIcon id={id} />}
{rationale?.title && <h1 className="text-xl pb-1">{rationale.title}</h1>}
{flags.successorMarkets && newMarketSuccessorId && (
<p data-testId="successor-link" className={successorMarketClasses}>
<span>{t('Successor market to: ')}</span>
<MarketLink id={newMarketSuccessorId} showMarketName={true} />
</p>
)}
{rationale?.description && (
<div className="pt-2 text-sm leading-tight">
<ReactMarkdown
@@ -76,6 +76,7 @@ export const TxProposal = ({ txData, pubKey, blockData }: TxProposalProps) => {
if (!txData || !txData.command.proposalSubmission) {
return <>{t('Awaiting Block Explorer transaction details')}</>;
}
let deterministicId = '';
const proposal: Proposal = txData.command.proposalSubmission;
+3
View File
@@ -21,6 +21,9 @@ export const ENV = {
vegaRepoUrl: windowOrDefault('NX_VEGA_REPO_URL'),
},
flags: {
successorMarkets: truthy.includes(
windowOrDefault('NX_EXPLORER_SUPPORTS_SUCCESSOR_MARKETS')
),
assets: truthy.includes(windowOrDefault('NX_EXPLORER_ASSETS')),
genesis: truthy.includes(windowOrDefault('NX_EXPLORER_GENESIS')),
governance: truthy.includes(windowOrDefault('NX_EXPLORER_GOVERNANCE')),
+10 -1
View File
@@ -1434,7 +1434,14 @@ export interface components {
/** @description Configuration of the new market. */
readonly changes?: components['schemas']['vegaNewMarketConfiguration'];
};
/** Configuration for a new futures market on Vega */
/** Configuration for a new market successor */
readonly vegaSuccessorConfiguration: {
/** @description ID of the market that this market is a successor to. */
readonly parentMarketId?: string;
/** @description proportion of the insurance pool to be allocated to the successor market. */
readonly insurancePoolFraction?: number;
};
/** Configuration for a new market on Vega */
readonly vegaNewMarketConfiguration: {
/**
* Format: uint64
@@ -1447,6 +1454,8 @@ export interface components {
readonly linearSlippageFactor?: string;
/** @description Liquidity monitoring parameters. */
readonly liquidityMonitoringParameters?: components['schemas']['vegaLiquidityMonitoringParameters'];
/** @description manual addition - successorMarketConfiguration */
readonly successorConfiguration?: components['schemas']['vegaSuccessorConfiguration'];
/** @description Log normal risk model parameters, valid only if MODEL_LOG_NORMAL is selected. */
readonly logNormal?: components['schemas']['vegaLogNormalRiskModel'];
/**