diff --git a/.changelog/1249.trivial.md b/.changelog/1249.trivial.md new file mode 100644 index 000000000..ef2e9f978 --- /dev/null +++ b/.changelog/1249.trivial.md @@ -0,0 +1 @@ +Rename components to prepare views for Consensus transactions diff --git a/src/app/components/Transactions/RuntimeTransactions.tsx b/src/app/components/Transactions/RuntimeTransactions.tsx new file mode 100644 index 000000000..dff524ad7 --- /dev/null +++ b/src/app/components/Transactions/RuntimeTransactions.tsx @@ -0,0 +1,214 @@ +import { FC } from 'react' +import { styled } from '@mui/material/styles' +import { useTranslation } from 'react-i18next' +import Box from '@mui/material/Box' +import ArrowForwardIcon from '@mui/icons-material/ArrowForward' +import LockIcon from '@mui/icons-material/Lock' +import { Table, TableCellAlign, TableColProps } from '../../components/Table' +import { StatusIcon } from '../StatusIcon' +import { RuntimeTransactionIcon } from '../../components/RuntimeTransactionLabel' +import { RoundedBalance } from '../../components/RoundedBalance' +import { RuntimeTransaction } from '../../../oasis-nexus/api' +import { COLORS } from '../../../styles/theme/colors' +import { TablePaginationProps } from '../Table/TablePagination' +import { BlockLink } from '../Blocks/BlockLink' +import { AccountLink } from '../Account/AccountLink' +import { TransactionLink } from './TransactionLink' +import { trimLongString } from '../../utils/trimLongString' +import Typography from '@mui/material/Typography' +import { doesAnyOfTheseLayersSupportEncryptedTransactions } from '../../../types/layers' +import { TransactionEncryptionStatus } from '../TransactionEncryptionStatus' +import { Age } from '../Age' + +const iconSize = '28px' +const StyledCircle = styled(Box)(({ theme }) => ({ + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + width: iconSize, + height: iconSize, + color: COLORS.eucalyptus, + backgroundColor: COLORS.lightGreen, + borderRadius: iconSize, + marginLeft: theme.spacing(3), + marginRight: `-${theme.spacing(4)}`, +})) + +type TableRuntimeTransaction = RuntimeTransaction & { + markAsNew?: boolean +} + +export type TableRuntimeTransactionList = { + transactions: TableRuntimeTransaction[] + total_count: number + is_total_count_clipped: boolean +} + +type TransactionsProps = { + transactions?: TableRuntimeTransaction[] + ownAddress?: string + isLoading: boolean + limit: number + pagination: false | TablePaginationProps + verbose?: boolean +} + +export const RuntimeTransactions: FC = ({ + isLoading, + limit, + pagination, + transactions, + ownAddress, + verbose = true, +}) => { + const { t } = useTranslation() + // We only want to show encryption status of we are listing transactions + // from paratimes that actually support encrypting transactions + const canHaveEncryption = doesAnyOfTheseLayersSupportEncryptedTransactions( + transactions?.map(tx => tx.layer), + ) + const tableColumns: TableColProps[] = [ + { key: 'status', content: t('common.status') }, + ...(verbose && canHaveEncryption + ? [{ key: 'encrypted', content: }] + : []), + { key: 'hash', content: t('common.hash') }, + { key: 'block', content: t('common.block') }, + { key: 'age', content: t('common.age'), align: TableCellAlign.Right }, + ...(verbose + ? [ + { key: 'type', content: t('common.type'), align: TableCellAlign.Center }, + { key: 'from', content: t('common.from'), width: '150px' }, + { key: 'to', content: t('common.to'), width: '150px' }, + { key: 'txnFee', content: t('common.transactionFee'), align: TableCellAlign.Right, width: '250px' }, + { key: 'value', align: TableCellAlign.Right, content: t('common.value'), width: '250px' }, + ] + : []), + ] + const tableRows = transactions?.map(transaction => ({ + key: transaction.hash, + data: [ + { + content: , + key: 'success', + }, + ...(verbose && canHaveEncryption + ? [ + { + content: , + key: 'encrypted', + }, + ] + : []), + { + content: ( + + ), + key: 'hash', + }, + { + content: , + key: 'round', + }, + { + align: TableCellAlign.Right, + content: , + key: 'timestamp', + }, + ...(verbose + ? [ + { + align: TableCellAlign.Center, + content: , + key: 'type', + }, + { + align: TableCellAlign.Right, + content: ( + + {!!ownAddress && + (transaction.sender_0_eth === ownAddress || transaction.sender_0 === ownAddress) ? ( + + {trimLongString(transaction.sender_0_eth || transaction.sender_0)} + + ) : ( + + )} + {transaction.to && ( + + + + )} + + ), + key: 'from', + }, + { + content: + !!ownAddress && (transaction.to_eth === ownAddress || transaction.to === ownAddress) ? ( + + {trimLongString(transaction.to_eth || transaction.to!)} + + ) : ( + + ), + key: 'to', + }, + { + align: TableCellAlign.Right, + content: , + key: 'fee_amount', + }, + { + align: TableCellAlign.Right, + content: , + key: 'value', + }, + ] + : []), + ], + highlight: transaction.markAsNew, + })) + + return ( + + ) +} diff --git a/src/app/components/Transactions/index.tsx b/src/app/components/Transactions/index.tsx index d0c91ccd0..d4748ab11 100644 --- a/src/app/components/Transactions/index.tsx +++ b/src/app/components/Transactions/index.tsx @@ -1,214 +1 @@ -import { FC } from 'react' -import { styled } from '@mui/material/styles' -import { useTranslation } from 'react-i18next' -import Box from '@mui/material/Box' -import ArrowForwardIcon from '@mui/icons-material/ArrowForward' -import LockIcon from '@mui/icons-material/Lock' -import { Table, TableCellAlign, TableColProps } from '../../components/Table' -import { StatusIcon } from '../StatusIcon' -import { RuntimeTransactionIcon } from '../../components/RuntimeTransactionLabel' -import { RoundedBalance } from '../../components/RoundedBalance' -import { RuntimeTransaction } from '../../../oasis-nexus/api' -import { COLORS } from '../../../styles/theme/colors' -import { TablePaginationProps } from '../Table/TablePagination' -import { BlockLink } from '../Blocks/BlockLink' -import { AccountLink } from '../Account/AccountLink' -import { TransactionLink } from './TransactionLink' -import { trimLongString } from '../../utils/trimLongString' -import Typography from '@mui/material/Typography' -import { doesAnyOfTheseLayersSupportEncryptedTransactions } from '../../../types/layers' -import { TransactionEncryptionStatus } from '../TransactionEncryptionStatus' -import { Age } from '../Age' - -const iconSize = '28px' -const StyledCircle = styled(Box)(({ theme }) => ({ - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - width: iconSize, - height: iconSize, - color: COLORS.eucalyptus, - backgroundColor: COLORS.lightGreen, - borderRadius: iconSize, - marginLeft: theme.spacing(3), - marginRight: `-${theme.spacing(4)}`, -})) - -type TableRuntimeTransaction = RuntimeTransaction & { - markAsNew?: boolean -} - -export type TableRuntimeTransactionList = { - transactions: TableRuntimeTransaction[] - total_count: number - is_total_count_clipped: boolean -} - -type TransactionsProps = { - transactions?: TableRuntimeTransaction[] - ownAddress?: string - isLoading: boolean - limit: number - pagination: false | TablePaginationProps - verbose?: boolean -} - -export const Transactions: FC = ({ - isLoading, - limit, - pagination, - transactions, - ownAddress, - verbose = true, -}) => { - const { t } = useTranslation() - // We only want to show encryption status of we are listing transactions - // from paratimes that actually support encrypting transactions - const canHaveEncryption = doesAnyOfTheseLayersSupportEncryptedTransactions( - transactions?.map(tx => tx.layer), - ) - const tableColumns: TableColProps[] = [ - { key: 'status', content: t('common.status') }, - ...(verbose && canHaveEncryption - ? [{ key: 'encrypted', content: }] - : []), - { key: 'hash', content: t('common.hash') }, - { key: 'block', content: t('common.block') }, - { key: 'age', content: t('common.age'), align: TableCellAlign.Right }, - ...(verbose - ? [ - { key: 'type', content: t('common.type'), align: TableCellAlign.Center }, - { key: 'from', content: t('common.from'), width: '150px' }, - { key: 'to', content: t('common.to'), width: '150px' }, - { key: 'txnFee', content: t('common.transactionFee'), align: TableCellAlign.Right, width: '250px' }, - { key: 'value', align: TableCellAlign.Right, content: t('common.value'), width: '250px' }, - ] - : []), - ] - const tableRows = transactions?.map(transaction => ({ - key: transaction.hash, - data: [ - { - content: , - key: 'success', - }, - ...(verbose && canHaveEncryption - ? [ - { - content: , - key: 'encrypted', - }, - ] - : []), - { - content: ( - - ), - key: 'hash', - }, - { - content: , - key: 'round', - }, - { - align: TableCellAlign.Right, - content: , - key: 'timestamp', - }, - ...(verbose - ? [ - { - align: TableCellAlign.Center, - content: , - key: 'type', - }, - { - align: TableCellAlign.Right, - content: ( - - {!!ownAddress && - (transaction.sender_0_eth === ownAddress || transaction.sender_0 === ownAddress) ? ( - - {trimLongString(transaction.sender_0_eth || transaction.sender_0)} - - ) : ( - - )} - {transaction.to && ( - - - - )} - - ), - key: 'from', - }, - { - content: - !!ownAddress && (transaction.to_eth === ownAddress || transaction.to === ownAddress) ? ( - - {trimLongString(transaction.to_eth || transaction.to!)} - - ) : ( - - ), - key: 'to', - }, - { - align: TableCellAlign.Right, - content: , - key: 'fee_amount', - }, - { - align: TableCellAlign.Right, - content: , - key: 'value', - }, - ] - : []), - ], - highlight: transaction.markAsNew, - })) - - return ( -
- ) -} +export * from './RuntimeTransactions' diff --git a/src/app/pages/AccountDetailsPage/AccountTransactionsCard.tsx b/src/app/pages/AccountDetailsPage/AccountTransactionsCard.tsx index bbf4abbf0..fb0e4f956 100644 --- a/src/app/pages/AccountDetailsPage/AccountTransactionsCard.tsx +++ b/src/app/pages/AccountDetailsPage/AccountTransactionsCard.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next' import Card from '@mui/material/Card' import CardHeader from '@mui/material/CardHeader' import CardContent from '@mui/material/CardContent' -import { Transactions } from '../../components/Transactions' +import { RuntimeTransactions } from '../../components/Transactions' import { NUMBER_OF_ITEMS_ON_SEPARATE_PAGE } from '../../config' import { ErrorBoundary } from '../../components/ErrorBoundary' import { LinkableDiv } from '../../components/PageLayout/LinkableDiv' @@ -38,7 +38,7 @@ const AccountTransactions: FC = ({ scope, address }) => { return ( <> {isFetched && !transactions?.length && } - = ({ scope }) => { +export const LatestRuntimeTransactions: FC<{ scope: SearchScope }> = ({ scope }) => { const { isTablet } = useScreenSize() const { t } = useTranslation() const { network, layer } = scope @@ -53,7 +53,7 @@ export const LatestTransactions: FC<{ scope: SearchScope }> = ({ scope }) => { } /> - { - + diff --git a/src/app/pages/RuntimeBlockDetailPage/TransactionsCard.tsx b/src/app/pages/RuntimeBlockDetailPage/TransactionsCard.tsx index fbc3a8a6c..059aeb168 100644 --- a/src/app/pages/RuntimeBlockDetailPage/TransactionsCard.tsx +++ b/src/app/pages/RuntimeBlockDetailPage/TransactionsCard.tsx @@ -7,7 +7,7 @@ import CardContent from '@mui/material/CardContent' import { useSearchParamsPagination } from '../../components/Table/useSearchParamsPagination' import { NUMBER_OF_ITEMS_ON_SEPARATE_PAGE } from '../../config' import { Layer, useGetRuntimeTransactions } from '../../../oasis-nexus/api' -import { Transactions } from '../../components/Transactions' +import { RuntimeTransactions } from '../../components/Transactions' import { ErrorBoundary } from '../../components/ErrorBoundary' import { AppErrors } from '../../../types/errors' import { SearchScope } from '../../../types/searchScope' @@ -37,7 +37,7 @@ const TransactionList: FC<{ scope: SearchScope; blockHeight: number }> = ({ scop } return ( - ({ marginBottom: '1em', })) -export const TransactionDetailPage: FC = () => { +export const RuntimeTransactionDetailPage: FC = () => { const { t } = useTranslation() const scope = useRequiredScopeParam() @@ -122,7 +122,7 @@ export const TransactionDetailPage: FC = () => { /> } > - > = ({ labe ) } -export const TransactionDetailView: FC<{ +export const RuntimeTransactionDetailView: FC<{ isLoading?: boolean transaction: TransactionDetailRuntimeBlock | undefined showLayer?: boolean diff --git a/src/app/pages/TransactionsPage/index.tsx b/src/app/pages/RuntimeTransactionsPage/index.tsx similarity index 93% rename from src/app/pages/TransactionsPage/index.tsx rename to src/app/pages/RuntimeTransactionsPage/index.tsx index b3c39dac8..4419d2f35 100644 --- a/src/app/pages/TransactionsPage/index.tsx +++ b/src/app/pages/RuntimeTransactionsPage/index.tsx @@ -4,7 +4,7 @@ import Divider from '@mui/material/Divider' import { useScreenSize } from '../../hooks/useScreensize' import { PageLayout } from '../../components/PageLayout' import { SubPageCard } from '../../components/SubPageCard' -import { TableRuntimeTransactionList, Transactions } from '../../components/Transactions' +import { TableRuntimeTransactionList, RuntimeTransactions } from '../../components/Transactions' import { Layer, useGetRuntimeTransactions } from '../../../oasis-nexus/api' import { NUMBER_OF_ITEMS_ON_SEPARATE_PAGE, REFETCH_INTERVAL } from '../../config' import { useSearchParamsPagination } from '../../components/Table/useSearchParamsPagination' @@ -12,7 +12,7 @@ import { AxiosResponse } from 'axios' import { AppErrors } from '../../../types/errors' import { LoadMoreButton } from '../../components/LoadMoreButton' import { TableLayout, TableLayoutButton } from '../../components/TableLayoutButton' -import { TransactionDetailView } from '../TransactionDetailPage' +import { RuntimeTransactionDetailView } from '../RuntimeTransactionDetailPage' import { useRequiredScopeParam } from '../../hooks/useScopeParam' import { useTokenPrice } from '../../../coin-gecko/api' import { getTickerForNetwork } from '../../../types/ticker' @@ -20,7 +20,7 @@ import { VerticalList } from '../../components/VerticalList' const limit = NUMBER_OF_ITEMS_ON_SEPARATE_PAGE -export const TransactionsPage: FC = () => { +export const RuntimeTransactionsPage: FC = () => { const [tableView, setTableView] = useState(TableLayout.Horizontal) const { t } = useTranslation() const { isMobile } = useScreenSize() @@ -95,7 +95,7 @@ export const TransactionsPage: FC = () => { noPadding={tableView === TableLayout.Vertical} > {tableView === TableLayout.Horizontal && ( - { {isLoading && [...Array(limit).keys()].map(key => ( - { {!isLoading && data?.data.transactions.map(tx => ( - item.resultType === 'transaction', )} resultComponent={item => ( - , + element: , }, { path: `tx/:hash`, - element: , + element: , loader: transactionParamLoader, }, {