From 32ea63a3d0d7a49e5c457e1378d69b397b0f600c Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 1 Aug 2021 23:10:32 -0300 Subject: [PATCH 01/12] Generalize parameter --- src/nodeFunctions.ts | 6 +++--- src/useErigonHooks.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/nodeFunctions.ts b/src/nodeFunctions.ts index d160dac..29bd5d5 100644 --- a/src/nodeFunctions.ts +++ b/src/nodeFunctions.ts @@ -1,12 +1,12 @@ import { ethers } from "ethers"; -import { TransactionData, InternalOperation } from "./types"; +import { InternalOperation } from "./types"; export const getInternalOperations = async ( provider: ethers.providers.JsonRpcProvider, - txData: TransactionData + txHash: string ) => { const rawTransfers = await provider.send("ots_getInternalOperations", [ - txData.transactionHash, + txHash, ]); const _transfers: InternalOperation[] = []; diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 588940e..4982f90 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -190,7 +190,10 @@ export const useInternalOperations = ( return; } - const _transfers = await getInternalOperations(provider, txData); + const _transfers = await getInternalOperations( + provider, + txData.transactionHash + ); for (const t of _transfers) { t.from = provider.formatter.address(t.from); t.to = provider.formatter.address(t.to); From 1dfafb29661a05c7d23f63bced33c63fd7cccb1f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 1 Aug 2021 23:22:55 -0300 Subject: [PATCH 02/12] Simplify search --- src/BlockTransactions.tsx | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index 2ce687b..7946fbd 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -5,13 +5,10 @@ import queryString from "query-string"; import StandardFrame from "./StandardFrame"; import BlockTransactionHeader from "./block/BlockTransactionHeader"; import BlockTransactionResults from "./block/BlockTransactionResults"; -import { - InternalOperation, - OperationType, - ProcessedTransaction, -} from "./types"; +import { OperationType, ProcessedTransaction } from "./types"; import { PAGE_SIZE } from "./params"; import { RuntimeContext } from "./useRuntime"; +import { getInternalOperations } from "./nodeFunctions"; type BlockParams = { blockNumber: string; @@ -82,29 +79,21 @@ const BlockTransactions: React.FC = () => { .reverse(); setTxs(responses); - const internalChecks = await Promise.all( + const checkTouchMinerAddr = await Promise.all( responses.map(async (res) => { - const r: InternalOperation[] = await provider.send( - "ots_getInternalOperations", - [res.hash] + const ops = await getInternalOperations(provider, res.hash); + return ( + ops.findIndex( + (op) => + op.type === OperationType.TRANSFER && + res.miner !== undefined && + res.miner === ethers.utils.getAddress(op.to) + ) !== -1 ); - for (const op of r) { - if (op.type !== OperationType.TRANSFER) { - continue; - } - if ( - res.miner && - (res.miner === ethers.utils.getAddress(op.from) || - res.miner === ethers.utils.getAddress(op.to)) - ) { - return true; - } - } - return false; }) ); const processedResponses = responses.map((r, i): ProcessedTransaction => { - return { ...r, internalMinerInteraction: internalChecks[i] }; + return { ...r, internalMinerInteraction: checkTouchMinerAddr[i] }; }); setTxs(processedResponses); }; From 2358f346dc0d5947526e7f7481fc6d256a32e995 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 1 Aug 2021 23:48:06 -0300 Subject: [PATCH 03/12] Simplify code --- src/BlockTransactions.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index 7946fbd..48a606b 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -46,11 +46,10 @@ const BlockTransactions: React.FC = () => { provider.getBlockWithTransactions(blockNumber.toNumber()), provider.send("eth_getBlockReceipts", [blockNumber.toNumber()]), ]); - document.title = `Block #${_block.number} Transactions | Otterscan`; const responses = _block.transactions - .map((t, i): ProcessedTransaction => { - return { + .map( + (t, i): ProcessedTransaction => ({ blockNumber: blockNumber.toNumber(), timestamp: _block.timestamp, miner: _block.miner, @@ -74,8 +73,8 @@ const BlockTransactions: React.FC = () => { : t.maxPriorityFeePerGas!.add(_block.baseFeePerGas!), data: t.data, status: provider.formatter.number(_receipts[i].status), - }; - }) + }) + ) .reverse(); setTxs(responses); @@ -92,9 +91,12 @@ const BlockTransactions: React.FC = () => { ); }) ); - const processedResponses = responses.map((r, i): ProcessedTransaction => { - return { ...r, internalMinerInteraction: checkTouchMinerAddr[i] }; - }); + const processedResponses = responses.map( + (r, i): ProcessedTransaction => ({ + ...r, + internalMinerInteraction: checkTouchMinerAddr[i], + }) + ); setTxs(processedResponses); }; readBlock(); From b2a54831d1cd251a56979aa5832e72b03f59077e Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sun, 1 Aug 2021 23:53:36 -0300 Subject: [PATCH 04/12] Extract custom hook --- src/BlockTransactions.tsx | 72 ++---------------------------------- src/useErigonHooks.ts | 77 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 69 deletions(-) diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index 48a606b..02352d7 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -1,14 +1,13 @@ -import React, { useEffect, useState, useMemo, useContext } from "react"; +import React, { useMemo, useContext } from "react"; import { useParams, useLocation } from "react-router"; import { ethers } from "ethers"; import queryString from "query-string"; import StandardFrame from "./StandardFrame"; import BlockTransactionHeader from "./block/BlockTransactionHeader"; import BlockTransactionResults from "./block/BlockTransactionResults"; -import { OperationType, ProcessedTransaction } from "./types"; import { PAGE_SIZE } from "./params"; import { RuntimeContext } from "./useRuntime"; -import { getInternalOperations } from "./nodeFunctions"; +import { useBlockTransactions } from "./useErigonHooks"; type BlockParams = { blockNumber: string; @@ -35,72 +34,7 @@ const BlockTransactions: React.FC = () => { [params.blockNumber] ); - const [txs, setTxs] = useState(); - useEffect(() => { - if (!provider) { - return; - } - - const readBlock = async () => { - const [_block, _receipts] = await Promise.all([ - provider.getBlockWithTransactions(blockNumber.toNumber()), - provider.send("eth_getBlockReceipts", [blockNumber.toNumber()]), - ]); - - const responses = _block.transactions - .map( - (t, i): ProcessedTransaction => ({ - blockNumber: blockNumber.toNumber(), - timestamp: _block.timestamp, - miner: _block.miner, - idx: i, - hash: t.hash, - from: t.from, - to: t.to, - createdContractAddress: _receipts[i].contractAddress, - value: t.value, - fee: - t.type !== 2 - ? provider.formatter - .bigNumber(_receipts[i].gasUsed) - .mul(t.gasPrice!) - : provider.formatter - .bigNumber(_receipts[i].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), - }) - ) - .reverse(); - setTxs(responses); - - const checkTouchMinerAddr = await Promise.all( - responses.map(async (res) => { - const ops = await getInternalOperations(provider, res.hash); - return ( - ops.findIndex( - (op) => - op.type === OperationType.TRANSFER && - res.miner !== undefined && - res.miner === ethers.utils.getAddress(op.to) - ) !== -1 - ); - }) - ); - const processedResponses = responses.map( - (r, i): ProcessedTransaction => ({ - ...r, - internalMinerInteraction: checkTouchMinerAddr[i], - }) - ); - setTxs(processedResponses); - }; - readBlock(); - }, [provider, blockNumber]); + const txs = useBlockTransactions(provider, blockNumber.toNumber()); const page = useMemo(() => { if (!txs) { diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 4982f90..999ad5f 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -6,6 +6,8 @@ import { TokenTransfer, TransactionData, InternalOperation, + ProcessedTransaction, + OperationType, } from "./types"; import erc20 from "./erc20.json"; @@ -65,6 +67,81 @@ export const readBlock = async ( return extBlock; }; +export const useBlockTransactions = ( + provider: ethers.providers.JsonRpcProvider | undefined, + blockNumber: number +) => { + const [txs, setTxs] = useState(); + + useEffect(() => { + if (!provider) { + return; + } + + const readBlock = async () => { + const [_block, _receipts] = await Promise.all([ + provider.getBlockWithTransactions(blockNumber), + provider.send("eth_getBlockReceipts", [blockNumber]), + ]); + + const responses = _block.transactions + .map( + (t, i): ProcessedTransaction => ({ + blockNumber: blockNumber, + timestamp: _block.timestamp, + miner: _block.miner, + idx: i, + hash: t.hash, + from: t.from, + to: t.to, + createdContractAddress: _receipts[i].contractAddress, + value: t.value, + fee: + t.type !== 2 + ? provider.formatter + .bigNumber(_receipts[i].gasUsed) + .mul(t.gasPrice!) + : provider.formatter + .bigNumber(_receipts[i].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), + }) + ) + .reverse(); + setTxs(responses); + + const checkTouchMinerAddr = await Promise.all( + responses.map(async (res) => { + const ops = await getInternalOperations(provider, res.hash); + return ( + ops.findIndex( + (op) => + op.type === OperationType.TRANSFER && + res.miner !== undefined && + res.miner === ethers.utils.getAddress(op.to) + ) !== -1 + ); + }) + ); + const processedResponses = responses.map( + (r, i): ProcessedTransaction => ({ + ...r, + internalMinerInteraction: checkTouchMinerAddr[i], + }) + ); + setTxs(processedResponses); + }; + readBlock(); + }, [provider, blockNumber]); + + return txs; +}; + export const useBlockData = ( provider: ethers.providers.JsonRpcProvider | undefined, blockNumberOrHash: string From 610be8191ee6ca463c9c50e4c7744c1526d15ea8 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 2 Aug 2021 01:53:08 -0300 Subject: [PATCH 05/12] Fix typo --- src/special/london/Blocks.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/special/london/Blocks.tsx b/src/special/london/Blocks.tsx index 7dc5f9a..441aa05 100644 --- a/src/special/london/Blocks.tsx +++ b/src/special/london/Blocks.tsx @@ -61,7 +61,7 @@ type BlocksProps = { const Blocks: React.FC = ({ latestBlock, targetBlockNumber }) => { const { provider } = useContext(RuntimeContext); - const [blocks, setBlock] = useState([]); + const [blocks, setBlocks] = useState([]); const [now, setNow] = useState(Date.now()); const addBlock = useCallback( @@ -77,7 +77,7 @@ const Blocks: React.FC = ({ latestBlock, targetBlockNumber }) => { const extBlock = await readBlock(provider, blockNumber.toString()); setNow(Date.now()); - setBlock((_blocks) => { + setBlocks((_blocks) => { if (_blocks.length > 0 && blockNumber === _blocks[0].number) { return _blocks; } From 3cbc0b0d3ccea10b8b6ddedc0d52177cf1d86cdd Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 2 Aug 2021 15:43:37 -0300 Subject: [PATCH 06/12] Make use of the new ots_getBlockDetails API --- src/Block.tsx | 2 +- src/useErigonHooks.ts | 38 +++++++++++++++++--------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index a515036..298ef01 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -83,7 +83,7 @@ const Block: React.FC = () => { className="bg-link-blue bg-opacity-10 text-link-blue hover:bg-opacity-100 hover:text-white rounded-lg px-2 py-1 text-xs" to={blockTxsURL(block.number)} > - {block.transactions.length} transactions + {block.transactionCount} transactions {" "} in this block diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 999ad5f..ac8a5aa 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -22,6 +22,7 @@ export interface ExtendedBlock extends ethers.providers.Block { sha3Uncles: string; stateRoot: string; totalDifficulty: BigNumber; + transactionCount: number; } export const readBlock = async ( @@ -30,38 +31,33 @@ export const readBlock = async ( ) => { let blockPromise: Promise; if (ethers.utils.isHexString(blockNumberOrHash, 32)) { + // TODO: fix blockPromise = provider.send("eth_getBlockByHash", [ blockNumberOrHash, false, ]); } else { - blockPromise = provider.send("eth_getBlockByNumber", [ - blockNumberOrHash, - false, - ]); + blockPromise = provider.send("ots_getBlockDetails", [blockNumberOrHash]); } - const [_rawBlock, _rawIssuance, _rawReceipts] = await Promise.all([ - blockPromise, - provider.send("erigon_issuance", [blockNumberOrHash]), - provider.send("eth_getBlockReceipts", [blockNumberOrHash]), - ]); - const receipts = (_rawReceipts as any[]).map((r) => - provider.formatter.receipt(r) - ); - const fees = receipts.reduce( - (acc, r) => acc.add(r.effectiveGasPrice.mul(r.gasUsed)), - BigNumber.from(0) - ); - const _block = provider.formatter.block(_rawBlock); + const _rawBlock = await blockPromise; + const _block = provider.formatter.block(_rawBlock.block); + const _rawIssuance = _rawBlock.issuance; + const fees = provider.formatter.bigNumber(_rawBlock.totalFees); + const extBlock: ExtendedBlock = { blockReward: provider.formatter.bigNumber(_rawIssuance.blockReward ?? 0), unclesReward: provider.formatter.bigNumber(_rawIssuance.uncleReward ?? 0), feeReward: fees, - size: provider.formatter.number(_rawBlock.size), - sha3Uncles: _rawBlock.sha3Uncles, - stateRoot: _rawBlock.stateRoot, - totalDifficulty: provider.formatter.bigNumber(_rawBlock.totalDifficulty), + size: provider.formatter.number(_rawBlock.block.size), + sha3Uncles: _rawBlock.block.sha3Uncles, + stateRoot: _rawBlock.block.stateRoot, + totalDifficulty: provider.formatter.bigNumber( + _rawBlock.block.totalDifficulty + ), + transactionCount: provider.formatter.number( + _rawBlock.block.transactionCount + ), ..._block, }; return extBlock; From 46bc4a7a11141979fdc6f54b17b62d7409388335 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 2 Aug 2021 17:06:53 -0300 Subject: [PATCH 07/12] 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; From 795d054a38968b6b232f8e544e0ba7273d02c1fb Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 2 Aug 2021 17:16:34 -0300 Subject: [PATCH 08/12] Fix flickering when there is no internal ops inside tx --- src/transaction/Details.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 69e40fe..2946df5 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -130,7 +130,7 @@ const Details: React.FC = ({ )} - {internalOps && ( + {internalOps && internalOps.length > 0 && (
{internalOps.map((op, i) => ( Date: Mon, 2 Aug 2021 23:07:27 -0300 Subject: [PATCH 09/12] Use first iteration of ots_getBlockTransactions --- src/useErigonHooks.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index e904137..8fe170e 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -1,5 +1,6 @@ import { useState, useEffect } from "react"; import { ethers, BigNumber } from "ethers"; +import { BlockWithTransactions } from "@ethersproject/abstract-provider"; import { getInternalOperations } from "./nodeFunctions"; import { TokenMetas, @@ -75,12 +76,15 @@ export const useBlockTransactions = ( } const readBlock = async () => { - const [_block, _receipts] = await Promise.all([ - provider.getBlockWithTransactions(blockNumber), - provider.send("eth_getBlockReceipts", [blockNumber]), + const result = await provider.send("ots_getBlockTransactions", [ + blockNumber, ]); + const _block = provider.formatter.blockWithTransactions( + result.fullblock + ) as unknown as BlockWithTransactions; + const _receipts = result.receipts; - const responses = _block.transactions + const rawTxs = _block.transactions .map( (t, i): ProcessedTransaction => ({ blockNumber: blockNumber, @@ -109,10 +113,10 @@ export const useBlockTransactions = ( }) ) .reverse(); - setTxs(responses); + setTxs(rawTxs); const checkTouchMinerAddr = await Promise.all( - responses.map(async (res) => { + rawTxs.map(async (res) => { const ops = await getInternalOperations(provider, res.hash); return ( ops.findIndex( @@ -124,13 +128,13 @@ export const useBlockTransactions = ( ); }) ); - const processedResponses = responses.map( + const processedTxs = rawTxs.map( (r, i): ProcessedTransaction => ({ ...r, internalMinerInteraction: checkTouchMinerAddr[i], }) ); - setTxs(processedResponses); + setTxs(processedTxs); }; readBlock(); }, [provider, blockNumber]); From a6b1551756aa306a5fabbdecb0c8abab537821df Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Tue, 3 Aug 2021 00:45:07 -0300 Subject: [PATCH 10/12] Use total info from node --- src/BlockTransactions.tsx | 9 ++++++--- src/useErigonHooks.ts | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index 02352d7..f8a3bf9 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -34,7 +34,10 @@ const BlockTransactions: React.FC = () => { [params.blockNumber] ); - const txs = useBlockTransactions(provider, blockNumber.toNumber()); + const [totalTxs, txs] = useBlockTransactions( + provider, + blockNumber.toNumber() + ); const page = useMemo(() => { if (!txs) { @@ -43,7 +46,7 @@ const BlockTransactions: React.FC = () => { const pageStart = (pageNumber - 1) * PAGE_SIZE; return txs.slice(pageStart, pageStart + PAGE_SIZE); }, [txs, pageNumber]); - const total = useMemo(() => txs?.length ?? 0, [txs]); + const total = totalTxs; document.title = `Block #${blockNumber} Txns | Otterscan`; @@ -52,7 +55,7 @@ const BlockTransactions: React.FC = () => { diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 8fe170e..56677af 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -67,7 +67,8 @@ export const readBlock = async ( export const useBlockTransactions = ( provider: ethers.providers.JsonRpcProvider | undefined, blockNumber: number -) => { +): [number | undefined, ProcessedTransaction[] | undefined] => { + const [totalTxs, setTotalTxs] = useState(); const [txs, setTxs] = useState(); useEffect(() => { @@ -114,6 +115,7 @@ export const useBlockTransactions = ( ) .reverse(); setTxs(rawTxs); + setTotalTxs(result.fullblock.transactionCount); const checkTouchMinerAddr = await Promise.all( rawTxs.map(async (res) => { @@ -139,7 +141,7 @@ export const useBlockTransactions = ( readBlock(); }, [provider, blockNumber]); - return txs; + return [totalTxs, txs]; }; export const useBlockData = ( From d7621eec5945b737863a68fc9e1787ceb522b896 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Tue, 3 Aug 2021 01:34:14 -0300 Subject: [PATCH 11/12] Add server side pagination support --- src/BlockTransactions.tsx | 17 +++++------------ src/useErigonHooks.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index f8a3bf9..4835fd3 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -36,26 +36,19 @@ const BlockTransactions: React.FC = () => { const [totalTxs, txs] = useBlockTransactions( provider, - blockNumber.toNumber() + blockNumber.toNumber(), + pageNumber - 1, + PAGE_SIZE ); - const page = useMemo(() => { - if (!txs) { - return undefined; - } - const pageStart = (pageNumber - 1) * PAGE_SIZE; - return txs.slice(pageStart, pageStart + PAGE_SIZE); - }, [txs, pageNumber]); - const total = totalTxs; - document.title = `Block #${blockNumber} Txns | Otterscan`; return ( diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 56677af..0c9c7c5 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -66,7 +66,9 @@ export const readBlock = async ( export const useBlockTransactions = ( provider: ethers.providers.JsonRpcProvider | undefined, - blockNumber: number + blockNumber: number, + pageNumber: number, + pageSize: number ): [number | undefined, ProcessedTransaction[] | undefined] => { const [totalTxs, setTotalTxs] = useState(); const [txs, setTxs] = useState(); @@ -79,6 +81,8 @@ export const useBlockTransactions = ( const readBlock = async () => { const result = await provider.send("ots_getBlockTransactions", [ blockNumber, + pageNumber, + pageSize, ]); const _block = provider.formatter.blockWithTransactions( result.fullblock @@ -139,7 +143,7 @@ export const useBlockTransactions = ( setTxs(processedTxs); }; readBlock(); - }, [provider, blockNumber]); + }, [provider, blockNumber, pageNumber, pageSize]); return [totalTxs, txs]; }; From 5293e7eb0a77f12c9f5ac2d33bef342e49fa18c5 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Tue, 3 Aug 2021 15:23:01 -0300 Subject: [PATCH 12/12] Revert to using http; need to fix ws:// connection lost issues first --- public/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/config.json b/public/config.json index 5573731..1db5aa7 100644 --- a/public/config.json +++ b/public/config.json @@ -1,4 +1,4 @@ { - "erigonURL": "ws://localhost:8545", + "erigonURL": "http://localhost:8545", "assetsURLPrefix": "http://localhost:3001" } \ No newline at end of file