fix: dont crash on invalid tokenId (#7410)
This commit is contained in:
parent
4a79280edc
commit
bab8506919
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user