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

View File

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

View File

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