Show contract creation on search results

This commit is contained in:
Willian Mitsuda 2021-07-21 01:42:49 -03:00
parent dcc121ccc2
commit b8fcc8914d
3 changed files with 20 additions and 2 deletions

View File

@ -35,7 +35,10 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
direction = Direction.SELF; direction = Direction.SELF;
} else if (tx.from === selectedAddress) { } else if (tx.from === selectedAddress) {
direction = Direction.OUT; direction = Direction.OUT;
} else if (tx.to === selectedAddress) { } else if (
tx.to === selectedAddress ||
tx.createdContractAddress === selectedAddress
) {
direction = Direction.IN; direction = Direction.IN;
} else { } else {
direction = Direction.INTERNAL; direction = Direction.INTERNAL;
@ -44,6 +47,10 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
const ensFrom = ensCache && tx.from && ensCache[tx.from]; const ensFrom = ensCache && tx.from && ensCache[tx.from];
const ensTo = ensCache && tx.to && ensCache[tx.to]; const ensTo = ensCache && tx.to && ensCache[tx.to];
const ensCreated =
ensCache &&
tx.createdContractAddress &&
ensCache[tx.createdContractAddress];
const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction; const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction;
return ( return (
@ -89,7 +96,7 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
</span> </span>
<span className="col-span-2 flex items-baseline" title={tx.to}> <span className="col-span-2 flex items-baseline" title={tx.to}>
<span className="truncate"> <span className="truncate">
{tx.to && ( {tx.to ? (
<AddressHighlighter address={tx.to}> <AddressHighlighter address={tx.to}>
<DecoratedAddressLink <DecoratedAddressLink
address={tx.to} address={tx.to}
@ -98,6 +105,15 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
miner={tx.miner === tx.to} miner={tx.miner === tx.to}
/> />
</AddressHighlighter> </AddressHighlighter>
) : (
<AddressHighlighter address={tx.createdContractAddress!}>
<DecoratedAddressLink
address={tx.createdContractAddress!}
ensName={ensCreated}
selectedAddress={selectedAddress}
creation
/>
</AddressHighlighter>
)} )}
</span> </span>
</span> </span>

View File

@ -45,6 +45,7 @@ export class SearchController {
hash: t.hash, hash: t.hash,
from: t.from, from: t.from,
to: t.to, to: t.to,
createdContractAddress: _receipt.contractAddress,
value: t.value, value: t.value,
fee: _receipt.gasUsed.mul(t.gasPrice!), fee: _receipt.gasUsed.mul(t.gasPrice!),
gasPrice: t.gasPrice!, gasPrice: t.gasPrice!,

View File

@ -16,6 +16,7 @@ export type ProcessedTransaction = {
hash: string; hash: string;
from?: string; from?: string;
to?: string; to?: string;
createdContractAddress?: string;
internalMinerInteraction?: boolean; internalMinerInteraction?: boolean;
value: BigNumber; value: BigNumber;
fee: BigNumber; fee: BigNumber;