Skip to content

Commit 0f1fade

Browse files
fix: mms-2135 is isBridgning with the correct network (#31211)
## **Description** Dont check on the last selected EVM account to see if solana bridge is enabled [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/31211?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. selecte Sepolia network, then select solana 2. the bridge and swap button do not work ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 27ed099 commit 0f1fade

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ui/selectors/selectors.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ import { getSelectedInternalAccount, getInternalAccounts } from './accounts';
129129
import {
130130
getMultichainBalances,
131131
getMultichainNetworkProviders,
132+
getMultichainNetwork,
132133
} from './multichain';
133134
import { getRemoteFeatureFlags } from './remote-feature-flags';
134135
import { getApprovalRequestsByType } from './approvals';
@@ -1740,7 +1741,19 @@ export function getIsSwapsChain(state, overrideChainId) {
17401741
}
17411742

17421743
export function getIsBridgeChain(state, overrideChainId) {
1743-
const currentChainId = getCurrentChainId(state);
1744+
const account = getSelectedInternalAccount(state);
1745+
const { chainId: selectedMultiChainId, isEvmNetwork } = getMultichainNetwork(
1746+
state,
1747+
account,
1748+
);
1749+
1750+
let currentChainId = selectedMultiChainId;
1751+
1752+
// While we do not support the multichain network on EVM chains (ex: mainnet is epi155:1), use the old chainId
1753+
if (isEvmNetwork) {
1754+
currentChainId = getCurrentChainId(state);
1755+
}
1756+
17441757
const chainId = overrideChainId ?? currentChainId;
17451758
return ALLOWED_BRIDGE_CHAIN_IDS.includes(chainId);
17461759
}

ui/selectors/selectors.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { mockNetworkState } from '../../test/stub/networks';
1414
import { DeleteRegulationStatus } from '../../shared/constants/metametrics';
1515
import { selectSwitchedNetworkNeverShowMessage } from '../components/app/toast-master/selectors';
1616
import * as networkSelectors from '../../shared/modules/selectors/networks';
17+
import { MultichainNetworks } from '../../shared/constants/multichain/networks';
18+
1719
import * as selectors from './selectors';
1820

1921
jest.mock('../../shared/modules/selectors/networks', () => ({
@@ -1231,16 +1233,38 @@ describe('Selectors', () => {
12311233
const isOptimismSupported = selectors.getIsBridgeChain({
12321234
metamask: {
12331235
...mockNetworkState({ chainId: CHAIN_IDS.OPTIMISM }),
1236+
internalAccounts: {
1237+
selectedAccount: '0xabc',
1238+
accounts: { '0xabc': { metadata: { keyring: {} } } },
1239+
},
12341240
},
12351241
});
12361242
expect(isOptimismSupported).toBeTruthy();
12371243

12381244
const isFantomSupported = selectors.getIsBridgeChain({
12391245
metamask: {
12401246
...mockNetworkState({ chainId: CHAIN_IDS.FANTOM }),
1247+
internalAccounts: {
1248+
selectedAccount: '0xabc',
1249+
accounts: { '0xabc': { metadata: { keyring: {} } } },
1250+
},
12411251
},
12421252
});
12431253
expect(isFantomSupported).toBeFalsy();
1254+
1255+
const isSolanaSupported = selectors.getIsBridgeChain({
1256+
metamask: {
1257+
...mockNetworkState({ chainId: MultichainNetworks.SOLANA }),
1258+
internalAccounts: {
1259+
selectedAccount: '0xabc',
1260+
accounts: {
1261+
'0xabc': { metadata: { keyring: {} } },
1262+
type: 'solana',
1263+
},
1264+
},
1265+
},
1266+
});
1267+
expect(isSolanaSupported).toBeTruthy();
12441268
});
12451269

12461270
it('returns proper values for snaps privacy warning shown status', () => {

0 commit comments

Comments
 (0)