Commit 70260756 authored by tom's avatar tom

fix skeletons for tx logs

parent 313e4ac9
...@@ -6,7 +6,24 @@ import { TX_HASH } from './tx'; ...@@ -6,7 +6,24 @@ import { TX_HASH } from './tx';
export const LOG: Log = { export const LOG: Log = {
address: ADDRESS_PARAMS, address: ADDRESS_PARAMS,
data: '0x000000000000000000000000000000000000000000000000000000d75e4be200', data: '0x000000000000000000000000000000000000000000000000000000d75e4be200',
decoded: null, decoded: {
method_call: 'CreditSpended(uint256 indexed _type, uint256 _quantity)',
method_id: '58cdf94a',
parameters: [
{
indexed: true,
name: '_type',
type: 'uint256',
value: 'placeholder',
},
{
indexed: false,
name: '_quantity',
type: 'uint256',
value: 'placeholder',
},
],
},
index: 42, index: 42,
topics: [ topics: [
'0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925', '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
......
...@@ -30,7 +30,7 @@ const TokenTransferNft = ({ hash, id, className, isDisabled, isLoading, truncati ...@@ -30,7 +30,7 @@ const TokenTransferNft = ({ hash, id, className, isDisabled, isLoading, truncati
w="100%" w="100%"
className={ className } className={ className }
> >
<Icon as={ nftPlaceholder } boxSize="30px" color="inherit" isLoading={ isLoading }/> <Icon as={ nftPlaceholder } boxSize="30px" color="inherit" isLoading={ isLoading } borderRadius="base"/>
<Skeleton isLoaded={ !isLoading } maxW="calc(100% - 34px)" ml={ 1 }> <Skeleton isLoaded={ !isLoading } maxW="calc(100% - 34px)" ml={ 1 }>
{ truncation === 'constant' ? <HashStringShorten hash={ id }/> : <HashStringShortenDynamic hash={ id } fontWeight={ 500 }/> } { truncation === 'constant' ? <HashStringShorten hash={ id }/> : <HashStringShortenDynamic hash={ id } fontWeight={ 500 }/> }
</Skeleton> </Skeleton>
......
import { Flex, Text, Grid, GridItem, useColorModeValue } from '@chakra-ui/react'; import { Flex, Grid, GridItem, useColorModeValue, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { DecodedInput } from 'types/api/decodedInput'; import type { DecodedInput } from 'types/api/decodedInput';
...@@ -13,12 +13,13 @@ interface RowProps { ...@@ -13,12 +13,13 @@ interface RowProps {
name: string; name: string;
type: string; type: string;
indexed?: boolean; indexed?: boolean;
isLoading?: boolean;
} }
const PADDING = 4; const PADDING = 4;
const GAP = 5; const GAP = 5;
const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => { const TableRow = ({ isLast, name, type, children, indexed, isLoading }: RowProps) => {
const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50'); const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
return ( return (
...@@ -31,7 +32,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => { ...@@ -31,7 +32,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => {
bgColor={ bgColor } bgColor={ bgColor }
borderBottomLeftRadius={ isLast ? 'md' : 'none' } borderBottomLeftRadius={ isLast ? 'md' : 'none' }
> >
{ name } <Skeleton isLoaded={ !isLoading } display="inline-block">{ name }</Skeleton>
</GridItem> </GridItem>
<GridItem <GridItem
pr={ GAP } pr={ GAP }
...@@ -39,7 +40,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => { ...@@ -39,7 +40,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => {
pb={ isLast ? PADDING : 0 } pb={ isLast ? PADDING : 0 }
bgColor={ bgColor } bgColor={ bgColor }
> >
{ type } <Skeleton isLoaded={ !isLoading } display="inline-block">{ type }</Skeleton>
</GridItem> </GridItem>
{ indexed !== undefined && ( { indexed !== undefined && (
<GridItem <GridItem
...@@ -48,7 +49,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => { ...@@ -48,7 +49,7 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => {
pb={ isLast ? PADDING : 0 } pb={ isLast ? PADDING : 0 }
bgColor={ bgColor } bgColor={ bgColor }
> >
{ indexed ? 'true' : 'false' } <Skeleton isLoaded={ !isLoading } display="inline-block">{ indexed ? 'true' : 'false' }</Skeleton>
</GridItem> </GridItem>
) } ) }
<GridItem <GridItem
...@@ -66,9 +67,10 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => { ...@@ -66,9 +67,10 @@ const TableRow = ({ isLast, name, type, children, indexed }: RowProps) => {
interface Props { interface Props {
data: DecodedInput; data: DecodedInput;
isLoading?: boolean;
} }
const LogDecodedInputData = ({ data }: Props) => { const LogDecodedInputData = ({ data, isLoading }: Props) => {
const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50'); const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
const hasIndexed = data.parameters.some(({ indexed }) => indexed !== undefined); const hasIndexed = data.parameters.some(({ indexed }) => indexed !== undefined);
...@@ -81,10 +83,10 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -81,10 +83,10 @@ const LogDecodedInputData = ({ data }: Props) => {
<Grid gridTemplateColumns={ gridTemplateColumns } fontSize="sm" lineHeight={ 5 } w="100%"> <Grid gridTemplateColumns={ gridTemplateColumns } fontSize="sm" lineHeight={ 5 } w="100%">
{ /* FIRST PART OF BLOCK */ } { /* FIRST PART OF BLOCK */ }
<GridItem fontWeight={ 600 } pl={{ base: 0, lg: PADDING }} pr={{ base: 0, lg: GAP }} colSpan={{ base: colNumber, lg: undefined }}> <GridItem fontWeight={ 600 } pl={{ base: 0, lg: PADDING }} pr={{ base: 0, lg: GAP }} colSpan={{ base: colNumber, lg: undefined }}>
Method Id <Skeleton isLoaded={ !isLoading }>Method Id</Skeleton>
</GridItem> </GridItem>
<GridItem colSpan={{ base: colNumber, lg: colNumber - 1 }} pr={{ base: 0, lg: PADDING }} mt={{ base: 2, lg: 0 }}> <GridItem colSpan={{ base: colNumber, lg: colNumber - 1 }} pr={{ base: 0, lg: PADDING }} mt={{ base: 2, lg: 0 }}>
{ data.method_id } <Skeleton isLoaded={ !isLoading } display="inline-block">{ data.method_id }</Skeleton>
</GridItem> </GridItem>
<GridItem <GridItem
py={ 2 } py={ 2 }
...@@ -96,7 +98,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -96,7 +98,7 @@ const LogDecodedInputData = ({ data }: Props) => {
borderTopWidth="1px" borderTopWidth="1px"
colSpan={{ base: colNumber, lg: undefined }} colSpan={{ base: colNumber, lg: undefined }}
> >
Call <Skeleton isLoaded={ !isLoading }>Call</Skeleton>
</GridItem> </GridItem>
<GridItem <GridItem
py={{ base: 0, lg: 2 }} py={{ base: 0, lg: 2 }}
...@@ -108,7 +110,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -108,7 +110,7 @@ const LogDecodedInputData = ({ data }: Props) => {
borderTopWidth={{ base: '0px', lg: '1px' }} borderTopWidth={{ base: '0px', lg: '1px' }}
whiteSpace="normal" whiteSpace="normal"
> >
{ data.method_call } <Skeleton isLoaded={ !isLoading } display="inline-block">{ data.method_call }</Skeleton>
</GridItem> </GridItem>
{ /* TABLE INSIDE OF BLOCK */ } { /* TABLE INSIDE OF BLOCK */ }
{ data.parameters.length > 0 && ( { data.parameters.length > 0 && (
...@@ -121,7 +123,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -121,7 +123,7 @@ const LogDecodedInputData = ({ data }: Props) => {
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Name <Skeleton isLoaded={ !isLoading } display="inline-block">Name</Skeleton>
</GridItem> </GridItem>
<GridItem <GridItem
pr={ GAP } pr={ GAP }
...@@ -130,7 +132,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -130,7 +132,7 @@ const LogDecodedInputData = ({ data }: Props) => {
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Type <Skeleton isLoaded={ !isLoading } display="inline-block">Type</Skeleton>
</GridItem> </GridItem>
{ hasIndexed && ( { hasIndexed && (
<GridItem <GridItem
...@@ -140,7 +142,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -140,7 +142,7 @@ const LogDecodedInputData = ({ data }: Props) => {
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Inde<wbr/>xed? <Skeleton isLoaded={ !isLoading } display="inline-block">Inde<wbr/>xed?</Skeleton>
</GridItem> </GridItem>
) } ) }
<GridItem <GridItem
...@@ -150,7 +152,7 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -150,7 +152,7 @@ const LogDecodedInputData = ({ data }: Props) => {
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Data <Skeleton isLoaded={ !isLoading } display="inline-block">Data</Skeleton>
</GridItem> </GridItem>
</> </>
) } ) }
...@@ -159,8 +161,8 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -159,8 +161,8 @@ const LogDecodedInputData = ({ data }: Props) => {
if (type === 'address' && typeof value === 'string') { if (type === 'address' && typeof value === 'string') {
return ( return (
<Address justifyContent="space-between"> <Address justifyContent="space-between">
<AddressLink type="address" hash={ value }/> <AddressLink type="address" hash={ value } isLoading={ isLoading }/>
<CopyToClipboard text={ value }/> <CopyToClipboard text={ value } isLoading={ isLoading }/>
</Address> </Address>
); );
} }
...@@ -169,22 +171,29 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -169,22 +171,29 @@ const LogDecodedInputData = ({ data }: Props) => {
const text = JSON.stringify(value, undefined, 4); const text = JSON.stringify(value, undefined, 4);
return ( return (
<Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all"> <Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all">
<div>{ text }</div> <Skeleton isLoaded={ !isLoading } display="inline-block">{ text }</Skeleton>
<CopyToClipboard text={ text }/> <CopyToClipboard text={ text } isLoading={ isLoading }/>
</Flex> </Flex>
); );
} }
return ( return (
<Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all"> <Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all">
<Text>{ value }</Text> <Skeleton isLoaded={ !isLoading } display="inline-block">{ value }</Skeleton>
<CopyToClipboard text={ value }/> <CopyToClipboard text={ value } isLoading={ isLoading }/>
</Flex> </Flex>
); );
})(); })();
return ( return (
<TableRow key={ name } name={ name } type={ type } isLast={ index === data.parameters.length - 1 } indexed={ indexed }> <TableRow
key={ name }
name={ name }
type={ type }
isLast={ index === data.parameters.length - 1 }
indexed={ indexed }
isLoading={ isLoading }
>
{ content } { content }
</TableRow> </TableRow>
); );
......
...@@ -78,9 +78,9 @@ const LogItem = ({ address, index, topics, data, decoded, type, tx_hash: txHash, ...@@ -78,9 +78,9 @@ const LogItem = ({ address, index, topics, data, decoded, type, tx_hash: txHash,
</GridItem> </GridItem>
{ decoded && ( { decoded && (
<> <>
<RowHeader>Decode input data</RowHeader> <RowHeader isLoading={ isLoading }>Decode input data</RowHeader>
<GridItem> <GridItem>
<LogDecodedInputData data={ decoded }/> <LogDecodedInputData data={ decoded } isLoading={ isLoading }/>
</GridItem> </GridItem>
</> </>
) } ) }
......
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