Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick ab37660 (PR ##27543) to V12.4.0 #27577

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export default class PreferencesController {
}
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
/**
* Setter for the `watchEthereumAccountEnabled` property.
*
Expand All @@ -302,6 +303,7 @@ export default class PreferencesController {
watchEthereumAccountEnabled,
});
}
///: END:ONLY_INCLUDE_IF

/**
* Setter for the `bitcoinSupportEnabled` property.
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/lib/snap-keyring/account-watcher-snap.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// BEGIN:ONLY_INCLUDE_IF(build-flask)
import { SnapId } from '@metamask/snaps-sdk';
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';

Expand All @@ -6,3 +7,4 @@ export const ACCOUNT_WATCHER_SNAP_ID: SnapId =

export const ACCOUNT_WATCHER_NAME: string =
AccountWatcherSnap.manifest.proposedName;
// END:ONLY_INCLUDE_IF
2 changes: 2 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3155,10 +3155,12 @@ export default class MetamaskController extends EventEmitter {
preferencesController,
),
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
setWatchEthereumAccountEnabled:
preferencesController.setWatchEthereumAccountEnabled.bind(
preferencesController,
),
///: END:ONLY_INCLUDE_IF
setBitcoinSupportEnabled:
preferencesController.setBitcoinSupportEnabled.bind(
preferencesController,
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/snaps/preinstalled-snaps.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { PreinstalledSnap } from '@metamask/snaps-controllers';
import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json';
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
import BitcoinWalletSnap from '@metamask/bitcoin-wallet-snap/dist/preinstalled-snap.json';
///: END:ONLY_INCLUDE_IF

// The casts here are less than ideal but we expect the SnapController to validate the inputs.
const PREINSTALLED_SNAPS = Object.freeze<PreinstalledSnap[]>([
MessageSigningSnap as PreinstalledSnap,
AccountWatcherSnap as PreinstalledSnap,
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
AccountWatcherSnap as PreinstalledSnap,
BitcoinWalletSnap as unknown as PreinstalledSnap,
///: END:ONLY_INCLUDE_IF
]);
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,9 @@ export enum MetaMetricsEventName {
WalletSetupCanceled = 'Wallet Setup Canceled',
WalletSetupFailed = 'Wallet Setup Failed',
WalletCreated = 'Wallet Created',
// BEGIN:ONLY_INCLUDE_IF(build-flask)
WatchEthereumAccountsToggled = 'Watch Ethereum Accounts Toggled',
// END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
DeeplinkClicked = 'Deeplink Clicked',
ConnectCustodialAccountClicked = 'Connect Custodial Account Clicked',
Expand Down
47 changes: 26 additions & 21 deletions ui/components/multichain/account-list-menu/account-list-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ import {
getIsAddSnapAccountEnabled,
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
getIsWatchEthereumAccountEnabled,
getIsBitcoinSupportEnabled,
getIsBitcoinTestnetSupportEnabled,
///: END:ONLY_INCLUDE_IF
getMetaMaskAccountsOrdered,
getOriginOfCurrentTab,
getSelectedInternalAccount,
getUpdatedAndSortedAccounts,
getIsWatchEthereumAccountEnabled,
} from '../../../selectors';
import { setSelectedAccount } from '../../../store/actions';
import {
Expand All @@ -82,6 +82,10 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
import { getAccountLabel } from '../../../helpers/utils/accounts';
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
import {
ACCOUNT_WATCHER_NAME,
ACCOUNT_WATCHER_SNAP_ID,
} from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap';
import {
hasCreatedBtcMainnetAccount,
hasCreatedBtcTestnetAccount,
Expand All @@ -93,10 +97,6 @@ import {
AccountConnections,
MergedInternalAccount,
} from '../../../selectors/selectors.types';
import {
ACCOUNT_WATCHER_NAME,
ACCOUNT_WATCHER_SNAP_ID,
} from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap';
import { HiddenAccountList } from './hidden-account-list';

const ACTION_MODES = {
Expand All @@ -106,9 +106,9 @@ const ACTION_MODES = {
MENU: 'menu',
// Displays the add account form controls
ADD: 'add',
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
// Displays the add account form controls (for watch-only account)
ADD_WATCH_ONLY: 'add-watch-only',
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
// Displays the add account form controls (for bitcoin account)
ADD_BITCOIN: 'add-bitcoin',
// Same but for testnet
Expand All @@ -132,9 +132,9 @@ export const getActionTitle = (
switch (actionMode) {
case ACTION_MODES.ADD:
case ACTION_MODES.MENU:
case ACTION_MODES.ADD_WATCH_ONLY:
return t('addAccount');
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
case ACTION_MODES.ADD_WATCH_ONLY:
case ACTION_MODES.ADD_BITCOIN:
return t('addAccount');
case ACTION_MODES.ADD_BITCOIN_TESTNET:
Expand Down Expand Up @@ -225,6 +225,7 @@ export const AccountListMenu = ({
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled);
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
const isAddWatchEthereumAccountEnabled = useSelector(
getIsWatchEthereumAccountEnabled,
);
Expand All @@ -242,7 +243,7 @@ export const AccountListMenu = ({
onClose();
history.push(`/snaps/view/${encodeURIComponent(ACCOUNT_WATCHER_SNAP_ID)}`);
}, [trackEvent, onClose, history]);
///: BEGIN:ONLY_INCLUDE_IF(build-flask)

const bitcoinSupportEnabled = useSelector(getIsBitcoinSupportEnabled);
const bitcoinTestnetSupportEnabled = useSelector(
getIsBitcoinTestnetSupportEnabled,
Expand Down Expand Up @@ -544,19 +545,23 @@ export const AccountListMenu = ({
</Box>
///: END:ONLY_INCLUDE_IF
}
{isAddWatchEthereumAccountEnabled && (
<Box marginTop={4}>
<ButtonLink
disabled={!isAddWatchEthereumAccountEnabled}
size={ButtonLinkSize.Sm}
startIconName={IconName.Eye}
onClick={handleAddWatchAccount}
data-testid="multichain-account-menu-popover-add-watch-only-account"
>
{t('addEthereumWatchOnlyAccount')}
</ButtonLink>
</Box>
)}
{
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
isAddWatchEthereumAccountEnabled && (
<Box marginTop={4}>
<ButtonLink
disabled={!isAddWatchEthereumAccountEnabled}
size={ButtonLinkSize.Sm}
startIconName={IconName.Eye}
onClick={handleAddWatchAccount}
data-testid="multichain-account-menu-popover-add-watch-only-account"
>
{t('addEthereumWatchOnlyAccount')}
</ButtonLink>
</Box>
)
///: END:ONLY_INCLUDE_IF
}
</Box>
) : null}
{actionMode === ACTION_MODES.LIST ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
});
}

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
renderWatchAccountToggle() {
const { t, trackEvent } = this.context;
const { watchAccountEnabled, setWatchAccountEnabled } = this.props;
Expand Down Expand Up @@ -297,7 +298,6 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
});
}

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
// We're only setting the code fences here since
// we should remove it for the feature release
renderBitcoinSupport() {
Expand Down Expand Up @@ -385,7 +385,11 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
this.renderKeyringSnapsToggle()
///: END:ONLY_INCLUDE_IF
}
{this.renderWatchAccountToggle()}
{
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
this.renderWatchAccountToggle()
///: END:ONLY_INCLUDE_IF
}
{
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
// We're only setting the code fences here since
Expand Down
Loading