fix: dont crash on invalid tokenId (#7410)

This commit is contained in:
eddie 2023-10-05 12:12:34 -07:00 committed by GitHub
parent 4a79280edc
commit bab8506919
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -384,13 +384,22 @@ const PositionLabelRow = styled(RowFixed)({
gap: 8, gap: 8,
}) })
function parseTokenId(tokenId: string | undefined): BigNumber | undefined {
if (!tokenId) return
try {
return BigNumber.from(tokenId)
} catch (error) {
return
}
}
function PositionPageContent() { function PositionPageContent() {
const { tokenId: tokenIdFromUrl } = useParams<{ tokenId?: string }>() const { tokenId: tokenIdFromUrl } = useParams<{ tokenId?: string }>()
const { chainId, account, provider } = useWeb3React() const { chainId, account, provider } = useWeb3React()
const theme = useTheme() const theme = useTheme()
const { formatTickPrice } = useFormatter() const { formatTickPrice } = useFormatter()
const parsedTokenId = tokenIdFromUrl ? BigNumber.from(tokenIdFromUrl) : undefined const parsedTokenId = parseTokenId(tokenIdFromUrl)
const { loading, position: positionDetails } = useV3PositionFromTokenId(parsedTokenId) const { loading, position: positionDetails } = useV3PositionFromTokenId(parsedTokenId)
const { const {