Commit 38cde648 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: add a catch on collect static call (#6491)

* fix: add a catch on collect static call

* comment
parent 33c09911
...@@ -27,9 +27,10 @@ export function useV3PositionFees( ...@@ -27,9 +27,10 @@ export function useV3PositionFees(
// latestBlockNumber is included to ensure data stays up-to-date every block // latestBlockNumber is included to ensure data stays up-to-date every block
const [amounts, setAmounts] = useState<[BigNumber, BigNumber] | undefined>() const [amounts, setAmounts] = useState<[BigNumber, BigNumber] | undefined>()
useEffect(() => { useEffect(() => {
;(async function getFees() {
if (positionManager && tokenIdHexString && owner) { if (positionManager && tokenIdHexString && owner) {
positionManager.callStatic try {
.collect( const results = await positionManager.callStatic.collect(
{ {
tokenId: tokenIdHexString, tokenId: tokenIdHexString,
recipient: owner, // some tokens might fail if transferred to address(0) recipient: owner, // some tokens might fail if transferred to address(0)
...@@ -38,10 +39,14 @@ export function useV3PositionFees( ...@@ -38,10 +39,14 @@ export function useV3PositionFees(
}, },
{ from: owner } // need to simulate the call as the owner { from: owner } // need to simulate the call as the owner
) )
.then((results) => {
setAmounts([results.amount0, results.amount1]) setAmounts([results.amount0, results.amount1])
}) } catch {
// If the static call fails, the default state will remain for `amounts`.
// This case is handled by returning unclaimed fees as empty.
// TODO(INFRA-178): Look into why we have failures with call data being 0x.
} }
}
})()
}, [positionManager, tokenIdHexString, owner, latestBlockNumber]) }, [positionManager, tokenIdHexString, owner, latestBlockNumber])
if (pool && amounts) { if (pool && amounts) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment