Styled tx:id
This commit is contained in:
parent
001848fc78
commit
b61bf984b1
@ -57,7 +57,7 @@ export const TableRow = ({
|
|||||||
...props
|
...props
|
||||||
}: TableRowProps) => {
|
}: TableRowProps) => {
|
||||||
const cellClasses = classnames(className, {
|
const cellClasses = classnames(className, {
|
||||||
'border-b border-white-40': modifier === 'bordered',
|
'border-b border-white-40 py-2': modifier === 'bordered',
|
||||||
'bg-white-25 border-b-4 border-b-black': modifier === 'background',
|
'bg-white-25 border-b-4 border-b-black': modifier === 'background',
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response';
|
import { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response';
|
||||||
import { Table } from '../../table';
|
|
||||||
import { SyntaxHighlighter } from '../../syntax-highlighter';
|
import { SyntaxHighlighter } from '../../syntax-highlighter';
|
||||||
|
import { Table, TableRow, TableHeader, TableCell } from '../../table';
|
||||||
|
import { TxOrderType } from '../tx-order-type';
|
||||||
|
import { StatusMessage } from '../../status-message';
|
||||||
|
|
||||||
interface TxContentProps {
|
interface TxContentProps {
|
||||||
data: ChainExplorerTxResponse | undefined;
|
data: ChainExplorerTxResponse | undefined;
|
||||||
@ -8,29 +10,30 @@ interface TxContentProps {
|
|||||||
|
|
||||||
export const TxContent = ({ data }: TxContentProps) => {
|
export const TxContent = ({ data }: TxContentProps) => {
|
||||||
if (!data?.Command) {
|
if (!data?.Command) {
|
||||||
return <>Awaiting decoded transaction data</>;
|
return (
|
||||||
|
<StatusMessage>Could not retrieve transaction content</StatusMessage>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { marketId, type, side, size } = JSON.parse(data.Command);
|
|
||||||
|
|
||||||
const displayCode = {
|
|
||||||
market: marketId,
|
|
||||||
type,
|
|
||||||
side,
|
|
||||||
size,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Table>
|
<Table className="mb-12">
|
||||||
<tr>
|
<TableRow modifier="bordered">
|
||||||
<td>Type</td>
|
<TableHeader scope="row" className="w-[160px]">
|
||||||
<td>{data.Type}</td>
|
Type
|
||||||
</tr>
|
</TableHeader>
|
||||||
|
<TableCell modifier="bordered">
|
||||||
|
<TxOrderType orderType={data.Type} />
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
<h3>Decoded transaction content</h3>
|
{data.Command && (
|
||||||
<SyntaxHighlighter data={displayCode} />
|
<>
|
||||||
|
<h3 className="font-mono mb-8">Decoded transaction content</h3>
|
||||||
|
<SyntaxHighlighter data={JSON.parse(data.Command)} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,50 +1,63 @@
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Routes } from '../../../routes/router-config';
|
import { Routes } from '../../../routes/router-config';
|
||||||
import { Result } from '../../../routes/txs/tendermint-transaction-response.d';
|
import { Result } from '../../../routes/txs/tendermint-transaction-response.d';
|
||||||
import { Table, TableRow, TableCell } from '../../table';
|
import { Table, TableRow, TableCell, TableHeader } from '../../table';
|
||||||
|
import { TruncateInline } from '../../truncate/truncate';
|
||||||
|
|
||||||
interface TxDetailsProps {
|
interface TxDetailsProps {
|
||||||
txData: Result | undefined;
|
txData: Result | undefined;
|
||||||
pubKey: string | undefined;
|
pubKey: string | undefined;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TxDetails = ({ txData, pubKey }: TxDetailsProps) => {
|
const truncateLength = 30;
|
||||||
|
|
||||||
|
export const TxDetails = ({ txData, pubKey, className }: TxDetailsProps) => {
|
||||||
if (!txData) {
|
if (!txData) {
|
||||||
return <>Awaiting Tendermint transaction details</>;
|
return <>Awaiting Tendermint transaction details</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table className={className}>
|
||||||
<TableRow>
|
<TableRow modifier="bordered">
|
||||||
<TableCell>Hash</TableCell>
|
<TableCell>Hash</TableCell>
|
||||||
<TableCell data-testid="hash">{txData.hash}</TableCell>
|
<TableCell modifier="bordered" data-testid="hash">
|
||||||
|
{txData.hash}
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
{pubKey ? (
|
<TableRow modifier="bordered">
|
||||||
<TableRow>
|
<TableHeader scope="row" className="w-[160px]">
|
||||||
<td>Submitted by</td>
|
Submitted by
|
||||||
<td data-testid="submitted-by">
|
</TableHeader>
|
||||||
<Link to={`/${Routes.PARTIES}/${pubKey}`}>{pubKey}</Link>
|
<TableCell modifier="bordered" data-testid="submitted-by">
|
||||||
</td>
|
<Link
|
||||||
</TableRow>
|
className="text-vega-yellow"
|
||||||
) : (
|
to={`/${Routes.PARTIES}/${pubKey}`}
|
||||||
<TableRow>
|
>
|
||||||
<td>Submitted by</td>
|
{pubKey}
|
||||||
<td>Awaiting decoded transaction data</td>
|
</Link>
|
||||||
</TableRow>
|
</TableCell>
|
||||||
)}
|
</TableRow>
|
||||||
{txData.height ? (
|
<TableRow modifier="bordered">
|
||||||
<TableRow>
|
<TableCell>Block</TableCell>
|
||||||
<td>Block</td>
|
<TableCell modifier="bordered" data-testid="block">
|
||||||
<td data-testid="block">
|
<Link
|
||||||
<Link to={`/${Routes.BLOCKS}/${txData.height}`}>
|
className="text-vega-yellow"
|
||||||
{txData.height}
|
to={`/${Routes.BLOCKS}/${txData.height}`}
|
||||||
</Link>
|
>
|
||||||
</td>
|
{txData.height}
|
||||||
</TableRow>
|
</Link>
|
||||||
) : null}
|
</TableCell>
|
||||||
<TableRow>
|
</TableRow>
|
||||||
<td>Encoded tnx</td>
|
<TableRow modifier="bordered">
|
||||||
<td data-testid="encoded-tnx">{txData.tx}</td>
|
<TableCell>Encoded tnx</TableCell>
|
||||||
|
<TableCell modifier="bordered" data-testid="encoded-tnx">
|
||||||
|
<TruncateInline
|
||||||
|
text={txData.tx}
|
||||||
|
startChars={truncateLength}
|
||||||
|
endChars={truncateLength}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</Table>
|
</Table>
|
||||||
);
|
);
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { TxContent, TxDetails } from '../../../components/txs';
|
|
||||||
import { DATA_SOURCES } from '../../../config';
|
|
||||||
import useFetch from '../../../hooks/use-fetch';
|
import useFetch from '../../../hooks/use-fetch';
|
||||||
import { ChainExplorerTxResponse } from '../../types/chain-explorer-response';
|
|
||||||
import { TendermintTransactionResponse } from '../tendermint-transaction-response.d';
|
import { TendermintTransactionResponse } from '../tendermint-transaction-response.d';
|
||||||
|
import { ChainExplorerTxResponse } from '../../types/chain-explorer-response';
|
||||||
|
import { DATA_SOURCES } from '../../../config';
|
||||||
|
import { TxContent, TxDetails } from '../../../components/txs';
|
||||||
|
import { RouteTitle } from '../../../components/route-title';
|
||||||
|
import { RenderFetched } from '../../../components/render-fetched';
|
||||||
|
|
||||||
const Tx = () => {
|
const Tx = () => {
|
||||||
const { txHash } = useParams<{ txHash: string }>();
|
const { txHash } = useParams<{ txHash: string }>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: { data: transactionData },
|
state: { data: tTxData, loading: tTxLoading, error: tTxError },
|
||||||
} = useFetch<TendermintTransactionResponse>(
|
} = useFetch<TendermintTransactionResponse>(
|
||||||
`${DATA_SOURCES.tendermintUrl}/tx?hash=${txHash}`
|
`${DATA_SOURCES.tendermintUrl}/tx?hash=${txHash}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
state: { data: decodedData },
|
state: { data: ceTxData, loading: ceTxLoading, error: ceTxError },
|
||||||
} = useFetch<ChainExplorerTxResponse>(DATA_SOURCES.chainExplorerUrl, {
|
} = useFetch<ChainExplorerTxResponse>(DATA_SOURCES.chainExplorerUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -25,13 +29,20 @@ const Tx = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<h1>Transaction details</h1>
|
<RouteTitle>Transaction details</RouteTitle>
|
||||||
<TxDetails
|
|
||||||
txData={transactionData?.result}
|
<RenderFetched error={tTxError} loading={tTxLoading}>
|
||||||
pubKey={decodedData?.PubKey}
|
<TxDetails
|
||||||
/>
|
className="mb-28"
|
||||||
<h2>Transaction content</h2>
|
txData={tTxData?.result}
|
||||||
<TxContent data={decodedData} />
|
pubKey={ceTxData?.PubKey}
|
||||||
|
/>
|
||||||
|
</RenderFetched>
|
||||||
|
|
||||||
|
<h2 className="text-h4 uppercase mb-16">Transaction content</h2>
|
||||||
|
<RenderFetched error={ceTxError} loading={ceTxLoading}>
|
||||||
|
<TxContent data={ceTxData} />
|
||||||
|
</RenderFetched>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user