Fix negative block numbers

This commit is contained in:
Willian Mitsuda 2022-02-18 04:11:10 -03:00
parent 9ca79e838f
commit 088781babb
2 changed files with 8 additions and 6 deletions

View File

@ -6,11 +6,9 @@ type BlockNotFoundProps = {
};
const BlockNotFound: React.FC<BlockNotFoundProps> = ({ blockNumberOrHash }) => (
<>
<ContentFrame>
<div className="py-4 text-sm">Block "{blockNumberOrHash}" not found.</div>
</ContentFrame>
</>
<ContentFrame>
<div className="py-4 text-sm">Block "{blockNumberOrHash}" not found.</div>
</ContentFrame>
);
export default React.memo(BlockNotFound);

View File

@ -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;