feat(governance): use rest to expose proposal data (#3827)
This commit is contained in:
parent
162b167860
commit
fca229e62a
@ -17,6 +17,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
|||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/test/announcements.json
|
||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||||
|
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||||
|
|
||||||
#Test configuration variables
|
#Test configuration variables
|
||||||
CYPRESS_FAIRGROUND=false
|
CYPRESS_FAIRGROUND=false
|
||||||
|
@ -15,6 +15,7 @@ NX_DELEGATIONS_PAGINATION=50
|
|||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json
|
||||||
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
|
||||||
|
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||||
|
|
||||||
#Test configuration variables
|
#Test configuration variables
|
||||||
CYPRESS_FAIRGROUND=false
|
CYPRESS_FAIRGROUND=false
|
||||||
|
@ -17,6 +17,7 @@ NX_VEGA_WALLET_URL=http://localhost:1789
|
|||||||
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
||||||
NX_DELEGATIONS_PAGINATION=50
|
NX_DELEGATIONS_PAGINATION=50
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
|
NX_VEGA_REST_URL=http://localhost:3008/api/v2/
|
||||||
|
|
||||||
#Test configuration variables
|
#Test configuration variables
|
||||||
CYPRESS_FAIRGROUND=false
|
CYPRESS_FAIRGROUND=false
|
||||||
|
@ -11,3 +11,4 @@ NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
|||||||
NX_DELEGATIONS_PAGINATION=50
|
NX_DELEGATIONS_PAGINATION=50
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-devnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-devnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
|
NX_VEGA_REST_URL=https://api.n00.devnet1.vega.xyz/api/v2/
|
||||||
|
@ -12,3 +12,4 @@ NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40:87edc2605e544f888305d7fc4
|
|||||||
NX_DELEGATIONS_PAGINATION=50
|
NX_DELEGATIONS_PAGINATION=50
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-mainnet-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/mainnet/announcements.json
|
||||||
|
NX_VEGA_REST_URL=https://api.vega.community/api/v2/
|
||||||
|
@ -8,3 +8,4 @@ NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet
|
|||||||
NX_DELEGATIONS_PAGINATION=50
|
NX_DELEGATIONS_PAGINATION=50
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
|
NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/
|
||||||
|
@ -12,3 +12,4 @@ NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
|
|||||||
NX_DELEGATIONS_PAGINATION=50
|
NX_DELEGATIONS_PAGINATION=50
|
||||||
NX_TRANCHES_SERVICE_URL=https://tranches-testnet-k8s.ops.vega.xyz
|
NX_TRANCHES_SERVICE_URL=https://tranches-testnet-k8s.ops.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
|
NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/
|
@ -9,3 +9,4 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io
|
|||||||
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz
|
NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz
|
||||||
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
|
||||||
|
NX_VEGA_REST_URL=https://api-validators-testnet.vega.rocks/api/v2/
|
@ -62,6 +62,7 @@ export const ENV = {
|
|||||||
ethWalletMnemonic: windowOrDefault('NX_ETH_WALLET_MNEMONIC'),
|
ethWalletMnemonic: windowOrDefault('NX_ETH_WALLET_MNEMONIC'),
|
||||||
localProviderUrl: windowOrDefault('NX_LOCAL_PROVIDER_URL'),
|
localProviderUrl: windowOrDefault('NX_LOCAL_PROVIDER_URL'),
|
||||||
delegationsPagination: windowOrDefault('NX_DELEGATIONS_PAGINATION'),
|
delegationsPagination: windowOrDefault('NX_DELEGATIONS_PAGINATION'),
|
||||||
|
rest: windowOrDefault('NX_VEGA_REST_URL'),
|
||||||
flags: {
|
flags: {
|
||||||
NETWORK_DOWN: TRUTHY.includes(windowOrDefault('NX_NETWORK_DOWN')),
|
NETWORK_DOWN: TRUTHY.includes(windowOrDefault('NX_NETWORK_DOWN')),
|
||||||
MOCK: TRUTHY.includes(windowOrDefault('NX_MOCKED')),
|
MOCK: TRUTHY.includes(windowOrDefault('NX_MOCKED')),
|
||||||
|
@ -43,13 +43,17 @@ jest.mock('../list-asset', () => ({
|
|||||||
|
|
||||||
it('Renders with data-testid', async () => {
|
it('Renders with data-testid', async () => {
|
||||||
const proposal = generateProposal();
|
const proposal = generateProposal();
|
||||||
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
|
render(
|
||||||
|
<Proposal restData={{}} proposal={proposal as ProposalQuery['proposal']} />
|
||||||
|
);
|
||||||
expect(await screen.findByTestId('proposal')).toBeInTheDocument();
|
expect(await screen.findByTestId('proposal')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders each section', async () => {
|
it('renders each section', async () => {
|
||||||
const proposal = generateProposal();
|
const proposal = generateProposal();
|
||||||
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
|
render(
|
||||||
|
<Proposal restData={{}} proposal={proposal as ProposalQuery['proposal']} />
|
||||||
|
);
|
||||||
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();
|
||||||
@ -76,6 +80,8 @@ it('renders whitelist section if proposal is new asset and source is erc20', asy
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
render(<Proposal proposal={proposal as ProposalQuery['proposal']} />);
|
render(
|
||||||
|
<Proposal restData={{}} proposal={proposal as ProposalQuery['proposal']} />
|
||||||
|
);
|
||||||
expect(screen.getByTestId('proposal-list-asset')).toBeInTheDocument();
|
expect(screen.getByTestId('proposal-list-asset')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
@ -24,9 +24,11 @@ export enum ProposalType {
|
|||||||
}
|
}
|
||||||
export interface ProposalProps {
|
export interface ProposalProps {
|
||||||
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
proposal: ProposalFieldsFragment | ProposalQuery['proposal'];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
restData: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Proposal = ({ proposal }: ProposalProps) => {
|
export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
||||||
const { params, loading, error } = useNetworkParams([
|
const { params, loading, error } = useNetworkParams([
|
||||||
NetworkParams.governance_proposal_market_minVoterBalance,
|
NetworkParams.governance_proposal_market_minVoterBalance,
|
||||||
NetworkParams.governance_proposal_updateMarket_minVoterBalance,
|
NetworkParams.governance_proposal_updateMarket_minVoterBalance,
|
||||||
@ -104,7 +106,7 @@ export const Proposal = ({ proposal }: ProposalProps) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<ProposalJson proposal={proposal} />
|
<ProposalJson proposal={restData?.data?.proposal} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mb-10">
|
<div className="mb-10">
|
||||||
|
@ -5,9 +5,15 @@ import { useParams } from 'react-router-dom';
|
|||||||
import { Proposal } from '../components/proposal';
|
import { Proposal } from '../components/proposal';
|
||||||
import { ProposalNotFound } from '../components/proposal-not-found';
|
import { ProposalNotFound } from '../components/proposal-not-found';
|
||||||
import { useProposalQuery } from './__generated__/Proposal';
|
import { useProposalQuery } from './__generated__/Proposal';
|
||||||
|
import { useFetch } from '@vegaprotocol/react-helpers';
|
||||||
|
import { ENV } from '../../../config';
|
||||||
|
|
||||||
export const ProposalContainer = () => {
|
export const ProposalContainer = () => {
|
||||||
const params = useParams<{ proposalId: string }>();
|
const params = useParams<{ proposalId: string }>();
|
||||||
|
const {
|
||||||
|
state: { loading: restLoading, error: restError, data: restData },
|
||||||
|
} = useFetch(`${ENV.rest}governance?proposalId=${params.proposalId}`);
|
||||||
|
console.log(restLoading, restError, restData);
|
||||||
const { data, loading, error, refetch } = useProposalQuery({
|
const { data, loading, error, refetch } = useProposalQuery({
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
errorPolicy: 'ignore',
|
errorPolicy: 'ignore',
|
||||||
@ -23,7 +29,7 @@ export const ProposalContainer = () => {
|
|||||||
return (
|
return (
|
||||||
<AsyncRenderer loading={loading} error={error} data={data}>
|
<AsyncRenderer loading={loading} error={error} data={data}>
|
||||||
{data?.proposal ? (
|
{data?.proposal ? (
|
||||||
<Proposal proposal={data.proposal} />
|
<Proposal proposal={data.proposal} restData={restData} />
|
||||||
) : (
|
) : (
|
||||||
<ProposalNotFound />
|
<ProposalNotFound />
|
||||||
)}
|
)}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import Highlighter from 'react-syntax-highlighter';
|
import Highlighter from 'react-syntax-highlighter';
|
||||||
|
|
||||||
export const SyntaxHighlighter = ({
|
export const SyntaxHighlighter = ({
|
||||||
@ -8,6 +9,13 @@ export const SyntaxHighlighter = ({
|
|||||||
data: unknown;
|
data: unknown;
|
||||||
size?: 'smaller' | 'default';
|
size?: 'smaller' | 'default';
|
||||||
}) => {
|
}) => {
|
||||||
|
const parsedData = useMemo(() => {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(data, null, ' ');
|
||||||
|
} catch (e) {
|
||||||
|
return 'Unable to parse data';
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames('syntax-highlighter-wrapper', {
|
className={classNames('syntax-highlighter-wrapper', {
|
||||||
@ -15,7 +23,7 @@ export const SyntaxHighlighter = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Highlighter language="json" useInlineStyles={false}>
|
<Highlighter language="json" useInlineStyles={false}>
|
||||||
{JSON.stringify(data, null, ' ')}
|
{parsedData}
|
||||||
</Highlighter>
|
</Highlighter>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user