From a67f8e0155d7c293ef5c06c485ad627a83fa766c Mon Sep 17 00:00:00 2001 From: Edd Date: Wed, 1 Mar 2023 17:23:52 +0000 Subject: [PATCH] chore(explorer): finish splitting up signature bundle component --- .../details/proposal/proposal-status-icon.tsx | 6 +- .../details/proposal/signature-bundle-new.tsx | 42 +++++++++ .../proposal/signature-bundle-update.tsx | 39 ++++++++ .../txs/details/proposal/signature-bundle.tsx | 92 ++----------------- .../signature-bundle/bundle-error.tsx | 34 +++++++ .../signature-bundle/bundle-exists.tsx | 46 ++++++++++ .../proposal/signature-bundle/bundle-icon.tsx | 20 ++++ .../proposal/signature-bundle/details.tsx | 41 +++++++++ 8 files changed, 231 insertions(+), 89 deletions(-) create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle-new.tsx create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle-update.tsx create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle/bundle-error.tsx create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle/bundle-exists.tsx create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle/bundle-icon.tsx create mode 100644 apps/explorer/src/app/components/txs/details/proposal/signature-bundle/details.tsx diff --git a/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx b/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx index 7ec3692f8..7e4f696c5 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx +++ b/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx @@ -64,7 +64,7 @@ export function getIconAndLabelForStatus( }; case 'STATE_FAILED': return { - icon: 'ban-circle', + icon: 'thumbs-down', label: t('Proposal became invalid and was not processed'), }; case 'STATE_OPEN': @@ -82,8 +82,8 @@ export function getIconAndLabelForStatus( }; case 'STATE_REJECTED': return { - icon: 'thumbs-down', - label: t('Voting is complete and this proposal was rejected'), + icon: 'disable', + label: t('The proposal was invalid'), }; case 'STATE_WAITING_FOR_NODE_VOTE': return { diff --git a/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-new.tsx b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-new.tsx new file mode 100644 index 000000000..483d312f6 --- /dev/null +++ b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-new.tsx @@ -0,0 +1,42 @@ +import { Loader } from '@vegaprotocol/ui-toolkit'; +import { BundleError } from './signature-bundle/bundle-error'; +import { BundleExists } from './signature-bundle/bundle-exists'; +import { useExplorerNewAssetSignatureBundleQuery } from './__generated__/SignatureBundle'; + +export interface ProposalSignatureBundleByTypeProps { + id: string; +} + +/** + * If a proposal needs a signature bundle, AND that signature bundle exists + * AND that proposal is a New Asset Proposal, render an overview of the + * signature bundle. Or an error. + * + * There is an almost identical component, ProposalSignatureBundleUpdateAsset + */ +export const ProposalSignatureBundleNewAsset = ({ + id, +}: ProposalSignatureBundleByTypeProps) => { + const { data, error, loading } = useExplorerNewAssetSignatureBundleQuery({ + variables: { + id, + }, + }); + + if (loading) { + return ; + } + + if (data?.erc20ListAssetBundle?.signatures) { + return ( + + ); + } else { + return ; + } +}; diff --git a/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-update.tsx b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-update.tsx new file mode 100644 index 000000000..290a37d11 --- /dev/null +++ b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle-update.tsx @@ -0,0 +1,39 @@ +import { Loader } from '@vegaprotocol/ui-toolkit'; +import type { ProposalSignatureBundleByTypeProps } from './signature-bundle-new'; +import { BundleError } from './signature-bundle/bundle-error'; +import { BundleExists } from './signature-bundle/bundle-exists'; +import { useExplorerUpdateAssetSignatureBundleQuery } from './__generated__/SignatureBundle'; + +/** + * If a proposal needs a signature bundle, AND that signature bundle exists + * AND that proposal is a Asset Limits Proposal, render an overview of the + * signature bundle. Or an error. + * + * There is an almost identical component, ProposalSignatureBundleNewAsset + */ +export const ProposalSignatureBundleUpdateAsset = ({ + id, +}: ProposalSignatureBundleByTypeProps) => { + const { data, error, loading } = useExplorerUpdateAssetSignatureBundleQuery({ + variables: { + id, + }, + }); + + if (loading) { + return ; + } + + if (data?.erc20SetAssetLimitsBundle?.signatures) { + return ( + + ); + } else { + return ; + } +}; diff --git a/apps/explorer/src/app/components/txs/details/proposal/signature-bundle.tsx b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle.tsx index bd2f11489..6f8e7d3d6 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/signature-bundle.tsx +++ b/apps/explorer/src/app/components/txs/details/proposal/signature-bundle.tsx @@ -1,10 +1,5 @@ -import { Icon } from '@vegaprotocol/ui-toolkit'; -import ProposalLink from '../../../links/proposal-link/proposal-link'; -import { - useExplorerNewAssetSignatureBundleQuery, - useExplorerUpdateAssetSignatureBundleQuery, -} from './__generated__/SignatureBundle'; -import { t } from '@vegaprotocol/i18n'; +import { ProposalSignatureBundleNewAsset } from './signature-bundle-new'; +import { ProposalSignatureBundleUpdateAsset } from './signature-bundle-update'; export function format(date: string | undefined, def: string) { if (!date) { @@ -20,92 +15,17 @@ interface ProposalSignatureBundleProps { } /** - * Some proposals, if enacted, generate a signature bundle + * Some proposals, if enacted, generate a signature bundle. + * The queries have to be split due to the way the API returns + * errors, hence this slightly redundant feeling switcher. */ export const ProposalSignatureBundle = ({ id, type, }: ProposalSignatureBundleProps) => { - return type == 'NewAsset' ? ( + return type === 'NewAsset' ? ( ) : ( ); }; - -interface ProposalSignatureBundleByTypeProps { - id: string; -} - -export const ProposalSignatureBundleNewAsset = ({ - id, -}: ProposalSignatureBundleByTypeProps) => { - const { data, error, loading } = useExplorerNewAssetSignatureBundleQuery({ - variables: { - id, - }, - }); - - if (data?.erc20ListAssetBundle?.signatures) { - return ( -
- -

{t('Signature bundle generated')}

- {data.asset?.status} - -
- See details - -
-

{t('Signatures')}

-

-