From 0439be7ac9086f0cfa912fc0bcf70bacaf2be489 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 4 Dec 2021 17:22:17 -0300 Subject: [PATCH] Fix display Sourcify verification status for created contracts on block tx results --- src/address/AddressTransactionResults.tsx | 3 +++ src/block/BlockTransactionResults.tsx | 11 ++++++++++- src/useErigonHooks.ts | 21 +++++++++++++-------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/address/AddressTransactionResults.tsx b/src/address/AddressTransactionResults.tsx index 07f8e4f..f1a373e 100644 --- a/src/address/AddressTransactionResults.tsx +++ b/src/address/AddressTransactionResults.tsx @@ -114,6 +114,9 @@ const AddressTransactionResults: React.FC = ({ if (t.to) { _addresses.push(t.to); } + if (t.createdContractAddress) { + _addresses.push(t.createdContractAddress); + } } } return _addresses; diff --git a/src/block/BlockTransactionResults.tsx b/src/block/BlockTransactionResults.tsx index 3931c46..01d867c 100644 --- a/src/block/BlockTransactionResults.tsx +++ b/src/block/BlockTransactionResults.tsx @@ -40,7 +40,16 @@ const BlockTransactionResults: React.FC = ({ 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); diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index a1e45f1..30effa2 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -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);