From 46bc4a7a11141979fdc6f54b17b62d7409388335 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 2 Aug 2021 17:06:53 -0300 Subject: [PATCH] Make use of ots_getBlockDetails on tx details to save traffic when calculating block tx count (because of tx idx position) --- src/useErigonHooks.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index ac8a5aa..e904137 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -169,12 +169,12 @@ export const useTxData = ( return; } - const readBlock = async () => { + const readTxData = async () => { const [_response, _receipt] = await Promise.all([ provider.getTransaction(txhash), provider.getTransactionReceipt(txhash), ]); - const _block = await provider.getBlock(_receipt.blockNumber); + const _block = await readBlock(provider, _receipt.blockNumber.toString()); document.title = `Transaction ${_response.hash} | Otterscan`; // Extract token transfers @@ -222,7 +222,7 @@ export const useTxData = ( status: _receipt.status === 1, blockNumber: _receipt.blockNumber, transactionIndex: _receipt.transactionIndex, - blockTransactionCount: _block.transactions.length, + blockTransactionCount: _block.transactionCount, confirmations: _receipt.confirmations, timestamp: _block.timestamp, miner: _block.miner, @@ -245,7 +245,7 @@ export const useTxData = ( logs: _receipt.logs, }); }; - readBlock(); + readTxData(); }, [provider, txhash]); return txData;