Commit db1e20c5 authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #309 from blockscout/tx-contract-created

created contract tx state
parents 02bc55b3 ae65e565
...@@ -18,7 +18,7 @@ export interface Transaction { ...@@ -18,7 +18,7 @@ export interface Transaction {
timestamp: string | null; timestamp: string | null;
confirmation_duration: Array<number>; confirmation_duration: Array<number>;
from: AddressParam; from: AddressParam;
to: AddressParam; to: AddressParam | null;
created_contract: AddressParam; created_contract: AddressParam;
value: string; value: string;
fee: Fee; fee: Fee;
...@@ -39,7 +39,7 @@ export interface Transaction { ...@@ -39,7 +39,7 @@ export interface Transaction {
token_transfers: Array<TokenTransfer> | null; token_transfers: Array<TokenTransfer> | null;
token_transfers_overflow: boolean; token_transfers_overflow: boolean;
exchange_rate: string; exchange_rate: string;
method: string; method: string | null;
tx_types: Array<TransactionType>; tx_types: Array<TransactionType>;
tx_tag: string | null; tx_tag: string | null;
} }
......
...@@ -58,10 +58,11 @@ const TxDetails = () => { ...@@ -58,10 +58,11 @@ const TxDetails = () => {
...data.from.watchlist_names || [], ...data.from.watchlist_names || [],
].map((tag) => <Tag key={ tag.label }>{ tag.display_name }</Tag>); ].map((tag) => <Tag key={ tag.label }>{ tag.display_name }</Tag>);
const toAddress = data.to && data.to.hash ? data.to : data.created_contract;
const addressToTags = [ const addressToTags = [
...data.to.private_tags || [], ...toAddress.private_tags || [],
...data.to.public_tags || [], ...toAddress.public_tags || [],
...data.to.watchlist_names || [], ...toAddress.watchlist_names || [],
].map((tag) => <Tag key={ tag.label }>{ tag.display_name }</Tag>); ].map((tag) => <Tag key={ tag.label }>{ tag.display_name }</Tag>);
return ( return (
...@@ -143,31 +144,40 @@ const TxDetails = () => { ...@@ -143,31 +144,40 @@ const TxDetails = () => {
) } ) }
</DetailsInfoItem> </DetailsInfoItem>
<DetailsInfoItem <DetailsInfoItem
title={ data.to.is_contract ? 'Interacted with contract' : 'To' } title={ toAddress.is_contract ? 'Interacted with contract' : 'To' }
hint="Address (external or contract) receiving the transaction." hint="Address (external or contract) receiving the transaction."
flexWrap={{ base: 'wrap', lg: 'nowrap' }} flexWrap={{ base: 'wrap', lg: 'nowrap' }}
columnGap={ 3 } columnGap={ 3 }
> >
<Address> { data.to && data.to.hash ? (
<AddressIcon hash={ data.to.hash }/> <Address>
<AddressLink ml={ 2 } hash={ data.to.hash }/> <AddressIcon hash={ toAddress.hash }/>
<CopyToClipboard text={ data.to.hash }/> <AddressLink ml={ 2 } hash={ toAddress.hash }/>
</Address> <CopyToClipboard text={ toAddress.hash }/>
{ data.to.is_contract && data.result === 'success' && ( </Address>
) : (
<Flex width="100%" whiteSpace="pre">
<span>[Contract </span>
<AddressLink hash={ toAddress.hash }/>
<span> created]</span>
<CopyToClipboard text={ toAddress.hash }/>
</Flex>
) }
{ toAddress.name && <Text>{ toAddress.name }</Text> }
{ toAddress.is_contract && data.result === 'success' && (
<Tooltip label="Contract execution completed"> <Tooltip label="Contract execution completed">
<chakra.span display="inline-flex"> <chakra.span display="inline-flex">
<Icon as={ successIcon } boxSize={ 4 } color="green.500" cursor="pointer"/> <Icon as={ successIcon } boxSize={ 4 } color="green.500" cursor="pointer"/>
</chakra.span> </chakra.span>
</Tooltip> </Tooltip>
) } ) }
{ data.to.is_contract && Boolean(data.status) && data.result !== 'success' && ( { toAddress.is_contract && Boolean(data.status) && data.result !== 'success' && (
<Tooltip label="Error occured during contract execution"> <Tooltip label="Error occured during contract execution">
<chakra.span display="inline-flex"> <chakra.span display="inline-flex">
<Icon as={ errorIcon } boxSize={ 4 } color="red.500" cursor="pointer"/> <Icon as={ errorIcon } boxSize={ 4 } color="red.500" cursor="pointer"/>
</chakra.span> </chakra.span>
</Tooltip> </Tooltip>
) } ) }
{ data.to.name && <Text>{ data.to.name }</Text> }
{ addressToTags.length > 0 && ( { addressToTags.length > 0 && (
<Flex columnGap={ 3 }> <Flex columnGap={ 3 }>
{ addressToTags } { addressToTags }
......
...@@ -33,6 +33,7 @@ const TxsListItem = ({ tx }: {tx: Transaction}) => { ...@@ -33,6 +33,7 @@ const TxsListItem = ({ tx }: {tx: Transaction}) => {
const iconColor = useColorModeValue('blue.600', 'blue.300'); const iconColor = useColorModeValue('blue.600', 'blue.300');
const borderColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200'); const borderColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200');
const dataTo = tx.to && tx.to.hash ? tx.to : tx.created_contract;
return ( return (
<> <>
...@@ -99,10 +100,10 @@ const TxsListItem = ({ tx }: {tx: Transaction}) => { ...@@ -99,10 +100,10 @@ const TxsListItem = ({ tx }: {tx: Transaction}) => {
color="gray.500" color="gray.500"
/> />
<Address width="calc((100%-40px)/2)"> <Address width="calc((100%-40px)/2)">
<AddressIcon hash={ tx.to.hash }/> <AddressIcon hash={ dataTo.hash }/>
<AddressLink <AddressLink
hash={ tx.to.hash } hash={ dataTo.hash }
alias={ tx.to.name } alias={ dataTo.name }
fontWeight="500" fontWeight="500"
ml={ 2 } ml={ 2 }
/> />
......
...@@ -44,12 +44,14 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => { ...@@ -44,12 +44,14 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => {
</Address> </Address>
); );
const dataTo = tx.to && tx.to.hash ? tx.to : tx.created_contract;
const addressTo = ( const addressTo = (
<Address> <Address>
<Tooltip label={ tx.to.implementation_name }> <Tooltip label={ dataTo.implementation_name }>
<Box display="flex"><AddressIcon hash={ tx.to.hash }/></Box> <Box display="flex"><AddressIcon hash={ dataTo.hash }/></Box>
</Tooltip> </Tooltip>
<AddressLink hash={ tx.to.hash } alias={ tx.to.name } fontWeight="500" ml={ 2 } truncation="constant"/> <AddressLink hash={ dataTo.hash } alias={ dataTo.name } fontWeight="500" ml={ 2 } truncation="constant"/>
</Address> </Address>
); );
...@@ -92,13 +94,13 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => { ...@@ -92,13 +94,13 @@ const TxsTableItem = ({ tx }: {tx: Transaction}) => {
</VStack> </VStack>
</Td> </Td>
<Td> <Td>
<TruncatedTextTooltip label={ tx.method }> { tx.method ? (
<Tag <TruncatedTextTooltip label={ tx.method }>
colorScheme={ tx.method === 'Multicall' ? 'teal' : 'gray' } <Tag colorScheme={ tx.method === 'Multicall' ? 'teal' : 'gray' }>
> { tx.method }
{ tx.method } </Tag>
</Tag> </TruncatedTextTooltip>
</TruncatedTextTooltip> ) : '-' }
</Td> </Td>
<Td> <Td>
{ tx.block && <Link href={ link('block', { id: tx.block.toString() }) }>{ tx.block }</Link> } { tx.block && <Link href={ link('block', { id: tx.block.toString() }) }>{ tx.block }</Link> }
......
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