Commit 3716c2f0 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Arbitrum: handle case with partial data in latest deposits on main page (#2244)

* Arbitrum: handle case with partial data in latest deposits on main page

Fixes #2243

* [skip ci] roll back arbitrum envs
parent 99446524
...@@ -42,12 +42,12 @@ import type { AddressesResponse, AddressesMetadataSearchResult, AddressesMetadat ...@@ -42,12 +42,12 @@ import type { AddressesResponse, AddressesMetadataSearchResult, AddressesMetadat
import type { AddressMetadataInfo, PublicTagTypesResponse } from 'types/api/addressMetadata'; import type { AddressMetadataInfo, PublicTagTypesResponse } from 'types/api/addressMetadata';
import type { import type {
ArbitrumL2MessagesResponse, ArbitrumL2MessagesResponse,
ArbitrumL2MessagesItem,
ArbitrumL2TxnBatch, ArbitrumL2TxnBatch,
ArbitrumL2TxnBatchesResponse, ArbitrumL2TxnBatchesResponse,
ArbitrumL2BatchTxs, ArbitrumL2BatchTxs,
ArbitrumL2BatchBlocks, ArbitrumL2BatchBlocks,
ArbitrumL2TxnBatchesItem, ArbitrumL2TxnBatchesItem,
ArbitrumLatestDepositsResponse,
} from 'types/api/arbitrumL2'; } from 'types/api/arbitrumL2';
import type { TxBlobs, Blob } from 'types/api/blobs'; import type { TxBlobs, Blob } from 'types/api/blobs';
import type { import type {
...@@ -1028,7 +1028,7 @@ Q extends 'homepage_blocks' ? Array<Block> : ...@@ -1028,7 +1028,7 @@ Q extends 'homepage_blocks' ? Array<Block> :
Q extends 'homepage_txs' ? Array<Transaction> : Q extends 'homepage_txs' ? Array<Transaction> :
Q extends 'homepage_txs_watchlist' ? Array<Transaction> : Q extends 'homepage_txs_watchlist' ? Array<Transaction> :
Q extends 'homepage_optimistic_deposits' ? Array<OptimisticL2DepositsItem> : Q extends 'homepage_optimistic_deposits' ? Array<OptimisticL2DepositsItem> :
Q extends 'homepage_arbitrum_deposits' ? { items: Array<ArbitrumL2MessagesItem> } : Q extends 'homepage_arbitrum_deposits' ? ArbitrumLatestDepositsResponse :
Q extends 'homepage_zkevm_l2_batches' ? { items: Array<ZkEvmL2TxnBatchesItem> } : Q extends 'homepage_zkevm_l2_batches' ? { items: Array<ZkEvmL2TxnBatchesItem> } :
Q extends 'homepage_arbitrum_l2_batches' ? { items: Array<ArbitrumL2TxnBatchesItem>} : Q extends 'homepage_arbitrum_l2_batches' ? { items: Array<ArbitrumL2TxnBatchesItem>} :
Q extends 'homepage_indexing_status' ? IndexingStatus : Q extends 'homepage_indexing_status' ? IndexingStatus :
......
import type { ArbitrumL2MessagesResponse } from 'types/api/arbitrumL2'; import type { ArbitrumL2MessagesResponse, ArbitrumLatestDepositsResponse } from 'types/api/arbitrumL2';
export const baseResponse: ArbitrumL2MessagesResponse = { export const baseResponse: ArbitrumL2MessagesResponse = {
items: [ items: [
...@@ -27,3 +27,20 @@ export const baseResponse: ArbitrumL2MessagesResponse = { ...@@ -27,3 +27,20 @@ export const baseResponse: ArbitrumL2MessagesResponse = {
direction: 'to-rollup', direction: 'to-rollup',
}, },
}; };
export const latestDepositsResponse: ArbitrumLatestDepositsResponse = {
items: [
{
completion_transaction_hash: '0x3ccdf87449d3de6a9dcd3eddb7bc9ecdf1770d4631f03cdf12a098911618d138',
origination_transaction_block_number: 123400,
origination_transaction_hash: '0x210d9f70f411de1079e32a98473b04345a5ea6ff2340a8511ebc2df641274436',
origination_timestamp: '2023-06-01T14:46:48.000000Z',
},
{
completion_transaction_hash: '0xd16d918b2f95a5cdf66824f6291b6d5eb80b6f4acab3f9fb82ee0ec4109646a0',
origination_timestamp: null,
origination_transaction_block_number: null,
origination_transaction_hash: null,
},
],
};
import type { Block } from './block'; import type { Block } from './block';
import type { Transaction } from './transaction'; import type { Transaction } from './transaction';
export interface ArbitrumLatestDepositsItem {
completion_transaction_hash: string;
origination_timestamp: string | null;
origination_transaction_block_number: number | null;
origination_transaction_hash: string | null;
}
export interface ArbitrumLatestDepositsResponse {
items: Array<ArbitrumLatestDepositsItem>;
}
export type ArbitrumL2MessagesItem = { export type ArbitrumL2MessagesItem = {
completion_transaction_hash: string | null; completion_transaction_hash: string | null;
id: number; id: number;
origination_address: string; origination_address: string;
origination_timestamp: string | null; origination_timestamp: string | null;
origination_transaction_block_number: number; origination_transaction_block_number: number | null;
origination_transaction_hash: string; origination_transaction_hash: string;
status: 'initiated' | 'sent' | 'confirmed' | 'relayed'; status: 'initiated' | 'sent' | 'confirmed' | 'relayed';
} }
......
import React from 'react';
import * as depositMock from 'mocks/arbitrum/deposits';
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';
import { test, expect } from 'playwright/lib';
import LatestArbitrumDeposits from './LatestArbitrumDeposits';
test('default view +@mobile', async({ render, mockApiResponse, mockEnvs }) => {
await mockEnvs(ENVS_MAP.arbitrumRollup);
mockApiResponse('homepage_arbitrum_deposits', depositMock.latestDepositsResponse);
const component = await render(<LatestArbitrumDeposits/>);
await expect(component).toHaveScreenshot();
});
...@@ -2,6 +2,7 @@ import { ...@@ -2,6 +2,7 @@ import {
Box, Box,
Flex, Flex,
Grid, Grid,
GridItem,
Skeleton, Skeleton,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
...@@ -17,9 +18,9 @@ import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice'; ...@@ -17,9 +18,9 @@ import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import TimeAgoWithTooltip from 'ui/shared/TimeAgoWithTooltip'; import TimeAgoWithTooltip from 'ui/shared/TimeAgoWithTooltip';
type DepositsItem = { type DepositsItem = {
l1BlockNumber: number; l1BlockNumber: number | null;
l1TxHash: string; l1TxHash: string | null;
l2TxHash: string | null; l2TxHash: string;
timestamp: string | null; timestamp: string | null;
} }
...@@ -38,7 +39,7 @@ type ItemProps = { ...@@ -38,7 +39,7 @@ type ItemProps = {
const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const l1BlockLink = ( const l1BlockLink = item.l1BlockNumber ? (
<BlockEntityL1 <BlockEntityL1
number={ item.l1BlockNumber } number={ item.l1BlockNumber }
isLoading={ isLoading } isLoading={ isLoading }
...@@ -46,9 +47,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -46,9 +47,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
lineHeight={ 5 } lineHeight={ 5 }
fontWeight={ 700 } fontWeight={ 700 }
/> />
) : (
<BlockEntityL1
number="TBD"
isLoading={ isLoading }
fontSize="sm"
lineHeight={ 5 }
fontWeight={ 700 }
noLink
/>
); );
const l1TxLink = ( const l1TxLink = item.l1TxHash ? (
<TxEntityL1 <TxEntityL1
isLoading={ isLoading } isLoading={ isLoading }
hash={ item.l1TxHash } hash={ item.l1TxHash }
...@@ -56,9 +66,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -56,9 +66,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
lineHeight={ 5 } lineHeight={ 5 }
truncation={ isMobile ? 'constant_long' : 'dynamic' } truncation={ isMobile ? 'constant_long' : 'dynamic' }
/> />
) : (
<TxEntityL1
isLoading={ isLoading }
hash="To be determined"
fontSize="sm"
lineHeight={ 5 }
truncation="none"
noLink
/>
); );
const l2TxLink = item.l2TxHash ? ( const l2TxLink = (
<TxEntity <TxEntity
isLoading={ isLoading } isLoading={ isLoading }
hash={ item.l2TxHash } hash={ item.l2TxHash }
...@@ -66,7 +85,7 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -66,7 +85,7 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
lineHeight={ 5 } lineHeight={ 5 }
truncation={ isMobile ? 'constant_long' : 'dynamic' } truncation={ isMobile ? 'constant_long' : 'dynamic' }
/> />
) : null; );
const content = (() => { const content = (() => {
if (isMobile) { if (isMobile) {
...@@ -74,11 +93,13 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -74,11 +93,13 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
<> <>
<Flex justifyContent="space-between" alignItems="center" mb={ 1 }> <Flex justifyContent="space-between" alignItems="center" mb={ 1 }>
{ l1BlockLink } { l1BlockLink }
<TimeAgoWithTooltip { item.timestamp ? (
timestamp={ item.timestamp } <TimeAgoWithTooltip
isLoading={ isLoading } timestamp={ item.timestamp }
color="text_secondary" isLoading={ isLoading }
/> color="text_secondary"
/>
) : <GridItem/> }
</Flex> </Flex>
<Grid gridTemplateColumns="56px auto"> <Grid gridTemplateColumns="56px auto">
<Skeleton isLoaded={ !isLoading } my="5px" w="fit-content"> <Skeleton isLoaded={ !isLoading } my="5px" w="fit-content">
...@@ -101,14 +122,16 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -101,14 +122,16 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
L1 txn L1 txn
</Skeleton> </Skeleton>
{ l1TxLink } { l1TxLink }
<TimeAgoWithTooltip { item.timestamp ? (
timestamp={ item.timestamp } <TimeAgoWithTooltip
isLoading={ isLoading } timestamp={ item.timestamp }
color="text_secondary" isLoading={ isLoading }
w="fit-content" color="text_secondary"
h="fit-content" w="fit-content"
my="2px" h="fit-content"
/> my="2px"
/>
) : <GridItem/> }
<Skeleton isLoaded={ !isLoading } w="fit-content" h="fit-content" my="2px"> <Skeleton isLoaded={ !isLoading } w="fit-content" h="fit-content" my="2px">
L2 txn L2 txn
</Skeleton> </Skeleton>
......
...@@ -33,13 +33,15 @@ const ArbitrumL2MessagesListItem = ({ item, isLoading, direction }: Props) => { ...@@ -33,13 +33,15 @@ const ArbitrumL2MessagesListItem = ({ item, isLoading, direction }: Props) => {
<> <>
<ListItemMobileGrid.Label isLoading={ isLoading }>L1 block</ListItemMobileGrid.Label> <ListItemMobileGrid.Label isLoading={ isLoading }>L1 block</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value> <ListItemMobileGrid.Value>
<BlockEntityL1 { item.origination_transaction_block_number ? (
number={ item.origination_transaction_block_number } <BlockEntityL1
isLoading={ isLoading } number={ item.origination_transaction_block_number }
fontSize="sm" isLoading={ isLoading }
lineHeight={ 5 } fontSize="sm"
fontWeight={ 600 } lineHeight={ 5 }
/> fontWeight={ 600 }
/>
) : <chakra.span>N/A</chakra.span> }
</ListItemMobileGrid.Value> </ListItemMobileGrid.Value>
</> </>
) } ) }
...@@ -84,14 +86,18 @@ const ArbitrumL2MessagesListItem = ({ item, isLoading, direction }: Props) => { ...@@ -84,14 +86,18 @@ const ArbitrumL2MessagesListItem = ({ item, isLoading, direction }: Props) => {
) } ) }
</ListItemMobileGrid.Value> </ListItemMobileGrid.Value>
<ListItemMobileGrid.Label isLoading={ isLoading }>Age</ListItemMobileGrid.Label> { item.origination_timestamp && (
<ListItemMobileGrid.Value> <>
<TimeAgoWithTooltip <ListItemMobileGrid.Label isLoading={ isLoading }>Age</ListItemMobileGrid.Label>
timestamp={ item.origination_timestamp } <ListItemMobileGrid.Value>
isLoading={ isLoading } <TimeAgoWithTooltip
display="inline-block" timestamp={ item.origination_timestamp }
/> isLoading={ isLoading }
</ListItemMobileGrid.Value> display="inline-block"
/>
</ListItemMobileGrid.Value>
</>
) }
<ListItemMobileGrid.Label isLoading={ isLoading }>Status</ListItemMobileGrid.Label> <ListItemMobileGrid.Label isLoading={ isLoading }>Status</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value> <ListItemMobileGrid.Value>
......
...@@ -29,14 +29,16 @@ const ArbitrumL2MessagesTableItem = ({ item, direction, isLoading }: Props) => { ...@@ -29,14 +29,16 @@ const ArbitrumL2MessagesTableItem = ({ item, direction, isLoading }: Props) => {
<Tr> <Tr>
{ direction === 'to-rollup' && ( { direction === 'to-rollup' && (
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<BlockEntityL1 { item.origination_transaction_block_number ? (
number={ item.origination_transaction_block_number } <BlockEntityL1
isLoading={ isLoading } number={ item.origination_transaction_block_number }
fontSize="sm" isLoading={ isLoading }
lineHeight={ 5 } fontSize="sm"
fontWeight={ 600 } lineHeight={ 5 }
noIcon fontWeight={ 600 }
/> noIcon
/>
) : <chakra.span color="text_secondary">N/A</chakra.span> }
</Td> </Td>
) } ) }
{ direction === 'from-rollup' && ( { direction === 'from-rollup' && (
......
...@@ -48,7 +48,7 @@ const Content = chakra((props: ContentProps) => { ...@@ -48,7 +48,7 @@ const Content = chakra((props: ContentProps) => {
const Container = EntityBase.Container; const Container = EntityBase.Container;
export interface EntityProps extends EntityBase.EntityBaseProps { export interface EntityProps extends EntityBase.EntityBaseProps {
number: number; number: number | string;
hash?: string; hash?: string;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment