Commit 432d17bd authored by Noah Zinsmeister's avatar Noah Zinsmeister

only show buttons if nft is owned

parent 9743b211
...@@ -31,6 +31,7 @@ import ReactGA from 'react-ga' ...@@ -31,6 +31,7 @@ import ReactGA from 'react-ga'
import { TransactionResponse } from '@ethersproject/providers' import { TransactionResponse } from '@ethersproject/providers'
import { Dots } from 'components/swap/styleds' import { Dots } from 'components/swap/styleds'
import { getPriceOrderingFromPositionForUI } from '../../components/PositionListItem' import { getPriceOrderingFromPositionForUI } from '../../components/PositionListItem'
import { useSingleCallResult } from 'state/multicall/hooks'
const PageWrapper = styled.div` const PageWrapper = styled.div`
min-width: 800px; min-width: 800px;
...@@ -233,6 +234,9 @@ export function PositionPage({ ...@@ -233,6 +234,9 @@ export function PositionPage({
}) })
}, [chainId, feeValue0, feeValue1, positionManager, account, tokenId, addTransaction, library]) }, [chainId, feeValue0, feeValue1, positionManager, account, tokenId, addTransaction, library])
const owner = useSingleCallResult(!!tokenId ? positionManager : null, 'ownerOf', [tokenId]).result?.[0]
const ownsNFT = owner === account || positionDetails?.operator === account
return loading || poolState === PoolState.LOADING || !feeAmount ? ( return loading || poolState === PoolState.LOADING || !feeAmount ? (
<LoadingRows> <LoadingRows>
<div /> <div />
...@@ -262,41 +266,44 @@ export function PositionPage({ ...@@ -262,41 +266,44 @@ export function PositionPage({
<BadgeText>{basisPointsToPercent(feeAmount / 100).toSignificant()}%</BadgeText> <BadgeText>{basisPointsToPercent(feeAmount / 100).toSignificant()}%</BadgeText>
</Badge> </Badge>
</RowFixed> </RowFixed>
<RowFixed>
{feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0) || !!collectMigrationHash ? ( {ownsNFT && (
<ButtonConfirmed <RowFixed>
disabled={collecting || !!collectMigrationHash} {feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0) || !!collectMigrationHash ? (
confirmed={!!collectMigrationHash && !isCollectPending} <ButtonConfirmed
mr="15px" disabled={collecting || !!collectMigrationHash}
width="175px" confirmed={!!collectMigrationHash && !isCollectPending}
padding="8px" mr="15px"
style={{ borderRadius: '12px' }} width="175px"
onClick={collect} padding="8px"
> style={{ borderRadius: '12px' }}
{!!collectMigrationHash && !isCollectPending ? ( onClick={collect}
'Collected' >
) : isCollectPending || collecting ? ( {!!collectMigrationHash && !isCollectPending ? (
<Dots>Collecting</Dots> 'Collected'
) : ( ) : isCollectPending || collecting ? (
'Collect fees' <Dots>Collecting</Dots>
)} ) : (
</ButtonConfirmed> 'Collect fees'
) : null} )}
{currency0 && currency1 && feeAmount && tokenId ? ( </ButtonConfirmed>
<Link to={`/increase/${currencyId(currency0)}/${currencyId(currency1)}/${feeAmount}/${tokenId}`}> ) : null}
<ButtonPrimary mr="15px" width="175px" padding="8px" borderRadius="12px"> {currency0 && currency1 && feeAmount && tokenId ? (
Add liquidity <Link to={`/increase/${currencyId(currency0)}/${currencyId(currency1)}/${feeAmount}/${tokenId}`}>
</ButtonPrimary> <ButtonPrimary mr="15px" width="175px" padding="8px" borderRadius="12px">
</Link> Add liquidity
) : null} </ButtonPrimary>
{tokenId && ( </Link>
<Link to={`/remove/${tokenId}`}> ) : null}
<ButtonPrimary width="175px" padding="8px" borderRadius="12px"> {tokenId && (
Remove liquidity <Link to={`/remove/${tokenId}`}>
</ButtonPrimary> <ButtonPrimary width="175px" padding="8px" borderRadius="12px">
</Link> Remove liquidity
)} </ButtonPrimary>
</RowFixed> </Link>
)}
</RowFixed>
)}
</RowBetween> </RowBetween>
<RowBetween> <RowBetween>
<BadgeWrapper> <BadgeWrapper>
......
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