diff --git a/ui/ducks/metamask/constants.ts b/ui/ducks/metamask/constants.ts index 37c21a59ddf9..d7b4961cf040 100644 --- a/ui/ducks/metamask/constants.ts +++ b/ui/ducks/metamask/constants.ts @@ -1,6 +1,6 @@ -import { Preferences } from "../../../app/scripts/controllers/preferences-controller"; -import { MemStoreControllersComposedState } from "../../../app/scripts/metamask-controller-stores"; -import { DEFAULT_AUTO_LOCK_TIME_LIMIT } from "../../../shared/constants/preferences"; +import { Preferences } from '../../../app/scripts/controllers/preferences-controller'; +import { MemStoreControllersComposedState } from '../../../app/scripts/metamask-controller-stores'; +import { DEFAULT_AUTO_LOCK_TIME_LIMIT } from '../../../shared/constants/preferences'; export const initialMetamaskState: Partial<{ [ControllerName in keyof MemStoreControllersComposedState]: Partial< @@ -9,6 +9,7 @@ export const initialMetamaskState: Partial<{ }> = { KeyringController: { isUnlocked: false, + keyrings: [], }, AccountsController: { internalAccounts: { accounts: {}, selectedAccount: '' }, @@ -20,6 +21,10 @@ export const initialMetamaskState: Partial<{ AddressBookController: { addressBook: {}, }, + ApprovalController: { + pendingApprovals: {}, + approvalFlows: [], + }, CurrencyController: { currencyRates: { ETH: { @@ -29,12 +34,26 @@ export const initialMetamaskState: Partial<{ }, }, }, + ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) + CustodyController: { + custodyAccountDetails: {}, + }, + ///: END:ONLY_INCLUDE_IF + DecryptMessageController: { + unapprovedDecryptMsgs: {}, + }, + GasFeeController: { + gasFeeEstimates: {}, + gasEstimateType: 'none', + }, MetaMetricsController: { participateInMetaMetrics: null, dataCollectionForMarketing: null, }, NetworkController: { + selectedNetworkClientId: '', networkConfigurationsByChainId: {}, + networksMetadata: {}, }, OnboardingController: { firstTimeFlowType: null, @@ -46,6 +65,7 @@ export const initialMetamaskState: Partial<{ featureFlags: {}, currentLocale: '', knownMethodData: {}, + ledgerTransportType: undefined, preferences: { autoLockTimeLimit: DEFAULT_AUTO_LOCK_TIME_LIMIT, showExtensionInFullSizeView: false, @@ -58,6 +78,10 @@ export const initialMetamaskState: Partial<{ showMultiRpcModal: false, } as Preferences, }, + SignatureController: { + unapprovedPersonalMsgs: {}, + unapprovedTypedMessages: {}, + }, TokensController: { allTokens: {}, }, diff --git a/ui/store/store.ts b/ui/store/store.ts index 8433511380e7..a4f62a57b201 100644 --- a/ui/store/store.ts +++ b/ui/store/store.ts @@ -1,99 +1,7 @@ import { StoreEnhancer } from 'redux'; import { configureStore as baseConfigureStore } from '@reduxjs/toolkit'; import devtoolsEnhancer from 'remote-redux-devtools'; -import { ApprovalControllerState } from '@metamask/approval-controller'; -import { GasEstimateType, GasFeeEstimates } from '@metamask/gas-fee-controller'; -import { TransactionMeta } from '@metamask/transaction-controller'; -import { InternalAccount } from '@metamask/keyring-api'; -import { - NftControllerState, - TokensControllerState, -} from '@metamask/assets-controllers'; -import { NotificationServicesControllerState } from '@metamask/notification-services-controller/notification-services'; import rootReducer from '../ducks'; -import { LedgerTransportTypes } from '../../shared/constants/hardware-wallets'; -import type { NetworkStatus } from '../../shared/constants/network'; - -/** - * This interface is temporary and is copied from the message-manager.js file - * and is the 'msgParams' key of the interface declared there. We should get a - * universal Message type to use for this, the Message manager and all - * the other types of messages. - * - * TODO: Replace this - */ -export type TemporaryMessageDataType = { - id: string; - type: string; - msgParams: { - metamaskId: string; - data: string; - }; - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - metadata?: { - custodyId?: string; - }; - status?: string; - ///: END:ONLY_INCLUDE_IF -}; - -export type MessagesIndexedById = { - [id: string]: TemporaryMessageDataType; -}; - -/** - * This interface is a temporary interface to describe the state tree that is - * sent from the background. Ideally we can build this using Types in the - * backend when we compose the stores, then we can import it here and use it. - * - * Some of this is duplicated in the metamask redux duck. In *most* cases the - * state received from the background takes precedence over anything in the - * metamask reducer. - */ -type TemporaryBackgroundState = NftControllerState & - NotificationServicesControllerState & - TokensControllerState & { - addressBook: { - [chainId: string]: { - name: string; - }[]; - }; - // todo: can this be deleted post network controller v20 - providerConfig: { - chainId: string; - }; - transactions: TransactionMeta[]; - ledgerTransportType: LedgerTransportTypes; - unapprovedDecryptMsgs: MessagesIndexedById; - unapprovedPersonalMsgs: MessagesIndexedById; - unapprovedTypedMessages: MessagesIndexedById; - networksMetadata: { - [NetworkClientId: string]: { - EIPS: { [eip: string]: boolean }; - status: NetworkStatus; - }; - }; - selectedNetworkClientId: string; - pendingApprovals: ApprovalControllerState['pendingApprovals']; - approvalFlows: ApprovalControllerState['approvalFlows']; - knownMethodData?: { - [fourBytePrefix: string]: Record; - }; - gasFeeEstimates: GasFeeEstimates; - gasEstimateType: GasEstimateType; - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - custodyAccountDetails?: { [key: string]: any }; - ///: END:ONLY_INCLUDE_IF - internalAccounts: { - accounts: { - [key: string]: InternalAccount; - }; - selectedAccount: string; - }; - keyrings: { type: string; accounts: string[] }[]; - }; type RootReducerReturnType = ReturnType; @@ -101,7 +9,7 @@ export type CombinedBackgroundAndReduxState = RootReducerReturnType & { activeTab: { origin: string; }; - metamask: RootReducerReturnType['metamask'] & TemporaryBackgroundState; + metamask: RootReducerReturnType['metamask']; appState: RootReducerReturnType['appState']; send: RootReducerReturnType['send']; DNS: RootReducerReturnType['DNS'];