Skip to content
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: 0 additions & 2 deletions app/scripts/constants/sentry-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,8 @@ export const SENTRY_UI_STATE: SentryUiStateMask = {
isInitialized: true,
useSafeChainsListValidation: true,
watchEthereumAccountEnabled: false,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
addSnapAccountEnabled: false,
snapsAddSnapAccountModalDismissed: false,
///: END:ONLY_INCLUDE_IF
newPrivacyPolicyToastClickedOrClosed: false,
newPrivacyPolicyToastShownDate: false,
},
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/constants/snaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,19 @@ export const PREINSTALLED_SNAPS_URLS = [
import.meta.url,
),
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
new URL(
'@metamask/bitcoin-wallet-snap/dist/preinstalled-snap.json',
// @ts-expect-error TS1470: 'import.meta' is not allowed in CommonJS
import.meta.url,
),
///: END:ONLY_INCLUDE_IF
new URL(
'@metamask/solana-wallet-snap/dist/preinstalled-snap.json',
// @ts-expect-error TS1470: 'import.meta' is not allowed in CommonJS
import.meta.url,
),
///: BEGIN:ONLY_INCLUDE_IF(tron)
new URL(
'@metamask/tron-wallet-snap/dist/preinstalled-snap.json',
// @ts-expect-error TS1470: 'import.meta' is not allowed in CommonJS
import.meta.url,
),
///: END:ONLY_INCLUDE_IF
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import {
import { NetworkState } from '@metamask/network-controller';
import { MultichainNetworkControllerState } from '@metamask/multichain-network-controller';
import {
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
BtcScope,
///: END:ONLY_INCLUDE_IF
SolAccountType,
SolScope,
///: BEGIN:ONLY_INCLUDE_IF(tron)
TrxScope,
///: END:ONLY_INCLUDE_IF
} from '@metamask/keyring-api';
import {
CaipChainId,
Expand Down Expand Up @@ -119,14 +115,8 @@ const generateDefaultNetworkEnablementControllerState = (
}

const enabledMultichainNetworks: string[] = [SolScope.Mainnet];

///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
enabledMultichainNetworks.push(BtcScope.Mainnet);
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
enabledMultichainNetworks.push(TrxScope.Mainnet);
///: END:ONLY_INCLUDE_IF

return {
enabledNetworkMap: {
Expand Down Expand Up @@ -193,24 +183,18 @@ export const NetworkEnablementControllerInit: ControllerInitFunction<
scopes: [SolScope.Mainnet],
},
);

///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
const btcAccounts = initMessenger.call(
'AccountTreeController:getAccountsFromSelectedAccountGroup',
{
scopes: [BtcScope.Mainnet],
},
);
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
const trxAccounts = initMessenger.call(
'AccountTreeController:getAccountsFromSelectedAccountGroup',
{
scopes: [TrxScope.Mainnet],
},
);
///: END:ONLY_INCLUDE_IF

const allEnabledNetworks = {};

Expand All @@ -225,19 +209,12 @@ export const NetworkEnablementControllerInit: ControllerInitFunction<
if (chainId === SolScope.Mainnet && solAccounts.length === 0) {
shouldEnableMainnetNetworks = true;
}

///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
if (chainId === BtcScope.Mainnet && btcAccounts.length === 0) {
shouldEnableMainnetNetworks = true;
}
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
if (chainId === TrxScope.Mainnet && trxAccounts.length === 0) {
shouldEnableMainnetNetworks = true;
}
///: END:ONLY_INCLUDE_IF

if (shouldEnableMainnetNetworks) {
controller.enableNetwork('0x1');
}
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/controller-init/keyring-controller-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ export const KeyringControllerInit: ControllerInitFunction<
);
}

///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
const snapKeyringBuilder = getController('SnapKeyringBuilder');

// @ts-expect-error: `addAccounts` is missing in `SnapKeyring` type.
additionalKeyrings.push(snapKeyringBuilder);
///: END:ONLY_INCLUDE_IF

const controller = new KeyringController({
state: persistedState.KeyringController,
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/controller-init/messengers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import {
import {
getCronjobControllerMessenger,
getExecutionServiceMessenger,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
getMultichainRouterMessenger,
///: END:ONLY_INCLUDE_IF
getRateLimitControllerInitMessenger,
getRateLimitControllerMessenger,
getSnapControllerInitMessenger,
Expand Down Expand Up @@ -590,12 +588,10 @@ export const CONTROLLER_MESSENGERS = {
getMessenger: getMultichainNetworkControllerMessenger,
getInitMessenger: noop,
},
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
MultichainRouter: {
getMessenger: getMultichainRouterMessenger,
getInitMessenger: noop,
},
///: END:ONLY_INCLUDE_IF
NameController: {
getMessenger: getNameControllerMessenger,
getInitMessenger: getNameControllerInitMessenger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@ import {
MultichainAccountService,
AccountProviderWrapper,
SOL_ACCOUNT_PROVIDER_NAME,
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
BtcAccountProvider,
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(tron)
TrxAccountProvider,
///: END:ONLY_INCLUDE_IF
} from '@metamask/multichain-account-service';
import { ControllerInitFunction } from '../types';
import {
MultichainAccountServiceMessenger,
MultichainAccountServiceInitMessenger,
} from '../messengers/accounts';
import { previousValueComparator } from '../../lib/util';
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
import { isMultichainFeatureEnabled } from '../../../../shared/lib/multichain-feature-flags';
///: END:ONLY_INCLUDE_IF
import { trace } from '../../../../shared/lib/trace';

/**
Expand Down Expand Up @@ -49,30 +43,19 @@ export const MultichainAccountServiceInit: ControllerInitFunction<
},
};

///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
const btcProvider = new AccountProviderWrapper(
controllerMessenger,
new BtcAccountProvider(controllerMessenger, snapAccountProviderConfig),
);
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
const trxProvider = new AccountProviderWrapper(
controllerMessenger,
new TrxAccountProvider(controllerMessenger, snapAccountProviderConfig),
);
///: END:ONLY_INCLUDE_IF

const controller = new MultichainAccountService({
messenger: controllerMessenger,
providers: [
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
btcProvider,
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(tron)
trxProvider,
///: END:ONLY_INCLUDE_IF
],
providers: [btcProvider, trxProvider],
providerConfigs: {
[SOL_ACCOUNT_PROVIDER_NAME]: snapAccountProviderConfig,
},
Expand Down Expand Up @@ -111,24 +94,19 @@ export const MultichainAccountServiceInit: ControllerInitFunction<
'RemoteFeatureFlagController:getState',
);

///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
const initialBitcoinEnabled = isMultichainFeatureEnabled(
initialRemoteFeatureFlagsState?.remoteFeatureFlags?.bitcoinAccounts,
);
btcProvider.setEnabled(initialBitcoinEnabled);
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
const initialTronEnabled = isMultichainFeatureEnabled(
initialRemoteFeatureFlagsState?.remoteFeatureFlags?.tronAccounts,
);
trxProvider.setEnabled(initialTronEnabled);
///: END:ONLY_INCLUDE_IF

controllerMessenger.subscribe(
'RemoteFeatureFlagController:stateChange',
previousValueComparator((prevState, currState) => {
///: BEGIN:ONLY_INCLUDE_IF(bitcoin)
const prevBitcoinEnabled = isMultichainFeatureEnabled(
prevState?.remoteFeatureFlags?.bitcoinAccounts,
);
Expand All @@ -152,9 +130,7 @@ export const MultichainAccountServiceInit: ControllerInitFunction<
}
// Note: When disabled, no action needed as the provider won't create new accounts
}
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(tron)
const prevTronEnabled = isMultichainFeatureEnabled(
prevState?.remoteFeatureFlags?.tronAccounts,
);
Expand All @@ -174,7 +150,6 @@ export const MultichainAccountServiceInit: ControllerInitFunction<
});
}
}
///: END:ONLY_INCLUDE_IF

return true;
}, initialRemoteFeatureFlagsState),
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/controllers/metametrics-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,9 +1615,7 @@ describe('MetaMetricsController', function () {
[MetaMetricsUserTrait.SecurityProviders]: ['blockaid'],
[MetaMetricsUserTrait.IsMetricsOptedIn]: true,
[MetaMetricsUserTrait.ProfileId]: undefined,
///: BEGIN:ONLY_INCLUDE_IF(petnames)
[MetaMetricsUserTrait.PetnameAddressCount]: 3,
///: END:ONLY_INCLUDE_IF
[MetaMetricsUserTrait.TokenSortPreference]: 'token-sort-key',
[MetaMetricsUserTrait.PrivacyModeEnabled]: true,
[MetaMetricsUserTrait.NetworkFilterPreference]: [],
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/controllers/permissions/snaps/specifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ export function getSnapPermissionSpecifications(
*/
getClientCryptography: () => ({}),

///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
getSnapKeyring: async () => {
// TODO: Use `withKeyring` instead.
const [snapKeyring] = messenger.call(
Expand All @@ -279,7 +278,6 @@ export function getSnapPermissionSpecifications(

return snapKeyring;
},
///: END:ONLY_INCLUDE_IF
},
),
};
Expand Down
8 changes: 0 additions & 8 deletions app/scripts/controllers/preferences-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ export type PreferencesControllerState = Omit<
*/
export const getDefaultPreferencesControllerState =
(): PreferencesControllerState => ({
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
addSnapAccountEnabled: false,
///: END:ONLY_INCLUDE_IF
advancedGasFee: {},
currentLocale: '',
dismissSeedBackUpReminder: false,
Expand Down Expand Up @@ -233,9 +231,7 @@ export const getDefaultPreferencesControllerState =
securityAlertsEnabled: true,
selectedAddress: '',
snapRegistryList: {},
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
snapsAddSnapAccountModalDismissed: false,
///: END:ONLY_INCLUDE_IF
theme: ThemeType.os,
use4ByteResolution: true,
useAddressBarEnsResolution: true,
Expand Down Expand Up @@ -688,7 +684,6 @@ export class PreferencesController extends BaseController<
});
}

///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
/**
* Setter for the `addSnapAccountEnabled` property.
*
Expand All @@ -700,7 +695,6 @@ export class PreferencesController extends BaseController<
state.addSnapAccountEnabled = addSnapAccountEnabled;
});
}
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-experimental)
/**
Expand Down Expand Up @@ -1043,13 +1037,11 @@ export class PreferencesController extends BaseController<
});
}

///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
setSnapsAddSnapAccountModalDismissed(value: boolean): void {
this.update((state) => {
state.snapsAddSnapAccountModalDismissed = value;
});
}
///: END:ONLY_INCLUDE_IF

/**
* Resets the preferences state to the default values.
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/lib/approval/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { ApprovalType } from '@metamask/controller-utils';
import { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';
import { providerErrors } from '@metamask/rpc-errors';
import { createProjectLogger, Json } from '@metamask/utils';
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import { SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES } from '../../../../shared/constants/app';
///: END:ONLY_INCLUDE_IF

const log = createProjectLogger('approval-utils');

Expand Down Expand Up @@ -83,14 +81,12 @@ function rejectApproval({
deleteInterface?.(interfaceId);
break;

///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountCreation:
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountRemoval:
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showSnapAccountRedirect:
log('Rejecting snap account confirmation', { id, origin, type });
approvalController.accept(id, false);
break;
///: END:ONLY_INCLUDE_IF

default:
log('Rejecting pending approval', { id, origin, type });
Expand Down
Loading
Loading