From 13c9dffc3d0f217f4362744736dceaed96de0d49 Mon Sep 17 00:00:00 2001 From: Edd Date: Fri, 9 Dec 2022 11:02:01 +0000 Subject: [PATCH] feat(explorer): add withdrawsubmission view (#2366) * feat(explorer): add withdraw view * fix(explorer): regenerate types after rebasing develop --- .../asset-balance/asset-balance.tsx | 31 ++++ .../eth-explorer-link/eth-explorer-link.tsx | 2 +- .../{node-vote.ts => Node-vote.ts} | 0 .../txs/details/tx-details-wrapper.tsx | 3 + .../components/txs/details/tx-node-vote.tsx | 24 +-- .../txs/details/tx-withdraw-submission.tsx | 72 +++++++++ .../components/withdrawal/Withdrawal.graphql | 19 +++ .../withdrawal/__generated__/Withdrawal.ts | 64 ++++++++ .../withdrawal/withdrawal-progress.spec.tsx | 125 +++++++++++++++ .../withdrawal/withdrawal-progress.tsx | 149 ++++++++++++++++++ .../src/app/hooks/scroll-to-location.ts | 27 ++++ .../src/app/hooks/use-document-title.ts | 20 +++ .../__generated__/{assets.ts => Assets.ts} | 0 apps/explorer/src/app/routes/assets/index.tsx | 11 +- .../src/app/routes/blocks/home/index.tsx | 2 + .../src/app/routes/blocks/id/block.tsx | 2 + .../explorer/src/app/routes/genesis/index.tsx | 3 + .../src/app/routes/governance/index.tsx | 3 + apps/explorer/src/app/routes/home/index.tsx | 4 + .../__generated__/{markets.ts => Markets.ts} | 0 .../explorer/src/app/routes/markets/index.tsx | 9 +- .../network-parameters/network-parameters.tsx | 6 +- .../src/app/routes/parties/home/index.tsx | 3 + .../src/app/routes/parties/id/index.tsx | 3 + .../explorer/src/app/routes/pending/index.tsx | 3 + .../src/app/routes/txs/home/index.tsx | 3 + apps/explorer/src/app/routes/txs/id/index.tsx | 3 + .../src/app/routes/validators/index.tsx | 4 + 28 files changed, 579 insertions(+), 16 deletions(-) create mode 100644 apps/explorer/src/app/components/asset-balance/asset-balance.tsx rename apps/explorer/src/app/components/txs/details/__generated___/{node-vote.ts => Node-vote.ts} (100%) create mode 100644 apps/explorer/src/app/components/txs/details/tx-withdraw-submission.tsx create mode 100644 apps/explorer/src/app/components/withdrawal/Withdrawal.graphql create mode 100644 apps/explorer/src/app/components/withdrawal/__generated__/Withdrawal.ts create mode 100644 apps/explorer/src/app/components/withdrawal/withdrawal-progress.spec.tsx create mode 100644 apps/explorer/src/app/components/withdrawal/withdrawal-progress.tsx create mode 100644 apps/explorer/src/app/hooks/scroll-to-location.ts create mode 100644 apps/explorer/src/app/hooks/use-document-title.ts rename apps/explorer/src/app/routes/assets/__generated__/{assets.ts => Assets.ts} (100%) rename apps/explorer/src/app/routes/markets/__generated__/{markets.ts => Markets.ts} (100%) diff --git a/apps/explorer/src/app/components/asset-balance/asset-balance.tsx b/apps/explorer/src/app/components/asset-balance/asset-balance.tsx new file mode 100644 index 000000000..db51d8095 --- /dev/null +++ b/apps/explorer/src/app/components/asset-balance/asset-balance.tsx @@ -0,0 +1,31 @@ +import { addDecimalsFormatNumber } from '@vegaprotocol/react-helpers'; +import { AssetLink } from '../links'; +import { useExplorerAssetQuery } from '../links/asset-link/__generated__/Asset'; + +export type AssetBalanceProps = { + assetId: string; + price: string; +}; + +/** + * Given a market ID and a price it will fetch the market + * and format the price in that market's decimal places. + */ +const AssetBalance = ({ assetId, price }: AssetBalanceProps) => { + const { data } = useExplorerAssetQuery({ + variables: { id: assetId }, + }); + + const label = + data && data.asset?.decimals + ? addDecimalsFormatNumber(price, data.asset.decimals) + : price; + + return ( +
+ {label} +
+ ); +}; + +export default AssetBalance; diff --git a/apps/explorer/src/app/components/links/eth-explorer-link/eth-explorer-link.tsx b/apps/explorer/src/app/components/links/eth-explorer-link/eth-explorer-link.tsx index 24a81db89..64224d449 100644 --- a/apps/explorer/src/app/components/links/eth-explorer-link/eth-explorer-link.tsx +++ b/apps/explorer/src/app/components/links/eth-explorer-link/eth-explorer-link.tsx @@ -21,7 +21,7 @@ export const EthExplorerLink = ({ const link = `${DATA_SOURCES.ethExplorerUrl}/${type}/${id}`; return (