Use total info from node
This commit is contained in:
parent
e03e27c71b
commit
a6b1551756
|
@ -34,7 +34,10 @@ const BlockTransactions: React.FC = () => {
|
||||||
[params.blockNumber]
|
[params.blockNumber]
|
||||||
);
|
);
|
||||||
|
|
||||||
const txs = useBlockTransactions(provider, blockNumber.toNumber());
|
const [totalTxs, txs] = useBlockTransactions(
|
||||||
|
provider,
|
||||||
|
blockNumber.toNumber()
|
||||||
|
);
|
||||||
|
|
||||||
const page = useMemo(() => {
|
const page = useMemo(() => {
|
||||||
if (!txs) {
|
if (!txs) {
|
||||||
|
@ -43,7 +46,7 @@ const BlockTransactions: React.FC = () => {
|
||||||
const pageStart = (pageNumber - 1) * PAGE_SIZE;
|
const pageStart = (pageNumber - 1) * PAGE_SIZE;
|
||||||
return txs.slice(pageStart, pageStart + PAGE_SIZE);
|
return txs.slice(pageStart, pageStart + PAGE_SIZE);
|
||||||
}, [txs, pageNumber]);
|
}, [txs, pageNumber]);
|
||||||
const total = useMemo(() => txs?.length ?? 0, [txs]);
|
const total = totalTxs;
|
||||||
|
|
||||||
document.title = `Block #${blockNumber} Txns | Otterscan`;
|
document.title = `Block #${blockNumber} Txns | Otterscan`;
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ const BlockTransactions: React.FC = () => {
|
||||||
<BlockTransactionHeader blockTag={blockNumber.toNumber()} />
|
<BlockTransactionHeader blockTag={blockNumber.toNumber()} />
|
||||||
<BlockTransactionResults
|
<BlockTransactionResults
|
||||||
page={page}
|
page={page}
|
||||||
total={total}
|
total={total ?? 0}
|
||||||
pageNumber={pageNumber}
|
pageNumber={pageNumber}
|
||||||
/>
|
/>
|
||||||
</StandardFrame>
|
</StandardFrame>
|
||||||
|
|
|
@ -67,7 +67,8 @@ export const readBlock = async (
|
||||||
export const useBlockTransactions = (
|
export const useBlockTransactions = (
|
||||||
provider: ethers.providers.JsonRpcProvider | undefined,
|
provider: ethers.providers.JsonRpcProvider | undefined,
|
||||||
blockNumber: number
|
blockNumber: number
|
||||||
) => {
|
): [number | undefined, ProcessedTransaction[] | undefined] => {
|
||||||
|
const [totalTxs, setTotalTxs] = useState<number>();
|
||||||
const [txs, setTxs] = useState<ProcessedTransaction[]>();
|
const [txs, setTxs] = useState<ProcessedTransaction[]>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -114,6 +115,7 @@ export const useBlockTransactions = (
|
||||||
)
|
)
|
||||||
.reverse();
|
.reverse();
|
||||||
setTxs(rawTxs);
|
setTxs(rawTxs);
|
||||||
|
setTotalTxs(result.fullblock.transactionCount);
|
||||||
|
|
||||||
const checkTouchMinerAddr = await Promise.all(
|
const checkTouchMinerAddr = await Promise.all(
|
||||||
rawTxs.map(async (res) => {
|
rawTxs.map(async (res) => {
|
||||||
|
@ -139,7 +141,7 @@ export const useBlockTransactions = (
|
||||||
readBlock();
|
readBlock();
|
||||||
}, [provider, blockNumber]);
|
}, [provider, blockNumber]);
|
||||||
|
|
||||||
return txs;
|
return [totalTxs, txs];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useBlockData = (
|
export const useBlockData = (
|
||||||
|
|
Loading…
Reference in New Issue