diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a5c628f9..8a666b0d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Current Develop Branch +## 8.1.11 Thu Jan 07 2021 +- [#10155](https://github.com/MetaMask/metamask-extension/pull/10155): Disable swaps when the current network's chainId does not match the mainnet chain ID, instead of disabling based on network ID + ## 8.1.10 Fri Dec 18 2020 - [#10084](https://github.com/MetaMask/metamask-extension/pull/10084): Set last provider when switching to a customRPC - [#10096](https://github.com/MetaMask/metamask-extension/pull/10096): Update `@metamask/controllers` to v5.1.0 diff --git a/app/manifest/_base.json b/app/manifest/_base.json index 2a8ede39c..90e90df4c 100644 --- a/app/manifest/_base.json +++ b/app/manifest/_base.json @@ -78,6 +78,6 @@ "notifications" ], "short_name": "__MSG_appName__", - "version": "8.1.10", + "version": "8.1.11", "web_accessible_resources": ["inpage.js", "phishing.html"] } diff --git a/package.json b/package.json index f2e806440..210b1c8bf 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "3box/ipfs/ipld-zcash/zcash-bitcore-lib/elliptic": "^6.5.3", "3box/**/libp2p-crypto/node-forge": "^0.10.0", "3box/**/libp2p-keychain/node-forge": "^0.10.0", - "browserify-derequire/derequire": "^2.1.1" + "browserify-derequire/derequire": "^2.1.1", + "analytics-node/axios": "^0.21.1" }, "dependencies": { "3box": "^1.10.2", diff --git a/ui/app/components/app/wallet-overview/eth-overview.js b/ui/app/components/app/wallet-overview/eth-overview.js index b707e1924..4a550fcef 100644 --- a/ui/app/components/app/wallet-overview/eth-overview.js +++ b/ui/app/components/app/wallet-overview/eth-overview.js @@ -23,7 +23,7 @@ import { isBalanceCached, getSelectedAccount, getShouldShowFiat, - getCurrentNetworkId, + getCurrentChainId, getCurrentKeyring, } from '../../../selectors/selectors' import SwapIcon from '../../ui/icon/swap-icon.component' @@ -34,7 +34,7 @@ import { setSwapsFromToken, } from '../../../ducks/swaps/swaps' import IconButton from '../../ui/icon-button' -import { MAINNET_NETWORK_ID } from '../../../../../app/scripts/controllers/network/enums' +import { MAINNET_CHAIN_ID } from '../../../../../app/scripts/controllers/network/enums' import WalletOverview from './wallet-overview' const EthOverview = ({ className }) => { @@ -61,7 +61,7 @@ const EthOverview = ({ className }) => { const showFiat = useSelector(getShouldShowFiat) const selectedAccount = useSelector(getSelectedAccount) const { balance } = selectedAccount - const networkId = useSelector(getCurrentNetworkId) + const chainId = useSelector(getCurrentChainId) const enteredSwapsEvent = useNewMetricEvent({ event: 'Swaps Opened', properties: { source: 'Main View', active_currency: 'ETH' }, @@ -134,10 +134,10 @@ const EthOverview = ({ className }) => { {swapsEnabled ? ( { - if (networkId === MAINNET_NETWORK_ID) { + if (chainId === MAINNET_CHAIN_ID) { enteredSwapsEvent() dispatch(setSwapsFromToken(swapsEthToken)) if (usingHardwareWallet) { @@ -152,7 +152,7 @@ const EthOverview = ({ className }) => { {contents} diff --git a/ui/app/components/app/wallet-overview/token-overview.js b/ui/app/components/app/wallet-overview/token-overview.js index fe7f29087..3a2cfab90 100644 --- a/ui/app/components/app/wallet-overview/token-overview.js +++ b/ui/app/components/app/wallet-overview/token-overview.js @@ -25,9 +25,9 @@ import { import { getAssetImages, getCurrentKeyring, - getCurrentNetworkId, + getCurrentChainId, } from '../../../selectors/selectors' -import { MAINNET_NETWORK_ID } from '../../../../../app/scripts/controllers/network/enums' +import { MAINNET_CHAIN_ID } from '../../../../../app/scripts/controllers/network/enums' import SwapIcon from '../../ui/icon/swap-icon.component' import SendIcon from '../../ui/icon/overview-send-icon.component' @@ -58,7 +58,7 @@ const TokenOverview = ({ className, token }) => { balanceToRender, token.symbol, ) - const networkId = useSelector(getCurrentNetworkId) + const chainId = useSelector(getCurrentChainId) const enteredSwapsEvent = useNewMetricEvent({ event: 'Swaps Opened', properties: { source: 'Token View', active_currency: token.symbol }, @@ -100,10 +100,10 @@ const TokenOverview = ({ className, token }) => { {swapsEnabled ? ( { - if (networkId === MAINNET_NETWORK_ID) { + if (chainId === MAINNET_CHAIN_ID) { enteredSwapsEvent() dispatch( setSwapsFromToken({ @@ -125,7 +125,7 @@ const TokenOverview = ({ className, token }) => { {contents} diff --git a/ui/app/pages/swaps/index.js b/ui/app/pages/swaps/index.js index 1d340a61e..01c1f8f78 100644 --- a/ui/app/pages/swaps/index.js +++ b/ui/app/pages/swaps/index.js @@ -12,6 +12,7 @@ import { I18nContext } from '../../contexts/i18n' import { getSelectedAccount, getCurrentNetworkId, + getCurrentChainId, } from '../../selectors/selectors' import { getFromToken, @@ -47,6 +48,7 @@ import { SWAP_FAILED_ERROR, OFFLINE_FOR_MAINTENANCE, } from '../../helpers/constants/swaps' +import { MAINNET_CHAIN_ID } from '../../../../app/scripts/controllers/network/enums' import { resetBackgroundSwapsState, @@ -245,6 +247,11 @@ export default function Swap() { return () => window.removeEventListener('beforeunload', fn) }, [dispatch, isLoadingQuotesRoute]) + const chainId = useSelector(getCurrentChainId) + if (chainId !== MAINNET_CHAIN_ID) { + return + } + return (
diff --git a/yarn.lock b/yarn.lock index 56802930e..d15a7f87d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4572,12 +4572,12 @@ axios-retry@^3.0.2: dependencies: is-retry-allowed "^1.1.0" -axios@^0.19.2: - version "0.19.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" - integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== +axios@^0.19.2, axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== dependencies: - follow-redirects "1.5.10" + follow-redirects "^1.10.0" babel-code-frame@^6.16.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" @@ -7954,7 +7954,7 @@ debug@2, debug@2.6.9, debug@^2.1.1, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, de dependencies: ms "2.0.0" -debug@3.1.0, debug@=3.1.0, debug@~3.1.0: +debug@3.1.0, debug@~3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -11378,12 +11378,10 @@ fnv1a@^1.0.1: resolved "https://registry.yarnpkg.com/fnv1a/-/fnv1a-1.0.1.tgz#915e2d6d023c43d5224ad9f6d2a3c4156f5712f5" integrity sha1-kV4tbQI8Q9UiStn20qPEFW9XEvU= -follow-redirects@1.5.10: - version "1.5.10" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" - integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== - dependencies: - debug "=3.1.0" +follow-redirects@^1.10.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" + integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== for-each@^0.3.3, for-each@~0.3.3: version "0.3.3"