Commit aa932910 authored by isstuev's avatar isstuev

fix

parent b0fb59e1
...@@ -38,7 +38,7 @@ dayjs.updateLocale('en', { ...@@ -38,7 +38,7 @@ dayjs.updateLocale('en', {
relativeTime: { relativeTime: {
s: 'a sec', s: 'a sec',
ss: '%d secs', ss: '%d secs',
future: '%s left', future: 'in %s',
past: '%s ago', past: '%s ago',
m: '1 min', m: '1 min',
mm: '%d mins', mm: '%d mins',
......
...@@ -12,8 +12,8 @@ export const data = { ...@@ -12,8 +12,8 @@ export const data = {
public_tags: [], public_tags: [],
watchlist_names: [], watchlist_names: [],
}, },
l1_tx_hash: null, l1_tx_hash: '0x1a235bee32ac10cb7efdad98415737484ca66386e491cde9e17d42b136dca684',
l2_timestamp: '2023-02-15T12:50:02.000000Z', l2_timestamp: '2022-02-15T12:50:02.000000Z',
l2_tx_hash: '0x918cd8c5c24c17e06cd02b0379510c4ad56324bf153578fb9caaaa2fe4e7dc35', l2_tx_hash: '0x918cd8c5c24c17e06cd02b0379510c4ad56324bf153578fb9caaaa2fe4e7dc35',
msg_nonce: 396, msg_nonce: 396,
msg_nonce_raw: '1766847064778384329583297500742918515827483896875618958121606201292620172', msg_nonce_raw: '1766847064778384329583297500742918515827483896875618958121606201292620172',
...@@ -40,7 +40,7 @@ export const data = { ...@@ -40,7 +40,7 @@ export const data = {
msg_nonce: 390, msg_nonce: 390,
msg_nonce_raw: '1766847064778384329583297500742918515827483896875618958121606201292620166', msg_nonce_raw: '1766847064778384329583297500742918515827483896875618958121606201292620166',
msg_nonce_version: 1, msg_nonce_version: 1,
status: 'Ready for Relay', status: 'Ready for relay',
}, },
], ],
next_page_params: { next_page_params: {
......
...@@ -13,7 +13,7 @@ export type WithdrawalsItem = { ...@@ -13,7 +13,7 @@ export type WithdrawalsItem = {
export type WithdrawalStatus = export type WithdrawalStatus =
'In challenge period' | 'In challenge period' |
'Ready for Relay' | 'Ready for relay' |
'Relayed' | 'Relayed' |
'Waiting for state root' | 'Waiting for state root' |
'Ready to prove'; 'Ready to prove';
......
...@@ -49,7 +49,7 @@ const Withdrawals = () => { ...@@ -49,7 +49,7 @@ const Withdrawals = () => {
</Flex> </Flex>
</ActionBar> </ActionBar>
) } ) }
<Show below="lg" ssr={ false }>{ data.items.map((item => <WithdrawalsListItem key={ item.l2_tx_hash } { ...item }/>)) }</Show> <Show below="lg" ssr={ false }>{ data.items.map((item => <WithdrawalsListItem key={ item.l2_tx_hash } item={ item }/>)) }</Show>
<Hide below="lg" ssr={ false }><WithdrawalsTable items={ data.items } top={ isPaginationVisible ? 80 : 0 }/></Hide> <Hide below="lg" ssr={ false }><WithdrawalsTable items={ data.items } top={ isPaginationVisible ? 80 : 0 }/></Hide>
</> </>
); );
......
/* eslint-disable @typescript-eslint/naming-convention */
import { Box, Flex, Text, HStack, Icon } from '@chakra-ui/react'; import { Box, Flex, Text, HStack, Icon } from '@chakra-ui/react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
...@@ -17,61 +16,57 @@ import LinkExternal from 'ui/shared/LinkExternal'; ...@@ -17,61 +16,57 @@ import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile';
type Props = WithdrawalsItem; type Props = { item: WithdrawalsItem };
const WithdrawalsListItem = ({ const WithdrawalsListItem = ({ item }: Props) => {
msg_nonce, const timeAgo = useTimeAgoIncrement(item.l2_timestamp, false);
msg_nonce_version, const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : '';
l1_tx_hash,
l2_timestamp,
l2_tx_hash,
from,
status,
challenge_period_end,
}: Props) => {
const timeAgo = useTimeAgoIncrement(l2_timestamp, false);
const timeToEnd = dayjs(challenge_period_end).fromNow();
return ( return (
<ListItemMobile rowGap={ 3 }> <ListItemMobile rowGap={ 3 }>
<Flex alignItems="center" justifyContent="space-between" w="100%"> <Flex alignItems="center" justifyContent="space-between" w="100%">
<LinkInternal href={ route({ pathname: '/tx/[hash]', query: { hash: l2_tx_hash } }) } display="flex" alignItems="center"> <LinkInternal
href={ route({ pathname: '/tx/[hash]', query: { hash: item.l2_tx_hash } }) }
display="flex"
width="fit-content"
alignItems="center"
>
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/>
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShorten hash={ l2_tx_hash }/></Box> <Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShorten hash={ item.l2_tx_hash }/></Box>
</LinkInternal> </LinkInternal>
<Text variant="secondary">{ timeAgo }</Text> <Text variant="secondary">{ timeAgo }</Text>
</Flex> </Flex>
<HStack spacing={ 3 } width="100%"> <HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Msg nonce</Text> <Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Msg nonce</Text>
<Text variant="secondary">{ msg_nonce_version + '-' + msg_nonce }</Text> <Text variant="secondary">{ item.msg_nonce_version + '-' + item.msg_nonce }</Text>
</HStack> </HStack>
<HStack spacing={ 3 } width="100%"> <HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Status</Text> <Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Status</Text>
{ status === 'Ready for Relay' ? { item.status === 'Ready for relay' ?
<LinkExternal href={ appConfig.L2.withdrawalUrl }>{ status }</LinkExternal> : <LinkExternal href={ appConfig.L2.withdrawalUrl }>{ item.status }</LinkExternal> :
<Text variant="secondary">{ status }</Text> <Text variant="secondary">{ item.status }</Text>
} }
</HStack> </HStack>
{ from && ( { item.from && (
<HStack spacing={ 3 } width="100%"> <HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">From</Text> <Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">From</Text>
<Address> <Address>
<AddressIcon address={ from }/> <AddressIcon address={ item.from }/>
<AddressLink hash={ from.hash } type="address" truncation="constant" ml={ 2 }/> <AddressLink hash={ item.from.hash } type="address" truncation="constant" ml={ 2 }/>
</Address> </Address>
</HStack> </HStack>
) } ) }
{ l1_tx_hash && ( { item.l1_tx_hash && (
<HStack spacing={ 3 } width="100%"> <HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">L1 txn hash</Text> <Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">L1 txn hash</Text>
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: l1_tx_hash } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) }
> >
<HashStringShorten hash={ l1_tx_hash }/> <HashStringShorten hash={ item.l1_tx_hash }/>
</LinkExternal> </LinkExternal>
</HStack> </HStack>
) } ) }
{ challenge_period_end && ( { item.challenge_period_end && (
<HStack spacing={ 3 } width="100%"> <HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Time left</Text> <Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Time left</Text>
<Text variant="secondary">{ timeToEnd }</Text> <Text variant="secondary">{ timeToEnd }</Text>
......
...@@ -28,7 +28,7 @@ const WithdrawalsTable = ({ items, top }: Props) => { ...@@ -28,7 +28,7 @@ const WithdrawalsTable = ({ items, top }: Props) => {
</Thead> </Thead>
<Tbody> <Tbody>
{ items.map((item) => ( { items.map((item) => (
<WithdrawalsTableItem key={ item.l2_tx_hash } { ...item }/> <WithdrawalsTableItem key={ item.l2_tx_hash } item={ item }/>
)) } )) }
</Tbody> </Tbody>
</Table> </Table>
......
/* eslint-disable @typescript-eslint/naming-convention */
import { Box, Td, Tr, Text, Icon } from '@chakra-ui/react'; import { Box, Td, Tr, Text, Icon } from '@chakra-ui/react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
...@@ -7,6 +6,7 @@ import type { WithdrawalsItem } from 'types/api/withdrawals'; ...@@ -7,6 +6,7 @@ import type { WithdrawalsItem } from 'types/api/withdrawals';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import dayjs from 'lib/date/dayjs';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
...@@ -15,56 +15,51 @@ import HashStringShorten from 'ui/shared/HashStringShorten'; ...@@ -15,56 +15,51 @@ import HashStringShorten from 'ui/shared/HashStringShorten';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
type Props = WithdrawalsItem; type Props = { item: WithdrawalsItem };
const WithdrawalsTableItem = ({ const WithdrawalsTableItem = ({ item }: Props) => {
msg_nonce, const timeAgo = useTimeAgoIncrement(item.l2_timestamp, false) || 'N/A';
msg_nonce_version, const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : '-';
l1_tx_hash,
l2_timestamp,
l2_tx_hash,
from,
status,
challenge_period_end,
}: Props) => {
const timeAgo = useTimeAgoIncrement(l2_timestamp, false) || 'N/A';
const timeToEnd = useTimeAgoIncrement(challenge_period_end, false) || '-';
// const timeToEnd = challenge_period_end ? dayjs(challenge_period_end).fromNow() : '-';
return ( return (
<Tr> <Tr>
<Td verticalAlign="middle" fontWeight={ 600 }> <Td verticalAlign="middle" fontWeight={ 600 }>
<Text>{ msg_nonce_version + '-' + msg_nonce }</Text> <Text>{ item.msg_nonce_version + '-' + item.msg_nonce }</Text>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ from ? ( { item.from ? (
<Address> <Address>
<AddressIcon address={ from }/> <AddressIcon address={ item.from }/>
<AddressLink hash={ from.hash } type="address" truncation="constant" ml={ 2 }/> <AddressLink hash={ item.from.hash } type="address" truncation="constant" ml={ 2 }/>
</Address> </Address>
) : 'N/A' } ) : 'N/A' }
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<LinkInternal href={ route({ pathname: '/tx/[hash]', query: { hash: l2_tx_hash } }) } display="flex" alignItems="center"> <LinkInternal
href={ route({ pathname: '/tx/[hash]', query: { hash: item.l2_tx_hash } }) }
display="flex"
width="fit-content"
alignItems="center"
>
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/>
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShorten hash={ l2_tx_hash }/></Box> <Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShorten hash={ item.l2_tx_hash }/></Box>
</LinkInternal> </LinkInternal>
</Td> </Td>
<Td verticalAlign="middle" pr={ 12 }> <Td verticalAlign="middle" pr={ 12 }>
<Text variant="secondary">{ timeAgo }</Text> <Text variant="secondary">{ timeAgo }</Text>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ status === 'Ready for Relay' ? { item.status === 'Ready for relay' ?
<LinkExternal href={ appConfig.L2.withdrawalUrl }>{ status }</LinkExternal> : <LinkExternal href={ appConfig.L2.withdrawalUrl }>{ item.status }</LinkExternal> :
<Text>{ status }</Text> <Text>{ item.status }</Text>
} }
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ l1_tx_hash ? ( { item.l1_tx_hash ? (
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: l1_tx_hash } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) }
> >
<HashStringShorten hash={ l1_tx_hash }/> <HashStringShorten hash={ item.l1_tx_hash }/>
</LinkExternal> </LinkExternal>
) : ) :
'N/A' 'N/A'
......
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