Skip to content

Commit bae0053

Browse files
committed
Revert "Revert "feat: codefence Account Watcher for flask (#27543)""
This reverts commit 7c6fc74.
1 parent 06880d7 commit bae0053

File tree

8 files changed

+46
-28
lines changed

8 files changed

+46
-28
lines changed

app/scripts/controllers/preferences-controller.ts

+4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export type PreferencesControllerState = Omit<
136136
use4ByteResolution: boolean;
137137
useCurrencyRateCheck: boolean;
138138
useRequestQueue: boolean;
139+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
139140
watchEthereumAccountEnabled: boolean;
141+
///: END:ONLY_INCLUDE_IF
140142
bitcoinSupportEnabled: boolean;
141143
bitcoinTestnetSupportEnabled: boolean;
142144
addSnapAccountEnabled?: boolean;
@@ -651,6 +653,7 @@ export class PreferencesController extends BaseController<
651653
}
652654
///: END:ONLY_INCLUDE_IF
653655

656+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
654657
/**
655658
* Setter for the `watchEthereumAccountEnabled` property.
656659
*
@@ -662,6 +665,7 @@ export class PreferencesController extends BaseController<
662665
state.watchEthereumAccountEnabled = watchEthereumAccountEnabled;
663666
});
664667
}
668+
///: END:ONLY_INCLUDE_IF
665669

666670
/**
667671
* Setter for the `bitcoinSupportEnabled` property.

app/scripts/lib/snap-keyring/account-watcher-snap.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// BEGIN:ONLY_INCLUDE_IF(build-flask)
12
import { SnapId } from '@metamask/snaps-sdk';
23
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
34

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

78
export const ACCOUNT_WATCHER_NAME: string =
89
AccountWatcherSnap.manifest.proposedName;
10+
// END:ONLY_INCLUDE_IF

app/scripts/metamask-controller.js

+2
Original file line numberDiff line numberDiff line change
@@ -3313,10 +3313,12 @@ export default class MetamaskController extends EventEmitter {
33133313
preferencesController,
33143314
),
33153315
///: END:ONLY_INCLUDE_IF
3316+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
33163317
setWatchEthereumAccountEnabled:
33173318
preferencesController.setWatchEthereumAccountEnabled.bind(
33183319
preferencesController,
33193320
),
3321+
///: END:ONLY_INCLUDE_IF
33203322
setBitcoinSupportEnabled:
33213323
preferencesController.setBitcoinSupportEnabled.bind(
33223324
preferencesController,

app/scripts/snaps/preinstalled-snaps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { PreinstalledSnap } from '@metamask/snaps-controllers';
22
import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json';
33
import EnsResolverSnap from '@metamask/ens-resolver-snap/dist/preinstalled-snap.json';
4-
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
54
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
5+
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
66
import BitcoinWalletSnap from '@metamask/bitcoin-wallet-snap/dist/preinstalled-snap.json';
77
import PreinstalledExampleSnap from '@metamask/preinstalled-example-snap/dist/preinstalled-snap.json';
88
///: END:ONLY_INCLUDE_IF
@@ -11,8 +11,8 @@ import PreinstalledExampleSnap from '@metamask/preinstalled-example-snap/dist/pr
1111
const PREINSTALLED_SNAPS = Object.freeze<PreinstalledSnap[]>([
1212
MessageSigningSnap as unknown as PreinstalledSnap,
1313
EnsResolverSnap as PreinstalledSnap,
14-
AccountWatcherSnap as PreinstalledSnap,
1514
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
15+
AccountWatcherSnap as PreinstalledSnap,
1616
BitcoinWalletSnap as unknown as PreinstalledSnap,
1717
PreinstalledExampleSnap as unknown as PreinstalledSnap,
1818
///: END:ONLY_INCLUDE_IF

shared/constants/metametrics.ts

+2
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,9 @@ export enum MetaMetricsEventName {
734734
WalletSetupCanceled = 'Wallet Setup Canceled',
735735
WalletSetupFailed = 'Wallet Setup Failed',
736736
WalletCreated = 'Wallet Created',
737+
// BEGIN:ONLY_INCLUDE_IF(build-flask)
737738
WatchEthereumAccountsToggled = 'Watch Ethereum Accounts Toggled',
739+
// END:ONLY_INCLUDE_IF
738740
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
739741
DeeplinkClicked = 'Deeplink Clicked',
740742
ConnectCustodialAccountClicked = 'Connect Custodial Account Clicked',

ui/components/multichain/account-list-menu/account-list-menu.tsx

+28-23
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ import {
6060
getIsAddSnapAccountEnabled,
6161
///: END:ONLY_INCLUDE_IF
6262
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
63+
getIsWatchEthereumAccountEnabled,
6364
getIsBitcoinSupportEnabled,
6465
getIsBitcoinTestnetSupportEnabled,
6566
///: END:ONLY_INCLUDE_IF
6667
getMetaMaskAccountsOrdered,
6768
getOriginOfCurrentTab,
6869
getSelectedInternalAccount,
6970
getUpdatedAndSortedAccounts,
70-
getIsWatchEthereumAccountEnabled,
7171
} from '../../../selectors';
7272
import { setSelectedAccount } from '../../../store/actions';
7373
import {
@@ -87,6 +87,12 @@ import { getEnvironmentType } from '../../../../app/scripts/lib/util';
8787
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
8888
import { getAccountLabel } from '../../../helpers/utils/accounts';
8989
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
90+
import {
91+
ACCOUNT_WATCHER_NAME,
92+
ACCOUNT_WATCHER_SNAP_ID,
93+
// TODO: Remove restricted import
94+
// eslint-disable-next-line import/no-restricted-paths
95+
} from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap';
9096
import {
9197
hasCreatedBtcMainnetAccount,
9298
hasCreatedBtcTestnetAccount,
@@ -100,12 +106,6 @@ import {
100106
MergedInternalAccount,
101107
} from '../../../selectors/selectors.types';
102108
import { trace, endTrace, TraceName } from '../../../../shared/lib/trace';
103-
import {
104-
ACCOUNT_WATCHER_NAME,
105-
ACCOUNT_WATCHER_SNAP_ID,
106-
// TODO: Remove restricted import
107-
// eslint-disable-next-line import/no-restricted-paths
108-
} from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap';
109109
import { HiddenAccountList } from './hidden-account-list';
110110

111111
const ACTION_MODES = {
@@ -115,9 +115,9 @@ const ACTION_MODES = {
115115
MENU: 'menu',
116116
// Displays the add account form controls
117117
ADD: 'add',
118+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
118119
// Displays the add account form controls (for watch-only account)
119120
ADD_WATCH_ONLY: 'add-watch-only',
120-
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
121121
// Displays the add account form controls (for bitcoin account)
122122
ADD_BITCOIN: 'add-bitcoin',
123123
// Same but for testnet
@@ -141,9 +141,9 @@ export const getActionTitle = (
141141
switch (actionMode) {
142142
case ACTION_MODES.ADD:
143143
case ACTION_MODES.MENU:
144-
case ACTION_MODES.ADD_WATCH_ONLY:
145144
return t('addAccount');
146145
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
146+
case ACTION_MODES.ADD_WATCH_ONLY:
147147
case ACTION_MODES.ADD_BITCOIN:
148148
return t('addAccount');
149149
case ACTION_MODES.ADD_BITCOIN_TESTNET:
@@ -237,6 +237,7 @@ export const AccountListMenu = ({
237237
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
238238
const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled);
239239
///: END:ONLY_INCLUDE_IF
240+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
240241
const isAddWatchEthereumAccountEnabled = useSelector(
241242
getIsWatchEthereumAccountEnabled,
242243
);
@@ -254,7 +255,7 @@ export const AccountListMenu = ({
254255
onClose();
255256
history.push(`/snaps/view/${encodeURIComponent(ACCOUNT_WATCHER_SNAP_ID)}`);
256257
}, [trackEvent, onClose, history]);
257-
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
258+
258259
const bitcoinSupportEnabled = useSelector(getIsBitcoinSupportEnabled);
259260
const bitcoinTestnetSupportEnabled = useSelector(
260261
getIsBitcoinTestnetSupportEnabled,
@@ -554,19 +555,23 @@ export const AccountListMenu = ({
554555
</Box>
555556
///: END:ONLY_INCLUDE_IF
556557
}
557-
{isAddWatchEthereumAccountEnabled && (
558-
<Box marginTop={4}>
559-
<ButtonLink
560-
disabled={!isAddWatchEthereumAccountEnabled}
561-
size={ButtonLinkSize.Sm}
562-
startIconName={IconName.Eye}
563-
onClick={handleAddWatchAccount}
564-
data-testid="multichain-account-menu-popover-add-watch-only-account"
565-
>
566-
{t('addEthereumWatchOnlyAccount')}
567-
</ButtonLink>
568-
</Box>
569-
)}
558+
{
559+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
560+
isAddWatchEthereumAccountEnabled && (
561+
<Box marginTop={4}>
562+
<ButtonLink
563+
disabled={!isAddWatchEthereumAccountEnabled}
564+
size={ButtonLinkSize.Sm}
565+
startIconName={IconName.Eye}
566+
onClick={handleAddWatchAccount}
567+
data-testid="multichain-account-menu-popover-add-watch-only-account"
568+
>
569+
{t('addEthereumWatchOnlyAccount')}
570+
</ButtonLink>
571+
</Box>
572+
)
573+
///: END:ONLY_INCLUDE_IF
574+
}
570575
</Box>
571576
) : null}
572577
{actionMode === ACTION_MODES.LIST ? (

ui/pages/settings/experimental-tab/experimental-tab.component.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
263263
});
264264
}
265265

266+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
266267
renderWatchAccountToggle() {
267268
const { t, trackEvent } = this.context;
268269
const { watchAccountEnabled, setWatchAccountEnabled } = this.props;
@@ -297,7 +298,6 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
297298
});
298299
}
299300

300-
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
301301
// We're only setting the code fences here since
302302
// we should remove it for the feature release
303303
renderBitcoinSupport() {
@@ -385,12 +385,15 @@ export default class ExperimentalTab extends PureComponent<ExperimentalTabProps>
385385
this.renderKeyringSnapsToggle()
386386
///: END:ONLY_INCLUDE_IF
387387
}
388-
{this.renderWatchAccountToggle()}
388+
{
389+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
390+
this.renderWatchAccountToggle()
391+
///: END:ONLY_INCLUDE_IF
392+
}
389393
{
390394
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
391395
// We're only setting the code fences here since
392396
// we should remove it for the feature release
393-
394397
/* Section: Bitcoin Accounts */
395398
this.renderBitcoinSupport()
396399
///: END:ONLY_INCLUDE_IF

0 commit comments

Comments
 (0)