refactor: remove universal-router logic in pay with any token flag (#6127)

This commit is contained in:
Vignesh Mohankumar 2023-03-10 16:44:41 -05:00 committed by GitHub
parent c1297b2aa3
commit d06451cb98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,3 @@
import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { useWeb3React } from '@web3-react/core'
import { BaseVariant, FeatureFlag, useBaseFlag } from '../index' import { BaseVariant, FeatureFlag, useBaseFlag } from '../index'
export function usePayWithAnyTokenFlag(): BaseVariant { export function usePayWithAnyTokenFlag(): BaseVariant {
@ -8,17 +5,7 @@ export function usePayWithAnyTokenFlag(): BaseVariant {
} }
export function usePayWithAnyTokenEnabled(): boolean { export function usePayWithAnyTokenEnabled(): boolean {
const flagEnabled = usePayWithAnyTokenFlag() === BaseVariant.Enabled return usePayWithAnyTokenFlag() === BaseVariant.Enabled
const { chainId } = useWeb3React()
try {
// Detect if the Universal Router is not yet deployed to chainId.
// This is necessary so that we can fallback correctly on chains without a Universal Router deployment.
// It will be removed once Universal Router is deployed on all supported chains.
chainId && UNIVERSAL_ROUTER_ADDRESS(chainId)
return flagEnabled
} catch {
return false
}
} }
export { BaseVariant as PayWithAnyTokenVariant } export { BaseVariant as PayWithAnyTokenVariant }