Commit 23e48718 authored by tom's avatar tom

pending transaction details

parent 150b44c1
...@@ -8,8 +8,8 @@ export interface Transaction { ...@@ -8,8 +8,8 @@ export interface Transaction {
result: string; result: string;
confirmations: number; confirmations: number;
status: 'ok' | 'error' | null; status: 'ok' | 'error' | null;
block: number; block: number | null;
timestamp: string; timestamp: string | null;
confirmation_duration: Array<number>; confirmation_duration: Array<number>;
from: AddressParam; from: AddressParam;
to: AddressParam; to: AddressParam;
...@@ -18,7 +18,7 @@ export interface Transaction { ...@@ -18,7 +18,7 @@ export interface Transaction {
fee: Fee; fee: Fee;
gas_price: number; gas_price: number;
type: number; type: number;
gas_used: string; gas_used: string | null;
gas_limit: string; gas_limit: string;
max_fee_per_gas: number | null; max_fee_per_gas: number | null;
max_priority_fee_per_gas: number | null; max_priority_fee_per_gas: number | null;
......
...@@ -20,7 +20,7 @@ const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, ...token ...@@ -20,7 +20,7 @@ const TokenTransfer = ({ from, to, total, exchange_rate: exchangeRate, ...token
<AddressLink fontWeight="500" hash={ to.hash } truncation="constant"/> <AddressLink fontWeight="500" hash={ to.hash } truncation="constant"/>
</Flex> </Flex>
<Text fontWeight={ 500 } as="span">For:{ space } <Text fontWeight={ 500 } as="span">For:{ space }
<CurrencyValue value={ total.value.replaceAll(',', '') } unit="ether" exchangeRate={ exchangeRate } fontWeight={ 600 }/> <CurrencyValue value={ total.value } unit="ether" exchangeRate={ exchangeRate } fontWeight={ 600 }/>
</Text> </Text>
<TokenSnippet symbol={ token.token_symbol } hash={ token.token_address } name="Foo"/> <TokenSnippet symbol={ token.token_symbol } hash={ token.token_address } name="Foo"/>
</Flex> </Flex>
......
import { Grid, GridItem, Text, Box, Icon, Link, Flex } from '@chakra-ui/react'; import { Grid, GridItem, Text, Box, Icon, Link, Flex, Spinner } from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
...@@ -72,6 +72,7 @@ const TxDetails = () => { ...@@ -72,6 +72,7 @@ const TxDetails = () => {
hint="Unique character string (TxID) assigned to every verified transaction." hint="Unique character string (TxID) assigned to every verified transaction."
flexWrap="nowrap" flexWrap="nowrap"
> >
{ data.status === null && <Spinner mr={ 2 } size="sm" flexShrink={ 0 }/> }
<Box overflow="hidden"> <Box overflow="hidden">
<HashStringShortenDynamic hash={ data.hash }/> <HashStringShortenDynamic hash={ data.hash }/>
</Box> </Box>
...@@ -88,12 +89,17 @@ const TxDetails = () => { ...@@ -88,12 +89,17 @@ const TxDetails = () => {
title="Block" title="Block"
hint="Block number containing the transaction." hint="Block number containing the transaction."
> >
<Text>{ data.block }</Text> <Text>{ data.block === null ? 'Pending' : data.block }</Text>
{ Boolean(data.confirmations) && (
<>
<TextSeparator color="gray.500"/> <TextSeparator color="gray.500"/>
<Text variant="secondary"> <Text variant="secondary">
{ data.confirmations } Block confirmations { data.confirmations } Block confirmations
</Text> </Text>
</>
) }
</DetailsInfoItem> </DetailsInfoItem>
{ data.timestamp && (
<DetailsInfoItem <DetailsInfoItem
title="Timestamp" title="Timestamp"
hint="Date & time of transaction inclusion, including length of time for confirmation." hint="Date & time of transaction inclusion, including length of time for confirmation."
...@@ -104,6 +110,7 @@ const TxDetails = () => { ...@@ -104,6 +110,7 @@ const TxDetails = () => {
<Text whiteSpace="normal">{ dayjs(data.timestamp).format('LLLL') }<TextSeparator color="gray.500"/></Text> <Text whiteSpace="normal">{ dayjs(data.timestamp).format('LLLL') }<TextSeparator color="gray.500"/></Text>
<Text variant="secondary">{ getConfirmationDuration(data.confirmation_duration) }</Text> <Text variant="secondary">{ getConfirmationDuration(data.confirmation_duration) }</Text>
</DetailsInfoItem> </DetailsInfoItem>
) }
<GridItem colSpan={{ base: undefined, lg: 2 }} mt={{ base: 3, lg: 8 }}/> <GridItem colSpan={{ base: undefined, lg: 2 }} mt={{ base: 3, lg: 8 }}/>
<DetailsInfoItem <DetailsInfoItem
title="From" title="From"
...@@ -173,10 +180,10 @@ const TxDetails = () => { ...@@ -173,10 +180,10 @@ const TxDetails = () => {
title="Gas limit & usage by txn" title="Gas limit & usage by txn"
hint="Actual gas amount used by the transaction." hint="Actual gas amount used by the transaction."
> >
<Text>{ BigNumber(data.gas_used).toFormat() }</Text> <Text>{ BigNumber(data.gas_used || 0).toFormat() }</Text>
<TextSeparator/> <TextSeparator/>
<Text >{ BigNumber(data.gas_limit).toFormat() }</Text> <Text >{ BigNumber(data.gas_limit).toFormat() }</Text>
<Utilization ml={ 4 } value={ BigNumber(data.gas_used).dividedBy(BigNumber(data.gas_limit)).toNumber() }/> <Utilization ml={ 4 } value={ BigNumber(data.gas_used || 0).dividedBy(BigNumber(data.gas_limit)).toNumber() }/>
</DetailsInfoItem> </DetailsInfoItem>
{ (data.base_fee_per_gas || data.max_fee_per_gas || data.max_priority_fee_per_gas) && ( { (data.base_fee_per_gas || data.max_fee_per_gas || data.max_priority_fee_per_gas) && (
<DetailsInfoItem <DetailsInfoItem
...@@ -236,23 +243,34 @@ const TxDetails = () => { ...@@ -236,23 +243,34 @@ const TxDetails = () => {
title="Other" title="Other"
hint="Other data related to this transaction." hint="Other data related to this transaction."
> >
{ typeof data.type === 'number' && ( {
<Box> [
typeof data.type === 'number' && (
<Box key="type">
<Text as="span" fontWeight="500">Txn type: </Text> <Text as="span" fontWeight="500">Txn type: </Text>
<Text fontWeight="600" as="span">{ data.type }</Text> <Text fontWeight="600" as="span">{ data.type }</Text>
{ data.type === 2 && <Text fontWeight="400" as="span" ml={ 1 } variant="secondary">(EIP-1559)</Text> } { data.type === 2 && <Text fontWeight="400" as="span" ml={ 1 } variant="secondary">(EIP-1559)</Text> }
<TextSeparator/>
</Box> </Box>
) } ),
<Box> <Box key="nonce">
<Text as="span" fontWeight="500">Nonce: </Text> <Text as="span" fontWeight="500">Nonce: </Text>
<Text fontWeight="600" as="span">{ data.nonce }</Text> <Text fontWeight="600" as="span">{ data.nonce }</Text>
<TextSeparator/> </Box>,
</Box> data.position !== null && (
<Box> <Box key="position">
<Text as="span" fontWeight="500">Position: </Text> <Text as="span" fontWeight="500">Position: </Text>
<Text fontWeight="600" as="span">{ data.position }</Text> <Text fontWeight="600" as="span">{ data.position }</Text>
</Box> </Box>
),
]
.filter(Boolean)
.map((item, index) => (
<>
{ index !== 0 && <TextSeparator/> }
{ item }
</>
))
}
</DetailsInfoItem> </DetailsInfoItem>
<DetailsInfoItem <DetailsInfoItem
title="Raw input" title="Raw input"
......
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