Compare commits

...

7 Commits

Author SHA1 Message Date
Moody Salem
6c880d29a6 fix(position fee computation): incorrect sub underflow 2021-05-05 22:54:30 -04:00
Lint Action
a8baa6d6a5 Fix code style issues with ESLint 2021-05-05 21:56:49 +00:00
Callil Capuozzo
00a1dee073 Merge branch 'main' of https://github.com/Uniswap/uniswap-interface into main 2021-05-05 17:54:47 -04:00
Callil Capuozzo
a6de7d7846 add links 2021-05-05 17:54:33 -04:00
Moody Salem
e1a81a9996 uniswap protocol disclaimer 2021-05-05 17:40:22 -04:00
Noah Zinsmeister
0770bab032 try manual approve if erc712 doesn't work (#1397)
* initial impl

* fix async logic
2021-05-05 17:36:07 -04:00
Callil Capuozzo
e5404dbf97 Fix some links 2021-05-05 16:04:40 -04:00
9 changed files with 62 additions and 15 deletions

View File

@@ -213,12 +213,12 @@ export default function FullPositionCard({ pair, border, stakedBalance }: Positi
>
{showMore ? (
<>
Migrate
Manage
<ChevronUp size="20" style={{ marginLeft: '10px' }} />
</>
) : (
<>
Migrate
Manage
<ChevronDown size="20" style={{ marginLeft: '10px' }} />
</>
)}
@@ -296,7 +296,7 @@ export default function FullPositionCard({ pair, border, stakedBalance }: Positi
<ButtonSecondary padding="8px" borderRadius="8px">
<ExternalLink
style={{ width: '100%', textAlign: 'center' }}
href={`https://info.uniswap.org/account/${account}`}
href={`https://v2.info.uniswap.org/account/${account}`}
>
View accrued fees and analytics<span style={{ fontSize: '11px' }}></span>
</ExternalLink>

View File

@@ -338,9 +338,10 @@ export default function WalletModal({
<LightCard style={{ marginBottom: '16px' }}>
<AutoRow style={{ flexWrap: 'nowrap' }}>
<TYPE.main fontSize={14}>
By connecting a wallet, you agree to Uniswap Labs <ExternalLink href="">Terms of Service</ExternalLink>{' '}
and acknowledge that you have read and understand the{' '}
<ExternalLink href="">Uniswap protocol disclaimer</ExternalLink>.
By connecting a wallet, you agree to Uniswap Labs{' '}
<ExternalLink href="https://uniswap.org/terms-of-service/">Terms of Service</ExternalLink> and
acknowledge that you have read and understand the{' '}
<ExternalLink href="https://uniswap.org/disclaimer/">Uniswap protocol disclaimer</ExternalLink>.
</TYPE.main>
</AutoRow>
</LightCard>

View File

@@ -128,7 +128,18 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui
if (!pairContract || !library || !deadline) throw new Error('missing dependencies')
if (!parsedAmount) throw new Error('missing liquidity amount')
return gatherPermitSignature ? gatherPermitSignature() : approveCallback()
if (gatherPermitSignature) {
try {
await gatherPermitSignature()
} catch (error) {
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if (error?.code !== 4001) {
await approveCallback()
}
}
} else {
await approveCallback()
}
}
return (

View File

@@ -219,7 +219,7 @@ export function useERC20Permit(
message,
})
library
return library
.send('eth_signTypedData_v4', [account, data])
.then(splitSignature)
.then((signature) => {

View File

@@ -12,7 +12,7 @@ import { TokenAmount } from '@uniswap/sdk-core'
function subIn256(x: BigNumber, y: BigNumber): BigNumber {
const difference = x.sub(y)
return difference.lt(0) ? BigNumber.from(2).pow(256).sub(difference) : difference
return difference.lt(0) ? BigNumber.from(2).pow(256).add(difference) : difference
}
function getCounterfactualFees(

View File

@@ -239,7 +239,21 @@ function V2PairMigration({
const { signatureData, gatherPermitSignature } = useV2LiquidityTokenPermit(pairBalance, migratorAddress)
const approve = useCallback(async () => {
isNotUniswap ? approveManually() : gatherPermitSignature ? gatherPermitSignature() : approveManually()
if (isNotUniswap) {
// sushi has to be manually approved
await approveManually()
} else if (gatherPermitSignature) {
try {
await gatherPermitSignature()
} catch (error) {
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if (error?.code !== 4001) {
await approveManually()
}
}
} else {
await approveManually()
}
}, [isNotUniswap, gatherPermitSignature, approveManually])
const addTransaction = useTransactionAdder()

View File

@@ -192,7 +192,7 @@ export default function Pool() {
<>
<ButtonSecondary>
<RowBetween>
<ExternalLink href={'https://uniswap.info/account/' + account}>
<ExternalLink href={'https://v2.info.uniswap.org/account/' + account}>
Account analytics and accrued fees
</ExternalLink>
<span> </span>

View File

@@ -109,7 +109,18 @@ export default function RemoveLiquidity({
const liquidityAmount = parsedAmounts[Field.LIQUIDITY]
if (!liquidityAmount) throw new Error('missing liquidity amount')
return gatherPermitSignature ? gatherPermitSignature() : approveCallback()
if (gatherPermitSignature) {
try {
await gatherPermitSignature()
} catch (error) {
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if (error?.code !== 4001) {
await approveCallback()
}
}
} else {
await approveCallback()
}
}
// wrapped onUserInput to clear signatures

View File

@@ -205,9 +205,19 @@ export default function Swap({ history }: RouteComponentProps) {
allowedSlippage
)
const handleApprove = useCallback(() => {
if (signatureState === UseERC20PermitState.NOT_SIGNED && gatherPermitSignature) gatherPermitSignature()
else approveCallback()
const handleApprove = useCallback(async () => {
if (signatureState === UseERC20PermitState.NOT_SIGNED && gatherPermitSignature) {
try {
await gatherPermitSignature()
} catch (error) {
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if (error?.code !== 4001) {
await approveCallback()
}
}
} else {
await approveCallback()
}
}, [approveCallback, gatherPermitSignature, signatureState])
// check if user has gone through approval process, used to show two step buttons, reset on token change