Skip to content

Commit 230e316

Browse files
authored
chore: disable buttons for non-evm account (#31193)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** When basic functionality is off and the account is non-evm we want to also disable the Send and Bridge buttons. ![Screenshot 2025-03-21 at 10 07 23](https://github.com/user-attachments/assets/61ee87d3-6e21-4ba4-83b3-689e936d7062) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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 1cf1cd4 commit 230e316

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

ui/components/app/wallet-overview/coin-buttons.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
getMemoizedUnapprovedTemplatedConfirmations,
5353
///: END:ONLY_INCLUDE_IF
5454
getNetworkConfigurationIdByChainId,
55+
isNonEvmAccount,
5556
} from '../../../selectors';
5657
import Tooltip from '../../ui/tooltip';
5758
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
@@ -170,6 +171,9 @@ const CoinButtons = ({
170171

171172
const isExternalServicesEnabled = useSelector(getUseExternalServices);
172173

174+
const isNonEvmAccountWithoutExternalServices =
175+
!isExternalServicesEnabled && isNonEvmAccount(account);
176+
173177
const buttonTooltips = {
174178
buyButton: [
175179
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
@@ -463,7 +467,11 @@ const CoinButtons = ({
463467
<IconButton
464468
className={`${classPrefix}-overview__button`}
465469
iconButtonClassName={iconButtonClassName}
466-
disabled={!isBridgeChain || !isSigningEnabled}
470+
disabled={
471+
!isBridgeChain ||
472+
!isSigningEnabled ||
473+
isNonEvmAccountWithoutExternalServices
474+
}
467475
data-testid={`${classPrefix}-overview-bridge`}
468476
Icon={
469477
<Icon
@@ -491,7 +499,7 @@ const CoinButtons = ({
491499
size={IconSize.Sm}
492500
/>
493501
}
494-
disabled={!isSigningEnabled}
502+
disabled={!isSigningEnabled || isNonEvmAccountWithoutExternalServices}
495503
label={t('send')}
496504
onClick={handleSendOnClick}
497505
tooltipRender={(contents: React.ReactElement) =>

ui/components/app/wallet-overview/non-evm-overview.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const mockBuyableChainsWithBtc = [...mockBuyableChainsWithoutBtc, mockBtcChain];
8686

8787
const mockMetamaskStore = {
8888
...mockState.metamask,
89+
useExternalServices: true,
8990
accountsAssets: {
9091
[mockNonEvmAccount.id]: [MultichainNativeAssets.BITCOIN],
9192
},
@@ -418,4 +419,23 @@ describe('NonEvmOverview', () => {
418419
expect.any(Object),
419420
);
420421
});
422+
423+
it('disables the Send and Bridge buttons if external services are disabled', () => {
424+
const { queryByTestId } = renderWithProvider(
425+
<NonEvmOverview />,
426+
getStore({
427+
metamask: {
428+
...mockMetamaskStore,
429+
useExternalServices: false,
430+
},
431+
}),
432+
);
433+
434+
const sendButton = queryByTestId(BTC_OVERVIEW_SEND);
435+
const bridgeButton = queryByTestId(BTC_OVERVIEW_BRIDGE);
436+
expect(sendButton).toBeInTheDocument();
437+
expect(sendButton).toBeDisabled();
438+
expect(bridgeButton).toBeInTheDocument();
439+
expect(bridgeButton).toBeDisabled();
440+
});
421441
});

ui/selectors/accounts.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ export function isSolanaAccount(account: InternalAccount) {
2727
return Boolean(account && account.type === DataAccount);
2828
}
2929

30+
export function isNonEvmAccount(account: InternalAccount) {
31+
const { P2wpkh } = BtcAccountType;
32+
const { DataAccount } = SolAccountType;
33+
34+
return Boolean(
35+
account && (account.type === P2wpkh || account.type === DataAccount),
36+
);
37+
}
38+
3039
export const getInternalAccounts = createSelector(
3140
(state: AccountsState) =>
3241
Object.values(state.metamask.internalAccounts.accounts),

0 commit comments

Comments
 (0)