Skip to content

Commit 20698f5

Browse files
committed
Revert "Revert "feat: codefence Account Watcher for flask (#27543)""
This reverts commit 4e53d9a.
1 parent c94faad commit 20698f5

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
@@ -3319,10 +3319,12 @@ export default class MetamaskController extends EventEmitter {
33193319
preferencesController,
33203320
),
33213321
///: END:ONLY_INCLUDE_IF
3322+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
33223323
setWatchEthereumAccountEnabled:
33233324
preferencesController.setWatchEthereumAccountEnabled.bind(
33243325
preferencesController,
33253326
),
3327+
///: END:ONLY_INCLUDE_IF
33263328
setBitcoinSupportEnabled:
33273329
preferencesController.setBitcoinSupportEnabled.bind(
33283330
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
@@ -651,7 +651,9 @@ export enum MetaMetricsEventName {
651651
WalletSetupCanceled = 'Wallet Setup Canceled',
652652
WalletSetupFailed = 'Wallet Setup Failed',
653653
WalletCreated = 'Wallet Created',
654+
// BEGIN:ONLY_INCLUDE_IF(build-flask)
654655
WatchEthereumAccountsToggled = 'Watch Ethereum Accounts Toggled',
656+
// END:ONLY_INCLUDE_IF
655657
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
656658
DeeplinkClicked = 'Deeplink Clicked',
657659
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,
@@ -552,19 +553,23 @@ export const AccountListMenu = ({
552553
</Box>
553554
///: END:ONLY_INCLUDE_IF
554555
}
555-
{isAddWatchEthereumAccountEnabled && (
556-
<Box marginTop={4}>
557-
<ButtonLink
558-
disabled={!isAddWatchEthereumAccountEnabled}
559-
size={ButtonLinkSize.Sm}
560-
startIconName={IconName.Eye}
561-
onClick={handleAddWatchAccount}
562-
data-testid="multichain-account-menu-popover-add-watch-only-account"
563-
>
564-
{t('addEthereumWatchOnlyAccount')}
565-
</ButtonLink>
566-
</Box>
567-
)}
556+
{
557+
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
558+
isAddWatchEthereumAccountEnabled && (
559+
<Box marginTop={4}>
560+
<ButtonLink
561+
disabled={!isAddWatchEthereumAccountEnabled}
562+
size={ButtonLinkSize.Sm}
563+
startIconName={IconName.Eye}
564+
onClick={handleAddWatchAccount}
565+
data-testid="multichain-account-menu-popover-add-watch-only-account"
566+
>
567+
{t('addEthereumWatchOnlyAccount')}
568+
</ButtonLink>
569+
</Box>
570+
)
571+
///: END:ONLY_INCLUDE_IF
572+
}
568573
</Box>
569574
) : null}
570575
{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)