From 088781babb36703e77744678a0166345595c85b6 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Fri, 18 Feb 2022 04:11:10 -0300 Subject: [PATCH] Fix negative block numbers --- src/components/BlockNotFound.tsx | 8 +++----- src/useErigonHooks.ts | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/BlockNotFound.tsx b/src/components/BlockNotFound.tsx index 6a875db..b1ddee8 100644 --- a/src/components/BlockNotFound.tsx +++ b/src/components/BlockNotFound.tsx @@ -6,11 +6,9 @@ type BlockNotFoundProps = { }; const BlockNotFound: React.FC = ({ blockNumberOrHash }) => ( - <> - -
Block "{blockNumberOrHash}" not found.
-
- + +
Block "{blockNumberOrHash}" not found.
+
); export default React.memo(BlockNotFound); diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index c0d958b..ad9b0b8 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -43,7 +43,11 @@ export const readBlock = async ( blockNumberOrHash, ]); } else { - blockPromise = provider.send("ots_getBlockDetails", [blockNumberOrHash]); + const blockNumber = parseInt(blockNumberOrHash); + if (isNaN(blockNumber) || blockNumber < 0) { + return null; + } + blockPromise = provider.send("ots_getBlockDetails", [blockNumber]); } const _rawBlock = await blockPromise;