Fix display Sourcify verification status for created contracts on block tx results

This commit is contained in:
Willian Mitsuda 2021-12-04 17:22:17 -03:00
parent 9fb6e1877d
commit 0439be7ac9
3 changed files with 26 additions and 9 deletions

View File

@ -114,6 +114,9 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
if (t.to) {
_addresses.push(t.to);
}
if (t.createdContractAddress) {
_addresses.push(t.createdContractAddress);
}
}
}
return _addresses;

View File

@ -40,7 +40,16 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
return [];
}
return page.map((t) => t.to).filter((to): to is string => to !== null);
const _addresses: ChecksummedAddress[] = [];
for (const t of page) {
if (t.to) {
_addresses.push(t.to);
}
if (t.createdContractAddress) {
_addresses.push(t.createdContractAddress);
}
}
return _addresses;
}, [page]);
const metadatas = useContractsMetadata(addresses, provider);

View File

@ -95,8 +95,13 @@ export const useBlockTransactions = (
const _receipts = result.receipts;
const rawTxs = _block.transactions
.map(
(t, i): ProcessedTransaction => ({
.map((t, i): ProcessedTransaction => {
const _rawReceipt = _receipts[i];
// Empty logs on purpose because of ethers formatter requires it
_rawReceipt.logs = [];
const _receipt = provider.formatter.receipt(_rawReceipt);
return {
blockNumber: blockNumber,
timestamp: _block.timestamp,
miner: _block.miner,
@ -104,24 +109,24 @@ export const useBlockTransactions = (
hash: t.hash,
from: t.from,
to: t.to ?? null,
createdContractAddress: _receipts[i].contractAddress,
createdContractAddress: _receipt.contractAddress,
value: t.value,
fee:
t.type !== 2
? provider.formatter
.bigNumber(_receipts[i].gasUsed)
.bigNumber(_receipt.gasUsed)
.mul(t.gasPrice!)
: provider.formatter
.bigNumber(_receipts[i].gasUsed)
.bigNumber(_receipt.gasUsed)
.mul(t.maxPriorityFeePerGas!.add(_block.baseFeePerGas!)),
gasPrice:
t.type !== 2
? t.gasPrice!
: t.maxPriorityFeePerGas!.add(_block.baseFeePerGas!),
data: t.data,
status: provider.formatter.number(_receipts[i].status),
})
)
status: provider.formatter.number(_receipt.status),
};
})
.reverse();
setTxs(rawTxs);
setTotalTxs(result.fullblock.transactionCount);