From cc515c4c08c4243bc0ce95b1cdea08e1f7f1266c Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Fri, 21 Mar 2025 09:59:31 +0000 Subject: [PATCH 1/4] chore: disable buttons for solana --- ui/components/app/wallet-overview/coin-buttons.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index df8e42fdf0d6..90095cfecda0 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -52,6 +52,7 @@ import { getMemoizedUnapprovedTemplatedConfirmations, ///: END:ONLY_INCLUDE_IF getNetworkConfigurationIdByChainId, + isSolanaAccount, } from '../../../selectors'; import Tooltip from '../../ui/tooltip'; ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) @@ -170,6 +171,9 @@ const CoinButtons = ({ const isExternalServicesEnabled = useSelector(getUseExternalServices); + const isSolanaAccountWithoutExternalServices = + !isExternalServicesEnabled && isSolanaAccount(account); + const buttonTooltips = { buyButton: [ ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) @@ -463,7 +467,11 @@ const CoinButtons = ({ } - disabled={!isSigningEnabled} + disabled={!isSigningEnabled || isSolanaAccountWithoutExternalServices} label={t('send')} onClick={handleSendOnClick} tooltipRender={(contents: React.ReactElement) => From a4375202ea180eebe799c1a29830f470489e9ed2 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 25 Mar 2025 10:16:37 +0000 Subject: [PATCH 2/4] chore: update const check --- ui/components/app/wallet-overview/coin-buttons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index 90095cfecda0..bd756df27ed2 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -468,7 +468,7 @@ const CoinButtons = ({ className={`${classPrefix}-overview__button`} iconButtonClassName={iconButtonClassName} disabled={ - !isSwapsChain || + !isBridgeChain || !isSigningEnabled || isSolanaAccountWithoutExternalServices } From d7e5487e39a4a5c628466f7e0148e288b2d213a0 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 25 Mar 2025 11:37:39 +0000 Subject: [PATCH 3/4] chore: checks for both non evm account types --- ui/components/app/wallet-overview/coin-buttons.tsx | 10 +++++----- ui/selectors/accounts.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/components/app/wallet-overview/coin-buttons.tsx b/ui/components/app/wallet-overview/coin-buttons.tsx index bd756df27ed2..63088c9f34b5 100644 --- a/ui/components/app/wallet-overview/coin-buttons.tsx +++ b/ui/components/app/wallet-overview/coin-buttons.tsx @@ -52,7 +52,7 @@ import { getMemoizedUnapprovedTemplatedConfirmations, ///: END:ONLY_INCLUDE_IF getNetworkConfigurationIdByChainId, - isSolanaAccount, + isNonEvmAccount, } from '../../../selectors'; import Tooltip from '../../ui/tooltip'; ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) @@ -171,8 +171,8 @@ const CoinButtons = ({ const isExternalServicesEnabled = useSelector(getUseExternalServices); - const isSolanaAccountWithoutExternalServices = - !isExternalServicesEnabled && isSolanaAccount(account); + const isNonEvmAccountWithoutExternalServices = + !isExternalServicesEnabled && isNonEvmAccount(account); const buttonTooltips = { buyButton: [ @@ -470,7 +470,7 @@ const CoinButtons = ({ disabled={ !isBridgeChain || !isSigningEnabled || - isSolanaAccountWithoutExternalServices + isNonEvmAccountWithoutExternalServices } data-testid={`${classPrefix}-overview-bridge`} Icon={ @@ -499,7 +499,7 @@ const CoinButtons = ({ size={IconSize.Sm} /> } - disabled={!isSigningEnabled || isSolanaAccountWithoutExternalServices} + disabled={!isSigningEnabled || isNonEvmAccountWithoutExternalServices} label={t('send')} onClick={handleSendOnClick} tooltipRender={(contents: React.ReactElement) => diff --git a/ui/selectors/accounts.ts b/ui/selectors/accounts.ts index 0c18028224a4..441beffb8458 100644 --- a/ui/selectors/accounts.ts +++ b/ui/selectors/accounts.ts @@ -27,6 +27,15 @@ export function isSolanaAccount(account: InternalAccount) { return Boolean(account && account.type === DataAccount); } +export function isNonEvmAccount(account: InternalAccount) { + const { P2wpkh } = BtcAccountType; + const { DataAccount } = SolAccountType; + + return Boolean( + account && (account.type === P2wpkh || account.type === DataAccount), + ); +} + export const getInternalAccounts = createSelector( (state: AccountsState) => Object.values(state.metamask.internalAccounts.accounts), From 0f3c201bd34b03644902694e154d74a7449fd0ca Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 25 Mar 2025 11:55:31 +0000 Subject: [PATCH 4/4] chore: test update --- .../wallet-overview/non-evm-overview.test.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/components/app/wallet-overview/non-evm-overview.test.tsx b/ui/components/app/wallet-overview/non-evm-overview.test.tsx index 38db5fd4dc57..bcc8b2e7d30c 100644 --- a/ui/components/app/wallet-overview/non-evm-overview.test.tsx +++ b/ui/components/app/wallet-overview/non-evm-overview.test.tsx @@ -86,6 +86,7 @@ const mockBuyableChainsWithBtc = [...mockBuyableChainsWithoutBtc, mockBtcChain]; const mockMetamaskStore = { ...mockState.metamask, + useExternalServices: true, accountsAssets: { [mockNonEvmAccount.id]: [MultichainNativeAssets.BITCOIN], }, @@ -418,4 +419,23 @@ describe('NonEvmOverview', () => { expect.any(Object), ); }); + + it('disables the Send and Bridge buttons if external services are disabled', () => { + const { queryByTestId } = renderWithProvider( + , + getStore({ + metamask: { + ...mockMetamaskStore, + useExternalServices: false, + }, + }), + ); + + const sendButton = queryByTestId(BTC_OVERVIEW_SEND); + const bridgeButton = queryByTestId(BTC_OVERVIEW_BRIDGE); + expect(sendButton).toBeInTheDocument(); + expect(sendButton).toBeDisabled(); + expect(bridgeButton).toBeInTheDocument(); + expect(bridgeButton).toBeDisabled(); + }); });