fix: network connector fix and lists fix (#7185)
This commit is contained in:
parent
49f1acb52a
commit
bf1f613a4f
27
cypress/e2e/swap/unconnected.test.ts
Normal file
27
cypress/e2e/swap/unconnected.test.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { SwapEventName } from '@uniswap/analytics-events'
|
||||||
|
import { USDC_MAINNET } from 'constants/tokens'
|
||||||
|
|
||||||
|
import { getTestSelector } from '../../utils'
|
||||||
|
|
||||||
|
describe('Swap inputs with no wallet connected', () => {
|
||||||
|
it('can input and load a quote with no wallet connected', () => {
|
||||||
|
cy.visit(`/swap?inputCurrency=ETH&outputCurrency=${USDC_MAINNET.address}`)
|
||||||
|
|
||||||
|
cy.get(getTestSelector('web3-status-connected')).click()
|
||||||
|
// click twice, first time to show confirmation, second to confirm
|
||||||
|
cy.get(getTestSelector('wallet-disconnect')).click()
|
||||||
|
cy.get(getTestSelector('wallet-disconnect')).should('contain', 'Disconnect')
|
||||||
|
cy.get(getTestSelector('wallet-disconnect')).click()
|
||||||
|
cy.get(getTestSelector('close-account-drawer')).click()
|
||||||
|
|
||||||
|
// Enter amount to swap
|
||||||
|
cy.get('#swap-currency-output .token-amount-input').type('1').should('have.value', '1')
|
||||||
|
cy.get('#swap-currency-input .token-amount-input').should('not.have.value', '')
|
||||||
|
// Verify logging
|
||||||
|
cy.waitForAmplitudeEvent(SwapEventName.SWAP_QUOTE_RECEIVED).then((event: any) => {
|
||||||
|
cy.wrap(event.event_properties).should('have.property', 'quote_latency_milliseconds')
|
||||||
|
cy.wrap(event.event_properties.quote_latency_milliseconds).should('be.a', 'number')
|
||||||
|
cy.wrap(event.event_properties.quote_latency_milliseconds).should('be.gte', 0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -24,12 +24,13 @@ export default function useEagerlyConnect() {
|
|||||||
const rehydrated = useAppSelector((state) => state._persist.rehydrated)
|
const rehydrated = useAppSelector((state) => state._persist.rehydrated)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedWallet) return
|
|
||||||
try {
|
try {
|
||||||
const selectedConnection = getConnection(selectedWallet)
|
|
||||||
connect(gnosisSafeConnection.connector)
|
connect(gnosisSafeConnection.connector)
|
||||||
connect(networkConnection.connector)
|
connect(networkConnection.connector)
|
||||||
|
|
||||||
|
if (!selectedWallet) return
|
||||||
|
const selectedConnection = getConnection(selectedWallet)
|
||||||
|
|
||||||
if (selectedConnection) {
|
if (selectedConnection) {
|
||||||
connect(selectedConnection.connector)
|
connect(selectedConnection.connector)
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists'
|
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists'
|
||||||
import { useWeb3React } from '@web3-react/core'
|
import { useWeb3React } from '@web3-react/core'
|
||||||
import { DEFAULT_LIST_OF_LISTS, UNSUPPORTED_LIST_URLS } from 'constants/lists'
|
import { DEFAULT_LIST_OF_LISTS, UNSUPPORTED_LIST_URLS } from 'constants/lists'
|
||||||
|
import TokenSafetyLookupTable from 'constants/tokenSafetyLookup'
|
||||||
import useInterval from 'lib/hooks/useInterval'
|
import useInterval from 'lib/hooks/useInterval'
|
||||||
import ms from 'ms'
|
import ms from 'ms'
|
||||||
import { useCallback, useEffect } from 'react'
|
import { useCallback, useEffect } from 'react'
|
||||||
import { useAppDispatch } from 'state/hooks'
|
import { useAppDispatch, useAppSelector } from 'state/hooks'
|
||||||
import { useAllLists } from 'state/lists/hooks'
|
import { useAllLists } from 'state/lists/hooks'
|
||||||
|
|
||||||
import { useFetchListCallback } from '../../hooks/useFetchListCallback'
|
import { useFetchListCallback } from '../../hooks/useFetchListCallback'
|
||||||
@ -19,6 +20,11 @@ export default function Updater(): null {
|
|||||||
|
|
||||||
// get all loaded lists, and the active urls
|
// get all loaded lists, and the active urls
|
||||||
const lists = useAllLists()
|
const lists = useAllLists()
|
||||||
|
const listsState = useAppSelector((state) => state.lists)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
TokenSafetyLookupTable.update(listsState)
|
||||||
|
}, [listsState])
|
||||||
|
|
||||||
const fetchList = useFetchListCallback()
|
const fetchList = useFetchListCallback()
|
||||||
const fetchAllListsCallback = useCallback(() => {
|
const fetchAllListsCallback = useCallback(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user