From c3d2c438618a114c24b298264b74904cc1cf260d Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Tue, 7 Mar 2023 16:02:06 -0800 Subject: [PATCH] fix: unsupported chain bugs (#6098) * feat: upgrade widget again * fix: verify chainId is supported --- package.json | 2 +- src/components/WalletModal/index.tsx | 3 +- src/components/Widget/inputs.tsx | 3 +- yarn.lock | 140 ++++++++++++++------------- 4 files changed, 79 insertions(+), 69 deletions(-) diff --git a/package.json b/package.json index 984057ab5b..a48fb9a20f 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "@uniswap/v3-core": "1.0.0", "@uniswap/v3-periphery": "^1.1.1", "@uniswap/v3-sdk": "^3.9.0", - "@uniswap/widgets": "^2.44.4", + "@uniswap/widgets": "^2.47.0", "@vanilla-extract/css": "^1.7.2", "@vanilla-extract/css-utils": "^0.1.2", "@vanilla-extract/dynamic": "^2.0.2", diff --git a/src/components/WalletModal/index.tsx b/src/components/WalletModal/index.tsx index 62766d7b38..eb421ec7de 100644 --- a/src/components/WalletModal/index.tsx +++ b/src/components/WalletModal/index.tsx @@ -16,6 +16,7 @@ import { getIsInjected, getIsMetaMaskWallet, } from 'connection/utils' +import { isSupportedChain } from 'constants/chains' import usePrevious from 'hooks/usePrevious' import { useCallback, useEffect, useState } from 'react' import { ArrowLeft } from 'react-feather' @@ -207,7 +208,7 @@ export default function WalletModal({ // Keep the network connector in sync with any active user connector to prevent chain-switching on wallet disconnection. useEffect(() => { - if (chainId && connector !== networkConnection.connector) { + if (chainId && isSupportedChain(chainId) && connector !== networkConnection.connector) { networkConnection.connector.activate(chainId) } }, [chainId, connector]) diff --git a/src/components/Widget/inputs.tsx b/src/components/Widget/inputs.tsx index e804135549..3e812b0b51 100644 --- a/src/components/Widget/inputs.tsx +++ b/src/components/Widget/inputs.tsx @@ -3,6 +3,7 @@ import { InterfaceSectionName, SwapEventName } from '@uniswap/analytics-events' import { Currency, Field, SwapController, SwapEventHandlers, TradeType } from '@uniswap/widgets' import { useWeb3React } from '@web3-react/core' import CurrencySearchModal from 'components/SearchModal/CurrencySearchModal' +import { isSupportedChain } from 'constants/chains' import usePrevious from 'hooks/usePrevious' import { useCallback, useEffect, useMemo, useState } from 'react' @@ -50,7 +51,7 @@ export function useSyncWidgetInputs({ }, [defaultTokens, tokens]) useEffect(() => { - if (chainId !== previousChainId && !!previousChainId) { + if (chainId !== previousChainId && !!previousChainId && isSupportedChain(chainId)) { setTokens({ ...tokens, [Field.INPUT]: undefined, diff --git a/yarn.lock b/yarn.lock index b28e295a4e..c7babfe7f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5003,10 +5003,10 @@ react "^18.2.0" react-dom "^18.2.0" -"@uniswap/conedison@^1.3.0", "@uniswap/conedison@^1.4.0": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@uniswap/conedison/-/conedison-1.4.0.tgz#44ad96333b92913a57be34bf5effcfee6534cba1" - integrity sha512-ZZMfPTjUiYpLvO0SuMPGNzkFrRpzf+bQYSL/CzaYKGSVdorRUj4XpeMdjlbuKUtHqUEunOWE8eDL3J1Hl4HOUg== +"@uniswap/conedison@^1.4.0", "@uniswap/conedison@^1.5.1": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@uniswap/conedison/-/conedison-1.5.1.tgz#91527cc9928ce0187f30a5eb4abb705b8f0cd013" + integrity sha512-VJqUW4l54QVj5a4vAzAlWWd193iCcT8HMugFPB28S2Uqhs2elAg/RDQmiPOf9TOFB635MdBlD0S6xUuqo7FB4A== "@uniswap/default-token-list@^2.0.0": version "2.2.0" @@ -5255,17 +5255,17 @@ "@uniswap/v3-core" "1.0.0" "@uniswap/v3-periphery" "^1.0.1" -"@uniswap/widgets@^2.44.4": - version "2.44.4" - resolved "https://registry.yarnpkg.com/@uniswap/widgets/-/widgets-2.44.4.tgz#54323d891a4d4700631d582d7ce5c665345fbda9" - integrity sha512-7jgui71Y6ZTwdsqN3skmdNNEIbkz7hkMKfTiLPqWPhTF+rd/2RFQOijR/oQ9qGc833zGHOvVOSqbOmpvbUZrYA== +"@uniswap/widgets@^2.47.0": + version "2.47.0" + resolved "https://registry.yarnpkg.com/@uniswap/widgets/-/widgets-2.47.0.tgz#fa3fd5669c9340940d0f8350bbefc19cd0baa1d8" + integrity sha512-Jp+0F7kkld5LVjwLqN5drZOUxmdEbB4Ht6KbXwm7vV+08OhfpagPoKULfXWwIcEtNfWpbHeAAJfrhRN1E8Xx0g== dependencies: "@babel/runtime" ">=7.17.0" "@fontsource/ibm-plex-mono" "^4.5.1" "@fontsource/inter" "^4.5.1" "@popperjs/core" "^2.4.4" "@reduxjs/toolkit" "^1.6.1" - "@uniswap/conedison" "^1.3.0" + "@uniswap/conedison" "^1.5.1" "@uniswap/permit2-sdk" "^1.2.0" "@uniswap/redux-multicall" "^1.1.8" "@uniswap/router-sdk" "^1.3.0" @@ -5275,14 +5275,14 @@ "@uniswap/universal-router-sdk" "^1.3.8" "@uniswap/v2-sdk" "^3.0.1" "@uniswap/v3-sdk" "^3.8.2" - "@web3-react/core" "8.0.35-beta.0" - "@web3-react/eip1193" "8.0.27-beta.0" - "@web3-react/empty" "8.0.20-beta.0" - "@web3-react/metamask" "8.0.30-beta.0" - "@web3-react/network" "8.0.27-beta.0" - "@web3-react/types" "8.0.20-beta.0" - "@web3-react/url" "8.0.25-beta.0" - "@web3-react/walletconnect" "8.0.37-beta.0" + "@web3-react/core" "8.1.1-beta.0" + "@web3-react/eip1193" "8.1.1-beta.0" + "@web3-react/empty" "8.1.1-beta.0" + "@web3-react/metamask" "8.1.1-beta.0" + "@web3-react/network" "8.1.1-beta.0" + "@web3-react/types" "8.1.1-beta.0" + "@web3-react/url" "8.1.1-beta.0" + "@web3-react/walletconnect" "8.1.1-beta.0" ajv "^8.11.0" ajv-formats "^2.1.1" cids "^1.0.0" @@ -5811,14 +5811,14 @@ dependencies: "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/core@8.0.35-beta.0": - version "8.0.35-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/core/-/core-8.0.35-beta.0.tgz#8667483bdbc283fc8377d7f56faba1ec2fcdb095" - integrity sha512-vkEL2Vafu57lTA9T/cd3DNkZoDZ3G/JDUgxgjHqKLQVF4bPucrkeErqIHutAJ4suIi4bLOD0dFPMpFs+Bq7RgA== +"@web3-react/core@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/core/-/core-8.1.1-beta.0.tgz#76b81518829a1dd5bb3e992499824da96b71d2fd" + integrity sha512-7Fbsh+dLKAGrqZfDy+ZrFQraLwgnzrrI36YFdNUawUbLlaGAINFebQTUgQWAiEZ30S0xKLpggAdB+3rxwIqRKg== dependencies: - "@web3-react/store" "^8.0.25-beta.0" - "@web3-react/types" "^8.0.20-beta.0" - zustand "^4.0.0-rc.0" + "@web3-react/store" "^8.1.1-beta.0" + "@web3-react/types" "^8.1.1-beta.0" + zustand "4.3.3" optionalDependencies: "@ethersproject/providers" "^5" @@ -5833,12 +5833,12 @@ optionalDependencies: "@ethersproject/providers" "^5" -"@web3-react/eip1193@8.0.27-beta.0": - version "8.0.27-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/eip1193/-/eip1193-8.0.27-beta.0.tgz#b768fc3ae6e234627e6a8ecd4d5c473c371a816b" - integrity sha512-8aca1NDP+qigh/LOxSiC5N44qvVo1z5V7QI4T5iUpNrzbXEXV3G2JXutoW5fNEm+oK5fkHK64p9eZ6lo0qyMbQ== +"@web3-react/eip1193@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/eip1193/-/eip1193-8.1.1-beta.0.tgz#7f1d6065d1e3b7f1c6a4c169a1837d0c2b4a4da2" + integrity sha512-JT/heP/cnRh/wJ3+Y7Rt7SgNrChMRn6iqnmAMadGHq3hdZh5lUeKdgrIEJy5jFKOWqAzm82YNiJ0ZYN8Yd7DhA== dependencies: - "@web3-react/types" "^8.0.20-beta.0" + "@web3-react/types" "^8.1.1-beta.0" "@web3-react/eip1193@8.1.2-beta.0": version "8.1.2-beta.0" @@ -5847,12 +5847,12 @@ dependencies: "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/empty@8.0.20-beta.0": - version "8.0.20-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/empty/-/empty-8.0.20-beta.0.tgz#f8e2a6414ba49c7da3937776c213eb4c8ff6e2c7" - integrity sha512-hde1Wq7w03cal6hD0E+seVg6ZFMWKcaSZ0S5UwJi5CDxhF79oL8QuzpvTBslohRkWqzqlvl52wCSVaY+l2+F8Q== +"@web3-react/empty@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/empty/-/empty-8.1.1-beta.0.tgz#b032a721bde722c02c6720e7944110b9622a96cb" + integrity sha512-gmTX7KHrpnJgX/V5lxCpFhEk06RdSl3jCYCf2H9HOlypZ4JcRHNq9wiwUJocdUnhHbdD46J5D9N4YEDhVgtn9g== dependencies: - "@web3-react/types" "^8.0.20-beta.0" + "@web3-react/types" "^8.1.1-beta.0" "@web3-react/empty@8.1.2-beta.0": version "8.1.2-beta.0" @@ -5870,13 +5870,13 @@ "@safe-global/safe-apps-sdk" "^7.10.0" "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/metamask@8.0.30-beta.0": - version "8.0.30-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/metamask/-/metamask-8.0.30-beta.0.tgz#afab5d7cf556e3ec77836ff2b4753f6f301cfbeb" - integrity sha512-SzL8/RUmLHEQCdd6KNjEIHXwuYiQrKX5e1Bgipvtm8MKBRk1ty17Aj7MKWNRcl/Qt06pLSxbcEJeT9kPIrc0mg== +"@web3-react/metamask@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/metamask/-/metamask-8.1.1-beta.0.tgz#c67a6ea656b951596e7d47655e7c8da591447e87" + integrity sha512-+LNsX+cZblhXv5ayR/L7KxcyA2C6oQFRANm/KPQVAkz/vFepKcCCcULHrDWzm6PuIQ9e99UqECkerOlI42UFHw== dependencies: "@metamask/detect-provider" "^1.2.0" - "@web3-react/types" "^8.0.20-beta.0" + "@web3-react/types" "^8.1.1-beta.0" "@web3-react/metamask@8.1.2-beta.0": version "8.1.2-beta.0" @@ -5886,13 +5886,13 @@ "@metamask/detect-provider" "^1.2.0" "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/network@8.0.27-beta.0": - version "8.0.27-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/network/-/network-8.0.27-beta.0.tgz#7cb522b02efc9d0f877ac285f350810fbf322292" - integrity sha512-kLHilUpLkDejx0C5Rr57puQSEVA+BQmT58xN6D/elphcZpVHAIkbh/MCYm0XrnLmqq0uOjw+jDhEYBBn80ncHQ== +"@web3-react/network@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/network/-/network-8.1.1-beta.0.tgz#b6feb407f3d48c9793fdbe428e9e7a29c71f11ee" + integrity sha512-MnuPpxxsbrfbhKPJo9ELYkz6z4x9HDji8VCt9/KHe3p6/tjQL1sobiFZ7tzcderGY20o1VpV46rKFy1kiv0flg== dependencies: "@ethersproject/providers" "^5" - "@web3-react/types" "^8.0.20-beta.0" + "@web3-react/types" "^8.1.1-beta.0" "@web3-react/network@8.1.2-beta.0": version "8.1.2-beta.0" @@ -5902,14 +5902,14 @@ "@ethersproject/providers" "^5" "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/store@^8.0.25-beta.0": - version "8.0.25-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/store/-/store-8.0.25-beta.0.tgz#853a029a9f82d8950e306adb455ba308f908c8f4" - integrity sha512-YHrZ42EHiQ9UAJq8Y/pHsyXu6GhzbCSHaQJ9U0wCDhbPoQ9QjOj0Pwcaa/VLXljuynK/7ERP942nI1IzArt9Sg== +"@web3-react/store@^8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/store/-/store-8.1.1-beta.0.tgz#7abccfd7fe7b75d98d8ed2a9fdff931ed7e11b3a" + integrity sha512-hPS3QjbIOxDBT4zsKW7+SZ+LDFb7OpbTsdwSypuAUN8Z53biglF5Ge4U8U2jxMvnDvO3AMAOmDGslpF3j+W+Vg== dependencies: "@ethersproject/address" "^5" - "@web3-react/types" "^8.0.20-beta.0" - zustand "^4.0.0-rc.0" + "@web3-react/types" "^8.1.1-beta.0" + zustand "4.3.3" "@web3-react/store@^8.1.2-beta.0": version "8.1.2-beta.0" @@ -5920,12 +5920,12 @@ "@web3-react/types" "^8.1.2-beta.0" zustand "^4.3.5" -"@web3-react/types@8.0.20-beta.0", "@web3-react/types@^8.0.20-beta.0": - version "8.0.20-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/types/-/types-8.0.20-beta.0.tgz#6b4509bef8c5c7eb866e49295880c865c20fb565" - integrity sha512-qOZYMyUmsm3Um6t6Pg3OgnE86ufhWZpB5/VxsooB8cdpXc/C/f8KMyYSeM63GoKSMScOKwfqV6yODFL7g/Qc8g== +"@web3-react/types@8.1.1-beta.0", "@web3-react/types@^8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/types/-/types-8.1.1-beta.0.tgz#fe1b7bf256053cd6dfebb005cf689aacf04a29e4" + integrity sha512-H9iI8fmaytuNRXdk9+60nnhu3wyPJs6xa836ay+x+pJfqTM9EbJJUsTsNWSBEDevGGUIaE97yKD3izOcvfqnFg== dependencies: - zustand "^4.0.0-rc.0" + zustand "4.3.3" "@web3-react/types@8.1.2-beta.0", "@web3-react/types@^8.1.2-beta.0": version "8.1.2-beta.0" @@ -5934,13 +5934,13 @@ dependencies: zustand "^4.3.5" -"@web3-react/url@8.0.25-beta.0": - version "8.0.25-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/url/-/url-8.0.25-beta.0.tgz#68e464d2e78b89496e50e9e4a28e91281c4d53d6" - integrity sha512-cjFfAFjsWF5vqJ7TG79HT72jNNWlcS9bqbNK2jvu25zej62zMpPvy4iyYiV7zy2SLbAQTdsgvIMYAdxRbnzlWg== +"@web3-react/url@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/url/-/url-8.1.1-beta.0.tgz#da20ac2c4678b96b55197748718945db5da540e3" + integrity sha512-yRM9vruY5ksqPkvNYD+G+wJe0floRytlQ+K9pVi0XP/jWkE/P4vjW7D7ZGiGsh03fiG895tYqAeqPgVHyMpsag== dependencies: "@ethersproject/providers" "^5" - "@web3-react/types" "^8.0.20-beta.0" + "@web3-react/types" "^8.1.1-beta.0" "@web3-react/url@8.1.2-beta.0": version "8.1.2-beta.0" @@ -5950,12 +5950,13 @@ "@ethersproject/providers" "^5" "@web3-react/types" "^8.1.2-beta.0" -"@web3-react/walletconnect@8.0.37-beta.0": - version "8.0.37-beta.0" - resolved "https://registry.yarnpkg.com/@web3-react/walletconnect/-/walletconnect-8.0.37-beta.0.tgz#d375dc75f34e9bb225d26a88b16aa2a001b4e3bc" - integrity sha512-BW8tKE0dlFWSLBC/AWKULZbS1axToN7kMREKVY3YK1uj8bMRsoWcOQPceQl21WuEyVXax2V8My8SJgWuxcumvw== +"@web3-react/walletconnect@8.1.1-beta.0": + version "8.1.1-beta.0" + resolved "https://registry.yarnpkg.com/@web3-react/walletconnect/-/walletconnect-8.1.1-beta.0.tgz#6c699e8634bdc66dae7c8b982ba5553bbf86c1c5" + integrity sha512-3amB2uFq0Ixxv+SFr5yuR6f0uqpR+jwIKKaHaNOqfeYLPU24pvRPrudWeVrZGIMoIo3rTeN1UMT7UjZsDQgXUQ== dependencies: - "@web3-react/types" "^8.0.20-beta.0" + "@walletconnect/ethereum-provider" "^1.7.8" + "@web3-react/types" "^8.1.1-beta.0" eventemitter3 "^4.0.7" "@web3-react/walletconnect@8.1.2-beta.0": @@ -20334,7 +20335,14 @@ zen-observable@0.8.15: resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15" integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== -zustand@^4.0.0-rc.0, zustand@^4.3.5, zustand@^4.3.6: +zustand@4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.3.3.tgz#c9113499074dde2d6d99c1b5f591e9329572c224" + integrity sha512-x2jXq8S0kfLGNwGh87nhRfEc2eZy37tSatpSoSIN+O6HIaBhgQHSONV/F9VNrNcBcKQu/E80K1DeHDYQC/zCrQ== + dependencies: + use-sync-external-store "1.2.0" + +zustand@^4.3.5, zustand@^4.3.6: version "4.3.6" resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.3.6.tgz#ce7804eb75361af0461a2d0536b65461ec5de86f" integrity sha512-6J5zDxjxLE+yukC2XZWf/IyWVKnXT9b9HUv09VJ/bwGCpKNcaTqp7Ws28Xr8jnbvnZcdRaidztAPsXFBIqufiw==